query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Internal function to execute the merge on one key provided by _rh_merge if refuse_discordance is true, then result[key] can't be updated if stricly not of same type.
|
def _do_rh_merge(result, key, data, refuse_discordance = false)
value = data[key]
return if _rh_merge_do_add_key(result, key, value)
return if _rh_merge_recursive(result, key, data)
return if refuse_discordance
return unless _rh_struct_changing_ok?(result, key, data)
return unless _rh_merge_ok?(result, key)
_rh_merge_do_upd_key(result, key, value)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"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 _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 _rh_merge_ok?(result, key)\n if result.is_a?(Hash)\n control = result[:__protected]\n else\n control = result[0][:__protected]\n key -= 1\n end\n\n return false if control.is_a?(Array) && control.include?(key)\n\n true\n end",
"def merge!; end",
"def rh_merge!(data)\n _rh_merge(self, data)\n end",
"def perform_additional_merge_operations!(other)\n end",
"def process!()\n # Regarding updates or deletions of :badge_id\n # --------------------------------------------------------------------\n # This has to change only if it refers to a duplicate row;\n # that is, a row that will become a duplicate (and it will have to\n # be deleted) once that the update (and translation) process has been\n # completed.\n #\n # Thus, each linked entity that has a reference to one of these\n # possibly duplicate IDs has to be updated with the new destination value\n # (of which they are the duplicate); else, the value for :badge_id can stay untouched.\n\n merge_done = false\n if check\n process_text_log << \"\\r\\nMerging '#{ @slave_swimmer.complete_name }' (id: #{ @slave_swimmer.id}) => '#{@master_swimmer.complete_name}' (id: #{@master_swimmer.id })...\\r\\n\\r\\n\"\n sql_diff_text_log << \"-- Merging '#{ @slave_swimmer.complete_name }' (id: #{ @slave_swimmer.id}) => '#{@master_swimmer.complete_name}' (id: #{@master_swimmer.id })...\\r\\n\\r\\n\"\n\n # Define merge schema (involved entities)\n @involved_entities = SwimmerMerger.get_involved_entities\n\n # Collect entity row to merge\n @involved_entities.each do |involved_entity|\n collect_swimmer_inolved_entity( involved_entity )\n end\n\n # Collect badges to merge (both swimmers have badges for the same season)\n collect_badges_to_merge\n\n # N.B. Checks for some recalculation needed should be performed before update and delete phases\n # Check if Goggle Cup standards needs recalculation\n needs_goggle_cup_recalculation = needs_goggle_cup_recalculation?\n\n # Check if seasonal personal standards needs recalculation\n needs_season_personal_standard_recalculation = needs_season_personal_standard_recalculation?\n\n # Perform the merge: update and delete phases\n # Bail out from any of these, if something goes wrong:\n merge_done = update_phase! && create_alias_phase! && delete_phase! && execute_delete!( Swimmer )\n\n if merge_done\n if @row_collectors[ MeetingIndividualResult.table_name ].non_duplicates_rows.size > 0\n # Recalculate personal bests\n process_text_log << \"\\r\\n\\r\\nPersonal-bests recalculation needed...\\r\\n\"\n swimmer_best_updater = SwimmerPersonalBestUpdater.new( @master_swimmer )\n swimmer_best_updater.scan_for_personal_best!\n sql_diff_text_log << swimmer_best_updater.sql_diff_text_log\n process_text_log << \"Personal-bests recalculation done!\\r\\n\"\n end\n\n # TODO if needed, also recalculate goggle_cup_standards\n if needs_goggle_cup_recalculation\n process_text_log << \"\\r\\n\\r\\n*** I M P O R T A N T ***\\r\\n\"\n process_text_log << \"Goggle-cup standards recalculation needed...\\r\\n\"\n end\n\n # TODO if needed, also recalculate season_personal_standards\n if needs_season_personal_standard_recalculation?\n process_text_log << \"\\r\\n\\r\\n*** I M P O R T A N T ***\\r\\n\"\n process_text_log << \"Season personal standards recalculation needed...\\r\\n\"\n end\n end\n end\n merge_done\n end",
"def merge!(other_hash); end",
"def _rh_do_control_merge(_result_control, result, data_control, _data)\n if data_control[:__remove].is_a?(Array)\n _rh_do_control_remove(result, data_control[:__remove])\n elsif data_control[:__remove_index].is_a?(Array)\n index_to_remove = data_control[:__remove_index].uniq.sort.reverse\n _rh_do_control_remove_index(result, index_to_remove)\n end\n\n data_control.delete(:__remove)\n data_control.delete(:__remove_index)\n\n if data_control[:__add].is_a?(Array)\n data_control[:__add].each { |element| result << element }\n elsif data_control[:__add_index].is_a?(Hash)\n _rh_do_control_add_index(result, data_control[:__add_index].sort)\n end\n\n data_control.delete(:__add)\n data_control.delete(:__add_index)\n end",
"def perform_or_request_merge(src, dest)\n if in_admin_mode? || src.can_merge_into?(dest)\n perform_merge(src, dest)\n else\n request_merge(src, dest)\n end\n end",
"def merge!(hash); end",
"def merge_result!(key, val)\n if key\n result[key] = massage_value(val)\n else\n result.merge!(massage_value(val))\n end\n end",
"def creep_merge( j, o )\n result = nil\n if o.is_a? Hash\n o.keys.each do |k|\n puts \"== k: #{k} | #{k.class} | j: #{j.class}\" if ENV['VERBOSE'] == 'yes'\n if j.is_a?(Hash)\n unless j.key?(k)\n warn \"!!!!!!!!! WARNING NO key '#{k}'\"\n if ENV['PRY'] == 'yes'\n require 'pry'\n binding.pry\n end\n else\n j[k] = creep_merge(j[k], o[k])\n end\n else\n j = o[k]\n end\n result = j\n end\n else\n result = o\n end\n result\nend",
"def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n # We can't use use this.val.is_a?(Hash) because inside the refinement\n # returns false:\n # - refined_hash.class != Hash\n if this_val.class.name == \"Hash\" && other_val.class.name == \"Hash\"\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def merge_conflict?; 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 successfull_merge_or_nothing(i,j)\n # try a merge and determinize inside a transaction on the ufds\n @ufds.transactional do\n merge_and_determinize(i, j)\n end\n end",
"def merge(other_hash); end",
"def deep_merge(other, &bloc)\n other.keys.inject(dup) do |result, key|\n begin\n case result[key]\n when Hash\n if other[key].is_a?(Hash)\n result[key] = result[key].deep_merge(other[key], &bloc)\n result\n else\n raise MergeConflict\n end\n when nil then result.merge key => other[key]\n else\n raise MergeConflict\n end\n rescue MergeConflict\n if bloc.nil?\n result[key] = other[key]\n else\n result[key] = bloc.call(result, other, key) \n end\n result\n end\n end\n \n end",
"def rh_merge(data)\n _rh_merge(clone, data)\n 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 merge( key, value = {} )\n sync_on_hooks( key ) do |hks|\n hks.inject( value ) { |v, hook| v.merge( hook[0].call ) }\n end\n end",
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); 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 process_subrecord_for_merge(target, subrecord, jsonmodel_type, mode, ind)\n target_id = target['id']\n\n if jsonmodel_type == 'names'\n # an agent name can only have one authorized or display name.\n # make sure the name being merged in doesn't conflict with this\n\n # if appending, always disable fields that validate across a set. If replacing, always keep values from target\n if mode == \"append\"\n subrecord['authorized'] = false\n subrecord['is_display_name'] = false\n elsif mode == \"replace\"\n subrecord['authorized'] = target['names'][ind]['authorized']\n subrecord['is_display_name'] = target['names'][ind]['is_display_name']\n end\n\n elsif jsonmodel_type == 'agent_record_identifiers'\n # same with agent_record_identifiers being marked as primary, we can only have one\n\n if mode == \"append\"\n subrecord['primary_identifier'] = false\n\n elsif mode == \"replace\"\n subrecord['primary_identifier'] = target['agent_record_identifiers'][ind]['primary_identifier']\n end\n end\n\n set_agent_id(target_id, subrecord)\n\n return subrecord\n end",
"def deep_merge!(other_hash, &block); end",
"def merge!(*other_hashes, &blk); end",
"def merge_if_exists!\n t = merge_if_exists || self\n t.save!\n end",
"def reverse_merge!(other_hash); end",
"def merge!(with); end",
"def try_merge!(pin); end",
"def merge; 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 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 merge(opts); end",
"def do_merge\n\n return @workitem if @workitem\n\n list = if first?\n @workitems_by_arrival.reverse\n elsif last?\n @workitems_by_arrival\n elsif highest?\n @workitems_by_altitude.reverse\n elsif lowest?\n @workitems_by_altitude\n end\n\n list.inject(nil) do |result, wi|\n result = merge_workitems(result, wi, override?) if wi\n result\n end\n end",
"def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end",
"def merge_one(n)\n\n # if the primary library (self) does not contain the entry, don't merge\n # unless --merge option given\n citekey = n.citekey\n unless self.has_key?(citekey) and @opts[:add] == false\n STDERR.puts \"<#{n.citekey}> do not exist in primary bib file. use --add to force adding them\"\n else\n old = self[citekey]\n if old.bib_hash == n.bib_hash # if contents is same.. don't replace\n STDERR.puts \"Skiping: <#{citekey}>\"\n elsif old.inconsistent?(n)\n STDERR.puts \"Inconsistent: <#{citekey}>\"\n if @opts[:dump_mismatch]\n STDERR.puts \"----- #{old.bib_hash}\"\n STDERR.puts old.to_s\n STDERR.puts \"----- #{n.bib_hash}\"\n STDERR.puts n.to_s\n end\n else\n if @opts[:dump_mismatch]\n STDERR.puts \"----- #{old.bib_hash}\"\n STDERR.puts old.to_s\n STDERR.puts \"----- #{n.bib_hash}\"\n STDERR.puts n.to_s\n end\n\n if @opts[:overwrite] # dont overwrite unless specified\n STDERR.puts \"Replacing: <#{citekey}>\"\n self[citekey] = n\n else\n STDERR.puts \"*NOT* Replacing: <#{citekey}> -- use --overwrite to replace\"\n end\n end\n end\n end",
"def deep_merge_hashes!(target, overwrite); end",
"def wonkofile_merge(old, new)\n res = old.merge new\n # changing versions is not allowed by adding another version index (we might end up with a version in the index that\n # we don't have an actual version file for)\n res['versions'] = old['versions']\n res\nend",
"def deep_merge!(other_hash)\r\n replace(deep_merge(other_hash))\r\n end",
"def forcemerge(options = nil)\n request(:post, \"_forcemerge\", options)\n end",
"def deep_merge!(target, hash); end",
"def deep_merge!(target, hash); end",
"def merge_strategy(for_merge)\n if for_merge.respond_to? :call\n for_merge\n else\n -> {}\n end\n end",
"def reverse_merge(other_hash); end",
"def reverse_merge(other_hash); end",
"def deep_merge(other_hash, &blk)\n dup.deep_update(other_hash, &blk)\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 deep_merge!(other_hash = {})\n replace(deep_merge(other_hash))\n end",
"def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end",
"def pfmerge(dest_key, *source_key); end",
"def pfmerge(dest_key, *source_key); end",
"def deep_merge!(target, merge)\r\n merge.keys.each do |key|\r\n if merge[key].is_a? Hash and target[key].is_a? Hash\r\n target[key] = deep_merge!(target[key], merge[key])\r\n else\r\n target[key] = merge[key]\r\n end\r\n end\r\n\r\n target\r\n end",
"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 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 merge(merge_branch, options = {})\n merge_analysis = rugged.merge_analysis(merge_branch.name)\n if merge_analysis.include?(:fastforward)\n rugged.references.update(helper.head_ref, merge_branch.target_id)\n rugged.checkout_head(strategy: :force)\n elsif merge_analysis.include?(:normal)\n ours = helper.head_target\n theirs = merge_branch.target\n merge_base = rugged.merge_base(ours, theirs)\n raise(NoCommonCommit) unless merge_base\n\n base = rugged.rev_parse(merge_base)\n index = ours.tree.merge(theirs.tree, base.tree)\n\n commit_message =\n if index.conflicts?\n raise(MergeConflict) unless block_given?\n\n message = yield(index, rugged, helper.working_directory)\n raise(MergeConflict) unless message\n\n index.conflict_cleanup\n message\n else\n \"Merge branch '#{helper.head_branch.name}' of #{helper.head_remote.url}\"\n end\n\n helper.commit_create(\n commit_message,\n index.write_tree(rugged),\n [ours, theirs],\n options\n )\n rugged.checkout_head(strategy: :force)\n end\n\n self\n end",
"def _deep_merge(hash, other_hash); end",
"def perform_merge\n src_notes = @src.all_notes\n dest_notes = @dest.all_notes\n result = false\n\n # Mergeable if there are no fields which are non-blank in\n # both descriptions.\n if @src.class.all_note_fields.none? \\\n { |f| src_notes[f].present? && dest_notes[f].present? }\n result = true\n\n # Copy over all non-blank descriptive fields.\n src_notes.each do |f, val|\n @dest.send(\"#{f}=\", val) if val.present?\n end\n\n # Save changes to destination.\n @dest.save\n\n # Copy over authors and editors.\n @src.authors.each { |user| @dest.add_author(user) }\n @src.editors.each { |user| @dest.add_editor(user) }\n\n # Delete old description if requested.\n delete_src_description_and_update_parent if @delete_after\n end\n\n result\n end",
"def deep_merge(source, hash); end",
"def deep_merge(source, hash); end",
"def merged_result; end",
"def merge_into(target)\n target_id = target.id\n # Find all the Entries attached to this name, that will need to be\n # reindexed after the merge\n entry_ids = entry_ids_to_index_on_update\n\n ids = EntryArtist.where(artist_id: self.id).pluck(:id)\n EntryArtist.where(artist_id: self.id).update_all({ artist_id: target_id })\n EntryArtist.where( id: ids ).each(&:update_bunny)\n\n ids = EntryAuthor.where(author_id: self.id).pluck(:id)\n EntryAuthor.where(author_id: self.id).update_all({ author_id: target_id })\n EntryAuthor.where( id: ids ).each(&:update_bunny)\n\n ids = EntryScribe.where(scribe_id: self.id).pluck(:id)\n EntryScribe.where(scribe_id: self.id).update_all({ scribe_id: target_id })\n EntryScribe.where( id: ids ).each(&:update_bunny)\n\n ids = SaleAgent.where(agent_id: self.id).pluck(:id)\n SaleAgent.where(agent_id: self.id).update_all({ agent_id: target_id })\n SaleAgent.where( id: ids ).each(&:update_bunny)\n\n ids = SourceAgent.where(agent_id: self.id).pluck(:id)\n SourceAgent.where(agent_id: self.id).update_all({ agent_id: target_id })\n SourceAgent.where( id: ids ).each(&:update_bunny)\n\n ids = Provenance.where(provenance_agent_id: self.id).pluck(:id)\n Provenance.where(provenance_agent_id: self.id).update_all({ provenance_agent_id: target_id })\n Provenance.where( id: ids ).each(&:update_bunny)\n\n ids = DericciLink.where(name_id: self.id).pluck(:id)\n DericciLink.where(name_id: self.id).update_all({ name_id: target_id })\n DericciLink.where( id: ids ).each(&:update_bunny)\n\n ids = DericciRecord.where(verified_id: self.id).pluck(:id)\n DericciRecord.where(verified_id: self.id).update_all({verified_id: target_id})\n DericciRecord.where( id: ids ).each(&:update_bunny)\n\n # update flags on the target\n target.is_artist ||= self.is_artist\n target.is_author ||= self.is_author\n target.is_scribe ||= self.is_scribe\n target.is_provenance_agent ||= self.is_provenance_agent\n\n target.save\n\n # but ... CAN't SAVE when name is BLANK (nil)\n # self.name = nil\n self.viaf_id = nil\n self.deleted = true\n self.save!\n\n # slice into managable chunks to avoid running out of space in mysql\n entry_ids.each_slice(200) do |slice|\n SDBMSS::IndexJob.perform_later(Entry.to_s, slice)\n end\n\n Name.update_counters(target.id,\n :authors_count => target.author_entries.where(deprecated: false, draft: false).count - target.authors_count,\n :artists_count => target.artist_entries.where(deprecated: false, draft: false).count - target.artists_count,\n :scribes_count => target.scribe_entries.where(deprecated: false, draft: false).count - target.scribes_count,\n :sale_agents_count => target.sale_entries.where(deprecated: false, draft: false).count - target.sale_agents_count,\n :provenance_count => target.provenance_entries.where(deprecated: false, draft: false).count - target.provenance_count,\n :source_agents_count => target.agent_sources.count - target.source_agents_count\n )\n end",
"def shallow_merge(other_hash); end",
"def merge(base_hash, derived_hash); end",
"def merge(hash_1, hash_2)\n\nend",
"def merge(direction=:into_remote)\n begin\n @map = direction == :into_local ? @map.merge(read_data) : read_data.merge(@map)\n rescue LockMethod::Locked\n sleep 0.5\n merge(direction)\n end\n end",
"def reverse_significant_merge(other_hash={})\n return significant if (other_hash ||= {}).blank?\n significant.reverse_merge(other_hash)\n end",
"def reverse_merge!(other_hash)\n replace(reverse_merge(other_hash))\n end",
"def merge(to_be_merged)\n scheme_ids = identifiers.pluck(:identifier_scheme_id)\n # merge logic\n # => answers -> map id\n to_be_merged.answers.update_all(user_id: id)\n # => notes -> map id\n to_be_merged.notes.update_all(user_id: id)\n # => plans -> map on id roles\n to_be_merged.roles.update_all(user_id: id)\n # => prefs -> Keep's from self\n # => auths -> map onto keep id only if keep does not have the identifier\n to_be_merged.identifiers\n .where.not(identifier_scheme_id: scheme_ids)\n .update_all(identifiable_id: id)\n # => ignore any perms the deleted user has\n to_be_merged.destroy\n end",
"def merge(*other_hashes, &blk); end",
"def merge(filtered_reference)\n\t\t\traise ReferenceInvalidMergeParamError unless filtered_reference.kind_of?(Bibmix::FilteredReference)\n\t\t\t\n\t\t\treference = filtered_reference.reference\n\t\t\teach_attribute do |attr|\n\t\t\t\t\n\t\t\t\tif self.respond_to?(\"merge_#{attr}\")\n\t\t\t\t\tself.send(\"merge_#{attr}\", reference)\n\t\t\t\telsif self.send(attr).nil? && !reference.send(attr).nil?\n\t\t\t\t\tmerge_overwrite_attribute(attr, reference)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\tself\n\t\tend",
"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_into(r)\n if !self.metadata[:add].nil?\n if !r.metadata[:add].nil?\n r.metadata[:add] |= self.metadata[:add]\n else\n r.metadata[:add] = self.metadata[:add]\n end\n end\n\n if !self.metadata[:remove].nil?\n if !r.metadata[:remove].nil?\n r.metadata[:remove] |= self.metadata[:remove]\n else\n r.metadata[:remove] = self.metadata[:remove]\n end\n end\n\n if !r.metadata[:todos].nil?\n r.metadata[:todos] |= r.metadata[:add] - r.metadata[:remove]\n else\n r.metadata[:todos] = r.metadata[:add] - r.metadata[:remove]\n end\n\n if !r.metadata[:tags].nil?\n r.metadata[:tags] |= self.metadata[:tags] if !self.metadata[:tags].nil?\n else\n r.metadata[:tags] = self.metadata[:tags]\n end\n\n if !self.metadata[:tags]\n self.metadata[:tags].each do |tag|\n r.add_tags(tag)\n end\n end\n\n r.sector_tag_list |= self.sector_tag_list\n r.type_tag_list |= self.type_tag_list\n r.input_method_list |= self.input_method_list\n r.PFO_statu_list |= self.PFO_statu_list\n r.organizer_list |= self.organizer_list\n\n r.email << (\", \" + self.email) if r.email.blank? && !self.email.blank?\n r.phone = self.phone if r.phone.blank? && !self.phone.blank?\n r.organization = self.organization if r.organization.blank? && !self.organization.blank?\n r.position = self.position if r.position.blank? && !self.position.blank?\n r.address = self.address if r.address.blank? && !self.address.blank?\n\n r.street_address = self.street_address if r.street_address.nil? && !self.street_address.nil?\n r.user = self.user if r.user.nil? && !self.user.nil?\n\n if !self.notes.nil? && !self.notes.empty?\n if r.notes.nil?\n r.notes = self.notes\n else\n new_notes = r.notes << \", \" << self.notes\n r.notes = nil\n r.save\n r.notes = new_notes\n end\n end\n\n r.manually_added ||= self.manually_added\n r.save\n end",
"def merge(other)\n # By default just take the other change if applicable\n other.instance_of?(self.class) && other.key == key ? other : self\n end",
"def merge(with); end",
"def merge!(other)\n # @todo: use specific exception\n raise Exception, \"Cannot merge\" unless self.class == other.class &&\n coll_name == other.coll_name &&\n db_name == other.db_name\n @spec[batch_key] += other.spec[batch_key]\n @spec[:indexes] = indexes + other.indexes\n self\n end",
"def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end",
"def merge(source); end",
"def absorb_key mapping, target, paths\n building_natural_key = paths.detect{|k,i| i.is_a?(MM::Index) && i.composite_as_natural_index}\n fk_type = preferred_fk_type(building_natural_key, mapping.root, target.composite)\n target.re_rank\n target.all_member.sort_by(&:ordinal).each do |member|\n rank = member.rank_key[0]\n break unless rank <= MM::Component::RANK_IDENT\n if rank == MM::Component::RANK_SURROGATE && fk_type == :natural\n next\n end\n is_primary = member.is_in_primary && mapping.depth == 1\n member = member.fork_to_new_parent mapping\n augment_paths is_primary, paths, member\n if rank == MM::Component::RANK_SURROGATE && fk_type == :primary\n break # Will always be first (higher rank), and usurps others\n elsif member.is_a?(MM::Mapping) && !member.is_a?(MM::ValueField)\n object_type = member.object_type\n full_absorption = @composition.all_full_absorption[object_type]\n if full_absorption\n # The target object is fully absorbed. Absorb a key to where it was absorbed\n # We can't recurse here, because we must descend supertype absorptions\n while full_absorption && MM::Absorption === full_absorption.mapping\n trace :relational_columns?, \"Absorbing key of fully absorbed #{object_type.name}\" do\n member = mirror(cloned = full_absorption.mapping, member)\n augment_paths cloned.is_in_primary, paths, member\n # Descend so the key fields get fully populated\n absorb_key member, full_absorption.mapping.parent, paths\n full_absorption = @composition.all_full_absorption[member.object_type]\n end\n end\n else\n absorb_key member, @binary_mappings[object_type], paths\n end\n end\n end\n # mapping.re_rank\n end",
"def merged_result\n # conceptually this is just doing `merge_results(resultset_path)`\n # it's more involved to make syre `synchronize_resultset` is only used around reading\n resultset_hash = read_resultset\n command_names, coverage = merge_valid_results(resultset_hash)\n\n create_result(command_names, coverage)\n end",
"def use_merging(use = T.unsafe(nil)); end",
"def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def merge_or_replace(mode:)\n target = replication.target_table\n stage = temporary_table_name\n sql = send(\"#{mode}_statement\", target, stage)\n ::RailsRedshiftReplicator.connection.exec sql\n end",
"def merge_hash(hash, prelude = nil)\n hash.reduce({}) do |acc, kv|\n k, v = kv\n generated_key = prelude ? \"#{prelude}_#{k}\" : k.to_s\n #puts(\"Generated key #{generated_key}\")\n if v.is_a?(Hash)\n acc.merge!(merge_hash(v, generated_key))\n elsif v.is_a?(Array)\n acc[generated_key] = v.to_s\n else\n acc[generated_key] = v\n end\n acc\n end\n end",
"def merge!(type, behaviors, new_values)\n self.type ||= type\n self.behaviors += behaviors\n self.behaviors.uniq!\n self.values += new_values\n end",
"def merge!(new_args); end",
"def merge!(other); end",
"def deep_merge!(*args)\n replace deep_merge(*args)\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!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def merge hash = {}\n original.merge(hash)\n end",
"def merge_to(data)\n\n # prevent cross merging tickets\n target_ticket = Ticket.find_by(id: data[:ticket_id])\n raise 'no target ticket given' if !target_ticket\n raise Exceptions::UnprocessableEntity, 'ticket already merged, no merge into merged ticket possible' if target_ticket.state.state_type.name == 'merged'\n\n # check different ticket ids\n raise Exceptions::UnprocessableEntity, 'Can\\'t merge ticket with it self!' if id == target_ticket.id\n\n # update articles\n Transaction.execute do\n\n Ticket::Article.where(ticket_id: id).each(&:touch)\n\n # quiet update of reassign of articles\n Ticket::Article.where(ticket_id: id).update_all(['ticket_id = ?', data[:ticket_id]]) # rubocop:disable Rails/SkipsModelValidations\n\n # mark target ticket as updated\n # otherwise the \"received_merge\" history entry\n # will be the same as the last updated_at\n # which might be a long time ago\n target_ticket.updated_at = Time.zone.now\n\n # add merge event to both ticket's history (Issue #2469 - Add information \"Ticket merged\" to History)\n target_ticket.history_log(\n 'received_merge',\n data[:user_id],\n id_to: target_ticket.id,\n id_from: id,\n )\n history_log(\n 'merged_into',\n data[:user_id],\n id_to: target_ticket.id,\n id_from: id,\n )\n\n # create new merge article\n Ticket::Article.create(\n ticket_id: id,\n type_id: Ticket::Article::Type.find_by(name: 'note').id,\n sender_id: Ticket::Article::Sender.find_by(name: 'Agent').id,\n body: 'merged',\n internal: false,\n )\n\n # reassign links to the new ticket\n # rubocop:disable Rails/SkipsModelValidations\n Link.where(\n link_object_source_id: Link::Object.find_by(name: 'Ticket').id,\n link_object_source_value: id,\n ).update_all(link_object_source_value: data[:ticket_id])\n Link.where(\n link_object_target_id: Link::Object.find_by(name: 'Ticket').id,\n link_object_target_value: id,\n ).update_all(link_object_target_value: data[:ticket_id])\n # rubocop:enable Rails/SkipsModelValidations\n\n # link tickets\n Link.add(\n link_type: 'parent',\n link_object_source: 'Ticket',\n link_object_source_value: data[:ticket_id],\n link_object_target: 'Ticket',\n link_object_target_value: id\n )\n\n # set state to 'merged'\n self.state_id = Ticket::State.find_by(name: 'merged').id\n\n # rest owner\n self.owner_id = 1\n\n # save ticket\n save!\n\n # touch new ticket (to broadcast change)\n target_ticket.touch # rubocop:disable Rails/SkipsModelValidations\n end\n true\n 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 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!(comprehension)\n @result_ritual = comprehension.result_ritual || result_ritual\n @guards = guards.merge(comprehension.guards)\n @transfers = transfers.merge(comprehension.transfers)\n @aggregations = aggregations.merge(comprehension.aggregations)\n @distributions = distributions.merge(comprehension.distributions)\n end",
"def process_opportunity(opp)\n return {'anonymized': true} if opp['isAnonymized']\n \n result = {}\n log.log_prefix(opp['id'] + ': ')\n client.batch_updates\n\n # checks lastInteractionAt and tag checksum, creating checksum tag if necessary\n last_update = latest_change(opp)\n # should notify of change based on state before we executed?\n notify = last_update[:time] > last_change_detected(opp) + 100\n\n if check_no_posting(opp)\n # if we added to a job then reload as tags etc will have changed automagically \n # based on new posting assignment\n opp.merge!(client.get_opportunity(opp['id'], {expand: client.OPP_EXPAND_VALUES}))\n result['assigned_to_job'] = true\n end\n \n check_linkedin_optout(opp)\n remove_legacy_attributes(opp)\n\n if !Util.has_posting(opp) || Util.is_cohort_app(opp)\n prepare_app_responses(opp)\n add_links(opp)\n summarise_feedbacks(opp)\n # detect_duplicate_opportunities(opp)\n rules.do_update_tags(opp, parse_all_feedback_summary_link(opp))\n\n [tags_have_changed?(opp), links_have_changed?(opp)].each{ |update|\n unless update.nil?\n last_update = update\n notify = true\n end\n }\n\n if notify\n # send webhook of change\n notify_of_change(opp, last_update)\n result['sent_webhook'] = result['updated'] = true\n else \n # we didn't have a change to notify, but we added one or more notes\n # which will update lastInteractionAt\n # so update LAST_CHANGE_TAG to avoid falsely detecting update next time\n update_changed_tag(opp, [opp['_addedNoteTimestamp'], opp['lastInteractionAt'], last_change_detected(opp)].reject{ |v|v.nil? }.max)\n end\n\n if commit_bot_metadata(opp)\n result['updated'] = true\n end\n end\n\n if client.commit_opp(opp)\n result['updated'] = true\n end\n\n log.pop_log_prefix\n client.batch_updates(false)\n result\n end"
] |
[
"0.66566783",
"0.6546197",
"0.5866346",
"0.56332564",
"0.53934026",
"0.53718096",
"0.53412914",
"0.53256875",
"0.5317653",
"0.52883005",
"0.52566755",
"0.5231188",
"0.5226204",
"0.52182066",
"0.51989967",
"0.5190673",
"0.51871425",
"0.51842844",
"0.51671237",
"0.51543087",
"0.51534456",
"0.51398927",
"0.512615",
"0.51224715",
"0.51224715",
"0.51224715",
"0.51217496",
"0.511119",
"0.51015824",
"0.5094031",
"0.5075255",
"0.50603545",
"0.504714",
"0.50266474",
"0.50182706",
"0.50021166",
"0.49436432",
"0.49392608",
"0.4926912",
"0.4912763",
"0.49113953",
"0.49043867",
"0.49041015",
"0.48959216",
"0.48814544",
"0.48710436",
"0.48710436",
"0.48699924",
"0.48658237",
"0.48658237",
"0.48489583",
"0.48466247",
"0.48390898",
"0.48390847",
"0.48385465",
"0.48385465",
"0.48248062",
"0.48147047",
"0.48017976",
"0.47979513",
"0.47971255",
"0.4792868",
"0.4792016",
"0.4792016",
"0.47739726",
"0.47678235",
"0.47618395",
"0.4759517",
"0.475458",
"0.4747325",
"0.474537",
"0.47388628",
"0.47325006",
"0.47323313",
"0.4731208",
"0.472438",
"0.47168913",
"0.4705719",
"0.47054794",
"0.4704839",
"0.47022292",
"0.46964628",
"0.469622",
"0.46960574",
"0.4685075",
"0.46779707",
"0.46676922",
"0.4667345",
"0.4655513",
"0.46493134",
"0.4648454",
"0.4645552",
"0.46399316",
"0.46266383",
"0.4622265",
"0.4621296",
"0.46207786",
"0.4619093",
"0.4615097",
"0.46136156"
] |
0.8479817
|
0
|
Created On: 08/11/2014 Purpose: To get operating system statistics report ++
|
def get_access_operating_system(device_access)
total_device_count = device_access.count
computer_count = device_access.where(:access_operating_system=>"Computer").count
computer_count_percent = ((computer_count.to_f * 100) / total_device_count).round(2)
mobile_count = device_access.where(:access_operating_system=>"Mobile").count
mobile_count_percent = ((mobile_count.to_f * 100) / total_device_count).round(2)
tablet_count = device_access.where(:access_operating_system=>"Tablet").count
tablet_count_percent = ((tablet_count.to_f * 100) / total_device_count).round(2)
access_operating_system_data = Hash[
"computer_count_data" => computer_count, "mobile_count_data" => mobile_count,
"tablet_count_data" => tablet_count, "computer_percent" => computer_count_percent,
"mobile_percent" => mobile_count_percent, "tablet_percent" => tablet_count_percent
]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stats\n _get(\"/system/stats\") { |json| json }\n end",
"def device_operating_system_summary\n return @device_operating_system_summary\n end",
"def io_stats\n @vm[:netrx] = 0\n @vm[:nettx] = 0\n @vm[:diskrdbytes] = 0\n @vm[:diskwrbytes] = 0\n @vm[:diskrdiops] = 0\n @vm[:diskwriops] = 0\n\n return if @vm[:state] != 'RUNNING' ||\n REASONS_SKIP_IO.include?(@vm[:reason])\n\n vm_stats, _e, s = KVM.virsh(:domstats, @name)\n\n return if s.exitstatus != 0\n\n vm_stats.each_line do |line|\n columns = line.split(/=(\\d+)/)\n\n case columns[0]\n when /rx.bytes/\n @vm[:netrx] += columns[1].to_i\n when /tx.bytes/\n @vm[:nettx] += columns[1].to_i\n when /rd.bytes/\n @vm[:diskrdbytes] += columns[1].to_i\n when /wr.bytes/\n @vm[:diskwrbytes] += columns[1].to_i\n when /rd.reqs/\n @vm[:diskrdiops] += columns[1].to_i\n when /wr.reqs/\n @vm[:diskwriops] += columns[1].to_i\n end\n end\n end",
"def sysinfo\n\t\trequest = Packet.create_request('stdapi_sys_config_sysinfo')\n\t\tresponse = client.send_request(request)\n\n\t\t{\n\t\t\t'Computer' => response.get_tlv_value(TLV_TYPE_COMPUTER_NAME),\n\t\t\t'OS' => response.get_tlv_value(TLV_TYPE_OS_NAME),\n\t\t}\n\tend",
"def current_status\n if OperatingSystem.mac?\n return { os: {mac: 'mac' }}\n end\n\n if OperatingSystem.linux?\n top = %x(top -b -n 1)\n load_averages = top.split(\"\\n\")[0].partition(\"load average:\")[2].strip.split(\", \")\n puts \"Load last 1 minute: #{load_averages[0]}\"\n puts \"Load last 5 minutes: #{load_averages[1]}\"\n puts \"Load last 15 minutes: #{load_averages[2]}\"\n uptime = top.split(\"\\n\")[0].split(\", \")[0].partition(\"up\")[2].strip+','+top.split(\"\\n\")[0].split(\", \")[1]\n puts \"Uptime: #{uptime}\"\n user_sessions = top.split(\"\\n\")[0].split(\", \")[2].strip.to_i\n cpu = 100.0 - top.split(\"\\n\")[2].split(', ')[3].to_f\n puts \"Current User sessions: #{user_sessions}\"\n puts \"#{top.split(\"\\n\")[1]}\"\n puts \"% CPU (user processes): #{top.split(\"\\n\")[2].split(', ')[0].partition(\":\")[2]}\"\n puts \"% CPU (system processes): #{top.split(\"\\n\")[2].split(', ')[1]}\"\n puts \"% CPU (priority nice): #{top.split(\"\\n\")[2].split(', ')[2]}\"\n puts \"% CPU (idle): #{top.split(\"\\n\")[2].split(', ')[3]}\"\n puts \"% CPU (waiting for I/O): #{top.split(\"\\n\")[2].split(', ')[4]}\"\n puts \"% CPU (hardware interpts):#{top.split(\"\\n\")[2].split(', ')[5]}\"\n puts \"% CPU (software interpts):#{top.split(\"\\n\")[2].split(', ')[6]}\"\n puts \"RAM: #{top.split(\"\\n\")[3]}\"\n puts \"SWAP:#{top.split(\"\\n\")[4]}\"\n total_memory = top.split(\"\\n\")[3].split(' ')[2].to_f\n free_memory = top.split(\"\\n\")[3].split(' ')[6].to_f\n free_memory_perc = (free_memory / total_memory * 100).round\n swap_used = top.split(\"\\n\")[4].split(', ')[3].to_f\n\n disk_space = %x(df /tmp --total -k -h)\n puts \"Disk Space (Total): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[0]}\"\n puts \"Disk Space (Used): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[1]}\"\n puts \"Disk Space (Avail): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[2]}\"\n puts \"Disk Space (%Used): #{disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[3]}\"\n disk_space_used = disk_space.split(\"\\n\")[-1].partition(\"total\")[2].split[3].to_i\n puts \"---\"\n\n {\n os: {\n up_time: uptime,\n load: load_averages[0],\n cpu: cpu,\n free_memory: free_memory_perc,\n disk_space: disk_space_used,\n swap_used: swap_used,\n }\n }\n end\n end",
"def windows_os_graph\n\t\t\t\t\tg = Gruff::Pie.new(GRAPH_WIDTH)\n\t\t\t\t\tg.title = \"Windows Operating Systems By Percentage\"\n\t\t\t\t\tg.sort = false\n\t\t\t\t\tg.marker_count = 1\n\t\t\t\t\tg.theme = {\n\t\t\t\t\t\t:colors => Risu::GRAPH_COLORS,\n\t\t\t\t\t\t:background_colors => %w(white white)\n\t\t\t\t\t}\n\n\t\t\t\t\tnt = Host.os_windows_nt.to_a.size\n\t\t\t\t\tw2k = Host.os_windows_2k.to_a.size\n\t\t\t\t\txp = Host.os_windows_xp.to_a.size\n\t\t\t\t\tw2k3 = Host.os_windows_2k3.to_a.size\n\t\t\t\t\tvista = Host.os_windows_vista.to_a.size\n\t\t\t\t\tw2k8 = Host.os_windows_2k8.to_a.size\n\t\t\t\t\tw2k12 = Host.os_windows_2k12.to_a.size\n\t\t\t\t\tw7 = Host.os_windows_7.to_a.size\n\t\t\t\t\tw8 = Host.os_windows_8.to_a.size\n\t\t\t\t\tw10 = Host.os_windows_10.to_a.size\n\t\t\t\t\tother = (Host.os_windows.os_windows_other).to_a.size\n\n\t\t\t\t\tg.data(\"NT\", nt) if nt >= 1\n\t\t\t\t\tg.data(\"2000\", w2k) if w2k >= 1\n\t\t\t\t\tg.data(\"XP\", xp) if xp >= 1\n\t\t\t\t\tg.data(\"Server 2003\", w2k3) if w2k3 >= 1\n\t\t\t\t\tg.data(\"Vista\", vista) if vista >= 1\n\t\t\t\t\tg.data(\"Server 2008\", w2k8) if w2k8 >= 1\n\t\t\t\t\tg.data(\"Server 2012\", w2k12) if w2k12 >= 1\n\t\t\t\t\tg.data(\"7\", w7) if w7 >= 1\n\t\t\t\t\tg.data(\"8\", w8) if w8 >= 1\n\t\t\t\t\tg.data(\"10\", w10) if w10 >= 1\n\t\t\t\t\tg.data(\"Other Windows\", other) if other >= 1\n\n\t\t\t\t\tStringIO.new(g.to_blob)\n\t\t\t\tend",
"def get_sysinfo\n\t\tsystem_data = {}\n\t\tkernel_version = cmd_exec(\"uname -a\")\n\t\tversion = read_file(\"/etc/release\").split(\"\\n\")[0].strip\n\t\tsystem_data[:version] = version\n\t\tsystem_data[:kernel] = kernel_version\n\t\tsystem_data[:hostname] = kernel_version.split(\" \")[1]\n\t\treturn system_data\n\tend",
"def event_counter_statistics(flags=\"\")\n output = `vmstat #{flags}` \n keys = output.split(/\\d/).compact.join.split(\"\\n\").map(&:strip)\n # this looks silly. but I kind'a like it\n keys.map(&:downcase).map {|s| \n s.gsub(\" \", \"_\")}.map {|s| \n s.gsub(\"-\", \"_\")}.map {|s| \n s.gsub(/\\b(\\w){1}_{1}/, \"\") }.map(&:to_sym)\n values = output.split(/[A-z]/).compact.join.split(\"\\n\").map(&:strip)\n data = Hash[keys.zip values]\n Vmstator::DiskSummary.new(data)\n end",
"def system_info\n si = SysInfo.new\n si.to_hash\n rescue \n {}\n end",
"def system_describe\n return @sd_cache if @sd_cache\n sd = {:sdversion => @sd[:sdversion], :name => @sd[:name], :id => @sd[:id]}\n sd[:version] = @sd[:version] if @sd[:version]\n sd[:summary] = @sd[:summary] if @sd[:summary]\n sd[:help] = @sd[:help] if @sd[:help]\n sd[:address] = @sd[:address] if @sd[:address]\n sd[:procs] = []\n @procs.each do |name, prop|\n next if name == 'system.describe'\n pd = {:name => name}\n pd[:summary] = prop[:summary] if prop[:summary]\n pd[:help] = prop[:help] if prop[:help]\n pd[:idempotent] = prop[:idempotent] if prop[:idempotent]\n pd[:params] = prop[:params] if prop[:params]\n pd[:return] = prop[:return] if prop[:return]\n sd[:procs] << pd\n end\n @sd_cache = sd\n end",
"def get_statistics\n raise 'Method unavailable for Synergy'\n end",
"def disk_statistics(flags=\"\")\n disk_stats = Vmstator::DiskStatistics.new\n output = `vmstat #{flags}`.split(\"\\n\")\n # remove first line of the output\n output.shift\n output.shift\n output.each do |line|\n name, total, merged, sectors, ms, total, merged, sectors, ms, cur, sec = line.split\n data = {:name => name, :totoal => total, :merged => merged, :sectors => sectors,\n :ms => ms, :cur => cur, :sec => sec }\n disk_stats.update(data)\n end\n disk_stats\n end",
"def get_sysinfo\n system_data = {}\n kernel_version = cmd_exec(\"uname -a\")\n version = read_file(\"/etc/release\").split(\"\\n\")[0].strip\n system_data[:version] = version\n system_data[:kernel] = kernel_version\n system_data[:hostname] = kernel_version.split(\" \")[1]\n host_info = {\n :host => rhost,\n :os_name => 'Solaris',\n :name => system_data[:hostname]\n }\n # Test cases for these can be found here:\n # http://rubular.com/r/MsGuhp89F0\n # http://rubular.com/r/DWKG0jpPCk\n # http://rubular.com/r/EjiIa1RFxB\n if /(?<OS>(?<!Open|Oracle )Solaris).+s2?(?<major>\\d?\\d)[x|s]?(_u)(?<minor>\\d?\\d)/ =~ system_data[:version]\n host_info[:os_flavor] = \"#{major}.#{minor}\"\n elsif /(?<OS>Oracle Solaris) (?<major>\\d\\d)\\.(?<minor>\\d?\\d)/ =~ system_data[:version]\n host_info[:os_flavor] = \"#{major}.#{minor}\"\n elsif /(?<OS>OpenSolaris|OpenIndiana [\\w]+) (?<major>\\d\\d\\d\\d)\\.(?<minor>\\d\\d)/ =~ system_data[:version]\n host_info[:os_flavor] = \"#{major}.#{minor}\"\n end\n report_host(host_info)\n return system_data\n end",
"def get_windows_info()\n sysname = \"\"\n processor = \"\"\n os_info = \"\"\n\n require 'win32/registry'\n\n Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion') do |reg|\n type, sysname = reg.read('ProductName')\n end\n\n Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment') do |reg|\n type, processor = reg.read('PROCESSOR_ARCHITECTURE')\n end\n\n os_info = sysname + \" \" + processor\n os_info\nend",
"def statistics\n stats_hash = {}\n stats = info_cmd(\"statistics\")\n\n stats = stats.gsub!(/statistics\\s/, '').gsub!(/\\n/, '').split(\";\")\n\n stats.each do |st|\n type = \"\"\n value = nil\n\n st.split(\"=\").each_with_index do |val, i|\n type = val if i == 0\n value = val if i == 1\n end\n\n stats_hash[type] = value\n end\n\n stats_hash\n end",
"def total_per_sys_lang(&block)\n @systotals.sort.each do | name, linehash |\n puts \"System #{name}\"\n linehash.to_a.\n sort { |a,b| b[1] <=> a[1] } [0,10] .\n each { |e| output e[0], 0, e[1], &block }\n end\n end",
"def statistics; end",
"def info\n info = Hash.new\n output = @filer.invoke(\"system-get-info\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.children_get[0].children_get.each do |naelem|\n info[naelem.name] = naelem.content\n end\n end\n info\n end",
"def info(vm)\n used_cpu = @monitor[:used_cpu]\n used_memory = @monitor[:used_memory]\n netrx = @monitor[:netrx]\n nettx = @monitor[:nettx]\n diskrdbytes = @monitor[:diskrdbytes]\n diskwrbytes = @monitor[:diskwrbytes]\n diskrdiops = @monitor[:diskrdiops]\n diskwriops = @monitor[:diskwriops]\n\n if vm[:mob]\n guest_ip = vm[:mob].guest.ipAddress\n esx_host = vm[:mob].runtime.host.name.to_s\n guest_state = vm[:mob].guest.guestState.to_s\n vmware_tools = vm[:mob].guest.toolsRunningStatus.to_s\n vm_name = vm[:mob].name.to_s\n vmtools_ver = vm[:mob].guest.toolsVersion.to_s\n vmtools_verst = vm[:mob].guest.toolsVersionStatus2.to_s\n end\n\n # if vm[:mob]\n # rp_name = vm[:mob][:rp_list]\n # .select do |item|\n # item[:ref] == vm[:mob]['resourcePool']._ref\n # end\n # .first[:name] rescue ''\n\n # rp_name = 'Resources' if rp_name.empty?\n # else\n # rp_name = @vm['resourcePool'].name\n # end\n\n str_info = ''\n\n str_info << 'GUEST_IP=' << guest_ip.to_s << \"\\n\" if guest_ip\n\n if @guest_ip_addresses && !@guest_ip_addresses.empty?\n str_info << 'GUEST_IP_ADDRESSES=\"' << @guest_ip_addresses.to_s \\\n << '\" '\n end\n\n str_info << \"#{POLL_ATTRIBUTE[:cpu]}=\" << used_cpu.to_s << \"\\n\"\n str_info << \"#{POLL_ATTRIBUTE[:memory]}=\" << used_memory.to_s << \"\\n\"\n str_info << \"#{POLL_ATTRIBUTE[:netrx]}=\" << netrx.to_s << \"\\n\"\n str_info << \"#{POLL_ATTRIBUTE[:nettx]}=\" << nettx.to_s << \"\\n\"\n\n str_info << 'DISKRDBYTES=' << diskrdbytes.to_s << \"\\n\"\n str_info << 'DISKWRBYTES=' << diskwrbytes.to_s << \"\\n\"\n str_info << 'DISKRDIOPS=' << diskrdiops.to_s << \"\\n\"\n str_info << 'DISKWRIOPS=' << diskwriops.to_s << \"\\n\"\n\n str_info << 'VCENTER_ESX_HOST=\"' << esx_host << '\" ' << \"\\n\"\n str_info << 'VCENTER_GUEST_STATE=' << guest_state << \"\\n\"\n str_info << 'VCENTER_VM_NAME=\"' << vm_name << '\" ' << \"\\n\"\n str_info << 'VCENTER_VMWARETOOLS_RUNNING_STATUS=' << vmware_tools << \"\\n\"\n str_info << 'VCENTER_VMWARETOOLS_VERSION=' << vmtools_ver << \"\\n\"\n str_info << 'VCENTER_VMWARETOOLS_VERSION_STATUS=' \\\n << vmtools_verst << \"\\n\"\n # str_info << 'VCENTER_RP_NAME=\"' << rp_name << '\" '\n\n # I need modify this Carlos improvement.\n # @vm.info_disks.each do |disk|\n # str_info << \"DISK_#{disk[0]}_ACTUAL_PATH=\\\"[\" <<\n # disk[1].ds.name << '] ' << disk[1].path << '\" '\n # end\n\n str_info\n end",
"def system_usage_data\n {\n counts: {\n assignee_lists: count(List.assignee),\n boards: count(Board),\n ci_builds: count(::Ci::Build),\n ci_internal_pipelines: count(::Ci::Pipeline.internal),\n ci_external_pipelines: count(::Ci::Pipeline.external),\n ci_pipeline_config_auto_devops: count(::Ci::Pipeline.auto_devops_source),\n ci_pipeline_config_repository: count(::Ci::Pipeline.repository_source),\n ci_runners: count(::Ci::Runner),\n ci_triggers: count(::Ci::Trigger),\n ci_pipeline_schedules: count(::Ci::PipelineSchedule),\n auto_devops_enabled: count(::ProjectAutoDevops.enabled),\n auto_devops_disabled: count(::ProjectAutoDevops.disabled),\n deploy_keys: count(DeployKey),\n deployments: count(Deployment),\n successful_deployments: count(Deployment.success),\n failed_deployments: count(Deployment.failed),\n environments: count(::Environment),\n clusters: count(::Clusters::Cluster),\n clusters_enabled: count(::Clusters::Cluster.enabled),\n project_clusters_enabled: count(::Clusters::Cluster.enabled.project_type),\n group_clusters_enabled: count(::Clusters::Cluster.enabled.group_type),\n clusters_disabled: count(::Clusters::Cluster.disabled),\n project_clusters_disabled: count(::Clusters::Cluster.disabled.project_type),\n group_clusters_disabled: count(::Clusters::Cluster.disabled.group_type),\n clusters_platforms_gke: count(::Clusters::Cluster.gcp_installed.enabled),\n clusters_platforms_user: count(::Clusters::Cluster.user_provided.enabled),\n clusters_applications_helm: count(::Clusters::Applications::Helm.available),\n clusters_applications_ingress: count(::Clusters::Applications::Ingress.available),\n clusters_applications_cert_managers: count(::Clusters::Applications::CertManager.available),\n clusters_applications_prometheus: count(::Clusters::Applications::Prometheus.available),\n clusters_applications_runner: count(::Clusters::Applications::Runner.available),\n clusters_applications_knative: count(::Clusters::Applications::Knative.available),\n in_review_folder: count(::Environment.in_review_folder),\n groups: count(Group),\n issues: count(Issue),\n keys: count(Key),\n label_lists: count(List.label),\n lfs_objects: count(LfsObject),\n milestone_lists: count(List.milestone),\n milestones: count(Milestone),\n pages_domains: count(PagesDomain),\n projects: count(Project),\n projects_imported_from_github: count(Project.where(import_type: 'github')),\n projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)),\n projects_with_error_tracking_enabled: count(::ErrorTracking::ProjectErrorTrackingSetting.where(enabled: true)),\n protected_branches: count(ProtectedBranch),\n releases: count(Release),\n remote_mirrors: count(RemoteMirror),\n snippets: count(Snippet),\n suggestions: count(Suggestion),\n todos: count(Todo),\n uploads: count(Upload),\n web_hooks: count(WebHook)\n }\n .merge(services_usage)\n .merge(approximate_counts)\n }.tap do |data|\n if Feature.enabled?(:group_overview_security_dashboard)\n data[:counts][:user_preferences] = user_preferences_usage\n end\n end\n end",
"def operating_systems\n collect\n end",
"def get_unix_info()\n v = $VERBOSE\n $VERBOSE = nil\n sysname = `uname -s`\n $VERBOSE = v\n sysname = sysname.chomp\n\n if(sysname.include?(\"Linux\")) # for linux (rhel, suse, oel)\n # check if it is SUSE\n filepath = Pathname.new(\"/etc/SuSE-release\")\n if(filepath.exist?())\n release_file = '/etc/SuSE-release'\n else # for RHEL, OEL, etc.\n release_file = '/etc/issue'\n end\n\n $VERBOSE = nil\n flavor = `head -n 1 #{release_file}`\n $VERBOSE = v\n sysname = flavor.sub(/\\(\\w+\\)/, '').chomp\n sysname = sysname.sub(/\\s+\\Z/, \"\")\n\n else # for other unix platforms (solaris, aix, hpux)\n $VERBOSE = nil\n if(sysname.eql?(\"AIX\"))\n version = `oslevel`\n else\n version = `uname -r`\n end\n $VERBOSE = v\n sysname = sysname + \" \" + version.chomp\n end\n\n $VERBOSE = nil\n if(sysname.eql?(\"HP-UX\"))\n processor = `uname -m`\n else\n processor = `uname -p`\n end\n\n if(sysname.include?(\"SunOS\"))\n isainfo = `isainfo -b`\n isainfo = isainfo.chomp\n bitinfo = \" \" + isainfo + \"-bit\"\n else\n bitinfo = \"\"\n end\n $VERBOSE = v\n\n os_info = sysname + \" \" + processor.chomp + bitinfo\n os_info\nend",
"def memstats\n # initialize all counters\n rooms = objs = chars = accounts = scripts = strcount = strsize = ocount = 0\n\n # scan the ObjectSpace counting things\n ObjectSpace.each_object do |x|\n case x\n when String\n strcount += 1\n strsize += x.size\n when Character\n chars += 1\n when Account\n accounts += 1\n when Room\n rooms += 1\n when GameObject\n objs += 1\n when Script\n scripts += 1\n else\n ocount += 1\n end\n end\n\n # our report :\n # :NOTE: sprintf would be better\n memstats=<<EOD\n[COLOR Cyan]\n----* Memory Statistics *----\n Rooms - #{rooms}\n Objects - #{objs}\n Scripts - #{scripts}\n Accounts - #{accounts}\n Characters - #{chars}\n-----------------------------\n Strings - #{strcount}\n size - #{strsize} bytes\n Other - #{ocount}\n-----------------------------\n Total Objects - #{rooms+objs+chars+accounts+scripts+strcount+ocount}\n----* *----\n[/COLOR]\nEOD\n end",
"def generate_site_stats\n H.ul {\n H.li {\"#{$r.get(\"users.count\")} users\"} +\n H.li {\"#{$r.zcard(\"news.cron\")} news posted\"} +\n H.li {\"#{$r.info['used_memory_human']} of used memory\"}\n }\nend",
"def determine_io\n io = @info[:io] = {}\n\n iostat = @shell.query('IOSTAT', \"iostat -c|sed -n 4p|awk '#{print $4}'\")\n io[:wait] = iostat.to_f\n\n up = @shell.query('UPTIME', \"uptime|sed -e 's/.*up\\\\([^,]*\\\\),.*/\\\\1/'\")\n io[:uptime] = up.chomp\n end",
"def stats; end",
"def stats; end",
"def statistics(project, package_name, target, arch)\n cache(\"#{project}@#{package_name}@#{target}@#{arch}.statistics.xml\") do\n puts \"Obtaining build time for #{package_name}\"\n\n Dir.mktmpdir do |dir|\n Dir.chdir(dir) do\n # return code 0 even if no files are fetched\n Cheetah.run \"osc\", \"-v\", \"getbinaries\",\n project, package_name, target, arch, \"_statistics\"\n\n if File.exist? \"binaries/_statistics\"\n ret = File.read \"binaries/_statistics\"\n FileUtils.rm_rf \"binaries\"\n ret\n else\n \"\"\n end\n end\n end\n end\nend",
"def report_st_ops_file_stats(options)\n latest_st_ops_file_path = Subtitle::OperationsFile.find_latest(\n config.base_dir(:subtitle_operations_dir)\n )\n st_ops_json_string = File.read(latest_st_ops_file_path)\n\n operations = Hash.new(0)\n # Match lines like ` \"operation_type\": \"content_change\",`\n st_ops_json_string.scan(/^\\s+\"operation_type\": \"([^\"]+)\"/) { |match|\n # match example: [\"insert\"]\n operations[match.first] += 1\n }\n\n l = ['']\n l << \"st-ops file stats\".color(:blue)\n l << (\"=\" * 24).color(:blue)\n l << \"File: #{ latest_st_ops_file_path }\"\n l << \"Size: #{ (File.size(latest_st_ops_file_path).to_f / 2**20).round } MB\"\n l << ''\n l << \"Operations:\"\n l << \"-\" * 24\n operations.to_a.sort { |(k_a, _v_a),(k_b, _v_b)|\n k_a <=> k_b\n }.each { |k,v|\n number_with_delimiter = v.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n l << \"#{ k.ljust(16) } #{ number_with_delimiter.rjust(7) }\"\n }\n l << \"-\" * 24\n total_ops_count = operations.values.inject(0) { |m,v| m += v; m }\n l << \"Total: #{ total_ops_count.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse.rjust(17) }\"\n l << ''\n\n l.each { |e| $stderr.puts e }\n end",
"def stats\n ## TODO:\n end",
"def other_os_graph\n\t\t\t\t\tg = Gruff::Pie.new(GRAPH_WIDTH)\n\t\t\t\t\tg.title = \"Other Operating Systems Percentage\"\n\t\t\t\t\tg.sort = false\n\t\t\t\t\tg.marker_count = 1\n\t\t\t\t\tg.theme = {\n\t\t\t\t\t\t:colors => Risu::GRAPH_COLORS,\n\t\t\t\t\t\t:background_colors => %w(white white)\n\t\t\t\t\t}\n\n\t\t\t\t\tlinux = Host.os_linux.to_a.size\n\t\t\t\t\tosx = Host.os_osx.to_a.size\n\t\t\t\t\tfreebsd = Host.os_freebsd.to_a.size\n\t\t\t\t\tnetbsd = Host.os_netbsd.to_a.size\n\t\t\t\t\tcisco = Host.os_cisco.to_a.size\n\t\t\t\t\tvxworks = Host.os_vxworks.to_a.size\n\t\t\t\t\tesx = Host.os_vmware_esx.to_a.size\n\t\t\t\t\taix = Host.os_aix.to_a.size\n\t\t\t\t\tother = Host.os_other.to_a.size\n\n\t\t\t\t\tg.data(\"Linux\", linux) unless linux == 0\n\t\t\t\t\tg.data(\"OSX\", osx) unless osx == 0\n\t\t\t\t\tg.data(\"FreeBSD\", freebsd) unless freebsd == 0\n\t\t\t\t\tg.data(\"NetBSD\", netbsd) unless netbsd == 0\n\t\t\t\t\tg.data(\"Cisco IOS\", cisco) unless cisco == 0\n\t\t\t\t\tg.data(\"VxWorks\", vxworks) unless vxworks == 0\n\t\t\t\t\tg.data(\"VMware\", esx) unless esx == 0\n\t\t\t\t\tg.data(\"AIX\", aix) unless aix == 0\n\t\t\t\t\tg.data(\"Other\", other) unless other == 0\n\n\t\t\t\t\t#Creates very odd graphs\n\t\t\t\t\t#Host.os_other.each do |host|\n\t\t\t\t\t# g.data(host.os, Host.where(:os => host.os).size) unless host.os == nil\n\t\t\t\t\t#end\n\n\t\t\t\t\tStringIO.new(g.to_blob)\n\t\t\t\tend",
"def get_usage(args= {})\n args = {:day=>\"today\", :type=>\"heat\"}.merge(args)\n result = HTTParty.get( @tstat_ip + '/tstat/datalog', :headers => @headers) \n \n day = result[args[:day]]\n runtime = day[args[:type] + '_runtime']\n\n return runtime\n end",
"def filesystem_usage\n\n usage = {}\n\n df = capture_command_output('df', '-k')[1..-1] # Don't include the column headers.\n df.each do |df_line|\n\n df_line.strip!\n device = df_line.match(/^(.*?)\\s{2,}/)[1]\n tokens = df_line.gsub(/^#{Regexp.quote(device)}\\s+/, '').split(/\\s+/, 5)\n \n # Convert all KB values to bytes.\n size = tokens[0].to_i * 1024\n used = tokens[1].to_i * 1024\n available = tokens[2].to_i * 1024\n used_percentage = tokens[3].to_i\n\n usage[device] = {\n :size => size,\n :used => used,\n :used_percentage => used_percentage,\n :available => available\n }\n\n end\n\n usage\n\n end",
"def stat\n end",
"def disk_summary(flags=\"\")\n output = `vmstat #{flags}` \n keys = output.split(/\\d/).compact.join.split(\"\\n\").map(&:strip) \n keys.map(&:downcase).map {|s| \n s.gsub(\" \", \"_\")}.map {|s| \n s.gsub(\"-\", \"_\")}.map {|s|}.map(&:to_sym)\n end",
"def get_sysinfo\n\t\tsystem_data = {}\n\t\tetc_files = cmd_exec(\"ls /etc\").split()\n\n\t\tkernel_version = cmd_exec(\"uname -a\")\n\t\tsystem_data[:kernel] = kernel_version\n\n\t\t# Debian\n\t\tif etc_files.include?(\"debian_version\")\n\t\t\tif kernel_version =~ /Ubuntu/\n\t\t\t\tversion = read_file(\"/etc/issue\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\t\tsystem_data[:distro] = \"ubuntu\"\n\t\t\t\tsystem_data[:version] = version\n\t\t\telse\n\t\t\t\tversion = read_file(\"/etc/issue\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\t\tsystem_data[:distro] = \"debian\"\n\t\t\t\tsystem_data[:version] = version\n\t\t\tend\n\n\t\t# Amazon\n\t\telsif etc_files.include?(\"system-release\")\n\t\t\tversion = read_file(\"/etc/system-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"amazon\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# Fedora\n\t\telsif etc_files.include?(\"fedora-release\")\n\t\t\tversion = read_file(\"/etc/fedora-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"fedora\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# Oracle Linux\n\t\telsif etc_files.include?(\"enterprise-release\")\n\t\t\tversion = read_file(\"/etc/enterprise-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"oracle\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# RedHat\n\t\telsif etc_files.include?(\"redhat-release\")\n\t\t\tversion = read_file(\"/etc/redhat-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"redhat\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# Arch\n\t\telsif etc_files.include?(\"arch-release\")\n\t\t\tversion = read_file(\"/etc/arch-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"arch\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# Slackware\n\t\telsif etc_files.include?(\"slackware-version\")\n\t\t\tversion = read_file(\"/etc/slackware-version\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"slackware\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# Mandrake\n\t\telsif etc_files.include?(\"mandrake-release\")\n\t\t\tversion = read_file(\"/etc/mandrake-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"mandrake\"\n\t\t\tsystem_data[:version] = version\n\n\t\t#SuSE\n\t\telsif etc_files.include?(\"SuSE-release\")\n\t\t\tversion = read_file(\"/etc/SuSE-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"suse\"\n\t\t\tsystem_data[:version] = version\n\n\t\t# Gentoo\n\t\telsif etc_files.include?(\"gentoo-release\")\n\t\t\tversion = read_file(\"/etc/gentoo-release\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"gentoo\"\n\t\t\tsystem_data[:version] = version\n\t\telse\n\n\t\t\t# Others\n\t\t\tversion = read_file(\"/etc/issue\").gsub(/\\n|\\\\n|\\\\l/,'')\n\t\t\tsystem_data[:distro] = \"linux\"\n\t\t\tsystem_data[:version] = version\n\t\tend\n\t\treturn system_data\n\tend",
"def index\n @system_stats = SystemStat.all\n end",
"def collect_stats\n # code callously ripped from statistics.rake !\n folders = STATS_FOLDERS.select{|name, dir| File.directory?(dir) }\n cs = CodeStatistics.new(*folders)\n statz = cs.statistics\n tyme = Time.now.to_i\n yaml = { \"build_#{ tyme }\" => statz }.to_yaml\n return yaml.sub(/^---/, '') # abrogate that pesky document marker!\n end",
"def run\n print_status(\"Gathering System info ....\")\n vm = nil\n dmi_info = nil\n ls_pci_data = nil\n\n if is_root?\n dmi_info = cmd_exec(\"/usr/sbin/dmidecode\")\n end\n\n # Check DMi Info\n if dmi_info\n case dmi_info\n when /microsoft corporation/i\n vm = \"MS Hyper-V\"\n when /vmware/i\n vm = \"VMware\"\n when /virtualbox/i\n vm = \"VirtualBox\"\n when /qemu/i\n vm = \"Qemu/KVM\"\n when /domu/i\n vm = \"Xen\"\n end\n end\n\n # Check Modules\n if not vm\n loaded_modules = cmd_exec(\"/sbin/lsmod\")\n case loaded_modules.to_s.gsub(\"\\n\", \" \")\n when /vboxsf|vboxguest/i\n vm = \"VirtualBox\"\n when /vmw_ballon|vmxnet|vmw/i\n vm = \"VMware\"\n when /xen-vbd|xen-vnif/\n vm = \"Xen\"\n when /virtio_pci|virtio_net/\n vm = \"Qemu/KVM\"\n when /hv_vmbus|hv_blkvsc|hv_netvsc|hv_utils|hv_storvsc/\n vm = \"MS Hyper-V\"\n end\n end\n\n # Check SCSI Driver\n if not vm\n proc_scsi = read_file(\"/proc/scsi/scsi\") rescue \"\"\n case proc_scsi.gsub(\"\\n\", \" \")\n when /vmware/i\n vm = \"VMware\"\n when /vbox/i\n vm = \"VirtualBox\"\n end\n end\n\n # Check IDE Devices\n if not vm\n case cmd_exec(\"cat /proc/ide/hd*/model\")\n when /vbox/i\n vm = \"VirtualBox\"\n when /vmware/i\n vm = \"VMware\"\n when /qemu/i\n vm = \"Qemu/KVM\"\n when /virtual [vc]d/i\n vm = \"Hyper-V/Virtual PC\"\n end\n end\n\n # Check using lspci\n if not vm\n case get_sysinfo[:distro]\n when /oracle|centos|suse|redhat|mandrake|slackware|fedora/i\n lspci_data = cmd_exec(\"/sbin/lspci\")\n when /debian|ubuntu/\n lspci_data = cmd_exec(\"/usr/bin/lspci\")\n else\n lspci_data = cmd_exec(\"lspci\")\n end\n\n case lspci_data.to_s.gsub(\"\\n\", \" \")\n when /vmware/i\n vm = \"VMware\"\n when /virtualbox/i\n vm = \"VirtualBox\"\n end\n end\n\n # Xen bus check\n if not vm\n if cmd_exec(\"ls -1 /sys/bus\").to_s.split(\"\\n\").include?(\"xen\")\n vm = \"Xen\"\n end\n end\n\n # Check using lscpu\n if not vm\n case cmd_exec(\"lscpu\")\n when /Xen/i\n vm = \"Xen\"\n when /KVM/i\n vm = \"KVM\"\n when /Microsoft/i\n vm = \"MS Hyper-V\"\n end\n end\n\n # Check dmesg Output\n if not vm\n dmesg = cmd_exec(\"dmesg\")\n case dmesg\n when /vboxbios|vboxcput|vboxfacp|vboxxsdt|vbox cd-rom|vbox harddisk/i\n vm = \"VirtualBox\"\n when /vmware virtual ide|vmware pvscsi|vmware virtual platform/i\n vm = \"VMware\"\n when /xen_mem|xen-vbd/i\n vm = \"Xen\"\n when /qemu virtual cpu version/i\n vm = \"Qemu/KVM\"\n when /\\/dev\\/vmnet/\n vm = \"VMware\"\n end\n end\n\n if vm\n print_good(\"This appears to be a '#{vm}' virtual machine\")\n report_virtualization(vm)\n else\n print_status(\"This does not appear to be a virtual machine\")\n end\n\n end",
"def report_size!(elf)\n stats = `#{TOOLCHAIN}size #{elf}`.split(\"\\n\").last.split(\"\\t\").map {|s|s.strip}\n align = stats[3].length\n puts \"Statistics for #{elf}\"\n puts \" .text: #{stats[0].rjust(align)} bytes\"\n puts \" .data: #{stats[1].rjust(align)} bytes\"\n puts \" .bss: #{stats[2].rjust(align)} bytes\"\n puts \" #{'='*(align+6)}\"\n puts \" TOTAL: #{stats[3]} bytes (0x#{stats[4]})\"\nend",
"def cmd_sysinfo(*args)\n info = client.sys.config.sysinfo(refresh: true)\n width = \"Meterpreter\".length\n info.keys.each { |k| width = k.length if k.length > width and info[k] }\n\n info.each_pair do |key, value|\n print_line(\"#{key.ljust(width+1)}: #{value}\") if value\n end\n print_line(\"#{\"Meterpreter\".ljust(width+1)}: #{client.session_type}\")\n\n return true\n end",
"def os_versions_summary\n return @os_versions_summary\n end",
"def stats\n end",
"def stats\n end",
"def stat() end",
"def determine_memory_history\n result = @info[:memory_hist] = {}\n sar_cmd = \"for l in $(find /var/log -name 'sa??');do sar -r -f $l|\" \\\n \"grep Average;done|awk '{I+=1;TOT=$2+$3;CACHE+=$5+$6;\" \\\n \"FREE+=$2;SWAP+=$9;} END {CACHE=CACHE/I;FREE=FREE/I;\" \\\n \"SWAP=SWAP/I;print (TOT-(CACHE+FREE))/TOT*100,SWAP;}'\"\n\n sar_location = @shell.query('SAR_LOCATION', 'which sar 2>/dev/null')\n if sar_location =~ /bin\\//\n sar_usage = @shell.query('SAR', sar_cmd)\n\n if sar_usage =~/\\d \\d/\n mem, swap = sar_usage.split(/ /)\n result[:mem_used] = mem\n result[:swap_used] = swap\n end\n end\n end",
"def get_system_total()\n return token_counts( nil ,nil )\n end",
"def cpu_usage_information\n super\n end",
"def lstat() end",
"def info\n str_info = \"\"\n\n # CPU\n str_info << \"MODELNAME=\\\"\" << @cpuModel.to_s << \"\\\"\\n\"\n str_info << \"CPUSPEED=\" << @cpuMhz.to_s << \"\\n\"\n str_info << \"TOTALCPU=\" << @total_cpu.to_s << \"\\n\"\n str_info << \"USEDCPU=\" << @used_cpu.to_s << \"\\n\"\n str_info << \"FREECPU=\" << (@total_cpu - @used_cpu).to_s << \"\\n\"\n\n # Memory\n str_info << \"TOTALMEMORY=\" << @total_memory.to_s << \"\\n\"\n str_info << \"USEDMEMORY=\" << @used_memory.to_s << \"\\n\"\n str_info << \"FREEMEMORY=\" << (@total_memory - @used_memory).to_s << \"\\n\"\n\n # Networking\n str_info << \"NETRX=\" << @net_rx.to_s << \"\\n\"\n str_info << \"NETTX=\" << @net_tx.to_s << \"\\n\"\n\n # Datastores\n @free_ds_info.each{|k,v|\n used_space = v[:capacity].to_i - v[:free_space].to_i\n str_info << \"DS=[ID=\\\"#{k}\\\",USED_MB=#{used_space},\"\n str_info << \"TOTAL_MB=#{v[:capacity]},\"\n str_info << \"FREE_MB=#{v[:free_space]}]\\n\"\n }\n\n str_info.strip\n end",
"def physical_memory_info\n\n if PlatformInfo.linux?\n\n {\n :total => proc_meminfo['MemTotal'],\n :used => proc_meminfo['MemTotal'] - proc_meminfo['MemFree'],\n :cached => proc_meminfo['Cached'],\n :free => proc_meminfo['MemFree'] \n }\n\n elsif PlatformInfo.osx?\n\n hw_memsize = capture_command_output('sysctl', 'hw.memsize')[0]\n total_memory = hw_memsize.split(':')[1].strip.to_i\n\n # Parse the header information produced by top -l 1 to figure out the\n # physical memory stats.\n top = capture_command_output('top', '-l', '1')\n top_phys_mem = top.select { |t| t =~ /^PhysMem\\:/ }.first.strip.gsub(/^PhysMem\\:\\s+/, '')\n top_phys_mem_pairs = top_phys_mem.split(',')\n\n phys_mem = {}\n top_phys_mem_pairs.each do |top_phys_mem_pair|\n items = top_phys_mem_pair.strip.split(/\\s+/)\n key = items[1].gsub(/\\W/, '')\n value = items[0].to_i * 1024 * 1024 # Convert MB to bytes\n phys_mem[key] = value\n end\n\n {\n :total => total_memory,\n :used => phys_mem['used'],\n :free => phys_mem['free']\n }\n\n else\n unsupported_platform\n end\n\n end",
"def get_hypervisor_stats\n response = @connection.req('GET', '/os-hypervisors/statistics')\n OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)\n JSON.parse(response.body)['hypervisor_statistics']\n end",
"def allStats\n results = {}\n results[:langBytesPerc] = langBytesPerc(true)\n results[:avgPerRepo] = avgPerRepo(true)\n results[:avgPerLang] = avgPerLang(true)\n results[:langPerc] = langPerc(true)\n results[:mainLangPerc] = mainLangPerc(true)\n puts \"|allLanguagesStatistics| \\n\" + results.to_json.to_s\n FileHandle.write_file(@org, results, @subcommand, @filename) unless @onlycons\n return results\n end",
"def status_info\n { \n :time => Time.now, :pid => Process.pid, :started => @started,\n :max_conns => @maxconns, :conns => @threads.length, :systimes => Process.times,\n :shutdown => @shutdown, :dead => @dead, :total_conns => @total_conns\n }.inspect\n end",
"def device_operating_system_summary=(value)\n @device_operating_system_summary = value\n end",
"def get_hardware_info()\n results = { summary_string: \"Unknown hardware\" }\n return results if not is_sunxi_hardware()\n\n val = mem_read_word(VER_REG)\n return results if not val\n\n # Check the VER_R_EN bit and set it if necessary\n if (val & (1 << 15)) == 0 then\n mem_write_word(VER_REG, val | (1 << 15))\n val = mem_read_word(VER_REG)\n end\n\n # Test the SoC type\n case val >> 16\n when 0x1623\n results[:soc_type] = \"sun4i\"\n results[:soc_name] = \"Allwinner A10\"\n when 0x1625\n results[:soc_type] = \"sun5i\"\n case (mem_read_word(SID_KEY2) >> 12) & 0xF\n when 0\n results[:soc_name] = \"Allwinner A12\"\n when 3\n results[:soc_name] = \"Allwinner A13\"\n when 7\n results[:soc_name] = \"Allwinner A10s\"\n end\n when 0x1633\n results[:soc_type] = \"sun6i\"\n results[:soc_name] = \"Allwinner A31(s)\"\n when 0x1650\n results[:soc_type] = \"sun8i\"\n results[:soc_name] = \"Allwinner A23\"\n when 0x1651\n results[:soc_type] = \"sun7i\"\n results[:soc_name] = \"Allwinner A20\"\n end\n\n # Parse the dram info\n data = `a10-meminfo`\n dram_chip_density = 0\n dram_bus_width = 0\n dram_io_width = 0\n if data =~ /dram_clk\\s*\\=\\s*(\\d+)/ then\n results[:dram_clock] = $1.to_i\n end\n if data =~ /mbus_clk\\s*\\=\\s*(\\d+)/ then\n results[:mbus_clock] = $1.to_i\n end\n if data =~ /dram_chip_density\\s*\\=\\s*(\\d+)/ then\n dram_chip_density = $1.to_i\n end\n if data =~ /dram_bus_width\\s*\\=\\s*(\\d+)/ then\n dram_bus_width = $1.to_i\n end\n if data =~ /dram_io_width\\s*\\=\\s*(\\d+)/ then\n dram_io_width = $1.to_i\n end\n results[:dram_size] = dram_bus_width * dram_chip_density /\n (dram_io_width * 8)\n results[:dram_bus_width] = dram_bus_width\n\n results[:summary_string] = sprintf(\"SoC: %s\",\n (results[:soc_name] or \"unknown\"))\n\n if results[:dram_clock] then\n results[:summary_string] += sprintf(\", DRAM: %d MiB, %d-bit, %d MHz\",\n results[:dram_size],\n results[:dram_bus_width],\n results[:dram_clock])\n end\n\n if results[:mbus_clock] && results[:mbus_clock] != 0 then\n results[:summary_string] += sprintf(\", MBUS: %d MHz\",\n results[:mbus_clock])\n end\n\n return results\nend",
"def raw_summary\n report = { \"version\" => { \"config\" => configuration_version, \"puppet\" => Puppet.version } }\n\n @metrics.each do |name, metric|\n key = metric.name.to_s\n report[key] = {}\n metric.values.each do |name, label, value|\n report[key][name.to_s] = value\n end\n report[key][\"total\"] = 0 unless key == \"time\" or report[key].include?(\"total\")\n end\n (report[\"time\"] ||= {})[\"last_run\"] = Time.now.tv_sec\n report\n end",
"def usage_by_proc\n return nil unless File.exist? proc_status_file\n\n proc_status = File.open(proc_status_file, \"r\") { |f| f.read_nonblock(4096).strip }\n if (m = proc_status.match(/RSS:\\s*(\\d+) kB/i))\n m[1].to_f / 1.kilobyte\n end\n end",
"def global_host_statistics\n super\n end",
"def os_metadata\n os =\n case RbConfig::CONFIG['host_os']\n when /mac|darwin/\n 'macos'\n when /linux|cygwin/\n 'linux'\n when /mingw|mswin/\n 'windows'\n else\n 'other'\n end\n metadata = \"os/#{os}\"\n local_version = Gem::Platform.local.version\n metadata += \"##{local_version}\" if local_version\n metadata += \" md/#{RbConfig::CONFIG['host_cpu']}\"\n metadata\n end",
"def statistic\n\t @ksstat\n\t end",
"def get_rss_usage()\n rss = 0\n open(\"/proc/#{Process.pid}/status\").each do |line|\n if line.start_with?(\"Rss\")\n pieces = line.split\n rss += pieces[1].to_i\n end\n end\n rss\nend",
"def info\n return 'STATE=d' if @state == 'd'\n\n if @vm.vm_info\n guest_ip = @vm.vm_info['guest.ipAddress']\n else\n guest_ip = @vm['guest.ipAddress']\n end\n\n used_cpu = @monitor[:used_cpu]\n used_memory = @monitor[:used_memory]\n netrx = @monitor[:netrx]\n nettx = @monitor[:nettx]\n diskrdbytes = @monitor[:diskrdbytes]\n diskwrbytes = @monitor[:diskwrbytes]\n diskrdiops = @monitor[:diskrdiops]\n diskwriops = @monitor[:diskwriops]\n\n if @vm.vm_info\n esx_host = @vm.vm_info[:esx_host_name].to_s\n else\n esx_host = @vm['runtime.host.name'].to_s\n end\n\n if @vm.vm_info\n guest_state = @vm.vm_info['guest.guestState'].to_s\n else\n guest_state = @vm['guest.guestState'].to_s\n end\n\n if @vm.vm_info\n vmware_tools = @vm.vm_info['guest.toolsRunningStatus'].to_s\n else\n vmware_tools = @vm['guest.toolsRunningStatus'].to_s\n end\n\n if @vm.vm_info\n vm_name = @vm.vm_info['name'].to_s\n else\n vm_name = @vm['name'].to_s\n end\n\n if @vm.vm_info\n vmtools_ver = @vm.vm_info['guest.toolsVersion'].to_s\n else\n vmtools_ver = @vm['guest.toolsVersion'].to_s\n end\n\n if @vm.vm_info\n vmtools_verst = @vm.vm_info['guest.toolsVersionStatus2'].to_s\n else\n vmtools_verst = @vm['guest.toolsVersionStatus2'].to_s\n end\n\n if @vm.vm_info\n rp_name = @vm.vm_info[:rp_list]\n .select do |item|\n item[:ref] == @vm.vm_info['resourcePool']._ref\n end\n .first[:name] rescue ''\n\n rp_name = 'Resources' if rp_name.empty?\n else\n rp_name = @vm['resourcePool'].name\n end\n\n str_info = ''\n\n str_info = 'GUEST_IP=' << guest_ip.to_s << ' ' if guest_ip\n\n if @guest_ip_addresses && !@guest_ip_addresses.empty?\n str_info << 'GUEST_IP_ADDRESSES=\"' << @guest_ip_addresses.to_s \\\n << '\" '\n end\n\n str_info << \"#{POLL_ATTRIBUTE[:state]}=\" << @state << ' '\n str_info << \"#{POLL_ATTRIBUTE[:cpu]}=\" << used_cpu.to_s << ' '\n str_info << \"#{POLL_ATTRIBUTE[:memory]}=\" << used_memory.to_s << ' '\n str_info << \"#{POLL_ATTRIBUTE[:netrx]}=\" << netrx.to_s << ' '\n str_info << \"#{POLL_ATTRIBUTE[:nettx]}=\" << nettx.to_s << ' '\n\n str_info << 'DISKRDBYTES=' << diskrdbytes.to_s << ' '\n str_info << 'DISKWRBYTES=' << diskwrbytes.to_s << ' '\n str_info << 'DISKRDIOPS=' << diskrdiops.to_s << ' '\n str_info << 'DISKWRIOPS=' << diskwriops.to_s << ' '\n\n str_info << 'VCENTER_ESX_HOST=\"' << esx_host << '\" '\n str_info << 'VCENTER_GUEST_STATE=' << guest_state << ' '\n str_info << 'VCENTER_VM_NAME=\"' << vm_name << '\" '\n str_info << 'VCENTER_VMWARETOOLS_RUNNING_STATUS=' << vmware_tools << ' '\n str_info << 'VCENTER_VMWARETOOLS_VERSION=' << vmtools_ver << ' '\n str_info << 'VCENTER_VMWARETOOLS_VERSION_STATUS=' \\\n << vmtools_verst << ' '\n str_info << 'VCENTER_RP_NAME=\"' << rp_name << '\" '\n\n # @vm.info_disks.each do |disk|\n # str_info << \"DISK_#{disk[0]}_ACTUAL_PATH=\\\"[\" <<\n # disk[1].ds.name << '] ' << disk[1].path << '\" '\n # end\n\n str_info\n end",
"def cpu_usage\r\n # all usage\r\n total_used_cpu = IO.popen(\"ps aux\").read.split(\"\\n\").inject 0 do |a, i|\r\n a += i.split(' ')[2].to_f\r\n end\r\n # mysqld usage\r\n tread_desc = IO.popen(\"ps aux|grep mysqld\").read.split(\"\\n\")[0].split \" \" #get total info about mysql-process\r\n #form json\r\n return {\r\n rows: [{\r\n type: \"CPU free\",\r\n total: 100\r\n },{\r\n type: \"Mysql used\",\r\n total: tread_desc[2].to_f\r\n },{\r\n type: 'Other',\r\n total: total_used_cpu - tread_desc[2].to_f\r\n }]\r\n }.to_json\r\nend",
"def job_stats\n jobpath = Pathname.new(jobdir)\n std_out = jobpath + \"#{prefix}.o#{pid.split('.')[0]}\"\n\n nodes, elements, cputime, walltime = nil\n # if std_out.exist?\n # File.foreach(std_out) do |line|\n # nodes = line.split[4] if line.include? \"MAXIMUM NODE NUMBER\"\n # elements = line.split[4] if line.include? \"MAXIMUM ELEMENT NUMBER\"\n # cputime = \"#{line.split[5]} s\" if line.include? \"CP Time\"\n # walltime = \"#{line.split[5]} s\" if line.include? \"Elapsed Time\"\n # end\n # end\n Hash[\"Number of Nodes\" => nodes,\n \"Number of Elements\" => elements,\n \"CPU Time\" => cputime,\n \"Wall Time\" => walltime]\n end",
"def print_stats\n puts \"==================================================\"\n puts \"================= Statistics =====================\"\n puts \"==================================================\"\n \n calc_stats()\n \n puts \"Total Records = #{@total_rec_cnt}\"\n puts \"Well Formed Records = #{@well_formed_rec_cnt}\"\n puts \"Malformed Records = #{@malformed_rec_cnt}\"\n puts \"Unique Business Records = #{@biz_rec_cnt}\"\n puts \"Unique User Records = #{@user_rec_cnt}\"\n puts \"\"\n end",
"def get_process_stat\n self.get_all_pid.each do |pid|\n uid = self.get_uid_of_pid(pid)\n username = Etc::getpwuid(uid).name\n\n statline = IO.read(\"/proc/#{pid}/stat\")\n stat = statline.split(' ')\n #time = stat[13].to_i+stat[14].to_i+stat[15].to_i+stat[16].to_i\n time = stat[13].to_i+stat[14].to_i\n if (!@currprocstat.has_key?(username))\n @currprocstat[username] = 0\n end\n @currprocstat[username] = @currprocstat[username] + time \n\n iowait = stat[41].to_i\n if (!@currprociowait.has_key?(username))\n @currprociowait[username] = 0\n end\n @currprociowait[username] += iowait\n end\n end",
"def global_cpu_usage_extended_information\n super\n end",
"def monitor\n summary = @host.summary\n hardware = summary.hardware\n stats = summary.quickStats\n\n @cpuModel = hardware.cpuModel\n @cpuMhz = hardware.cpuMhz\n\n @total_cpu = hardware.numCpuCores*100\n @used_cpu = (stats.overallCpuUsage.to_f / @cpuMhz.to_f) * 100\n @used_cpu = sprintf('%.2f', @used_cpu).to_f # Trim precission\n\n @total_memory = hardware.memorySize/1024\n @used_memory = stats.overallMemoryUsage*1024\n\n net = VIDriver::retrieve_stats([@host],\n [\"net.packetsRx\",\"net.packetsTx\"])\n @net_rx = 0\n @net_tx = 0\n\n if net[@host] && net[@host][:metrics]\n if net[@host][:metrics][\"net.packetsRx\"]\n @net_rx = net[@host][:metrics][\"net.packetsRx\"].first\n end\n\n if net[@host][:metrics][\"net.packetsTx\"]\n @net_tx = net[@host][:metrics][\"net.packetsTx\"].first\n end\n end\n\n # Check for negative values\n @used_memory = 0 if @used_memory.to_i < 0\n @used_cpu = 0 if @used_cpu.to_i < 0\n @net_rx = 0 if @net_rx.to_i < 0\n @net_tx = 0 if @net_tx.to_i < 0\n\n # Check free datastore space\n @free_ds_info = VIDriver::retrieve_free_ds(@host)\n end",
"def monitor(stats)\n reset_monitor\n\n refresh_rate = 20 # 20 seconds between samples (realtime)\n\n @state = state_to_c(@vm.vm_info['summary.runtime.powerState'])\n\n return if @state != VM_STATE[:active]\n\n cpu_mhz = @vm.vm_info[:esx_host_cpu]\n\n # rubocop:disable Layout/LineLength\n @monitor[:used_memory] = @vm.vm_info['summary.quickStats.hostMemoryUsage'].to_i * 1024\n # rubocop:enable Layout/LineLength\n used_cpu = @vm.vm_info['summary.quickStats.overallCpuUsage'].to_f \\\n / cpu_mhz\n used_cpu = (used_cpu * 100).to_s\n # rubocop:disable Style/FormatStringToken\n @monitor[:used_cpu] = format('%.2f', used_cpu).to_s\n # rubocop:enable Style/FormatStringToken\n\n # Check for negative values\n @monitor[:used_memory] = 0 if @monitor[:used_memory].to_i < 0\n @monitor[:used_cpu] = 0 if @monitor[:used_cpu].to_i < 0\n\n guest_ip_addresses = []\n unless @vm['guest.net'].empty?\n @vm.vm_info['guest.net'].each do |net|\n next unless net.ipConfig\n next if net.ipConfig.ipAddress.empty?\n\n net.ipConfig.ipAddress.each do |ip|\n guest_ip_addresses << ip.ipAddress\n end\n end\n end\n\n @guest_ip_addresses = guest_ip_addresses.join(',')\n\n if stats.key?(@item)\n metrics = stats[@item][:metrics]\n\n nettx_kbpersec = 0\n if metrics['net.transmitted']\n metrics['net.transmitted'].each do |sample|\n nettx_kbpersec += sample if sample > 0\n end\n end\n\n netrx_kbpersec = 0\n if metrics['net.bytesRx']\n metrics['net.bytesRx'].each do |sample|\n netrx_kbpersec += sample if sample > 0\n end\n end\n\n read_kbpersec = 0\n if metrics['virtualDisk.read']\n metrics['virtualDisk.read'].each do |sample|\n read_kbpersec += sample if sample > 0\n end\n end\n\n read_iops = 0\n if metrics['virtualDisk.numberReadAveraged']\n metrics['virtualDisk.numberReadAveraged'].each do |sample|\n read_iops += sample if sample > 0\n end\n end\n\n write_kbpersec = 0\n if metrics['virtualDisk.write']\n metrics['virtualDisk.write'].each do |sample|\n write_kbpersec += sample if sample > 0\n end\n end\n\n write_iops = 0\n if metrics['virtualDisk.numberWriteAveraged']\n metrics['virtualDisk.numberWriteAveraged'].each do |sample|\n write_iops += sample if sample > 0\n end\n end\n else\n nettx_kbpersec = 0\n netrx_kbpersec = 0\n read_kbpersec = 0\n read_iops = 0\n write_kbpersec = 0\n write_iops = 0\n end\n\n # Accumulate values if present\n if @one_item && @one_item['MONITORING/NETTX']\n previous_nettx = @one_item['MONITORING/NETTX'].to_i\n else\n previous_nettx = 0\n end\n\n if @one_item && @one_item['MONITORING/NETRX']\n previous_netrx = @one_item['MONITORING/NETRX'].to_i\n else\n previous_netrx = 0\n end\n\n if @one_item && @one_item['MONITORING/DISKRDIOPS']\n previous_diskrdiops = @one_item['MONITORING/DISKRDIOPS'].to_i\n else\n previous_diskrdiops = 0\n end\n\n if @one_item && @one_item['MONITORING/DISKWRIOPS']\n previous_diskwriops = @one_item['MONITORING/DISKWRIOPS'].to_i\n else\n previous_diskwriops = 0\n end\n\n if @one_item && @one_item['MONITORING/DISKRDBYTES']\n previous_diskrdbytes = @one_item['MONITORING/DISKRDBYTES'].to_i\n else\n previous_diskrdbytes = 0\n end\n\n if @one_item && @one_item['MONITORING/DISKWRBYTES']\n previous_diskwrbytes = @one_item['MONITORING/DISKWRBYTES'].to_i\n else\n previous_diskwrbytes = 0\n end\n\n @monitor[:nettx] = previous_nettx +\n (nettx_kbpersec * 1024 * refresh_rate).to_i\n @monitor[:netrx] = previous_netrx +\n (netrx_kbpersec * 1024 * refresh_rate).to_i\n\n @monitor[:diskrdiops] = previous_diskrdiops + read_iops\n @monitor[:diskwriops] = previous_diskwriops + write_iops\n @monitor[:diskrdbytes] = previous_diskrdbytes +\n (read_kbpersec * 1024 * refresh_rate).to_i\n @monitor[:diskwrbytes] = previous_diskwrbytes +\n (write_kbpersec * 1024 * refresh_rate).to_i\n end",
"def resource_usage_summary(flavor, count)\n d = @flavormap[flavor]\n raise \"No such flavor #{flavor}\" if not d\n ram = d[\"ram\"] * count\n vcpus = d[\"vcpus\"] * count \n sprintf(\"%d\\t%d\", vcpus, ram)\nend",
"def parse_proc_stat\n file = '/proc/stat'\n puts \"Parsing #{file}\" if (@config[:verbose]) \n data = File.read(file)\n\n parsed = parse_proc_type_1(data)\n parsed[\"intr_total\"] = parsed[\"intr\"].slice(0,1)\n\n parsed.keys.grep(/^cpu/).sort.each do |cpu_id|\n [\"user_ticks\", \"user_nice_ticks\", \"system_ticks\", \"idle_ticks\", \"iowait_ticks\", \"irq_ticks\", \"softirq_ticks\"].zip(parsed[cpu_id]).each do |label,value|\n full_label = \"#{prefix}.stats.#{cpu_id}.#{label}\"\n prop_name = \"stats.#{label}\"\n emit_stats(prop_name, full_label, value)\n end\n end\n [\"btime\", \"ctxt\", \"intr_total\", \"softirq\", \"procs_blocked\", \"procs_running\", \"processes\"].each do |stat|\n full_label = \"#{prefix}.stats.#{stat}\" \n prop_name = \"stats.#{stat}\"\n value = parsed[stat].first\n \n emit_stats(prop_name, full_label, value)\n end\n end",
"def job_stats\n jobpath = Pathname.new(jobdir)\n std_out = jobpath + \"#{prefix}.o#{pid.split('.')[0]}\"\n\n nodes, elements, cputime, walltime = nil\n if std_out.exist?\n File.foreach(std_out) do |line|\n nodes = line.split[4] if line.include? \"MAXIMUM NODE NUMBER\"\n elements = line.split[4] if line.include? \"MAXIMUM ELEMENT NUMBER\"\n cputime = \"#{line.split[5]} s\" if line.include? \"CP Time\"\n walltime = \"#{line.split[5]} s\" if line.include? \"Elapsed Time\"\n end\n end\n Hash[\"Number of Nodes\" => nodes,\n \"Number of Elements\" => elements,\n \"CPU Time\" => cputime,\n \"Wall Time\" => walltime]\n end",
"def job_stats\n jobpath = Pathname.new(jobdir)\n std_out = jobpath + \"#{prefix}.o#{pid.split('.')[0]}\"\n\n nodes, elements, cputime, walltime = nil\n if std_out.exist?\n File.foreach(std_out) do |line|\n nodes = line.split[4] if line.include? \"MAXIMUM NODE NUMBER\"\n elements = line.split[4] if line.include? \"MAXIMUM ELEMENT NUMBER\"\n cputime = \"#{line.split[5]} s\" if line.include? \"CP Time\"\n walltime = \"#{line.split[5]} s\" if line.include? \"Elapsed Time\"\n end\n end\n Hash[\"Number of Nodes\" => nodes,\n \"Number of Elements\" => elements,\n \"CPU Time\" => cputime,\n \"Wall Time\" => walltime]\n end",
"def list_details\n max = ::Hash.new{|h,k| h[k]=0 }\n list = []\n\n names = $LOAD_MANAGER.names.sort\n\n names.each do |name|\n next if name == 'ruby'\n\n libs = $LOAD_MANAGER[name]\n libs = Array(libs).sort\n\n libs.each do |lib|\n data = lib.to_h.rekey\n #data[:loadpath] = data[:loadpath].join(' ')\n data[:date] = Utils.iso_date(data[:date])\n\n data.each do |k,v|\n max[k] = v.to_s.size if v.to_s.size > max[k]\n end\n\n list << data\n end\n end\n\n max = max.values_at(:name, :version, :date, :location) #, :loadpath)\n\n list = list.map do |data|\n data.values_at(:name, :version, :date, :location) #, :loadpath)\n end\n \n mask = max.map{ |size| \"%-#{size}s\" }.join(' ') + \"\\n\"\n\n out = ''\n list.each do |name, vers, date, locs, lpath|\n str = mask % [name, vers, date, locs, lpath]\n out << str \n end\n\n puts out\n end",
"def stats\n \n end",
"def outputs \n result = OpenStudio::Measure::OSOutputVector.new\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('panel_rated_output') # w/m^2\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('panel_rated_output_ip') # w/ft^2\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('system_rated_output') # w\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('pv_area_total_ip') # w\\ft^2\n result << OpenStudio::Measure::OSOutput.makeStringOutput('facade') # w\\ft^2\n return result\n end",
"def os_x_raw_ps\n\t\t`COLUMNS=9999 ps ax -o \"pid uid ppid rss cpu command\"`\n\tend",
"def os_x_raw_ps\n\t\t`COLUMNS=9999 ps ax -o \"pid uid ppid rss cpu command\"`\n\tend",
"def report_results( timings )\n t = timings.first\n output.puts \n output.puts \" Total files read : #{\"%12d\" % t.value_stats.count}\"\n output.puts \" Total bytes read : #{\"%12d\" % t.value_stats.sum}\"\n output.puts \" Minimum filesize : #{\"%12d\" % t.value_stats.min}\"\n output.puts \" Average filesize : #{\"%16.3f\" % t.value_stats.mean}\"\n output.puts \" Maximum filesize : #{\"%12d\" % t.value_stats.max}\"\n output.puts \" Stddev of sizes : #{\"%16.3f\" % t.value_stats.stddev}\"\n output.puts\n\n output.puts [\"%28s\" % \"read order\", \"%20s\" % \"Elapsed time (sec)\", \"%22s\" % \"Read rate (bytes/sec)\" ].join(\" \")\n output.puts \"-\" * 72\n timings.each do |timing|\n p = [ ]\n p << \"%28s\" % timing.name\n p << \"%20.3f\" % timing.timed_stats.sum\n p << \"%22.3f\" % timing.rate\n output.puts p.join(\" \")\n end\n output.puts\n end",
"def user_system_info\n {\n :system => NoPlanB::HttpHeaderUtils.extract_system_info(request.env['HTTP_USER_AGENT']),\n :browser => NoPlanB::HttpHeaderUtils.extract_browser_info(request.env['HTTP_USER_AGENT']),\n :ip_address => request.remote_ip\n }\n end",
"def dev_stat\n begin\n @dev_stat ||= Sys::Filesystem.stat dev_path\n rescue SystemCallError\n @dev_stat = nil\n end\n end",
"def disk_usage_information\n super\n end",
"def get_stats\n end_reg = /<\\/All_Nodes>/\n start_reg = /<All_Nodes>/\n lines = get_command_response(command: \"sgnodes all\", start_reg: start_reg, end_reg: end_reg)\n xml_string = lines.join(\"\\n\")\n stats = {\"Total\" => {count: 0}}\n doc = Nokogiri::XML(xml_string)\n handle_node(stats: stats, node: doc.root)\n stats\n end",
"def get_parallels_os(options,vm_name)\n\tmessage = \"Information:\\tDetermining OS for \"+vm_name\n\tcommand = \"prlctl list --info \\\"#{vm_name}\\\" |grep '^OS' |cut -f2 -d:\"\n\tos_info = execute_command(options,message,command)\n\tcase os_info\n\twhen /rhel/\n\t\tos_info = \"RedHat Enterprise Linux\"\n\tend\n\treturn os_info\nend",
"def system_bins\n %w[\n cal col colcrt colrm\n getopt\n hexdump\n logger look\n mesg more\n nologin\n renice rev\n ul\n whereis\n ]\n end",
"def get_idfw_system_statistics_data(opts = {})\n data, _status_code, _headers = get_idfw_system_statistics_data_with_http_info(opts)\n data\n end",
"def memory_usage\n return File.read('/proc/self/status').match(/VmRSS:\\s+(\\d+)/)[1].to_i * 1024\nend",
"def system_information\n super\n end",
"def system_information\n super\n end",
"def total_per_system(&block)\n @systotals.sort.each do | name, linehash |\n output name, 0, linehash.values.sum, &block\n end\n end",
"def html_report_stats\n @report << '<div id=\"title\"> General Statistics</div>'\n stat_tab = Ruport::Data::Table(%w[Stat Value])\n stat_tab << ['Number of servers Seen', @num_servers]\n stat_tab << ['Number of clients Seen', @num_clients]\n @num_by_cipher.each do |cipher, num|\n stat_tab << ['Encryption: ' + cipher, num]\n end\n @report << stat_tab.to_html\n @report << '<br /><br />'\n end",
"def all_cpu_usage_extended_information\n super\n end",
"def status(secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n stats = get_stats(secret)\n\n stats_str = <<-STATUS\n Currently using #{stats['cpu']} Percent CPU and #{stats['memory']} Percent Memory\n Hard disk is #{stats['disk']} Percent full\n Is currently: #{stats['roles'].join(', ')}\n Database is at #{stats['db_location']}\n Is in cloud: #{stats['cloud']}\n Current State: #{stats['state']}\n STATUS\n\n if my_node.is_appengine?\n app_names = []\n stats['apps'].each { |k, v|\n app_names << k\n }\n\n stats_str << \" Hosting the following apps: #{app_names.join(', ')}\\n\"\n\n stats['apps'].each { |app_name, is_loaded|\n next if !is_loaded\n next if app_name == \"none\"\n if !@app_info_map[app_name]['appengine'].nil?\n stats_str << \" The number of AppServers for app #{app_name} is: \" +\n \"#{@app_info_map[app_name]['appengine'].length}\\n\"\n end\n }\n end\n \n return stats_str\n end",
"def send_meminfo(event)\n if !$linux\n event << \"Sorry, this function requires a Linux system\"\n return\n end\n\n mem = `ps -p #{Process.pid} -o rss=`.to_i / 1024.0\n total = meminfo['MemTotal']\n available = meminfo['MemAvailable']\n used = total - available\n\n str = \"system: #{\"%4d MB\" % available} of #{\"%4d MB\" % total} (#{\"%5.2f%%\" % [100 * available / total]}) available\\n\"\n str << \"outte: #{\"%4d MB\" % mem} of #{\"%4d MB\" % used} (#{\"%5.2f%%\" % [100 * mem / used]}) used\"\n event << \"Memory usage:\\n#{format_block(str)}\"\nrescue => e\n lex(e, \"Error getting memory info.\", event: event)\nend",
"def do_stat\n\n lib.tcrdbstat(@db) # note : this is using tcrdbstat\n end",
"def list_system_statistics_historic\n @instance = prepare_param_instance\n @stat_class_bit = params[:stat_class][:bit] # Bit-wert fuer Test auf Statistic-Klasse\n @stat_class_bit = nil if @stat_class_bit == \"\"\n\n save_session_time_selection # Werte puffern fuer spaetere Wiederverwendung\n\n list_system_statistics_historic_sum if params[:sum]\n list_system_statistics_historic_full if params[:full]\n end",
"def filestat\n\t\tbrand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::FileStat)\n\tend",
"def haproxy_stat(pxname, svname)\n csv_content = haproxy_show_stat\n index = csv_content[0].index('status')\n\n csv_content.each do |line|\n if line[0] =~ /#{pxname}/i && line[1] =~ /#{svname}/\n return line[index].strip\n end\n end\n\n nil\nend",
"def show_stat\n \t\tputs \"=============Statistics============\"\n \t\tputs \"Score: #{get_score}\"\n \t\tputs \"Total time: \" + \"%0.2f\" %(@end_time - @start_time + @save_time) + \" seconds\"\n \t\tputs \"Number of sets found: #{@number_of_correct}\"\n \t\tputs \"#{@number_of_hint}/#{@total_hint} hints used\"\n \tend"
] |
[
"0.6882971",
"0.68804306",
"0.68587166",
"0.68384486",
"0.6808128",
"0.65560126",
"0.6497229",
"0.6483706",
"0.6420413",
"0.6406048",
"0.6335443",
"0.63300586",
"0.6326804",
"0.6307538",
"0.6275302",
"0.62235785",
"0.62192965",
"0.61828184",
"0.6137653",
"0.6125858",
"0.61115855",
"0.60952413",
"0.6086701",
"0.6083177",
"0.60673475",
"0.6036417",
"0.6036417",
"0.6032957",
"0.60282564",
"0.6013971",
"0.60136634",
"0.60038054",
"0.5997938",
"0.59783554",
"0.5977811",
"0.59687483",
"0.59675133",
"0.5943426",
"0.59279335",
"0.59161896",
"0.5910107",
"0.5909634",
"0.5903604",
"0.5903604",
"0.589197",
"0.587701",
"0.58768153",
"0.5866816",
"0.5862285",
"0.58562267",
"0.5854844",
"0.5854816",
"0.5848575",
"0.5836945",
"0.5824646",
"0.58246297",
"0.58234036",
"0.5820575",
"0.58188283",
"0.5791846",
"0.5784823",
"0.57840484",
"0.5781264",
"0.5777479",
"0.5766986",
"0.5762989",
"0.57571846",
"0.5757033",
"0.5756188",
"0.5747617",
"0.574092",
"0.57373685",
"0.5721617",
"0.5720998",
"0.57180345",
"0.5699146",
"0.56987566",
"0.56925654",
"0.56925654",
"0.56902957",
"0.5678297",
"0.56691664",
"0.5647154",
"0.5646245",
"0.56440216",
"0.56270707",
"0.5617564",
"0.56155366",
"0.56143975",
"0.56143975",
"0.5612021",
"0.56097275",
"0.5608465",
"0.5602175",
"0.5594549",
"0.55912566",
"0.55818707",
"0.5579976",
"0.55751294",
"0.55745506"
] |
0.623746
|
15
|
Created On: 08/11/2014 Purpose: To get browser statistics report ++
|
def get_access_browser(overall_device_access)
device_access = overall_device_access.where(access_operating_system: "Computer")
total_device_count = device_access.count
chrome_count = device_access.where(:access_browser => "Chrome").count
chrome_count_percent = ((chrome_count.to_f * 100) / total_device_count).round(2)
internet_explorer_count = device_access.where("access_browser like ?", "%#{"ie"}%").count
internet_explorer_count_percent = ((internet_explorer_count.to_f * 100) / total_device_count).round(2)
safari_count = device_access.where(:access_browser => "Safari").count
safari_count_percent = ((safari_count.to_f * 100) / total_device_count).round(2)
other_count = device_access.where(:access_browser => "Other").count
other_count_percent = ((other_count.to_f * 100) / total_device_count).round(2)
access_browser_data = Hash[
"chrome_count_data" => chrome_count, "internet_explorer_count_data" => internet_explorer_count,
"safari_count_data" => safari_count, "chrome_percent" => chrome_count_percent,
"internet_explorer_percent" => internet_explorer_count_percent, "safari_percent" => safari_count_percent,
"other_count_data" => other_count, "other_percent" => other_count_percent
]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def html_report_stats\n @report << '<div id=\"title\"> General Statistics</div>'\n stat_tab = Ruport::Data::Table(%w[Stat Value])\n stat_tab << ['Number of servers Seen', @num_servers]\n stat_tab << ['Number of clients Seen', @num_clients]\n @num_by_cipher.each do |cipher, num|\n stat_tab << ['Encryption: ' + cipher, num]\n end\n @report << stat_tab.to_html\n @report << '<br /><br />'\n end",
"def get_html_stats()\n\t\t\t\thtml = %Q{\n\t\t\t\t\t<html><head>\n\t\t\t\t\t\t<script src=\"#{XSSF_GUI_FILES}swfobject.js\" type=\"text/javascript\"></script>\n\t\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\t\tfunction createXHR() {\n\t\t\t\t\t\t\t\tif (window.XMLHttpRequest) return new XMLHttpRequest();\n\t\t\t \n\t\t\t\t\t\t\t\tif (window.ActiveXObject) {\n\t\t\t\t\t\t\t\t\tvar names = [\"Msxml2.XMLHTTP.6.0\", \"Msxml2.XMLHTTP.3.0\", \"Msxml2.XMLHTTP\", \"Microsoft.XMLHTTP\"];\n\t\t\t\t\t\t\t\t\tfor(var i in names) {\n\t\t\t\t\t\t\t\t\t\ttry{ return new ActiveXObject(names[i]); }\n\t\t\t\t\t\t\t\t\t\tcatch(e){}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfor i in (1..5)\n\t\t\t\t\thtml << %Q{ \n\t\t\t\t\t\tswfobject.embedSWF(\"#{XSSF_GUI_FILES}ofc.swf\", \"gr#{i}\", \"100%\", \"275\", \"9.0.0\", \"expressInstall.swf\", {\"data-file\":\"#{VICTIM_GUI}?#{PARAM_GUI_JSON}%3Dgr#{i}%26#{PARAM_GUI_PAGE}%3Dstat\"});\n\t\t\t\t\n\t\t\t\t\t\tsetInterval(update#{i}, 3000);\n\t\t\t\t\t\t\n\t\t\t\t\t\tfunction update#{i}() {\n\t\t\t\t\t\t\tchart_#{i} = document.getElementById(\"gr#{i}\");\n\n\t\t\t\t\t\t\txhr#{i} = createXHR();\n\t\t\t\t\t\t\txhr#{i}.open(\"GET\", '#{VICTIM_GUI}?#{PARAM_GUI_JSON}=gr#{i}&#{PARAM_GUI_PAGE}=stat&time=' + escape(new Date().getTime()), true);\n\t\t\t\t\t\t\txhr#{i}.send(null);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\txhr#{i}.onreadystatechange=function() {\tif (xhr#{i}.readyState == 4) { chart_#{i}.load(xhr#{i}.responseText); } }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tend\n\n\t\t\t\thtml << %Q{\t\t\t\t\t\n\t\t\t\t\t</script>\n\t\t\t\t\t</head><body bgcolor=black style='font-family:monospace'>\n\t\t\t\t\t\t<table width=100% height=95% cellpadding=0 cellspacing=0 cellmargin=0 BORDER>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><div id=\"gr1\"></div></td><td><div id=\"gr3\"></div></td><td rowspan=2 width=40%><div id=\"gr5\"></div></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><div id=\"gr2\"></div></td><td><div id=\"gr4\"></div></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t<center><div style=\"color:white\">Charts provided by <a href=\"javascript: top.location='http://teethgrinder.co.uk/open-flash-chart/'\">\"Open Flash Chart\"</a></div></center>\n\t\t\t\t\t</body></html>\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn html\n\t\t\tend",
"def statistics; end",
"def generate_site_stats\n H.ul {\n H.li {\"#{$r.get(\"users.count\")} users\"} +\n H.li {\"#{$r.zcard(\"news.cron\")} news posted\"} +\n H.li {\"#{$r.info['used_memory_human']} of used memory\"}\n }\nend",
"def raw_stats\n url = URI.parse(stats_url)\n Net::HTTP.start(url.host, url.port) {|http|\n http.request(Net::HTTP::Get.new(url.path))\n }.body\nend",
"def stats; end",
"def stats; end",
"def get_statistics\n response = get_siteinfo('statistics')\n ret = {}\n response['query']['statistics'].each { |k, v| ret[k] = v }\n ret\n end",
"def get_browser_sampling_profile\n {\n method: \"Memory.getBrowserSamplingProfile\"\n }\n end",
"def main_page_stats(params)\n s = \"\"\n # Show counters at the top of the page\n counters = {}\n params[:stats].each do |stat|\n if stat.class == Counter and stat.conditions.server == nil\n counters.update({stat.descr => stat.value})\n # s << output_counter(stat:stat)\n end\n end\n s << output_list_group(counters,tabs=params[:tabs])\n @inc = 0\n params[:stats].each do |stat|\n if stat.class == Distribution and stat.conditions.server == nil\n s << output_distrib_normal(stat:stat,tabs:params[:tabs],sort_type:stat.sort_type)\n end\n end\n s\n end",
"def getReport(oStatsProxy, iMechanizeAgent, iUserID)\n # Get the report page\n lReportPage = iMechanizeAgent.get(\"http://www.reverbnation.com/artist/artist_report_printable/#{iUserID}\")\n lChartPositionGenre = nil\n lChartPositionGlobal = nil\n lReportPage.root.css('body div#mainwrap div div div.control_room_graph_column').each do |iStatsSectionNode|\n lChildrenNodes = iStatsSectionNode.children\n lChildrenNodes.each_with_index do |iNode, iIdx|\n if (iNode.content == 'Genre:')\n lChartPositionGenre = Integer(lChildrenNodes[iIdx+1].content.strip.gsub(',',''))\n elsif (iNode.content == 'Global:')\n lChartPositionGlobal = Integer(lChildrenNodes[iIdx+1].content.strip.gsub(',',''))\n end\n end\n if ((lChartPositionGenre != nil) and\n (lChartPositionGlobal != nil))\n break\n end\n end\n if (lChartPositionGenre == nil)\n log_err \"Unable to get the chart positions: #{lReportPage.root}\"\n else\n lBandEquityScore = nil\n lNbrFriends = nil\n lReportPage.root.css('body div#mainwrap div div div.printable_pane').each do |iPaneNode|\n lChildrenNodes = iPaneNode.children\n lChildrenNodes.each_with_index do |iNode, iIdx|\n if (iNode.content == 'Band Equity Score: ')\n lBandEquityScore = Integer(lChildrenNodes[iIdx+1].content.strip.gsub(',',''))\n elsif (iNode.content == 'Total Fans: ')\n lNbrFriends = Integer(lChildrenNodes[iIdx+1].content.strip.gsub(',',''))\n end\n end\n if ((lBandEquityScore != nil) and\n (lNbrFriends != nil))\n break\n end\n end\n if (lBandEquityScore == nil)\n log_err \"Unable to get the band equity score: #{lReportPage.root}\"\n elsif (lNbrFriends == nil)\n log_err \"Unable to get the number of friends: #{lReportPage.root}\"\n else\n oStatsProxy.add_stat('Global', 'Chart position genre', lChartPositionGenre)\n oStatsProxy.add_stat('Global', 'Chart position global', lChartPositionGlobal)\n oStatsProxy.add_stat('Global', 'Band equity', lBandEquityScore)\n oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)\n end\n end\n end",
"def http_statistics\n super\n end",
"def stats\n ## TODO:\n end",
"def stats\n end",
"def stats\n end",
"def search_stats\n @page_source.find_element(:id, 'result-stats')&.text&.strip\n rescue element_not_found\n with_zero\n end",
"def get_statistics\n raise 'Method unavailable for Synergy'\n end",
"def statistics\n stats_hash = {}\n stats = info_cmd(\"statistics\")\n\n stats = stats.gsub!(/statistics\\s/, '').gsub!(/\\n/, '').split(\";\")\n\n stats.each do |st|\n type = \"\"\n value = nil\n\n st.split(\"=\").each_with_index do |val, i|\n type = val if i == 0\n value = val if i == 1\n end\n\n stats_hash[type] = value\n end\n\n stats_hash\n end",
"def stats\n request :get, \"_stats\"\n end",
"def stats\n request :get, \"_stats\"\n end",
"def response_time_metrics\n result = {}\n @urls.each do |url|\n result[url[:name]] = get_metrics(url[:path])\n end\n print result\n end",
"def usage_stats\n\t login_filter\n \n\t stats_page = @agent.get(\"/account\")\n\t \n\t stats = stats_page.at('#usage-percent').content.scan(/(\\d+(?:\\.\\d+)?)%\\ used\\ \\((\\d+(?:\\.\\d+)?)([MG])B of (\\d+(?:\\.\\d+)?)GB\\)/).collect{ |d|\n\t { :used => d[1].to_f * ((d[2] == \"G\") ? 1024 : 1),\n\t :total => d[3].to_f * 1024,\n\t :free => (d[3].to_f * 1024 - d[1].to_f * ((d[2] == \"G\") ? 1024 : 1)),\n\t :percent => Percentage.new(d[0].to_f/100)\n\t }\n\t }[0]\n\t \n\t regular_data = stats_page.at('span.bar-graph-legend.bar-graph-normal').next.content.scan(/\\((\\d+(?:\\.\\d+)?)([MG])B/)[0]\n\t stats[:regular_used] = regular_data[0].to_f * ((regular_data[1] == \"G\") ? 1024 : 1) unless regular_data.nil?\n\n\t shared_data = stats_page.at('span.bar-graph-legend.bar-graph-shared').next.content.scan(/\\((\\d+(?:\\.\\d+)?)([MG])B/)[0]\n\t stats[:shared_used] = shared_data[0].to_f * ((shared_data[1] == \"G\") ? 1024 : 1) unless shared_data.nil?\n\n return stats\n end",
"def stats\n _get(\"/system/stats\") { |json| json }\n end",
"def check_size\n c = HTTPClient.new\n ##\n # The downloaded page size\n ##\n #comp_get = c.head(@server.url)\n #byebug\n #compressed_page = comp_get.headers[\"Content-Length\"].to_i if comp_get.status == 200\n @result.passed(\"HTML: Page size #{@server.response.data.length.to_human} \") # (#{compressed_page.to_human} compressed)\")\n\n ##\n # Use this base\n ##\n base = URI.parse(\"#{@server.url.scheme}://#{@server.url.host}\")\n\n ## \n # Sum the Javascript scripts\n # Note: Need to take into account Google Analytics building a script tag that\n # this static analysis doesn't consider\n ##\n js_length = @server.response.doc.xpath('//script/@src').inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s).headers[\"Content-Length\"].to_i\n end\n\n ## This will produce incorrect results if the server doesn't support gz\n cjs_length = @server.response.doc.xpath('//script/@src').inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s + \".gz\").headers[\"Content-Length\"].to_i\n end\n @result.passed(\"HTML: Javascript size #{js_length.to_human} (Compressed: #{cjs_length.to_human})\")\n\n ##\n # Sum the CSS\n ##\n cs_length = @server.response.doc.xpath('//link/@href').select{|s| s.value[/css$/]}.inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s).headers[\"Content-Length\"].to_i\n end\n ccs_length = @server.response.doc.xpath('//link/@href').select{|s| s.value[/css$/]}.inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s + \".gz\").headers[\"Content-Length\"].to_i\n end\n @result.passed(\"HTML: Style size #{cs_length.to_human}\")\n end",
"def display_webpage_views\n webpage_views\n puts 'Overall webpage views'\n puts \"\\n\"\n @webpage_views_hash.each do |webpage, view_hash|\n puts webpage\n puts \"#{view_hash.values[0]} unique views\"\n puts \"#{view_hash.values[1]} total views\"\n puts \"\\n\"\n end\n end",
"def log_useful_data\n self.result.record_data('screen_size', \"#{@browser.screen_width} X #{@browser.screen_height}\")\n self.result.record_data('proxy_details', proxy_details)\n browser_info # Fetching the UserAgent data\n self.result.record_data('platform', browser_name: browser_name,\n browser_version: browser_version,\n os_platform: os_platform)\n end",
"def getDashboard(oStatsProxy, iMechanizeAgent)\n # Get the dashboard page\n lJSonData = eval(iMechanizeAgent.get_file('http://www.myspace.com/stats/fans_json/profile_stats/en-US/x=0').gsub(':','=>'))\n lNbrVisits = Integer(lJSonData['data'].select { |iItem| next (iItem[0] == 'myspace_views') }.first[-1].gsub(',',''))\n lNbrFriends = Integer(lJSonData['data'].select { |iItem| next (iItem[0] == 'myspace_friends') }.first[-1].gsub(',',''))\n oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)\n oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)\n\n # OLD VERSION (keeping it as Myspace changes all the time\n# lDashboardPage = iMechanizeAgent.get('http://www.myspace.com/music/dashboard')\n# # Get the variables used by the Ajax script\n# lMatch = lDashboardPage.root.css('section.moduleBody script').first.content.split(\"\\n\").join.match(/var appID = \"([^\"]*)\".*var pkey = \"([^\"]*)\";/)\n# lAppID, lPKey = lMatch[1..2]\n# lCoreUserID = nil\n# lDashboardPage.root.css('body script').each do |iScriptNode|\n# lMatch = iScriptNode.content.split(\"\\n\").join.match(/var coreUserId =(\\d*)/)\n# if (lMatch != nil)\n# # Found it\n# lCoreUserID = lMatch[1]\n# break\n# end\n# end\n# if (lCoreUserID == nil)\n# log_err \"Unable to find the core user ID: #{lDashboardPage.root}\"\n# else\n# # Call the Ajax script\n# lStatsAjaxContent = iMechanizeAgent.get_file(\"http://www.myspace.com/Modules/Music/Handlers/Dashboard.ashx?sourceApplication=#{lAppID}&pkey=#{lPKey}&action=GETCORESTATS&userID=#{lCoreUserID}\")\n# lStrVisits, lStrFriends = lStatsAjaxContent.match(/^\\{'totalprofileviews':'([^']*)','totalfriends':'([^']*)'/)[1..2]\n# lNbrVisits = Integer(lStrVisits.delete(','))\n# lNbrFriends = Integer(lStrFriends.delete(','))\n# oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)\n# oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)\n# end\n end",
"def track\n url = Rails.env.development? ? \"http://localhost:8000/stat\" : \"http://stats.universit.as/stat\"\n RestClient.get(url, :params => {\n :ip => request.remote_ip,\n :title => request.referrer\n })\n render :js => ''\n end",
"def report_html\n Report.html_version\n end",
"def print_congifugartion\n puts \"Configuration : \"+$driver.execute_script(\"return navigator.userAgent;\")\n puts \"Date and Time : #{Time.now}\"\nend",
"def server_page_stats(params)\n s = \"\"\n params[:stats].each do |stat|\n # Show counters at the top\n if stat.class == Counter and stat.conditions.server == params[:server]\n s << output_counter(stat:stat)\n end\n end\n # @inc = 0 Already in for_each_server\n params[:stats].each do |stat|\n if stat.class == Distribution and stat.conditions.server == params[:server]\n s << output_distrib_normal(stat:stat,tabs:params[:tabs],sort_type:stat.sort_type)\n end\n end\n s\n end",
"def get_question_stats\n question_stats = {}\n question_overview = @base_url + @question_overview_hash[@question].href\n @agent.get question_overview\n view_links = @agent.page.links.find_all{|link| link.text.include? 'view'}\n submission_page = view_links.first.click\n html = submission_page.body\n html_nokogiri = Nokogiri::HTML submission_page.body\n\n # regexp match to pull scores\n public_test_score = html[/[0-9]\\/[0-9]\\s*points for public test cases./]\n release_test_score = html[/[0-9]\\/[0-9]\\s*points for release tests./]\n release_tokens = html[/[0-9]\\s*release\\s*tokens\\s*/]\n release_token_regeneration = html_nokogiri.xpath('//ul').text.gsub!(/[^0-9A-Za-z ]/, '')\n\n question_stats['public_test'] = public_test_score[/[0-9]\\/[0-9]/] if public_test_score\n question_stats['release_test'] = release_test_score[/[0-9]\\/[0-9]/] if release_test_score\n question_stats['release_tokens'] = release_tokens[/[0-9]/] if release_tokens\n question_stats['release_token_regeneration'] = release_token_regeneration\n\n return question_stats\n end",
"def browser_info\n # Fetch the UserAgent string using javascript navigator object\n ua_string = browser.execute_script('return navigator.userAgent')\n @parsed_ua = UserAgent.parse(ua_string)\n end",
"def statistics\n JSON.parse @gapi.statistics.to_json\n end",
"def stats\n \n end",
"def send_agent_stats\n curr_time = Time.now\n\n if curr_time - @last_stat_flush > @stats_interval\n t = Process.times\n # amount of user/system cpu time in seconds\n Hastur.gauge(\"hastur.agent.utime\", t.utime, curr_time)\n Hastur.gauge(\"hastur.agent.stime\", t.stime, curr_time)\n # completed child processes' (plugins) user/system cpu time in seconds (always 0 on Windows NT)\n Hastur.gauge(\"hastur.agent.cutime\", t.cutime, curr_time)\n Hastur.gauge(\"hastur.agent.cstime\", t.cstime, curr_time)\n\n @counters.each do |name,count|\n if count > 0\n Hastur.counter(\"hastur.agent.#{name}\", count, curr_time)\n @counters[name] = 0\n end\n end\n\n # reset things\n @last_stat_flush = curr_time\n end\n end",
"def test_stats\n assert @page != nil\n\n wc = @analyzer.word_count @view\n puts wc\n # word count from MS Word: 3.648 (including UI text from Mahara)\n assert_equal 3759, wc\n\n external_links = @analyzer.external_links @view\n puts \"external links: #{external_links.size}\"\n # external_links.each do |link|\n # puts \"> \" + link.uri.to_s\n # end\n\n images = @analyzer.images @view\n puts \"images: #{images.size}\"\n # images.each do |image|\n # puts \"> \" + image.to_s\n # end\n\n uploaded_images = @analyzer.uploaded_images @view\n puts \"uploaded_images: #{uploaded_images.size}\"\n\n wikipedia_images = @analyzer.images_from_domain(@view, \"wikipedia\")\n puts \"wikipedia_images: #{wikipedia_images.size}\"\n end",
"def get_member_brief_stats(custid)\n res = $client.get(\"/membersite/member/CareerStats.do?custid=#{custid}\", $headers)\n start = res.body.index('buf = \\'{\"memberSince\"') + 7\n length = res.body.index(\"MemberProfile.driver = extractJSON\") - 3 - start\n data = res.body[start, length]\n JSON.parse data\nend",
"def stats\n Client.current.get(\"#{resource_url}/stats\")\n end",
"def monitoring_stats(region = current_region)\n redis = Redis.new :host => \"localhost\"\n today = \"2012-02-14\" # TODO(philc): \n request_count = redis.get(\"#{region.name}_request_count\").to_i\n errors = redis.get(\"html5player:error_count:#{today}\").to_i\n error_rate = (request_count == 0) ? 0 : (errors / request_count.to_f * 100)\n latency = (request_count == 0) ? 0 : redis.get(\"#{region.name}_latency\").to_i / request_count\n {\n :request_count => request_count,\n :average_latency => latency,\n :error_count => errors,\n :error_rate => error_rate\n }\n end",
"def browser_info(id)\n\t\t\t\tbegin\n\t\t\t\t\tv = find(XSSF_VICTIM_DB, XSSF_VICTIM_HASH, {\"ID\" => id.to_i})\n\t\t\t\t\treturn [v[XSSF_VICTIM_HASH[\"BROWSER_NAME\"]].to_s, v[XSSF_VICTIM_HASH[\"BROWSER_VERSION\"]].to_f, v[XSSF_VICTIM_HASH[\"OS_VERSION\"]].to_s]\n\t\t\t\trescue\n\t\t\t\t\tprint_error(\"Error 23: #{$!}\") if (XSSF_MODE[0] =~ /^Debug$/i)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn [\"Unknown\", \"0\"]\n\t\t\tend",
"def show_site_stats # :nologin: :norobots:\n store_location\n @site_data = SiteData.new.get_site_data\n\n # Add some extra stats.\n @site_data[:observed_taxa] = Name.connection.select_value %(\n SELECT COUNT(DISTINCT name_id) FROM observations\n )\n @site_data[:listed_taxa] = Name.connection.select_value %(\n SELECT COUNT(*) FROM names\n )\n\n # Get the last six observations whose thumbnails are highly rated.\n query = Query.lookup(:Observation, :all,\n by: :updated_at,\n where: \"images.vote_cache >= 3\",\n join: :\"images.thumb_image\")\n @observations = query.results(limit: 6,\n include: { thumb_image: :image_votes })\n end",
"def collect_stats\n # code callously ripped from statistics.rake !\n folders = STATS_FOLDERS.select{|name, dir| File.directory?(dir) }\n cs = CodeStatistics.new(*folders)\n statz = cs.statistics\n tyme = Time.now.to_i\n yaml = { \"build_#{ tyme }\" => statz }.to_yaml\n return yaml.sub(/^---/, '') # abrogate that pesky document marker!\n end",
"def parse_wa()\n state = \"WA\";\n url = 'https://www.doh.wa.gov/emergencies/coronavirus'\n\n browser = Watir::Browser.new\n browser.goto(url);\n\n sleep 10\n\n html = browser.html\n doc = Nokogiri::HTML.parse(html)\n \n tnow = DateTime.now().strftime();\n\n output_fn = \"data/\"+tnow+'_USA_'+state+'.html';\n f = File.open(output_fn,\"w\");\n\n f.puts(doc)\n \n# list_of_tables = doc.css(\"//table\");\n\n# for table in list_of_tables\n# f.puts(table)\n# end\n\n f.close();\n browser.close(); \n return ;\nend",
"def print_stats\n puts \"==================================================\"\n puts \"================= Statistics =====================\"\n puts \"==================================================\"\n \n calc_stats()\n \n puts \"Total Records = #{@total_rec_cnt}\"\n puts \"Well Formed Records = #{@well_formed_rec_cnt}\"\n puts \"Malformed Records = #{@malformed_rec_cnt}\"\n puts \"Unique Business Records = #{@biz_rec_cnt}\"\n puts \"Unique User Records = #{@user_rec_cnt}\"\n puts \"\"\n end",
"def xml_statistics\n super\n end",
"def report_results( timings )\n t = timings.first\n output.puts \n output.puts \" Total files read : #{\"%12d\" % t.value_stats.count}\"\n output.puts \" Total bytes read : #{\"%12d\" % t.value_stats.sum}\"\n output.puts \" Minimum filesize : #{\"%12d\" % t.value_stats.min}\"\n output.puts \" Average filesize : #{\"%16.3f\" % t.value_stats.mean}\"\n output.puts \" Maximum filesize : #{\"%12d\" % t.value_stats.max}\"\n output.puts \" Stddev of sizes : #{\"%16.3f\" % t.value_stats.stddev}\"\n output.puts\n\n output.puts [\"%28s\" % \"read order\", \"%20s\" % \"Elapsed time (sec)\", \"%22s\" % \"Read rate (bytes/sec)\" ].join(\" \")\n output.puts \"-\" * 72\n timings.each do |timing|\n p = [ ]\n p << \"%28s\" % timing.name\n p << \"%20.3f\" % timing.timed_stats.sum\n p << \"%22.3f\" % timing.rate\n output.puts p.join(\" \")\n end\n output.puts\n end",
"def get_stats\n end_reg = /<\\/All_Nodes>/\n start_reg = /<All_Nodes>/\n lines = get_command_response(command: \"sgnodes all\", start_reg: start_reg, end_reg: end_reg)\n xml_string = lines.join(\"\\n\")\n stats = {\"Total\" => {count: 0}}\n doc = Nokogiri::XML(xml_string)\n handle_node(stats: stats, node: doc.root)\n stats\n end",
"def work(filename = 'data.txt', number_lines = FIXNUM_MAX)\n file_lines = read_file(filename, number_lines)\n\n users, sessions = parse_lines(file_lines)\n\n unique_browsers = unique_browsers(sessions)\n\n report = {\n 'totalUsers' => users.length,\n 'uniqueBrowsersCount' => unique_browsers.length,\n 'totalSessions' => sessions.length,\n 'allBrowsers' => unique_browsers.sort!.join(','),\n 'usersStats' => {}\n }\n\n # Статистика по пользователям\n users_objects = collect_users_objects(users, sessions)\n\n collect_stats_from_users(report, users_objects) do |user|\n user_sessions = user.sessions\n user_sessions_times = user_sessions.map { |s| s[:time] }\n user_sessions_browsers = user_sessions.map { |s| s[:browser] }\n {\n 'sessionsCount' => user_sessions.length, # Собираем количество сессий по пользователям\n 'totalTime' => \"#{user_sessions_times.sum} min.\", # Собираем количество времени по пользователям\n 'longestSession' => \"#{user_sessions_times.max} min.\", # Выбираем самую длинную сессию пользователя\n 'browsers' => user_sessions_browsers.sort.join(', '), # Браузеры пользователя через запятую\n 'usedIE' => user_sessions_browsers.any? { |b| b.include?('INTERNET EXPLORER') }, # Хоть раз использовал IE?\n 'alwaysUsedChrome' => user_sessions_browsers.all? { |b| b.include?('CHROME') }, # Всегда использовал только Chrome?\n 'dates' => user_sessions.map! { |s| s[:date] }.sort!.reverse! # Даты сессий через запятую в обратном порядке в формате iso8601\n }\n end\n\n File.write('result.json', \"#{Oj.dump(report)}\\n\")\nend",
"def stats\n @page_title = I18n.t(\"statistics\")\n redirect_to root_url unless current_user.is_admin? # don't release this yet...it's not ready for public consumption\n @stats = PageStatsTaxon.latest\n end",
"def stats\n @stats = {}\n @stats[\"online\"] = \"Of course. That's how the internet works.\"\n @stats[\"requested_at\"] = Time.now\n @stats[\"total_tweets\"] = ActiveRecord::Base.connection.execute(\"explain select count(id) from tweets\").all_hashes.first[\"rows\"]\n @stats[\"total_users\"] = ActiveRecord::Base.connection.execute(\"explain select count(id) from users\").all_hashes.first[\"rows\"]\n @stats[\"number_collections\"] = ActiveRecord::Base.connection.execute(\"select count(id) from collections\").fetch_row.first\n @stats[\"researchers_active\"] = ActiveRecord::Base.connection.execute(\"select count(id) from researchers\").fetch_row.first\n @stats[\"scrape_count\"] = ActiveRecord::Base.connection.execute(\"select count(id) from scrapes\").fetch_row.first\n @stats[\"datasets_count\"] = ActiveRecord::Base.connection.execute(\"select count(id) from collections where single_dataset = 1\").fetch_row.first\n @stats[\"analysis_jobs_completed\"] = ActiveRecord::Base.connection.execute(\"select count(id) from analysis_metadatas\").fetch_row.first\n @stats[\"total_graphs\"] = ActiveRecord::Base.connection.execute(\"select count(id) from graphs\").all_hashes.first[\"rows\"]\n @stats[\"total_graph_points\"] = ActiveRecord::Base.connection.execute(\"select count(id) from graph_points\").all_hashes.first[\"rows\"]\n @stats[\"total_edges\"] = ActiveRecord::Base.connection.execute(\"select count(id) from edges\").fetch_row.first\n respond_to do |format|\n format.xml { render :xml => @stats.to_xml }\n format.json { render :json => @stats.to_json }\n end\n end",
"def quick_stats\n\tend",
"def html_report_inf\n @report << '<div id=\"title\">Infrastructure Networks</div><br /><br />'\n @log.debug(\"Starting reporting Infrastructure networks there were \" + @infrastructure_networks.length.to_s + \" networks to list\")\n @infrastructure_networks.each do |ssid,bssid|\n tab = Ruport::Data::Table(%w[bssid num_clients channel cipher cloaked? manufacturer first_seen last_seen max_signal_dbm])\n ssid = \"Hidden or Blank\" if ssid.length < 1\n @report << '<div id=\"title\">SSID: ' + ssid + ' </div>'\n bssid.each do |net,info|\n if @options.gps_data[net]\n point = net\n @log.debug(\"attempting to add link\")\n link_info = '+(' + ssid + ' | Ciphers: ' + info['cipher'] + ' | Channel: ' + info['channel'] + ')'\n url = 'http://maps.google.co.uk/maps?q=' + @options.gps_data[point]['lat'].to_s + ',' + @options.gps_data[point]['lon'].to_s + link_info\n net = '<a href=\"' + url + '\">' + point + '</a>'\n end\n tab << [net, info['clients'].length.to_s, info['channel'], info['cipher'], info['cloaked'], info['manufacturer'], info['first_seen'], info['last_seen'], info['max_signal_dbm']]\n end\n @report << tab.to_html\n @report << \"<br /> <br />\"\n end\n end",
"def size\n stats[:html]\n end",
"def print_html_time()\n @noko.css(\"li.g:first-of-type\").each do |e|\n puts e\n end\n end",
"def stats\n stats_cache.stats\n end",
"def html_report_probe\n @log.debug(\"Starting to report probe networks, there were \" + @probe_networks.length.to_s + \" to report\")\n @report << '<div id=\"title\">Probe Networks</div><br /><br />'\n @probe_tab = Ruport::Data::Table(%w[bssid manufacturer])\n @probe_networks.each do |probe,info|\n if @options.gps_data[probe]\n point = probe\n @log.debug(\"attempting to add link\")\n url = 'http://maps.google.co.uk/maps?q=' + @options.gps_data[point]['lat'].to_s + ',' + @options.gps_data[point]['lon'].to_s\n probe = '<a href=\"' + url + '\">' + point + '</a>'\n end\n @probe_tab << [probe, info['manufacturer']]\n end\n\t @report << @probe_tab.to_html\n\t @report << \"<br /><br />\"\n end",
"def performance\n authenticated_post(\"auth/r/stats/perf:1D/hist\")\n end",
"def parse_summary_stats(nokogiri)\n\n summary_stats = {}\n\n # Summary Stats.\n # Example:\n # <div class=\"spaceit_pad\"><span class=\"dark_text\">Watching:</span> 12,334</div>\n # <div class=\"spaceit_pad\"><span class=\"dark_text\">Completed:</span> 59,459</div>\n # <div class=\"spaceit_pad\"><span class=\"dark_text\">On-Hold:</span> 3,419</div>\n # <div class=\"spaceit_pad\"><span class=\"dark_text\">Dropped:</span> 2,907</div>\n # <div class=\"spaceit_pad\"><span class=\"dark_text\">Plan to Watch:</span> 17,571</div>\n # <div class=\"spaceit_pad\"><span class=\"dark_text\">Total:</span> 95,692</div>\n\n left_column_nodeset = nokogiri.xpath('//div[@id=\"content\"]/table/tr/td[@class=\"borderClass\"]')\n\n if (node = left_column_nodeset.at('//span[text()=\"Reading:\"]')) && node.next\n summary_stats[:in_progress] = node.next.text.strip.gsub(',','').to_i\n end\n if (node = left_column_nodeset.at('//span[text()=\"Completed:\"]')) && node.next\n summary_stats[:completed] = node.next.text.strip.gsub(',','').to_i\n end\n if (node = left_column_nodeset.at('//span[text()=\"On-Hold:\"]')) && node.next\n summary_stats[:on_hold] = node.next.text.strip.gsub(',','').to_i\n end\n if (node = left_column_nodeset.at('//span[text()=\"Dropped:\"]')) && node.next\n summary_stats[:dropped] = node.next.text.strip.gsub(',','').to_i\n end\n if (node = left_column_nodeset.at('//span[text()=\"Plan to Read:\"]')) && node.next\n summary_stats[:planned] = node.next.text.strip.gsub(',','').to_i\n end\n if (node = left_column_nodeset.at('//span[text()=\"Total:\"]')) && node.next\n summary_stats[:total] = node.next.text.strip.gsub(',','').to_i\n end\n\n summary_stats\n end",
"def global_host_statistics\n super\n end",
"def statistics\n stats = select(<<-SQL, \"Statistics\")\n SELECT relname AS name,\n reltuples AS rows,\n relpages AS pages\n FROM pg_class\n ORDER BY reltuples DESC, relpages DESC\n SQL\n\n stats.each do |s|\n s[\"rows\"] = s[\"rows\"].to_f.to_i\n s[\"pages\"] = s[\"pages\"].to_f.to_i\n s[\"size\"] = s[\"pages\"] * 8 * 1024\n s[\"average_row_size\"] = s[\"pages\"].to_f / (s[\"rows\"] + 1) * 8 * 1024\n end\n\n stats.to_a\n end",
"def session_report\n ts = Time.now\n now = ts.to_i\n session_info = Maglev::System.current_session_ids.map do |id|\n sess_desc = Maglev::System.description_of_session id\n sess_desc[0] = sess_desc[0].instance_variable_get(:@_st_userId) # UserProfile\n sess_desc[3] = '' if sess_desc[3] == 0 # Primitive?\n sess_desc[4] = format_secs(now - sess_desc[4]) # View Age\n sess_desc[6] = ['none', 'out', 'in'][sess_desc[6] + 1] # Transaction\n sess_desc[13] = format_secs(now - sess_desc[13]) # Quiet\n sess_desc[14] = format_secs(now - sess_desc[14]) # Age\n sess_desc\n # sess_cache_slot = Maglev::System.cache_slot_for_sessionid id\n end\n session_info\n end",
"def Summary(logfile)\n $time = Time.new\n $fileHtml = File.new(\"#{logfile}\", \"w+\")\n $fileHtml.puts \"<div> \n <img src='../Attachments/mvasist_logo.jpg' align='right' size=2 />\n <img src='../Attachments/zen_logo.png' align='left' size=2 />\n <br><br><br><br><br><br></div>\"\n $fileHtml.puts \"<html><head><title>Results</title></head><body><br><center><font size=5 face=candara><b>Test Execution Summary<br><center><table border=1 width=610><tr>\"\n $fileHtml.puts \"<body><br><center><font size=4 face=candara><b>Script execution started at #{$time.strftime(\"%b-%d %H:%M:%S\")}<br>\"\n $fileHtml.puts \"<tr><td bgcolor=#153E7E width=110><b><font color=white><center>Test Case #</td><td bgcolor=#153E7E width=400><b><font color=white><center>Test Scenario</td><td bgcolor=#153E7E width=100><b><font color=white><center>Result</td><td bgcolor=#153E7E width=110><b><font color=white><center>Execution Time</td><tr>\"\nend",
"def weekStats()\r\n # Get the first day\r\n curCal = JCalendar::getInstance()\r\n curCal.add(JCalendar::DATE, -7)\r\n weekStatsCount = @daohelper.getVisitAuditDate(curCal)\r\n \r\n # Extract visit stats for the last 7 days\r\n i = -6\r\n statMap = {}\r\n statMapDates = {}\r\n while i <= 0\r\n curCal = JCalendar::getInstance()\r\n curCal.add(JCalendar::DATE, i)\r\n curStat = @daohelper.getVisitAuditOnDate(curCal) \r\n strId = \"stats#{i + 6}\"\r\n statMap[strId] = curStat\r\n statMapDates[strId] = curCal\r\n i += 1\r\n end\r\n\r\n stats = BotListVisitLogStatsForm.new\r\n stats.weekVisits = weekStatsCount\r\n stats.weekStats = statMap\r\n stats.weekStatsDates = statMapDates\r\n return stats\r\n end",
"def statistics\n @statistics ||= []\n end",
"def scrape_misc\n doc.at_css('.stats-container')\n .children\n .map(&:text)\n .flat_map { |x| x.gsub(nbsp, ' ').strip.split(':') }\n .map(&:strip)\n .reject(&:empty?)\n .each_slice(2)\n .map { |(k, v)| [symbolize_text(k), v.to_f.zero? ? v : v.to_f] }\n .to_h\n end",
"def test_report_browser_status\n self.request = TestRequest.new(\n :method => :get,\n :request_uri => '/foo/bar?var=val'\n )\n self.session = {}\n\n @session_working = false\n @js = false\n str = report_browser_status\n assert_equal(nil, str)\n\n @session_working = true\n @js = false\n str = report_browser_status\n assert(str.match(/<script/))\n\n @js = true\n str = report_browser_status\n assert(str.match(/<noscript/))\n\n session[:js_override] = :off\n str = report_browser_status\n assert_equal(nil, str)\n end",
"def fasthttp_statistics\n super\n end",
"def getProfile(oStatsProxy, iMechanizeAgent)\n # Click on the Profile link from the home page\n lProfilePage = iMechanizeAgent.get('http://www.myspace.com/home').link_with(:text => 'Profile').click\n # Screen scrap it\n lNbrComments = Integer(lProfilePage.root.css('article#module18 div.wrapper section.content div.commentContainer a.moreComments span.cnt').first.content.match(/of (\\d*)/)[1])\n\n oStatsProxy.add_stat('Global', 'Comments', lNbrComments)\n end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def getSimpleHTML url\n if execLogin===false\n raise \"Login Failed\"\n end\n WebCrawler::getOriginalHTML url\n file = \"#{WEBCRAWLER_DIR_IMG}/#{Capybara::current_driver.to_s}/#{Time.now.to_i.to_s}_#{@session.__id__.to_s}\"\n WebCrawler::saveFilesReport \"#{file}_original\"\n\n timer = WebCrawler::startTime\n WebCrawler::executeScript 'pagePreload();'\n jSonList = WebCrawler::getURLjSonList\n res = WebCrawler::checkHTTPStatusList jSonList\n WebCrawler::logTime timer, 'executeScript', 'pagePreload()'\n\n if ((@vars[:sleepLoading]).to_i)>0\n sleep(((@vars[:sleepLoading]).to_i.to_f)/1000)\n end\n\n WebCrawler::defaultActions\n WebCrawler::executeScript 'window.onbeforeunload=null;', false\n WebCrawler::userActions\n WebCrawler::userActionsDrag\n\n timer = WebCrawler::startTime\n furl = file.sub 'public/', QCHECKER_SERVER+'/'\n furl = furl.sub 'www.', 'http://webcrawler.'\n execTime = WebCrawler::logTime @execTime, 'executionTime'\n extra = \"setWebCrawlerExtraInfos('#{furl}','#{@session.__id__.to_s}','#{execTime.to_i.to_s}')\"\n lastScript =\"updateHTTPStatusJSON('#{res.to_json.to_s}');#{extra};\"\n WebCrawler::executeScript lastScript\n WebCrawler::logTime timer, 'executeScript', 'updateHTTPStatusJSON() & setWebCrawlerExtraInfos()'\n WebCrawler::saveFilesReport file\n end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def WebReader(browser,share)\n\n if(!share.CompanySerial.nil?&&!share.ShareSerial.nil?)\n\n browser.goto \"http://www.tase.co.il/Eng/General/Company/Pages/companyHistoryData.aspx?companyID=\"+share.CompanySerial+\"&subDataType=0&shareID=\"+share.ShareSerial rescue notok=true\n sleep 10\n browser.input(value:'rbPeriod3').click\n sleep 1\n browser.input(value:\"Display Data\").click\n sleep 2\n doc=Nokogiri::HTML.parse(browser.html)\n\n tbody=nil\n doc.css('.gridHeader').each{|val|\n x=val.at_css('.titleGridRegNoB')\n if x.text==\"Date\"\n tbody=val.parent\n end\n }\n\n titles=[:Date, :AdjustedClosingPrice, :ClosingPrice, :Change, :OpeningPrice, :BasePrice, :High, :Low, :CapitalListedforTrading, :MarketCap, :Turnover, :Volume, :Trans, :ExType, :ExCoefficient, :IndexAdjustedNoofShares, :IndexAdjustedFreeFloatRate, :LastIANSUpdate]\n index =0\n data=[]\n hash=Hash.new\n tbody.css('tr').drop(1).each{|val|\n val.css('td').each{|item|\n\n if index%titles.count==0\n index=0\n if !hash.empty?\n data.push(hash)\n end\n hash=Hash.new\n end\n if item!=\"\\u00A0\"\n if !item.text.include?(\"%\")&&!item.text.include?(\"/\")\n if item.text.include?(\",\")\n string = item.text.gsub(/[\\s,]/ ,\"\")\n hash[titles[index]]=string.to_f\n else\n hash[titles[index]]=item.text.to_f\n\n end\n else\n hash[titles[index]]=item.text\n end\n else\n hash[titles[index]]=\"\"\n\n end\n index+=1\n }\n }\n share.share_values.update(data)\n\n browser.close\n end\n\n end",
"def getYieldAndClusterInfo(demuxStatsHTM)\n doc = open(demuxStatsHTM) { |f| Hpricot(f) }\n rows = (doc/\"/html/body/div[@ID='ScrollableTableBodyDiv']/table/tr\")\n\n if rows == nil || rows.length == 0\n rows = (doc/\"/html/body/div[@id='ScrollableTableBodyDiv']/table/tr\")\n end\n\n rows.each do |row|\n dataElements = (row/\"td\")\n\n if dataElements[1].inner_html.eql?(@fcBarcode)\n @yield = dataElements[7].inner_html.gsub(\",\", \"\")\n @percentPFReads = dataElements[8].inner_html\n @numRawReads = dataElements[9].inner_html.gsub(/,/, \"\")\n @numPFReads = (@numRawReads.to_f / 100.0) * @percentPFReads.to_f \n @percentPFReads = dataElements[8].inner_html\n @percentPerfectIndex = dataElements[11].inner_html\n @percent1MismatchIndex = dataElements[12].inner_html\n @percentQ30Bases = dataElements[13].inner_html\n @meanQualScore = dataElements[14].inner_html\n end\n end\n end",
"def print_index\n\t\tFile.open(@options[:output] + \"/index.html\",'w') do |f|\n\t\t\thtml_header(f,\"Home\")\n\n\t\t\tbar_js(f,\"bar_graph\",\"Top 20 Hosts\",@hosts.sort_by{|k,v| v[:total_excl_info]}.reverse.take(20))\n\n\t\t\tcrit_total = 0\n\t\t\thigh_total = 0\n\t\t\tmed_total = 0\n\t\t\tlow_total = 0\n\t\t\tinfo_total = 0\n\n\t\t\t@events.each do |k,v|\n\t\t\t\tcrit_total += 1 if v[:severity] == 4\n\t\t\t\thigh_total += 1 if v[:severity] == 3\n\t\t\t\tmed_total += 1 if v[:severity] == 2\n\t\t\t\tlow_total += 1 if v[:severity] == 1\n\t\t\t\tinfo_total += 1 if v[:severity] == 0\n\t\t\tend\n\n\t\t\tpie_data = []\n\t\t\tpie_data << ['Info',info_total.to_i,'blue'] if @options[:severity] <= 0 and info_total.to_i >= 0\n\t\t\tpie_data << ['Low',low_total.to_i,'green'] if @options[:severity] <= 1 and low_total.to_i > 0\n\t\t\tpie_data << ['Medium',med_total.to_i,'orange'] if @options[:severity] <= 2 and med_total.to_i > 0\n\t\t\tpie_data << ['High',high_total.to_i,'red'] if @options[:severity] <= 3 and high_total.to_i > 0\n\t\t\tpie_data << ['Critical',crit_total.to_i,'purple'] if @options[:severity] <= 4 and crit_total.to_i > 0\n\n\t\t\tpie_js(f,\"pie_graph\",\"Unique Vulnerability Breakdown\",\"Unique Vuln Breakdown\",pie_data,\"document.location.href = 'vuln_overview.html';\")\n\n\t\t\tcrit_total = 0\n\t\t\thigh_total = 0\n\t\t\tmed_total = 0\n\t\t\tlow_total = 0\n\t\t\tinfo_total = 0\n\n\t\t\t@hosts.each do |id,values|\n\t\t\t\tcrit_total += values[:crit].to_i\n\t\t\t\thigh_total += values[:high].to_i\n\t\t\t\tmed_total += values[:med].to_i\n\t\t\t\tlow_total += values[:low].to_i\n\t\t\t\tinfo_total += values[:info].to_i\n\t\t\tend\n\n\t\t\tpie_data = []\n\t\t\tpie_data << ['Info',info_total.to_i,'blue'] if @options[:severity] <= 0 and info_total.to_i >= 0\n\t\t\tpie_data << ['Low',low_total.to_i,'green'] if @options[:severity] <= 1 and low_total.to_i > 0\n\t\t\tpie_data << ['Medium',med_total.to_i,'orange'] if @options[:severity] <= 2 and med_total.to_i > 0\n\t\t\tpie_data << ['High',high_total.to_i,'red'] if @options[:severity] <= 3 and high_total.to_i > 0\n\t\t\tpie_data << ['Critical',crit_total.to_i,'purple'] if @options[:severity] <= 4 and crit_total.to_i > 0\n\n\t\t\tpie_js(f,\"pie_graph2\",\"Total Vulnerability Breakdown\",\"Total Vuln Breakdown\",pie_data,\"document.location = href= 'vuln_overview.html';\")\n\n\t\t\ttarget_lookup = \"var target_lookup = {\"\n\t\t\t@hosts.each_with_index do |host,index|\n\t\t\t\tif host[1][:hostname] == \"\"\n\t\t\t\t\ttarget_lookup += \"'\" + host[1][:ip] + \"'\"\n\t\t\t\telse\n\t\t\t\t\ttarget_lookup += \"'\" + host[1][:hostname] + \" (\" + host[1][:ip] + \")\" + \"'\"\n\t\t\t\tend\n\t\t\t\ttarget_lookup += \": \" + host[0].to_s\n\t\t\t\ttarget_lookup += \",\" unless index == @hosts.length - 1\n\t\t\tend\n\t\t\ttarget_lookup += \"}\"\n\n\t\t\tf.puts target_lookup\n\n\t\t\tclose_html_header(f)\n\n\t\t\tbody = '<div style=\"width: 800px; margin-left: auto; margin-right: auto; padding-top: 30px;\">'\n\t\t\tbody += '<div id=\"pie_graph\" style=\"min-width: 375px; height: 375px; margin: 0 auto; float: left\"></div>'\n\t\t\tbody += '<div id=\"pie_graph2\" style=\"min-width: 375px; height: 375px; margin: 0 auto; float: left\"></div>'\n\t\t\tbody += '</div>'\n\t\t\tbody += '<div style=\"clear: both;\"></div>'\n\t\t\tbody += '<div id=\"bar_graph\" style=\"min-width: 400px; height: 900px; margin: 0 auto\"></div>'\n\n\t\t\tbody += '<div id=\"allhosts\" style=\"font-family: Arial, Helvetica, sans-serif\"><h3>All Hosts</h3>'\n\n\t\t\tips = []\n\t\t\t@hosts.each do |host|\n\t\t\t\tips << host[1][:ip]\n\t\t\tend\n\n\t\t\tbody += '<table id=\"hosts_table\" class=\"display\"><thead><tr><th>IP</th><th>Hostname</th><th>OS</th><th>Vulnerability Count (Low to Critical)</th></tr></thead><tbody>'\n\t\t\tips.sort_by{|ip| ip.split('.').map{|octet| octet.to_i}}.each do |ip|\n\t\t\t\t@hosts.select{|k,v| v[:ip] == ip}.each do |k,v|\n\t\t\t\t\ttmp_actual_v_count = 0\n\t\t\t\t\ttmp_actual_v_count += v[:info].to_i if @options[:severity] <= 0 and v[:info].to_i >= 0\n\t\t\t\t\ttmp_actual_v_count += v[:low].to_i if @options[:severity] <= 1 and v[:low].to_i > 0\n\t\t\t\t\ttmp_actual_v_count += v[:med].to_i if @options[:severity] <= 2 and v[:med].to_i > 0\n\t\t\t\t\ttmp_actual_v_count += v[:high].to_i if @options[:severity] <= 3 and v[:high].to_i > 0\n\t\t\t\t\ttmp_actual_v_count += v[:crit].to_i if @options[:severity] <= 4 and v[:crit].to_i > 0\n\t\t\t\t\tbody += '<tr><td>'\n\t\t\t\t\tif tmp_actual_v_count > 0\n\t\t\t\t\t\tbody += '<a href=\"host_' + k.to_s + '.html\">' + ip + '</a>'\n\t\t\t\t\telse\n\t\t\t\t\t\tbody += ip\n\t\t\t\t\tend\n\t\t\t\t\tbody += '</td><td>' + v[:hostname] + '</td><td>' + v[:os] + '</td><td>' + v[:total_excl_info].to_s + '</td></tr>'\n\t\t\t\tend\n\t\t\tend\n\t\t\tbody += '</tbody></table>'\n\n\t\t\tbody += '<script>$(document).ready(function() { $(\\'#hosts_table\\').dataTable({\"bPaginate\": false}); });</script>'\n\n\t\t\tbody_text(f,body)\n\n\t\t\tclose_all(f)\n\n\t\tend\n\n\tend",
"def summary_site\n \t\tAPI.get_site_wordcount\n \tend",
"def raw_summary\n report = { \"version\" => { \"config\" => configuration_version, \"puppet\" => Puppet.version } }\n\n @metrics.each do |name, metric|\n key = metric.name.to_s\n report[key] = {}\n metric.values.each do |name, label, value|\n report[key][name.to_s] = value\n end\n report[key][\"total\"] = 0 unless key == \"time\" or report[key].include?(\"total\")\n end\n (report[\"time\"] ||= {})[\"last_run\"] = Time.now.tv_sec\n report\n end",
"def stats(socket)\n stats = Time.now.to_i + \"\\n\" + \n @data.flatten + \"\\n\" + \n @expire.flatten + \"\\n\"\n socket.print(stats, \"\\n\\r\")\n end",
"def analyzeDemandLog()\n demandLogFile = @basePath + \".demandLog.json\" ;\n com = \"../Savs/analyzeDemandLog #{demandLogFile}\" ;\n p [:com, com] ;\n jsonStr = `#{com}` ;\n @demandStat = JSON.load(jsonStr) ;\n return @demandStat ;\n end",
"def chrome_search(search, limit=5)\n searchword = \"%#{search}%\"\n urls = Url.where(\"title LIKE :search\", {:search => searchword})\n\n # get newest hit\n time_urls = Array.new\n urls.each do |u|\n time = 0\n u.visits.each do |v|\n vtime = v.visit_time.to_i\n time = vtime if time < vtime\n end\n time_urls << [time, u.title, u.url]\n end\n\n # get most recent hits\n time_urls.sort! {|x, y| y[0] <=> x[0]}\n return time_urls[0..limit-1].map {|x| [ \"GC: #{x[1]}\", x[2]] }\nend",
"def metrics\n report[\"columnHeader\"][\"metricHeader\"][\"metricHeaderEntries\"].map { |metric| metric[\"name\"] }\n end",
"def usage(browser, version)\n browser_data(browser)[\"usage_global\"][version]\n end",
"def getLastFmSimilarTrackData artist_name, album_name, track_name\n url = getLastFmSimilarTrackDataUrl(artist_name, album_name, track_name);\n proxy = getProxy();\n puts url+\"-[\"+proxy+\"]\";\n #url = \"http://www.google.com\" \n begin\n html = open(url, \"User-Agent\" => getUseragent(), :proxy=>proxy) \n document = Hpricot(html)\n #document = Nokogiri::HTML(html)\n #ar = document.css('div.skyWrap table.candyStriped') \n\n ar = document.search(\"//div[@class='skyWrap']\").search(\"//table[@class='candyStriped chart']\");\n #puts ar \n return ar\n rescue Exception => e\n return \"\"\n end \n end",
"def getAppStats(package, startDay, endDay)\n dim = \"overall,country,language,os_version,device,app_version,carrier&met=daily_device_installs,active_device_installs,daily_user_installs,total_user_installs,active_user_installs,daily_device_uninstalls,daily_user_uninstalls,daily_device_upgrades\"\n\n url = \"https://play.google.com/apps/publish/statistics/download\"\n url += \"?package=#{package}\"\n url += \"&sd=#{startDay}&ed=#{endDay}\"\n url += \"&dim=#{dim}\"\n url += \"&dev_acc=#{@dev_acc}\"\n\n puts url\n try_get(url)\n return @agent.page.body\n end",
"def collect_report_data\n report_data = { }\n\n # Read log file\n uploaded_files = parse_logfile(@logfile)\n report_data['uploaded_files'] = uploaded_files\n\n # Find local files\n local_files = []\n Find.find(@html_dir) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == ?.\n Find.prune\n end\n else\n local_files << path.sub(@html_path,'')\n end\n end\n report_data['local_files'] = local_files\n\n\n # Count vortex document types\n file_type_counts = { }\n uploaded_files.each do |key, val|\n type, server_path = uploaded_files[key]\n file_type_counts[type] = file_type_counts[type].to_i + 1\n end\n report_data['file_type_counts'] = file_type_counts\n\n\n # Count file extensions and calculate filesize\n extensions = { }\n uploaded_files.each do |filename, info|\n\n # TODO Remove temporarliy hack for PGP:\n if(filename == \"http\")\n next\n end\n filename = filename.gsub(\"http://varme.uio.no/pgp/\",\"\")\n\n extension = filename[/([^\\.]*)$/].downcase\n extensions[extension] = [] if(not(extensions[extension]))\n count = extensions[extension][0].to_i\n filesize = extensions[extension][1].to_i\n extensions[extension][0] = count + 1\n if(not(File.exists?(@html_path.to_s + filename)))\n throw \"Unknown file : '\" + @html_path + filename + \"' =>\" + info.to_s\n end\n extensions[extension][1] = filesize + File.size(@html_path.to_s + filename)\n end\n report_data['extensions'] = extensions\n\n\n # Count file extensions and calculate filesize for unpublished files\n unpublished_files = []\n unpublished_files_extensions = { }\n local_files.each do |local_filename|\n if(not(uploaded_files[local_filename]))then\n unpublished_files << local_filename\n extension = local_filename[/([^\\.]*)$/]\n unpublished_files_extensions[extension] = [] if(not(unpublished_files_extensions[extension]))\n count = unpublished_files_extensions[extension][0].to_i\n filesize = unpublished_files_extensions[extension][1].to_i\n unpublished_files_extensions[extension][0] = count + 1\n unpublished_files_extensions[extension][1] = filesize + File.size(@html_path.to_s + local_filename)\n end\n end\n report_data['unpublished_files'] = unpublished_files\n report_data['unpublished_files_extensions'] = unpublished_files_extensions\n\n return report_data\n end",
"def memstats\n # initialize all counters\n rooms = objs = chars = accounts = scripts = strcount = strsize = ocount = 0\n\n # scan the ObjectSpace counting things\n ObjectSpace.each_object do |x|\n case x\n when String\n strcount += 1\n strsize += x.size\n when Character\n chars += 1\n when Account\n accounts += 1\n when Room\n rooms += 1\n when GameObject\n objs += 1\n when Script\n scripts += 1\n else\n ocount += 1\n end\n end\n\n # our report :\n # :NOTE: sprintf would be better\n memstats=<<EOD\n[COLOR Cyan]\n----* Memory Statistics *----\n Rooms - #{rooms}\n Objects - #{objs}\n Scripts - #{scripts}\n Accounts - #{accounts}\n Characters - #{chars}\n-----------------------------\n Strings - #{strcount}\n size - #{strsize} bytes\n Other - #{ocount}\n-----------------------------\n Total Objects - #{rooms+objs+chars+accounts+scripts+strcount+ocount}\n----* *----\n[/COLOR]\nEOD\n end",
"def parse_dailydev_page\n start = Time.now\n items = @page.search('.ddinfo')\n if items.any?\n items.each do |item|\n desc = item.search('.foot').empty\n desc = item.inner_text.strip\n link_el = item.search('a').select { |item| /\\/deviation\\// === item.attributes['href'] }.first\n link = link_el.attributes['href']\n title = link_el.inner_text\n @daily_data << { :title => title, :desc => desc, :link => link }\n end\n end\n Time.now - start\n end",
"def index_page\n '<html><head> <title>%s</title>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /></head>\n <body> <h1>%s</h1> <hr /> <table> <tr> <th class=\"name\">Name</th>\n <th class=\"size\">Size</th> <th class=\"type\">Type</th> \n <th class=\"mtime\">Last Modified</th> </tr> %s </table> <hr /> </body></html>'\n end",
"def page_views_dashboard\n @timeframes = Impression::TIMEFRAMES\n end",
"def collect_all_stats()\n\n begin\n\n time = Time.now\n\n medusaLogWriter = nil\n if (@enable_medusa == true)\n medusaLogger = Logger.new(File.new(@medusa_log_file, File::WRONLY | File::CREAT | File::TRUNC))\n # Ruby logger.formatter supports four input parameters : |severity, datetime, progname, msg|, here, we only need to pass msg into the proc.\n medusaLogger.formatter = proc { |_s, _d, _p, msg| \"#{msg}\\n\" }\n medusaLogWriter = MedusaLogWriter.new(medusaLogger)\n end\n\n graphiteWriter = nil\n if (@graphite_hosts != nil)\n # @environment holds the environment_profile, eg: dev/ prod/ qa/stg\n # @environment_name holds the user defined environment name. eg: datacenter name in ms-df-solrcloud prod clusters\n graphiteWriter = GraphiteWriter.new(@prefix, @environment, @node_ip, @graphite_hosts, @datacenter, @environment_name)\n graphiteWriter.open_tcp_sockets\n end\n\n # keeping both the node status metrics and jmx metrics separately since our JMX metrics scripts could stop working for any reason\n # (eg, metric names changes with diff solr versions etc).\n # If it breaks, telegraf will block all metrics that comes from jmx metrics file.\n # So better to keep node status metrics separately from JMX metrics. Telegraf will read from both at any point of time provided jmx_metrics are enabled.\n if (@enable_rest_metrics == \"true\" || @enable_jmx_metrics == \"true\")\n get_solr_node_status(time, medusaLogWriter, graphiteWriter)\n end\n\n if (@enable_rest_metrics == \"true\")\n # Get the metrics from Solr REST APIs\n SolrClusterSummaryStats.get_stats(@hostname, @port, time, medusaLogWriter, graphiteWriter, @solr_version, @collections)\n end\n\n if (@enable_jmx_metrics == \"true\")\n jmx_medusaLogWriter = nil\n if (@enable_medusa == true)\n jmx_medusaLogger = Logger.new(File.new(@jmx_medusa_log_file, File::WRONLY | File::CREAT | File::TRUNC))\n # Ruby logger.formatter supports four input parameters : |severity, datetime, progname, msg|, here, we only need to pass msg into the proc.\n jmx_medusaLogger.formatter = proc { |_s, _d, _p, msg| \"#{msg}\\n\" }\n jmx_medusaLogWriter = MedusaLogWriter.new(jmx_medusaLogger)\n end\n mbean_sum_stat_obj = SolrMBeanSummaryStats.new(jmx_medusaLogWriter, graphiteWriter, @metric_level, @jolokia_port, @solr_jmx_port, @solr_version, time)\n mbean_sum_stat_obj.collect_jmx_metrics()\n end\n\n rescue Exception => e\n puts \"collect_all_stats:exception: #{e}\"\n ensure\n if (@graphite_hosts != nil)\n graphiteWriter.close_tcp_sockets\n end\n end\n\n end",
"def analyze_session session\n visit_time = DateTime.parse(session[0][\"visit_time\"])\n mark_landing = false\n mark_conversion = false\n\n viewed_pages = Set.new\n\n unless during?(\n session[0][\"visit_time\"],\n \"2012-05-17 22:00:00 +0900\",\n \"2012-07-22 11:00:00 +0900\")\n return\n end\n\n version = \"\"\n \n analyze session do |action|\n if !mark_landing and action[\"_type\"] == \"page_load\"\n if front_porch? action\n mark_landing = true\n version = extract_version action[\"pageurl\"]\n end\n end\n \n if action[\"_type\"] == \"page_load\"\n if conversion? action\n mark_conversion = true\n break\n else\n pageurl = action[\"pageurl\"]\n pageurl = pageurl.split(\"?\")[0]\n viewed_pages.add(pageurl)\n end\n end\n end\n\n unless mark_landing\n return\n end\n\n viewed_pages.each do |viewed_page|\n @page_view[version] ||= {}\n @page_view[version][viewed_page] ||= 0\n @page_view[version][viewed_page] += 1\n end\n\n @visits[version] ||= 0 \n @visits[version] += 1\n\n end",
"def stats\n adapter.stats\n end"
] |
[
"0.6890602",
"0.6672983",
"0.64488024",
"0.64312273",
"0.62585163",
"0.618761",
"0.618761",
"0.6166706",
"0.6129158",
"0.61225843",
"0.6115214",
"0.60773706",
"0.6054409",
"0.5993558",
"0.5993558",
"0.5973039",
"0.5967543",
"0.59601164",
"0.5958867",
"0.5958867",
"0.5945499",
"0.5944647",
"0.5942003",
"0.59222955",
"0.591139",
"0.58976847",
"0.5877245",
"0.58755773",
"0.5870526",
"0.5843651",
"0.5829809",
"0.58239716",
"0.5814885",
"0.57869464",
"0.5756033",
"0.5755767",
"0.5747836",
"0.57477283",
"0.57395583",
"0.57275987",
"0.571749",
"0.57141924",
"0.57132214",
"0.5710503",
"0.5705787",
"0.5700849",
"0.56848806",
"0.56820923",
"0.56768054",
"0.5665832",
"0.56567776",
"0.5649755",
"0.5638982",
"0.563344",
"0.56176436",
"0.56050617",
"0.5603316",
"0.559769",
"0.55803967",
"0.55754864",
"0.55703694",
"0.55609465",
"0.55483544",
"0.55423427",
"0.55372196",
"0.55370706",
"0.55370235",
"0.55311614",
"0.55204237",
"0.5510307",
"0.5510307",
"0.5510307",
"0.5510307",
"0.5510307",
"0.55080265",
"0.54873455",
"0.54873455",
"0.54873455",
"0.54873455",
"0.54873455",
"0.5480651",
"0.5471916",
"0.54686826",
"0.54625374",
"0.5453727",
"0.54461855",
"0.54439926",
"0.5436185",
"0.54340786",
"0.5432407",
"0.5427424",
"0.542492",
"0.5417588",
"0.54108787",
"0.540711",
"0.53921753",
"0.53906673",
"0.53880686",
"0.53836924",
"0.5378034"
] |
0.61475533
|
8
|
Created On: 08/11/2014 Purpose: To get country statistics report ++
|
def get_country_statistics_report(country_list, device_access)
@country_hash = {}
country_list.each do |country|
country_count = device_access.where(:access_country => country).count
@country_hash[country] = country_count
end
country_stat = @country_hash.sort_by {|_key, value| value}.reverse
hash = Hash[*country_stat.flatten]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def country; end",
"def country; end",
"def country; end",
"def countries_geo_entity_stats\n countries.present? ? GeoEntityStat.where(geo_entity_id: countries.map(&:id)) : geo_entity_stats\n end",
"def country_details(region, input)\n country = @countries[input - 1]\n\n Table.display_as_summary(country)\n browse_online(country)\n end",
"def represented_country; end",
"def get_countries\n \tresponse = invoke(\"web:GetCountries\", :soap_action => :none)\n\n \tnode = response.document.xpath('//ns:GetCountriesResult', ns)[0]\n \tparse_country_description(node)\n end",
"def country\n data['country']\n end",
"def country_gb()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"89.187.117.101\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n end",
"def all_countries_totals\n json_response('/country/all')\n end",
"def country_names(params = {})\n timeseries = params.is_a?(Timeseries) ? params : Timeseries.new(params)\n table = :\"bitcoinppi_#{timeseries.tick.sub(\" \", \"_\")}\"\n dataset = DB[table]\n .select { distinct(country) }\n .order(:country)\n .map { |row| { key: row[:country], label: Country[row[:country]].name } }\n end",
"def registered_country; end",
"def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end",
"def country_us()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"12.25.205.51\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n end",
"def country_values\n %w(\n Austria\n Belgium\n Denmark\n Finland\n France\n Germany\n Greece\n Iceland\n Ireland\n Italy\n Netherlands\n Norway\n Portugal\n Spain\n Sweden\n Switzerland\n United Kingdom\n USA\n )\n end",
"def country_fr()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"178.251.201.141\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n\t\tend",
"def make_summaries\n if @data.key?(\"Global\") && @data.key?(\"Countries\") && @data.key?(\"Date\")\n global_data = @data[\"Global\"]\n global_data[\"Date\"] = @data[\"Date\"]\n global_data[\"Country\"] = \"Global\"\n\n # Clean up global_data with the parser method\n global_hash = parser(global_data)\n\n # Create the Summary object for global info\n CovidTracking::Summary.new(global_hash)\n\n @data[\"Countries\"].each {|ctry_info| CovidTracking::CountrySummary.new(parser(ctry_info))}\n else\n raise DataError\n end\n\n end",
"def countries_of_members_data(country_name = false)\n data = [['Country', 'Users']]\n members.group(:country).where.not(country: [nil, '']).select('country, COUNT(*) AS number_of_users').each{|i| data << [country_name ? ISO3166::Country.new(i.country).try(:name) : i.country, i.number_of_users] }\n data\n end",
"def countries\n doc.search(\"table.info a[href*='/m_act%5Bcountry%5D/']\").map(&:text)\n end",
"def get_country\n @single_city_data[\"sys\"][\"country\"]\n end",
"def country\n 'United Kingdom'\n end",
"def countries(params = {})\n timeseries = params.is_a?(Timeseries) ? params : Timeseries.new(params)\n table = :\"bitcoinppi_#{timeseries.tick.sub(\" \", \"_\")}\"\n dataset = DB[table]\n .select(:time, :tick, :country, :currency, :bitcoin_price, :bigmac_price, :weight, :local_ppi)\n .where(tick: timeseries.range)\n .order(Sequel.desc(:tick))\n end",
"def by_country(country='all')\n\n result = [ ['Country', 'Amount'] ]\n country = (country == 'all') ? \"[Nationalities].children\" : \"[Nationalities].[#{country}]\"\n\n r = @connection.from('Gears').\n columns('[Measures].[Players]').\n rows(country).\n nonempty().execute\n\n r.axis_full_names[1].each_with_index {|country, index|\n\n c = TZInfo::Country.get(country.split('.')[1].gsub('[','').gsub(']','')).name\n v = r.values[index][0]\n result << [ c , v ]\n }\n result\n end",
"def country_total\n @totals = {}\n (@start_date..@end_date).each do |date|\n key_pattern = params[:country].present? ? \"Country:#{date}:#{params[:country]}*\" : \"Country:#{date}*\"\n keys = REDIS.keys key_pattern\n keys.each do |key|\n value = REDIS.get key\n split_key = key.split ':'\n split_value = value.split ':'\n country = split_key[2]\n currency = split_key[3]\n amount = split_value[0]\n usd_amount = split_value[1]\n total = split_value[2]\n country_name = split_value[3]\n total_key = \"#{country}_#{currency}\"\n @totals[total_key] ||= { currency: currency,\n country_total: 0,\n country_total_usd: 0,\n country_name: country_name,\n total_count: 0,\n arpu: 0 }\n @totals[total_key][:country_total] += amount.to_d.truncate(2).to_money(currency)\n @totals[total_key][:country_total_usd] += usd_amount.to_d.truncate(2).to_money\n @totals[total_key][:total_count] += total.to_i\n @totals[total_key][:arpu] = @totals[total_key][:country_total_usd] / @totals[total_key][:total_count]\n end\n end\n\n @totals = @totals.sort_by { |_key, value| value[:total_count] }.reverse\n @country_total = @totals.map { |_key, total| total[:country_total_usd] }.sum\n @total_count = @totals.map { |_key, value| value[:total_count] }.sum\n\n respond_to do |format|\n format.html do\n end\n format.csv do\n send_data to_csv('country_total', @totals), type: 'text/csv; charset=utf-8; header=present',\n disposition: \"attachment; filename=country_total-#{Time.now.strftime('%Y-%m-%d-%H:%M:%S')}.csv\"\n end\n end\n end",
"def get_country_name\n subdivision = Geonames::WebService.country_subdivision @latitude, @longitude\n subdivision.country_name\n end",
"def countries\n document[\"nationality\"].collect {|nation| nation[\"$\"]} rescue nil\n end",
"def country_str(specimens)\r\n v = {} \r\n v[\"country not specified\"] = []\r\n specimens.each do |s|\r\n if !s.ce.blank? && !s.ce.geog.blank? && !s.ce.geog.country.blank? && !s.ce.geog.country.name.blank?\r\n if v[s.ce.geog.country.name].nil?\r\n v[s.ce.geog.country.name] = [s]\r\n else\r\n v[s.ce.geog.country.name] << s\r\n end\r\n else\r\n v[\"country not specified\"] << s\r\n end\r\n end\r\n v.delete(\"country not specified\") if v[\"country not specified\"].size == 0 \r\n is = []\r\n v.keys.sort.each do |c|\r\n txt = \"#{c.upcase}: \"\r\n txt << sex_str(v[c])\r\n txt += \". \"\r\n txt += inst_str(v[c]) + \".\"\r\n is << txt\r\n end\r\n is.join(\" \") \r\n end",
"def count_by(geo, results)\n totals = results.each_with_object(Hash.new(0)) do |res,counts|\n # binding.pry\n next unless [\"us\",\"ca\"].include?(res.country)\n counts[res.send(geo.to_sym)] += 1\n end\n puts \"TOTAL: #{totals.values.inject(:+)}\"\n\n totals = totals.sort_by { |geo,count| -count }\n\n puts \"Total groups by #{geo.to_s}: \"\n totals.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def print_all_countries\n @country_lists.each do |country|\n puts puts \"#{country.country_name}\\t#{}\"\n end\n end",
"def get_countries\n doc = Nokogiri::HTML(open('https://www.britannica.com/topic/list-of-countries-1993160'))\n countries_extracted = doc.css(\"li a\").text.split('Britannica')[1].split(' geography')[0].rstrip\n @processed_countries = countries_extracted.split(/(?<!\\s)(?=[A-Z])/)\n end",
"def all_countries \n\t\tself.class.get('/all')\n\tend",
"def country_code; end",
"def country_code; end",
"def statistics; end",
"def spot_countries\n now = DateTime.now\n hash_groups = countries(from: now - 24.hours, to: now, tick: \"15 minutes\")\n .select_append { avg(:local_ppi).over(partition: :country, order: Sequel.desc(:tick), frame: :all).as(:avg_24h_local_ppi) }\n .to_hash_groups(:country)\n hash_groups.each { |country, data| hash_groups[country] = data.first }\n hash_groups\n end",
"def country\n query = create_query(\n :Location, :regexp_search, regexp: \"#{params[:country]}$\"\n )\n show_selected_locations(query, link_all_sorts: true)\n end",
"def countries\n xml.css('country').map{|c| Allorails::Country.new(c)}\n end",
"def country\n 'Australia'\n end",
"def country\n self.well_info.country\n end",
"def show\n @countries = [[\"OC Oceania\",\"oc\"],[\"AD Andorra\", \"ad\"],[\"AE United Arab Emirates\", \"ae\"],[\"AF Afghanistan\", \"af\"],[\"AG Antigua and Barbuda\", \"ag\"],[\"AI Anguilla\", \"ai\"],[\"AL Albania\", \"al\"],[\"AM Armenia\", \"am\"],[\"AO Angola\", \"ao\"],[\"AQ Antarctica\", \"aq\"],[\"AR Argentina\", \"ar\"],[\"AS American Samoa\", \"as\"],[\"AT Austria\", \"at\"],[\"AU Australia\", \"au\"],[\"AW Aruba\", \"aw\"],[\"AX Åland Islands\", \"ax\"],[\"AZ Azerbaijan\", \"az\"],[\"BA Bosnia and Herzegovina\", \"ba\"],[\"BB Barbados\", \"bb\"],[\"BD Bangladesh\", \"bd\"],[\"BE Belgium\", \"be\"],[\"BF Burkina Faso\", \"bf\"],[\"BG Bulgaria\", \"bg\"],[\"BH Bahrain\", \"bh\"],[\"BI Burundi\", \"bi\"],[\"BJ Benin\", \"bj\"],[\"BL Saint Barthélemy\", \"bl\"],[\"BM Bermuda\", \"bm\"],[\"BN Brunei Darussalam\", \"bn\"],[\"BO Bolivia, Plurinational State of\", \"bo\"],[\"BQ Bonaire, Sint Eustatius and Saba\", \"bq\"],[\"BR Brazil\", \"br\"],[\"BS Bahamas\", \"bs\"],[\"BT Bhutan\", \"bt\"],[\"BV Bouvet Island\", \"bv\"],[\"BW Botswana\", \"bw\"],[\"BY Belarus\", \"by\"],[\"BZ Belize\", \"bz\"],[\"CA Canada\", \"ca\"],[\"CC Cocos (Keeling) Islands\", \"cc\"],[\"CD Congo, the Democratic Republic of the\", \"cd\"],[\"CF Central African Republic\", \"cf\"],[\"CG Congo\", \"cg\"],[\"CH Switzerland\", \"ch\"],[\"CI Côte d'Ivoire\", \"ci\"],[\"CK Cook Islands\", \"ck\"],[\"CL Chile\", \"cl\"],[\"CM Cameroon\", \"cm\"],[\"CN China\", \"cn\"],[\"CO Colombia\", \"co\"],[\"CR Costa Rica\", \"cr\"],[\"CU Cuba\", \"cu\"],[\"CV Cape Verde\", \"cv\"],[\"CW Curaçao\", \"cw\"],[\"CX Christmas Island\", \"cx\"],[\"CY Cyprus\", \"cy\"],[\"CZ Czech Republic\", \"cz\"],[\"DE Germany\", \"de\"],[\"DJ Djibouti\", \"dj\"],[\"DK Denmark\", \"dk\"],[\"DM Dominica\", \"dm\"],[\"DO Dominican Republic\", \"do\"],[\"DZ Algeria\", \"dz\"],[\"EC Ecuador\", \"ec\"],[\"EE Estonia\", \"ee\"],[\"EG Egypt\", \"eg\"],[\"EH Western Sahara\", \"eh\"],[\"ER Eritrea\", \"er\"],[\"ES Spain\", \"es\"],[\"ET Ethiopia\", \"et\"],[\"FI Finland\", \"fi\"],[\"FJ Fiji\", \"fj\"],[\"FK Falkland Islands (Malvinas)\", \"fk\"],[\"FM Micronesia, Federated States of\", \"fm\"],[\"FO Faroe Islands\", \"fo\"],[\"FR France\", \"fr\"],[\"GA Gabon\", \"ga\"],[\"GB United Kingdom\", \"gb\"],[\"GD Grenada\", \"gd\"],[\"GE Georgia\", \"ge\"],[\"GF French Guiana\", \"gf\"],[\"GG Guernsey\", \"gg\"],[\"GH Ghana\", \"gh\"],[\"GI Gibraltar\", \"gi\"],[\"GL Greenland\", \"gl\"],[\"GM Gambia\", \"gm\"],[\"GN Guinea\", \"gn\"],[\"GP Guadeloupe\", \"gp\"],[\"GQ Equatorial Guinea\", \"gq\"],[\"GR Greece\", \"gr\"],[\"GS South Georgia and the South Sandwich Islands\", \"gs\"],[\"GT Guatemala\", \"gt\"],[\"GU Guam\", \"gu\"],[\"GW Guinea-Bissau\", \"gw\"],[\"GY Guyana\", \"gy\"],[\"HK Hong Kong\", \"hk\"],[\"HM Heard Island and McDonald Islands\", \"hm\"],[\"HN Honduras\", \"hn\"],[\"HR Croatia\", \"hr\"],[\"HT Haiti\", \"ht\"],[\"HU Hungary\", \"hu\"],[\"ID Indonesia\", \"id\"],[\"IE Ireland\", \"ie\"],[\"IL Israel\", \"il\"],[\"IM Isle of Man\", \"im\"],[\"IN India\", \"in\"],[\"IO British Indian Ocean Territory\", \"io\"],[\"IQ Iraq\", \"iq\"],[\"IR Iran, Islamic Republic of\", \"ir\"],[\"IS Iceland\", \"is\"],[\"IT Italy\", \"it\"],[\"JE Jersey\", \"je\"],[\"JM Jamaica\", \"jm\"],[\"JO Jordan\", \"jo\"],[\"JP Japan\", \"jp\"],[\"KE Kenya\", \"ke\"],[\"KG Kyrgyzstan\", \"kg\"],[\"KH Cambodia\", \"kh\"],[\"KI Kiribati\", \"ki\"],[\"KM Comoros\", \"km\"],[\"KN Saint Kitts and Nevis\", \"kn\"],[\"KP Korea, Democratic People's Republic of\", \"kp\"],[\"KR Korea, Republic of\", \"kr\"],[\"KW Kuwait\", \"kw\"],[\"KY Cayman Islands\", \"ky\"],[\"KZ Kazakhstan\", \"kz\"],[\"LA Lao People's Democratic Republic\", \"la\"],[\"LB Lebanon\", \"lb\"],[\"LC Saint Lucia\", \"lc\"],[\"LI Liechtenstein\", \"li\"],[\"LK Sri Lanka\", \"lk\"],[\"LR Liberia\", \"lr\"],[\"LS Lesotho\", \"ls\"],[\"LT Lithuania\", \"lt\"],[\"LU Luxembourg\", \"lu\"],[\"LV Latvia\", \"lv\"],[\"LY Libya\", \"ly\"],[\"MA Morocco\", \"ma\"],[\"MC Monaco\", \"mc\"],[\"MD Moldova, Republic of\", \"md\"],[\"ME Montenegro\", \"me\"],[\"MF Saint Martin (French part)\", \"mf\"],[\"MG Madagascar\", \"mg\"],[\"MH Marshall Islands\", \"mh\"],[\"MK Macedonia, the former Yugoslav Republic of\", \"mk\"],[\"ML Mali\", \"ml\"],[\"MM Myanmar\", \"mm\"],[\"MN Mongolia\", \"mn\"],[\"MO Macao\", \"mo\"],[\"MP Northern Mariana Islands\", \"mp\"],[\"MQ Martinique\", \"mq\"],[\"MR Mauritania\", \"mr\"],[\"MS Montserrat\", \"ms\"],[\"MT Malta\", \"mt\"],[\"MU Mauritius\", \"mu\"],[\"MV Maldives\", \"mv\"],[\"MW Malawi\", \"mw\"],[\"MX Mexico\", \"mx\"],[\"MY Malaysia\", \"my\"],[\"MZ Mozambique\", \"mz\"],[\"NA Namibia\", \"na\"],[\"NC New Caledonia\", \"nc\"],[\"NE Niger\", \"ne\"],[\"NF Norfolk Island\", \"nf\"],[\"NG Nigeria\", \"ng\"],[\"NI Nicaragua\", \"ni\"],[\"NL Netherlands\", \"nl\"],[\"NO Norway\", \"no\"],[\"NP Nepal\", \"np\"],[\"NR Nauru\", \"nr\"],[\"NU Niue\", \"nu\"],[\"NZ New Zealand\", \"nz\"],[\"OM Oman\", \"om\"],[\"PA Panama\", \"pa\"],[\"PE Peru\", \"pe\"],[\"PF French Polynesia\", \"pf\"],[\"PG Papua New Guinea\", \"pg\"],[\"PH Philippines\", \"ph\"],[\"PK Pakistan\", \"pk\"],[\"PL Poland\", \"pl\"],[\"PM Saint Pierre and Miquelon\", \"pm\"],[\"PN Pitcairn\", \"pn\"],[\"PR Puerto Rico\", \"pr\"],[\"PS Palestine, State of\", \"ps\"],[\"PT Portugal\", \"pt\"],[\"PW Palau\", \"pw\"],[\"PY Paraguay\", \"py\"],[\"QA Qatar\", \"qa\"],[\"RE Réunion\", \"re\"],[\"RO Romania\", \"ro\"],[\"RS Serbia\", \"rs\"],[\"RU Russian Federation\", \"ru\"],[\"RW Rwanda\", \"rw\"],[\"SA Saudi Arabia\", \"sa\"],[\"SB Solomon Islands\", \"sb\"],[\"SC Seychelles\", \"sc\"],[\"SD Sudan\", \"sd\"],[\"SE Sweden\", \"se\"],[\"SG Singapore\", \"sg\"],[\"SH Saint Helena, Ascension and Tristan da Cunha\", \"sh\"],[\"SI Slovenia\", \"si\"],[\"SJ Svalbard and Jan Mayen\", \"sj\"],[\"SK Slovakia\", \"sk\"],[\"SL Sierra Leone\", \"sl\"],[\"SM San Marino\", \"sm\"],[\"SN Senegal\", \"sn\"],[\"SO Somalia\", \"so\"],[\"SR Suriname\", \"sr\"],[\"SS South Sudan\", \"ss\"],[\"ST Sao Tome and Principe\", \"st\"],[\"SV El Salvador\", \"sv\"],[\"SX Sint Maarten (Dutch part)\", \"sx\"],[\"SY Syrian Arab Republic\", \"sy\"],[\"SZ Swaziland\", \"sz\"],[\"TC Turks and Caicos Islands\", \"tc\"],[\"TD Chad\", \"td\"],[\"TF French Southern Territories\", \"tf\"],[\"TG Togo\", \"tg\"],[\"TH Thailand\", \"th\"],[\"TJ Tajikistan\", \"tj\"],[\"TK Tokelau\", \"tk\"],[\"TL Timor-Leste\", \"tl\"],[\"TM Turkmenistan\", \"tm\"],[\"TN Tunisia\", \"tn\"],[\"TO Tonga\", \"to\"],[\"TR Turkey\", \"tr\"],[\"TT Trinidad and Tobago\", \"tt\"],[\"TV Tuvalu\", \"tv\"],[\"TW Taiwan, Province of China\", \"tw\"],[\"TZ Tanzania, United Republic of\", \"tz\"],[\"UA Ukraine\", \"ua\"],[\"UG Uganda\", \"ug\"],[\"UM United States Minor Outlying Islands\", \"um\"],[\"US United States\", \"us\"],[\"UY Uruguay\", \"uy\"],[\"UZ Uzbekistan\", \"uz\"],[\"VA Holy See (Vatican City State)\", \"va\"],[\"VC Saint Vincent and the Grenadines\", \"vc\"],[\"VE Venezuela, Bolivarian Republic of\", \"ve\"],[\"VG Virgin Islands, British\", \"vg\"],[\"VI Virgin Islands, U.S.\", \"vi\"],[\"VN Viet Nam\", \"vn\"],[\"VU Vanuatu\", \"vu\"],[\"WF Wallis and Futuna\", \"wf\"],[\"WS Samoa\", \"ws\"],[\"YE Yemen\", \"ye\"],[\"YT Mayotte\", \"yt\"],[\"ZA South Africa\", \"za\"],[\"ZM Zambia\", \"zm\"],[\"ZW Zimbabwe\", \"zw\"]]\n @fullscreen = true\n @match = nil\n # current match\n if @table.matches.where(is_running: true).size > 0\n @match = @table.matches.where(is_running: true).first\n end\n # previous match\n if @table.matches.where(is_running: true).size == 0 && @table.matches.where(is_over: true).size > 0\n @match = @table.matches.where(is_over: true).reorder(\"matches.finished_at DESC\").first\n end\n if @table.banner.blank?\n @banner = false\n else\n @banner = true\n end\n end",
"def collect_countries(country_table)\n result = []\n chunked = []\n\n country_table.each_with_index do |v, i|\n if i.even?\n country_abbreviation = v.attributes['name'].value\n result << country_abbreviation\n else\n country_name = v.children.text\n country_link = v.attributes['href'].value\n result << country_name\n result << \"https://www.geonames.org#{country_link}\"\n end\n end\n#taking each set of three data points and associating them together\n while result.length > 3\n chunked << result.slice!(0,3)\n end\n chunked\nend",
"def full_country_report(hash)\n\n hash.each do |key, value|\n new_state = VirusPredictor.new(key, STATE_DATA[key][:population_density], STATE_DATA[key][:population])\n new_state.virus_effects\n end\n\nend",
"def get_continent(country_doc)\n my_html = Nokogiri::HTML(country_doc)\n doc = my_html.at(\"table tr td div.region1 a\")\n region = nil\n if doc != nil then\n region = doc.text.to_s\n if str_include?(region, 'Asia')\n region = 'Asia'\n elsif str_include?(region, 'middle east')\n region = 'Asia'\n end\n end\n return region\n end",
"def country\n query_root_node(\"gdacs:country/text()\", @@NAMESPACES)\n end",
"def country(code, name); end",
"def zone_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true\n self.get_statistics('ox.bannerZoneStatistics', start_on, end_on, local_time_zone)\n end",
"def total_members_by(geo, results)\n totals = results.each_with_object(Hash.new(0)) do |res,counts|\n next unless [\"us\",\"ca\"].include?(res.country)\n counts[res.send(geo.to_sym)] += res.members.to_i\n end\n puts \"TOTAL: #{totals.values.inject(:+)}\"\n \n totals = totals.sort_by { |geo,count| -count }\n puts \"Total members by #{geo.to_s}: \"\n totals.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend",
"def country\n client.places.get_countries.select{|hash| hash[\"cid\"] == @params[:country].to_i}.first[:title]\n end",
"def countries\r\n\t\t\tCOUNTRIES\r\n\t\tend",
"def country\n @country\n end",
"def show\n\n\n @populationresponse = @country.retrievePopulation(2017)\n\n\n end",
"def show\n @country1 = params[:c1]\n @reports = DailyReport.select(\"day, sum(deaths) as deaths, sum(confirmed) as confirmed, sum(recovery) as recovery\").where(:country => @country1).group(:country).group(:day).order(day: :desc)\n end",
"def country_list\n get_request( \"/api/v2_1/api/countries\")\n end",
"def show\r\n\t\trender_result(\r\n\t\t\tdata: @addr_country,\r\n\t\t\tmeta: {}\r\n\t\t)\r\n\tend",
"def render_toc_countries( countries, opts={} )\r\n buf = ''\r\n countries.each do |country|\r\n #<!-- fix: add to models -> countries_w_breweries_or_beers ?? -->\r\n # <!-- todo: use helper e.g. has_beers_or_breweries? or similar ?? -->\r\n national_teams_count = country.teams.where(club:false).count # fix: add assoc national_teams !!!\r\n clubs_count = country.teams.where(club:true).count # fix: add assoc clubs !!!\r\n leagues_count = country.leagues.count\r\n ## events_count = country.events.count <!-- fix: add to sportdb gem -->\r\n \r\n # skip country w/o teams or leagues\r\n next if national_teams_count == 0 && clubs_count == 0 && leagues_count == 0\r\n \r\n buf << link_to_country( country, opts )\r\n buf << \" -- \"\r\n \r\n counts = []\r\n counts << \"_#{national_teams_count} National Team_{:.count}\" if national_teams_count > 0\r\n counts << \"_#{clubs_count} Clubs_{:.count}\" if clubs_count > 0\r\n counts << \"_#{leagues_count} Leagues_{:.count} \" if leagues_count > 0\r\n \r\n buf << counts.join(', ')\r\n buf << \" <br>\"\r\n buf << \"\\n\"\r\n end\r\n buf\r\nend",
"def count_population_of_uk(collection_of_countries)\n total_population = 0\n for country in collection_of_countries\n total_population += country[:population]\n end\n return total_population\nend",
"def countries(data)\n my_hash = JSON.parse(data)\n conv_name = my_hash[0]['conventional_short_form']\n puts conv_name\nend",
"def report_data\n House.cities.each_with_object([]) do |city, report|\n sum_house_daylights = House.sum_house_daylights(city)\n item = {\n name: city,\n daylight: average_house_daylights(sum_house_daylights).round(1).to_s,\n }\n report << item\n end\n end",
"def get_all_countries\n puts \"collecting countries infomation..\"\n f1 = open(@CIA_URL)\n doc = Nokogiri::HTML(f1)\n open('countries.txt', 'wb') do |file|\n file << open(@CIA_URL)\n end\n doc.css(\"ul#GetAppendix_TextVersion li a\").each do |item|\n country_name = item.text\n next if country_name == \"World\" or country_name == \"European Union\" or country_name == \"Antarctica\"\n country_url = @CIA_URL\n new_url = (country_url.split('/')[0..-2]).join('/')\n country_url = new_url << '/' << item['href']\n puts \"#{country_name}\"\n f = open(country_url)\n doc = f.read()\n f.close()\n country = CountryInfo.new(country_name, country_url, doc)\n continent = get_continent(doc)\n if continent != nil\n continent.downcase!\n @country_lists[continent] += [country]\n end\n \n end\n # helper_save\n puts \"========================================================================\"\n puts \"========================================================================\"\n puts \"==============================start parsing=============================\"\n puts \"========================================================================\"\n puts \"========================================================================\"\n end",
"def country\n self[:C]\n end",
"def call\n\n self.get_nationwide_data\n puts self.todays_rankings_output\n self.get_more_info?\n end",
"def full_descriptor\n city_country_tz = \"<img src='/images/flags/#{self.country.country_code.downcase}.png' /> #{self.utf8_name}\" # we will search on the ascii name but display the UTF8 one\n \n # if city has a region mapped in the db, print it out\n city_country_tz += \", #{self.region.name}\" if (self.region)\n \n # If the city has a country mapped in the db, print it out\n city_country_tz += \", #{self.country.name}\" if (self.country)\n \n # If the city has a time zone mapped in the db, print it out\n city_country_tz += \" (#{self.time_zone.name})\" if (self.time_zone) \n \n # this is a bad hack to make sure the seperator value is include\n # need to figure out how auto-complete can append this once a selection is selected\n #city_country_tz += \"; \"\n \n # Return the array\n city_country_tz\n end",
"def index\n @ag_countries = Ag::Country.all\n end",
"def countries_list\n [\n ['Afghanistan', 'Afghanistan'],\n ['Albania', 'Albania'],\n ['Algeria', 'Algeria'],\n ['American Samoa', 'American Samoa'],\n ['Andorra', 'Andorra'],\n ['Angola', 'Angola'],\n ['Antigua and Barbuda', 'Antigua and Barbuda'],\n ['Argentina', 'Argentina'],\n ['Armenia', 'Armenia'],\n ['Australia', 'Australia'],\n ['Austria', 'Austria'],\n ['Azerbaijan', 'Azerbaijan'],\n ['Bahamas', 'Bahamas'],\n ['Bahrain', 'Bahrain'],\n ['Bangladesh', 'Bangladesh'],\n ['Barbados', 'Barbados'],\n ['Belarus', 'Belarus'],\n ['Belgium', 'Belgium'],\n ['Belize', 'Belize'],\n ['Benin', 'Benin'],\n ['Bermuda', 'Bermuda'],\n ['Bhutan', 'Bhutan'],\n ['Bolivia', 'Bolivia'],\n ['Bosnia and Herzegovina', 'Bosnia and Herzegovina'],\n ['Botswana', 'Botswana'],\n ['Brazil', 'Brazil'],\n ['Brunei', 'Brunei'],\n ['Bulgaria', 'Bulgaria'],\n ['Burkina Faso', 'Burkina Faso'],\n ['Burundi', 'Burundi'],\n ['Cambodia', 'Cambodia'],\n ['Cameroon', 'Cameroon'],\n ['Canada', 'Canada'],\n ['Cape Verde', 'Cape Verde'],\n ['Cayman Islands', 'Cayman Islands'],\n ['Central African Republic', 'Central African Republic'],\n ['Chad', 'Chad'],\n ['Chile', 'Chile'],\n ['China', 'China'],\n ['Colombia', 'Colombia'],\n ['Comoros', 'Comoros'],\n ['Congo, Democratic Republic of the', 'Congo, Democratic Republic of the'],\n ['Congo, Republic of the', 'Congo, Republic of the'],\n ['Costa Rica', 'Costa Rica'],\n [\"Côte d'Ivoire\", \"Côte d'Ivoire\"],\n ['Croatia', 'Croatia'],\n ['Cuba', 'Cuba'],\n ['Cyprus', 'Cyprus'],\n ['Czech Republic', 'Czech Republic'],\n ['Denmark', 'Denmark'],\n ['Djibouti', 'Djibouti'],\n ['Dominica', 'Dominica'],\n ['Dominican Republic', 'Dominican Republic'],\n ['East Timor', 'East Timor'],\n ['Ecuador', 'Ecuador'],\n ['Egypt', 'Egypt'],\n ['El Salvador', 'El Salvador'],\n ['Equatorial Guinea', 'Equatorial Guinea'],\n ['Eritrea', 'Eritrea'],\n ['Estonia', 'Estonia'],\n ['Ethiopia', 'Ethiopia'],\n ['Fiji', 'Fiji'],\n ['Finland', 'Finland'],\n ['France', 'France'],\n ['French Polynesia', 'French Polynesia'],\n ['Gabon', 'Gabon'],\n ['Gambia', 'Gambia'],\n ['Georgia', 'Georgia'],\n ['Germany', 'Germany'],\n ['Ghana', 'Ghana'],\n ['Greece', 'Greece'],\n ['Greenland', 'Greenland'],\n ['Grenada', 'Grenada'],\n ['Guam', 'Guam'],\n ['Guatemala', 'Guatemala'],\n ['Guinea', 'Guinea'],\n ['Guinea-Bissau', 'Guinea-Bissau'],\n ['Guyana', 'Guyana'],\n ['Haiti', 'Haiti'],\n ['Honduras', 'Honduras'],\n ['Hong Kong', 'Hong Kong'],\n ['Hungary', 'Hungary'],\n ['Iceland', 'Iceland'],\n ['India', 'India'],\n ['Indonesia', 'Indonesia'],\n ['Iran', 'Iran'],\n ['Iraq', 'Iraq'],\n ['Ireland', 'Ireland'],\n ['Israel', 'Israel'],\n ['Italy', 'Italy'],\n ['Jamaica', 'Jamaica'],\n ['Japan', 'Japan'],\n ['Jordan', 'Jordan'],\n ['Kazakhstan', 'Kazakhstan'],\n ['Kenya', 'Kenya'],\n ['Kiribati', 'Kiribati'],\n ['North Korea', 'North Korea'],\n ['South Korea', 'South Korea'],\n ['Kosovo', 'Kosovo'],\n ['Kuwait', 'Kuwait'],\n ['Kyrgyzstan', 'Kyrgyzstan'],\n ['Laos', 'Laos'],\n ['Latvia', 'Latvia'],\n ['Lebanon', 'Lebanon'],\n ['Lesotho', 'Lesotho'],\n ['Liberia', 'Liberia'],\n ['Libya', 'Libya'],\n ['Liechtenstein', 'Liechtenstein'],\n ['Lithuania', 'Lithuania'],\n ['Luxembourg', 'Luxembourg'],\n ['Macedonia', 'Macedonia'],\n ['Madagascar', 'Madagascar'],\n ['Malawi', 'Malawi'],\n ['Malaysia', 'Malaysia'],\n ['Maldives', 'Maldives'],\n ['Mali', 'Mali'],\n ['Malta', 'Malta'],\n ['Marshall Islands', 'Marshall Islands'],\n ['Mauritania', 'Mauritania'],\n ['Mauritius', 'Mauritius'],\n ['Mexico', 'Mexico'],\n ['Micronesia', 'Micronesia'],\n ['Moldova', 'Moldova'],\n ['Monaco', 'Monaco'],\n ['Mongolia', 'Mongolia'],\n ['Montenegro', 'Montenegro'],\n ['Morocco', 'Morocco'],\n ['Mozambique', 'Mozambique'],\n ['Myanmar', 'Myanmar'],\n ['Namibia', 'Namibia'],\n ['Nauru', 'Nauru'],\n ['Nepal', 'Nepal'],\n ['Netherlands', 'Netherlands'],\n ['New Zealand', 'New Zealand'],\n ['Nicaragua', 'Nicaragua'],\n ['Niger', 'Niger'],\n ['Nigeria', 'Nigeria'],\n ['Norway', 'Norway'],\n ['Northern Mariana Islands', 'Northern Mariana Islands'],\n ['Oman', 'Oman'],\n ['Pakistan', 'Pakistan'],\n ['Palau', 'Palau'],\n ['Palestine', 'Palestine'],\n ['Panama', 'Panama'],\n ['Papua New Guinea', 'Papua New Guinea'],\n ['Paraguay', 'Paraguay'],\n ['Peru', 'Peru'],\n ['Philippines', 'Philippines'],\n ['Poland', 'Poland'],\n ['Portugal', 'Portugal'],\n ['Puerto Rico', 'Puerto Rico'],\n ['Qatar', 'Qatar'],\n ['Romania', 'Romania'],\n ['Russia', 'Russia'],\n ['Rwanda', 'Rwanda'],\n ['Saint Kitts and Nevis', 'Saint Kitts and Nevis'],\n ['Saint Lucia', 'Saint Lucia'],\n ['Saint Vincent and the Grenadines', 'Saint Vincent and the Grenadines'],\n ['Samoa', 'Samoa'],\n ['San Marino', 'San Marino'],\n ['Sao Tome and Principe', 'Sao Tome and Principe'],\n ['Saudi Arabia', 'Saudi Arabia'],\n ['Senegal', 'Senegal'],\n ['Serbia and Montenegro', 'Serbia and Montenegro'],\n ['Seychelles', 'Seychelles'],\n ['Sierra Leone', 'Sierra Leone'],\n ['Singapore', 'Singapore'],\n ['Slovakia', 'Slovakia'],\n ['Slovenia', 'Slovenia'],\n ['Solomon Islands', 'Solomon Islands'],\n ['Somalia', 'Somalia'],\n ['South Africa', 'South Africa'],\n ['Spain', 'Spain'],\n ['Sri Lanka', 'Sri Lanka'],\n ['Sudan', 'Sudan'],\n ['Sudan, South', 'Sudan, South'],\n ['Suriname', 'Suriname'],\n ['Swaziland', 'Swaziland'],\n ['Sweden', 'Sweden'],\n ['Switzerland', 'Switzerland'],\n ['Syria', 'Syria'],\n ['Taiwan', 'Taiwan'],\n ['Tajikistan', 'Tajikistan'],\n ['Tanzania', 'Tanzania'],\n ['Thailand', 'Thailand'],\n ['Togo', 'Togo'],\n ['Tonga', 'Tonga'],\n ['Trinidad and Tobago', 'Trinidad and Tobago'],\n ['Tunisia', 'Tunisia'],\n ['Turkey', 'Turkey'],\n ['Turkmenistan', 'Turkmenistan'],\n ['Tuvalu', 'Tuvalu'],\n ['Uganda', 'Uganda'],\n ['Ukraine', 'Ukraine'],\n ['United Arab Emirates', 'United Arab Emirates'],\n ['United Kingdom', 'United Kingdom'],\n ['United States', 'United States'],\n ['Uruguay', 'Uruguay'],\n ['Uzbekistan', 'Uzbekistan'],\n ['Vanuatu', 'Vanuatu'],\n ['Vatican City', 'Vatican City'],\n ['Venezuela', 'Venezuela'],\n ['Vietnam', 'Vietnam'],\n ['Virgin Islands, British', 'Virgin Islands, British'],\n ['Virgin Islands, U.S.', 'Virgin Islands, U.S.'],\n ['Yemen', 'Yemen'],\n ['Zambia', 'Zambia'],\n ['Zimbabwe', 'Zimbabwe']\n ]\n end",
"def countries\n puts \"Which country would you like to explore?\"\n puts <<-DOC\n 1. Scotland\n 2. Ireland\n 3. United States of America\n 4. Japan\n 5. Canada\n 6. Other countries\n DOC\n country_list\n end",
"def country\n \tself.contry\n end",
"def getCountryVisited\n countries = [] \n logs = self.user_logs.where(visited: true)\n \n if !logs.nil?\n logs = (logs.order(:updated_at)).reverse \n\t logs.each do |log|\n\t\t countries += [log.country]\n\t end\n end\n \n\t return countries\n end",
"def index\n @public_relations = PublicRelation.all.order(round: :desc, created_at: :desc)\n @countries = countries.collect{|x|x[0]}\n end",
"def country\n RAILS_DEFAULT_LOGGER.debug(\"profile.country -- returning #{setting(:company_country)}\")\n \n setting(:company_country).to_s\n end",
"def countries\n @data.map { |iso2, data| iso2 }\n end",
"def title_with_country\n # Remove special country values (e.g. 'DIT HQ')\n countries = opportunity.countries.where.not(id: [198, 199, 142, 200])\n if source('post') && !countries.empty? && countries.map(&:region_id).include?(18)\n opportunity.title\n else\n country = if countries.size > 1\n 'Multi Country'\n else\n countries.map(&:name).join\n end\n\n if country.present?\n \"#{country} - #{opportunity.title}\"\n else\n opportunity.title\n end\n end\n end",
"def get_iso_country(country)\n #Kinda redundant but downcasing first makes the hardcoding a bit more obvious\n country = country.downcase\n\n if country == \"bosnia-herzogovnia\"\n country = \"bosnia and herzogovnia\"\n elsif country == \"russia\"\n country = \"russian federation\"\n elsif country == \"laos\"\n country = \"lao peoples democratic republic\"\n elsif country == \"iran\"\n country = \"islamic republic of iran\"\n elsif country == \"taiwan\"\n country = \"province of china taiwan\"\n elsif country == \"north korea\"\n country = \"democratic people's republic of korea\"\n elsif country == \"south korea\"\n country = \"republic of korea\"\n elsif country == \"basque spain\"\n country = \"spain\"\n elsif country == \"macedonia\"\n country = \"the former yugoslav republic of macedonia\"\n elsif country == \"tanzania\"\n country = \"united republic of tanzania\"\n elsif country == \"vietnam\"\n country = \"viet nam\"\n elsif country == \"venezuela\"\n country = \"bolivarian republic of venezuela\"\n elsif country == \"syria\"\n country = \"syrian arab republic\"\n elsif country == \"rep.dem.congo\"\n country = \"congo\"\n elsif country == \"dagestan\"\n country = \"russian federation\"\n elsif country == \"adygea\"\n country = \"russian federation\"\n elsif country == \"karachaevo circassia\"\n country = \"russian federation\"\n elsif country == \"tartarstan\"\n country = \"russian federation\"\n #elsif country == \"ivory coast\"\n # This seems like the wrong way of doing this but not sure how else to guarentee the match\n #country = \"CÃTE D'IVOIRE\".downcase\n end\n\n country = normalize(country)\n \n @@iso_country_codes.xpath(\"//ISO_3166-1_Entry\").each do |code|\n n_country = normalize(code.xpath(\"ISO_3166-1_Country_name\")[0].content)\n\n if (country.upcase == n_country.upcase)\n return code.xpath(\"ISO_3166-1_Alpha-2_Code_element\")[0].content\n end\n end\n return \"ZZ\"\n end",
"def filter_countries\n SUPER_COUNTRIES\n end",
"def summary_region(region)\n \t\tAPI.get_regional_wordcount(region)\n \tend",
"def extract_countries_and_regions\n infile, result, *others = params\n out_file_name = \"countries_and_regions.csv\"\n\n puts; print \"Extracting countries and regions from #{infile}\"\n\n col_filter = \"COUNTRIES:4-6+REGIONS:18\"\n\n Sycsvpro::Collector.new(infile: infile,\n outfile: out_file_name,\n cols: col_filter).execute\n\n puts; puts \"You can find the collection result in #{out_file_name}\"\nend",
"def get_aditional_data\n require 'hpricot'\n require 'open-uri'\n doc = Hpricot(open(\"http://gc.kls2.com/airport/#{iata_code}\",\n \"User-Agent\" => \"Ruby\"))\n self.lat = doc.at(\"abbr.latitude\")['title'].to_f\n self.lng = doc.at(\"abbr.longitude\")['title'].to_f\n self.city = doc.at(\"span.locality\").inner_html\n self.country = doc.at(\"span.country-name\").inner_html\n self.name = doc.at(\"td.fn\").inner_html.gsub(/<[^>]+>/,'')\n end",
"def count_population(country)\n population = 0\n for country in country\n population += country[:population]\n end\n return population\nend",
"def show\n @country = Carmen::Country.coded(@profile.country_code)\n @subregions = @country.subregions\n @state = @subregions.coded(@profile.state_code)\n end",
"def countries\n document.search(\"h5[text()='Country:'] ~ a[@href*=/country/']\").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []\n end",
"def regions\n client.get_stats('/stats/regions')\n end",
"def index\r\n @countries = Country.all\r\n\r\n @chart_data = {}\r\n if @user\r\n\t visits = @user.visits.sort_by{|visit| visit[:visit_date]}\r\n\t min_date = visits.first[:visit_date]\r\n\t max_date = visits.last[:visit_date]\r\n\t\t\tvisits.each do |visit|\r\n\t\t\t\tif visit.visit_date.is_a? Date\r\n\t\t\t\t\tkey = visit.visit_date.year.to_s + '-' + sprintf(\"%02d\", visit.visit_date.month.to_s)\r\n\t\t\t\t\t@chart_data[key] = @chart_data[key].nil? ? 1 : @chart_data[key] + 1\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t for i in (min_date.year*100 + min_date.month)..(max_date.year*100 + max_date.month)\r\n\t\t key = (i/100).to_s + '-' + sprintf(\"%02d\", (i%100).to_s)\r\n\t\t @chart_data[key] = 0 if @chart_data[key].nil?\r\n\t end\r\n\t @chart_data = @chart_data.sort\r\n\t\t\tif @chart_data.size > 1\r\n\t\t\t\tq = 0\r\n\t\t\t\tx = {}\r\n\t\t\t\t@chart_data.each{|k, v|\r\n\t\t\t\t\tq = v + q\r\n\t\t\t\t\tx[k]=q\r\n\t\t\t\t}\r\n\t\t\t\t@chart_data = x\r\n\t\t\tend\r\n end\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.xml { render :xml => @countries }\r\n end\r\n end",
"def office_country\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"country\")\n end",
"def stats; end",
"def stats; end",
"def country_code\n end",
"def index\n\t @events = @univers.events\n\t \n\t #FOR SORTING\n\t @newarray = Array.new\n\t @country_name_array = Array.new\n\t\t\n\t @events.each do |event|\n\t\t @newarray << event.place.country\n\t\t @country_name_array << event.place.country_name\t\t\n\t\tend\n\t \n\t\t@top_countries = @newarray.uniq\n\t\t@top_countries_name = @country_name_array.uniq\n\t @super_countries = Array.new\n\t\t\n\t \n\t \n\t \n end",
"def list_all_countries\n column_width = @country_hash.values.max_by {|name| name.length}.length + 4\n columns = 3\n organizer = 1\n @country_hash.each do |key, value|\n name = \"(#{key}) #{format_name(value)}\"\n if organizer % columns == 0\n puts \"#{name}\".colorize(:blue)\n else\n (column_width - name.length).times do\n name << \" \"\n end\n print \"#{name}\".colorize(:blue)\n end\n organizer += 1\n end\n puts\n end",
"def build_areas_from_country_codes\n CSV.read(\"#{@args[:data_directory]}data/external/country_names_and_code_elements.txt\", options = {headers: true, col_sep: ';'}).each do |r|\n @data_index.add_item(\n name: uncapitalize(r['Country Name']),\n parent_names: [@earth.name],\n lvl0: uncapitalize(r['Country Name']),\n source_table: 'country_names_and_code_elements',\n geographic_area_type_name: 'Country',\n is_internal_node: true,\n iso_3166_a2: r['ISO 3166-1-alpha-2 code']\n )\n end\n end",
"def continent; end",
"def country_api\n # endpoint = \"https://corona.lmao.ninja/countries\"\n endpoint = 'https://corona.lmao.ninja/v2/countries'\n response = HTTParty.get(endpoint)\n data = JSON.parse response.body\n res = data\n result =[]\n endpoint_all = \"https://corona.lmao.ninja/all\"\n response1 = HTTParty.get(endpoint_all)\n data1 = JSON.parse response1.body\n res1 = data1\n result<<{\n country: \"world\",\n cases: res1[\"cases\"],\n todayCases: res1[\"todayCases\"],\n deaths: res1[\"deaths\"],\n todayDeaths: res1[\"todayDeaths\"],\n recovered: res1[\"recovered\"],\n active: res1[\"active\"],\n critical: res1[\"critical\"],\n casesPerOneMillion: res1[\"casesPerOneMillion\"],\n deathsPerOneMillion: res1[\"deathsPerOneMillion\"],\n tests: res1[\"tests\"],\n testsPerOneMillion: res1[\"testsPerOneMillion\"],\n affectedCountries: res1[\"affectedCountries\"]\n }\n\n res.each do |country|\n result<<{\n country: country[\"country\"],\n lat: country[\"countryInfo\"][\"lat\"],\n long: country[\"countryInfo\"][\"long\"],\n flag: country[\"countryInfo\"][\"flag\"],\n cases: country[\"cases\"],\n todayCases: country[\"todayCases\"],\n deaths: country[\"deaths\"],\n todayDeaths: country[\"todayDeaths\"],\n recovered: country[\"recovered\"],\n active: country[\"active\"],\n critical: country[\"critical\"],\n casesPerOneMillion: country[\"casesPerOneMillion\"],\n deathsPerOneMillion: country[\"deathsPerOneMillion\"],\n tests: country[\"tests\"],\n testsPerOneMillion: country[\"testsPerOneMillion\"]\n }\n end\n render json: result\n end",
"def pbGetCountry()\n getUserGeoID=Win32API.new(\"kernel32\",\"GetUserGeoID\",\"l\",\"i\") rescue nil\n if getUserGeoID\n return getUserGeoID.call(16)\n end\n return 0\nend",
"def countries\n array = []\n details.css(\"div.txt-block a[href^='/country/']\").each do |node|\n array << {:code => node['href'].clean_href, :name => node.text.strip}\n end\n\n array\n end",
"def country_counts(opts={ })\n unless (leftovers = opts.keys - VALID_COUNT_OPTIONS).empty?\n raise \"Invalid keys: #{leftovers.join(', ')}\"\n end\n\n params = []\n clauses = []\n sql = \"SELECT country, SUM(install_count), SUM(update_count) FROM reports\"\n\n if opts[:from]\n clauses << \"report_date >= ?\"\n params << format_date(opts[:from])\n end\n\n if opts[:to]\n clauses << \"report_date <= ?\"\n params << format_date(opts[:to])\n end\n\n if opts[:country]\n clauses << \"country = ?\"\n params << opts[:country]\n end\n\n sql << \" WHERE \" unless clauses.empty?\n sql << clauses.join(\" AND \") unless params.empty?\n sql << \" GROUP BY country ORDER BY country\"\n\n @db.execute(sql, params).map do |row|\n OpenStruct.new({\n :country => row[0],\n :install_count => row[1].to_i,\n :update_count => row[2].to_i\n })\n end\n end",
"def index\n @countryinfos = Countryinfo.all\n end"
] |
[
"0.6671692",
"0.6671692",
"0.6671692",
"0.66341335",
"0.66064835",
"0.6473873",
"0.64499825",
"0.63868284",
"0.6376618",
"0.6353003",
"0.6335491",
"0.63140094",
"0.62906873",
"0.62640035",
"0.62503564",
"0.6236346",
"0.6235966",
"0.62233686",
"0.62133247",
"0.61735654",
"0.61679864",
"0.61523503",
"0.6124918",
"0.61190826",
"0.61185896",
"0.610562",
"0.60805875",
"0.6050412",
"0.6044692",
"0.6044692",
"0.6044692",
"0.6044692",
"0.6044692",
"0.6044692",
"0.603966",
"0.6025585",
"0.6017223",
"0.6006717",
"0.6006717",
"0.6005267",
"0.6003752",
"0.60012996",
"0.59929764",
"0.5991637",
"0.59914",
"0.59731823",
"0.59656537",
"0.5958921",
"0.5953038",
"0.5935439",
"0.593183",
"0.5919317",
"0.59120107",
"0.5910942",
"0.59104645",
"0.59103763",
"0.5903938",
"0.5897271",
"0.5869135",
"0.58619076",
"0.58448505",
"0.5838701",
"0.5837465",
"0.58318675",
"0.5829055",
"0.58239585",
"0.5806571",
"0.58026224",
"0.5802105",
"0.5795112",
"0.57946354",
"0.57915074",
"0.57906574",
"0.5780252",
"0.5778267",
"0.5755339",
"0.57497454",
"0.5746341",
"0.5743094",
"0.57401973",
"0.57308745",
"0.5714425",
"0.570862",
"0.570109",
"0.5699722",
"0.5698676",
"0.56849015",
"0.56835055",
"0.56824327",
"0.56824327",
"0.56719005",
"0.5668211",
"0.5663092",
"0.56603813",
"0.5658437",
"0.5657406",
"0.5655304",
"0.5652459",
"0.5650602",
"0.5639151"
] |
0.73234856
|
0
|
Created On: 08/11/2014 Purpose: To get city statistics report ++
|
def get_city_statistics_report(city_list, device_access)
@city_hash = {}
city_list.each do |city|
city_count = device_access.where(:access_city => city).count
@city_hash[city] = city_count
end
city_stat = @city_hash.sort_by {|_key, value| value}.reverse
hash = Hash[*city_stat.flatten]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def report_data\n House.cities.each_with_object([]) do |city, report|\n sum_house_daylights = House.sum_house_daylights(city)\n item = {\n name: city,\n daylight: average_house_daylights(sum_house_daylights).round(1).to_s,\n }\n report << item\n end\n end",
"def get_nationwide_data\n\n #scrape page for top ranking cities\n @html = AirQualityIndex::Scraper.new.nationwide_aqi_scraper\n\n #create and store first rank data\n @first_city = AirQualityIndex::City.new\n\n self.first_city.location_name_full = self.html.search(\"a.NtnlSummaryCity\")[0].text.strip\n self.first_city.index = self.html.search(\"div.TabbedPanelsContent\").children.css(\"tr td\")[1].children.text.strip\n self.first_city.message = aqi_message_set(self.first_city.index)\n self.first_city.link = html.search(\"a.NtnlSummaryCity\")[0]['href']\n\n #store second rank data\n @second_city = AirQualityIndex::City.new\n\n self.second_city.location_name_full = self.html.search(\"a.NtnlSummaryCity\")[1].text.strip\n self.second_city.index = self.html.search(\"div.TabbedPanelsContent\").children.css(\"tr td\")[6].children.text.strip\n self.second_city.message = aqi_message_set(self.second_city.index)\n self.second_city.link = html.search(\"a.NtnlSummaryCity\")[1]['href']\n\n #store third rank data\n @third_city = AirQualityIndex::City.new\n\n self.third_city.location_name_full = self.html.search(\"a.NtnlSummaryCity\")[2].text.strip\n self.third_city.index = self.html.search(\"div.TabbedPanelsContent\").children.css(\"tr td\")[11].children.text.strip\n self.third_city.message = aqi_message_set(self.third_city.index)\n self.third_city.link = html.search(\"a.NtnlSummaryCity\")[2]['href']\n\n #store fourth rank data\n @fourth_city = AirQualityIndex::City.new\n\n self.fourth_city.location_name_full = self.html.search(\"a.NtnlSummaryCity\")[3].text.strip\n self.fourth_city.index = self.html.search(\"div.TabbedPanelsContent\").children.css(\"tr td\")[16].children.text.strip\n self.fourth_city.message = aqi_message_set(self.fourth_city.index)\n self.fourth_city.link = html.search(\"a.NtnlSummaryCity\")[3]['href']\n\n #store fifth rank data\n @fifth_city = AirQualityIndex::City.new\n\n self.fifth_city.location_name_full = self.html.search(\"a.NtnlSummaryCity\")[4].text.strip\n self.fifth_city.index = self.html.search(\"div.TabbedPanelsContent\").children.css(\"tr td\")[21].children.text.strip\n self.fifth_city.message = aqi_message_set(self.fifth_city.index)\n self.fifth_city.link = html.search(\"a.NtnlSummaryCity\")[4]['href']\n\n end",
"def print_city_list\n\n # simply call the print_vertices function of the graph API\n @query.get_graph.each_key { |city| puts \"#{get_city_info(city,\"name\")}\"}\n\n end",
"def analysis_data()\n first_destination = metro[metro.keys[0]].destination\n longest_distance = first_destination[first_destination.keys[0]]\n shortest_distance = first_destination[first_destination.keys[0]]\n avg_distance = 0\n total_number = 0\n longest_city_pair = \"#{metro.keys[0]}-#{first_destination.keys[0]}\"\n shortest_city_pair = \"#{metro.keys[0]}-#{first_destination.keys[0]}\"\n\n biggest_population = metro[metro.keys[0]].population\n smallest_population = metro[metro.keys[0]].population\n avg_population = 0\n biggest_city = metro.keys[0]\n smallest_city = metro.keys[0]\n\n continent = []\n hub_city = metro.keys[0]\n hub_size = first_destination.length\n\n #start the iteration for distance.\n @metros.each do |city_code, city|\n dest = city.destination\n dest.each do |dest, distance|\n if distance > longest_distance\n longest_distance = distance\n longest_city_pair = \"#{city.code}-#{dest}\"\n end\n if distance < shortest_distance\n shortest_distance = distance\n shortest_city_pair = \"#{city.code}-#{dest}\"\n end\n #calculate average\n avg_distance += distance\n total_number += 1\n end\n end\n\n #Search all values needed about continent, population and length.\n city_num = 0\n @metros.each do |city_code, city|\n if !continent.include?(city.continent)\n continent.push(city.continent)\n end\n\n if city.destination.length > hub_size\n hub_city = city_code\n hub_size = city.destination.length\n end\n if city.population > biggest_population\n biggest_population = city.population\n biggest_city = city_code\n end\n if city.population < smallest_population\n smallest_population = city.population\n smallest_city = city_code\n end\n avg_population += city.population\n city_num += 1\n end\n\n @longest_dist = longest_distance\n @shortest_dist = shortest_distance\n @avg_dist = avg_distance\n @biggest_pop = biggest_population\n @biggest_city = biggest_city\n @avg_pop = avg_population/city_num\n @hub_ct = hub_city\n #Here is the printing.\n puts \"------------------CSAIR information---------------------\"\n puts \"The longest distance in CSAIR is #{longest_distance}, #{longest_city_pair}\"\n puts \"The shortest distance in CSAIR is #{shortest_distance}, #{shortest_city_pair}\"\n puts \"The average distance is #{avg_distance/total_number}\"\n puts \"The biggest city is #{biggest_city}, population #{biggest_population}\"\n puts \"The smallest city is #{smallest_city}, population #{smallest_population}\"\n puts \"The average population is #{avg_population/city_num}\"\n puts \"We fly to these continents and cities:\"\n continent.each do |single_continent|\n print \"#{single_continent}: \"\n @metros.each do |city_code, attri|\n if attri.continent == single_continent\n print \"#{city_code} \"\n end\n end\n print \"\\n\"\n end\n puts \"Our hub city is #{hub_city}, it has #{hub_size} lines\"\n puts \"------------------CSAIR information---------------------\"\n puts \"\"\n end",
"def city_scraper\n #Id,Id2,Geography,Target Geo Id,Target Geo Id2,Geographical Area,Geographical Area,,,Total area,Water area,Land area,Population,Housing units\n #0400000US01,01,Alabama,1600000US0107000,0107000,\"Alabama - PLACE - Birmingham city, Alabama\",\"Birmingham city, Alabama\",242820,111927,151.95,2.04,149.92,1619.7,746.6\n # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 \n @states = Array.new\n @cities = Array.new\n \n count = 0\n state_name = \"\"\n CSV.foreach(\"data/DEC_10_SF1_GCTPH1.ST13.csv\") do |row|\n count = count + 1\n city_name = \"\"\n population = 0\n elevation = 0\n lat_dir = \"\"\n lat_deg = 0\n lat_min = 0\n lat_sec = 0\n lon_dir = \"\"\n lon_deg = 0\n lon_min = 0\n lon_sec = 0\n if(row[2] == row[5])\n #its a state\n puts \"State: #{row[2]}\"\n state_name = row[2]\n state = State.new(:name => row[2])\n if(@states.length == 51)\n break\n end\n @states << state\n next\n end\n \n geographical_area = CSV.parse(row[6])\n city_name = geographical_area[0][0]\n if(city_name.match(/(part)/))\n #puts \"skipping #{city_name}\"\n next\n end\n \n city_name = city_name.downcase.gsub(/ city/,'').gsub(/ town/,'').gsub(/ village/,'').gsub(/ cdp/,'').gsub(/ borough/,'').gsub(/ municipality/,'').gsub(/ and/,'')\n city_name.strip.capitalize!\n city_name = city_name.capitalize\n #puts \"#{city_name} #{count}\"\n \n city_name_uri = URI.escape(city_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n state_name_uri = URI.escape(state_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n city_html = Net::HTTP.get(URI.parse(\"http://www.geonames.org/search.html?q=#{city_name_uri}%2C+#{state_name_uri}&country=US\"))\n #puts \"http://www.geonames.org/search.html?q=#{city_name}%2C+#{state_name}&country=US\"\n @city_doc = Hpricot(city_html)\n \n @city_doc.search(\"//table[@class='restable']\") do |table|\n tr_count = 0\n table.search(\"//tr\") do |tr|\n #puts \"in tr search\"\n tr_count = tr_count + 1\n if(tr_count < 3)\n next\n end\n #puts \"in tr search 2\"\n td_count = 0\n tr.search(\"//td\") do |td|\n #puts \"in td search\"\n td_count = td_count + 1\n if(td_count < 4)\n next\n end\n if(td_count == 4)\n td.search(\"//small\") do |small|\n #population = \"#{small.match(/\\\\d+/)[1]}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n #puts td_count\n #puts \"#{small.inner_html}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n pop_elev = small.inner_html\n #population = \"#{pop_elev.match(/\\d+,\\d*/)}\".gsub(/,/,'')\n elevation = \"#{pop_elev.match(/\\d+m/)}\".gsub(/m/,'')\n #puts population\n #puts elevation\n end\n end\n if(td_count == 5)\n lat_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lat_deg = matches[0][0]\n lat_min = matches[1][0]\n lat_sec = matches[2][0]\n end\n if(td_count == 6)\n lon_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lon_deg = matches[0][0]\n lon_min = matches[1][0]\n lon_sec = matches[2][0]\n end\n end\n break\n \n end \n end\n city = City.new(\n :name => city_name,\n :states_id => @states.length,\n :total_area => row[9],\n :water_area => row[10],\n :land_area => row[11],\n :population => row[7],\n :population_density => row[12],\n :lat_deg => lat_deg,\n :lat_min => lat_min,\n :lat_sec => lat_sec,\n :lat_dir => lat_dir,\n :lon_deg => lon_deg, \n :lon_min => lon_min,\n :lon_sec => lon_sec,\n :lon_dir => lon_dir,\n :elevation => elevation)\n \n @cities << city\n if(count % 10 == 0)\n puts count\n end\n end\n \n @states.each do |state|\n state.save\n end\n \n @cities.each do |state|\n state.save\n end\n \n end",
"def index\n @ge_asset_list = GeCityApi.get_asset_list\n @historical_data = GeCityApi.get_asset_historical_data\n @current_data = GeCityApi.get_asset_current_data(@historical_data.keys)\n @anomaly = GeCityApi.check_anomalies(@current_data, @historical_data)\n # @ge_city_apis = GeCityApi.all\n end",
"def city; end",
"def city; end",
"def statistics; end",
"def city; end",
"def city; end",
"def city; end",
"def city; end",
"def full_descriptor\n city_country_tz = \"<img src='/images/flags/#{self.country.country_code.downcase}.png' /> #{self.utf8_name}\" # we will search on the ascii name but display the UTF8 one\n \n # if city has a region mapped in the db, print it out\n city_country_tz += \", #{self.region.name}\" if (self.region)\n \n # If the city has a country mapped in the db, print it out\n city_country_tz += \", #{self.country.name}\" if (self.country)\n \n # If the city has a time zone mapped in the db, print it out\n city_country_tz += \" (#{self.time_zone.name})\" if (self.time_zone) \n \n # this is a bad hack to make sure the seperator value is include\n # need to figure out how auto-complete can append this once a selection is selected\n #city_country_tz += \"; \"\n \n # Return the array\n city_country_tz\n end",
"def results_output(city,results,count)\n #Output the name of the current city.\n puts \"#{city}:\"\n #If there are a positive number of listings format the results.\n if count>0\n #Loop through each result.\n results.each do |item|\n #Convert the number of listings for each language into a percentage.\n item[1] = (((item[1].to_f / count.to_f) *100).round())\n end\n #Sort descending by percentage\n sorted = results.sort_by{|x,y|y}.reverse\n #Loop through sorted results filtering out results with zero listings and formatting for output\n sorted.each do |item|\n #If the given language has more than zero results\n if item[1] >0\n #Output \"- Langauge: 50%\"\n puts \"- #{item[0]}: #{item[1].to_s} %\"\n end\n end\n #Otherwise, if the current city has no listings for any of the languages, output \"No Results\".\n else\n puts \"- No Results\"\n end\n end",
"def make_summaries\n if @data.key?(\"Global\") && @data.key?(\"Countries\") && @data.key?(\"Date\")\n global_data = @data[\"Global\"]\n global_data[\"Date\"] = @data[\"Date\"]\n global_data[\"Country\"] = \"Global\"\n\n # Clean up global_data with the parser method\n global_hash = parser(global_data)\n\n # Create the Summary object for global info\n CovidTracking::Summary.new(global_hash)\n\n @data[\"Countries\"].each {|ctry_info| CovidTracking::CountrySummary.new(parser(ctry_info))}\n else\n raise DataError\n end\n\n end",
"def city_info(cities)\n cities.each do |key, value|\n puts \"#{key} has #{value.length} main cities: #{value[0..-2].join(\", \")} and #{value[-1]}\"\n # puts \"#{key} has #{value.length} main cities: #{value.join(\", \")}\"\n end\nend",
"def cities_of_paks_not_in_regions\n res = $store.raw_select(\"select add_city, count(add_city) from \" +\n \"user_table, contact, membership, address \" +\n \"where mem_affiliate=? \" +\n \" and mem_region is null \" +\n \" and mem_admin = user_id \" +\n \" and mem_state != '#{StateNameTable::Suspended}'\" +\n \" and user_contact = con_id \" +\n \" and con_mail = add_id \" +\n \"group by add_city\",\n @data_object.aff_id)\n res.map {|row| \"#{row[0]}(#{row[1]})\" }\n end",
"def weather_hourly(city, state)\n request = \"http://api.wunderground.com/api/747e267558954ba9/hourly/q/#{state}/#{city}.json\"\n hourly = HTTParty.get(request)\n hourly[\"hourly_forecast\"].each do |hour| \n puts \"#{hour[\"FCTTIME\"][\"civil\"]}: #{hour[\"temp\"][\"english\"]}F\"\n end\nend",
"def cities\n CS.get :us, :ca\n end",
"def index\n # @incidents = Incident.all.order(\"id desc\")\n @search = IncidentSearch.new(params[:search])\n @incidents = @search.scope.order('id desc')\n @incident = Incident.new\n @incidentcategory = Incidentcategory.all\n respond_to do |format|\n format.html\n format.csv { send_data @incidents.to_csv }\n format.xlsx { send_data @incidents.to_csv(col_sep: \"\\t\") }\n end\n @city = request.location.city\n end",
"def city\n data['City']\n end",
"def metadata_cities(structure)\n place = []\n courses = structure.courses\n\n place << 'A domicile' if courses.where(type: 'Course::Private').any?\n if (public_courses = courses.where.not(type: 'Course::Private')).any?\n place += public_courses.flat_map(&:places).flat_map(&:city).uniq.map(&:name).sort\n end\n\n place.first(3).to_sentence\n end",
"def index # shows locations according to their cities\n @locs = Loc.where(city_id: @city.id).sorted\n end",
"def getCityInfo(city)\r\n result = @vertex.find{ |code, cname| (code == city || cname.name == city)}\r\n\r\n if result.nil?\r\n puts \"There is no such city in CSAir.\"\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n else\r\n result[1].printVertex\r\n puts \"\"\r\n connectedCities(result[1].code)\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n end\r\n end",
"def index\n geo = ip_lookup ( request.remote_ip )\n wind = Wind.new( lat: geo.lat, lng: geo.lng )\n loc = wind.location\n @speed = wind.speed\n @bearing = wind.bearing\n @citystate = \"#{loc.city}, #{loc.state}\"\n end",
"def call\n\n self.get_nationwide_data\n puts self.todays_rankings_output\n self.get_more_info?\n end",
"def get_weather(city)\n #collects the weather conditions from the specefied location\n response = HTTP.get(\"http://api.openweathermap.org/data/2.5/weather?q=#{city},us&units=imperial&APPID=INSERT\")\n weather_data = response.parse\n return weather_data\nend",
"def employeeLocationsByCity()\n locations = Hash.new\n \n employeesList = (RawData.new(\"employee_details\").getMnoData())['content']['employees']\n \n employeesList.each do | employee |\n # extract the city/country information from the 'address' field\n address = employee['address']\n location = employee['address'].gsub(/\\ \\d+/, \"\")\n location = location.split(/\\s*[,;]\\s*/x).from(-2).join(', ')\n \n # Add to locations records\n occurrence = locations.fetch(location, nil)\n \n if !occurrence\n locations[location] = Array.new\n end \n \n locations[location].push(address)\n \n #puts locations\n end\n\n return locations\n end",
"def get_city_info(city, infoKey)\n\n info_dict = @query.json_graph_api.get_vertex_data(city)\n return info_dict[infoKey]\n\n end",
"def cities\n gallaries.map{|place| place.city}\n\n end",
"def local_aqi_index(city)\n\n #If a ranked city instance is supplied, set @city to this instance, otherwise, create a new city instance\n city.nil?? @city = AirQualityIndex::City.new : @city = city\n\n #store location information\n self.city.location_city = self.doc.search(\".ActiveCity\").text.strip\n self.city.location_state = self.doc.search(\"a.Breadcrumb\")[1].text.strip\n\n #store aqi index\n set_msg_or_attribute('current_aqi_index', self.doc.at('.TblInvisible').css('tr td').children[1])\n set_msg_or_attribute('current_aqi_msg', self.doc.search(\"td.AQDataLg\")[0])\n set_msg_or_attribute('current_health_msg', self.doc.search(\"td.HealthMessage\")[0])\n\n #store current aqi/ozone data\n set_msg_or_attribute('current_pm', self.doc.search(\"table\")[14].children.css(\"td\")[4])\n set_msg_or_attribute('current_pm_msg', self.doc.search(\"td.AQDataPollDetails\")[3])\n set_msg_or_attribute('current_ozone', self.doc.search(\"table\")[14].children.css(\"td\")[1])\n set_msg_or_attribute('current_ozone_msg', self.doc.search(\"td.AQDataPollDetails\")[1])\n\n #Extract time from site\n self.city.current_aqi_timestamp = self.timestamp\n self.doc.search(\"td.AQDataContent\")[0].css(\"tr\")[2].text.strip\n\n #store todays forecast data\n set_msg_or_attribute('today_aqi', self.doc.search(\"td.AQDataContent\")[0].css(\"td\")[3])\n set_msg_or_attribute('today_aqi_num', self.doc.search(\"td.AQDataContent\")[0].css(\"tr\")[2])\n set_msg_or_attribute('today_health_msg', self.doc.search(\"td.HealthMessage\")[1])\n\n #store tomorrows forecast data\n set_msg_or_attribute('tomorrow_aqi', self.doc.search(\"td.AQDataContent\")[1].css(\"td\")[3])\n set_msg_or_attribute('tomorrow_aqi_num', self.doc.search(\"td.AQDataContent\")[1].css(\"tr\")[2])\n set_msg_or_attribute('tomorrow_health_msg', self.doc.search(\"td.HealthMessage\")[2])\n\n #save instance to City.all\n self.city.save\n\n #return self\n self\n end",
"def todays_rankings_output\n puts \"\"\n puts \"Nationwide AQI Rankings for #{self.todays_date.month}/#{self.todays_date.day}/#{self.todays_date.year}\"\n puts \"\"\n puts <<-DOC\n 1. #{self.first_city.location_name_full} - #{self.first_city.index} (#{self.first_city.message})\n 2. #{self.second_city.location_name_full} - #{self.second_city.index} (#{self.second_city.message})\n 3. #{self.third_city.location_name_full} - #{self.third_city.index} (#{self.third_city.message})\n 4. #{self.fourth_city.location_name_full} - #{self.fourth_city.index} (#{self.fourth_city.message})\n 5. #{self.fifth_city.location_name_full} - #{self.fifth_city.index} (#{self.fifth_city.message})\n DOC\n end",
"def get_summary_for_site(name=@name)\n summary = {} \n summary[:name] = name\n # total\n summary[:total] = Sensor.count(:all, :conditions=>['name=?',name])\n # first obs date\n rs = Sensor.find(:first, :conditions=>['name=?',name], :order=>\"created_at\")\n summary[:first_datetime] = (!rs.nil?) ? rs.created_at : \"\"\n # last obs date\n rs = Sensor.find(:first, :conditions=>['name=?',name], :order=>\"created_at DESC\")\n summary[:last_datetime] = (!rs.nil?) ? rs.created_at : \"\"\n # max\n rs = Sensor.maximum(:temp, :conditions=>['name=?',name])\n summary[:max] = rs\n # min\n rs = Sensor.minimum(:temp, :conditions=>['name=?',name])\n summary[:min] = rs\n # avg\n rs = Sensor.average(:temp, :conditions=>['name=?',name])\n summary[:mean] = rs.to_f\n \n return summary\n end",
"def index\n load_incidents\n incident = Incident.all\n @incidents = incident.count\n @status = incident.group(:status).count\n @monthly_incidents = incident.group_by_month(:created_at, format: \"%b %Y\").count\n @victim_by_age = Victim.group(:agegroup).count\n @offendercategory = Offendercategory.group(:name).count\n @followupsstatus = Incidentfollowup.group(:status).count\n @closedcase = incident.where.not(status: %w[Solved Resolved resolved solved]).count\n @opencases = incident.where(status: %w[Solved Resolved resolved solved]).count\n @dropped = incident.where(status: %w[Dropped dropped]).count\n @nooffenders = incident.where(offender: '').count\n @mostrecent = incident.group_by_week(:created_at, last: 4)\n @timeofday = incident.group_by_hour_of_day(:created_at, format: \"%-l %P\").count\n @address = incident.group(:address).count\n\n @tests = incident.each do |incident|\n @bearing = incident.latitude.to_s + \",\"+incident.longitude.to_s\n @incidentaddress = Geocoder.address(@bearing)\n end\n \n @city = request.location.city\n\n\n # @result = @location_picker.city\n # @incidents_address = incident.group_by_month(:address, last: 4).count\n # @reversed = address.full_street_address\n end",
"def current_conditions(city:)\n result = api_call(path: '/data/2.5/weather', query: { q: city, units: 'metric' })\n { city: result['name'],\n cloud_cover: result.dig('clouds', 'all'),\n condition: result.dig('weather', 0, 'description').titleize,\n country_code: result.dig('sys', 'country'),\n icon_url: icon_url(icon_id: result.dig('weather', 0, 'icon')),\n temp: result.dig('main', 'temp'),\n visibility: (result['visibility'] / 1000.0 if result['visibility']),\n wind_deg: result.dig('wind', 'deg'),\n wind_speed: wind_speed_in_kmh(result.dig('wind', 'speed')) }\n end",
"def summary_region(region)\n \t\tAPI.get_regional_wordcount(region)\n \tend",
"def cities_count_by\n\n respond_to do |format|\n format.html\n format.json { render json: city_count_data.to_json }\n end\n end",
"def index\n @graphium_cities = Graphium::City.all\n end",
"def country_details(region, input)\n country = @countries[input - 1]\n\n Table.display_as_summary(country)\n browse_online(country)\n end",
"def node_info(node_city)\n node = @nodes[node_city]\n info = \"#{node_city}:\\n\\tCity Name: #{node.name} \\n\\tCountry: #{node.country}, \\n\\tContinent: #{node.continent} \\n\\tTimezone: #{node.timezone} \\n\\tCoordinates: #{node.coords} \\n\\tPopulation: #{node.pop} \\n\\tRegion: #{node.region} \\n\\tRoutes:\"\n \n if @edges[node_city].empty? \n info += \"\\n\\tNo Routes\"\n else \n @edges[node_city].each do |edge|\n info += \"\\n\\t#{edge.name}, #{edge.distance} miles\"\n end\n end\n info \n end",
"def print_city_info(code, graph_instance)\n city = graph_instance.node_hash[code]\n if(city == nil)\n puts \"Not a valid city code\"\n else\n puts \"Name : #{city.name}\"\n puts \"Code : #{city.code}\"\n puts \"Country : #{city.country}\" \n puts \"Continent : #{city.continent}\" \n puts \"Timezone : #{city.timezone}\"\n puts \"Coordinates : #{city.coordinates}\"\n puts \"Population : #{city.population}\"\n puts \"Region : #{city.region}\"\n puts \"Linked Cities :\\n\"\n city.linked_cities.each { |route|\n puts \"Distance : #{route.distance} to #{route.city}\"\n }\n end\nend",
"def city_weather\n self.class.get(\"/data/2.5/forecast\", @options)\n end",
"def index\n @cities = do_index(City, params)\n\n# #availability_occupancy\n# start_month = 5.months.ago.beginning_of_month\n# end_month = 6.months.from_now.end_of_month\n#\n# working_days_by_month = Array.new\n# resources_by_month = Array.new\n# next_month = start_month\n# 12.times do\n# working_days_by_month << Holiday.how_many_working_days_in_month(next_month)\n# User.actives.resources.where()\n# next_month += 1.month\n# end\n#\n# puts \"########################################\"\n# puts working_days_by_month.join(\", \")\n# puts \"########################################\"\n#\n# capacity_by_month = Array.new\n#\n# 12.times do\n#\n# end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @cities }\n end\n end",
"def office_city\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"city\")\n end",
"def get_city_from_api(city_hash)\n city_name = city_hash['_embedded']['city:item']['name']\n city_population = city_hash['_embedded']['city:item']['population']\n if city_hash['_embedded']['city:item']['_embedded'].nil?\n puts \"Sorry, this city does not belong to an urban area with Quality of Life data! :( \\nBringing you back to the main menu!\\n \".cyan\n return nil\n else\n urban_area_state = city_hash['_embedded']['city:item']['full_name'].split(', ')[1]\n urban_area = city_hash['_embedded']['city:item']['_embedded']['city:urban_area']\n urban_area_name = urban_area['name']\n housing = urban_area['_embedded']['ua:scores']['categories'][0]['score_out_of_10']\n cost_of_living = urban_area['_embedded']['ua:scores']['categories'][1]['score_out_of_10']\n startups = urban_area['_embedded']['ua:scores']['categories'][2]['score_out_of_10']\n venture_capital = urban_area['_embedded']['ua:scores']['categories'][3]['score_out_of_10']\n travel_connectivity = urban_area['_embedded']['ua:scores']['categories'][4]['score_out_of_10']\n commute = urban_area['_embedded']['ua:scores']['categories'][5]['score_out_of_10']\n business_freedom = urban_area['_embedded']['ua:scores']['categories'][6]['score_out_of_10']\n safety = urban_area['_embedded']['ua:scores']['categories'][7]['score_out_of_10']\n healthcare = urban_area['_embedded']['ua:scores']['categories'][8]['score_out_of_10']\n education = urban_area['_embedded']['ua:scores']['categories'][9]['score_out_of_10']\n environmental_quality = urban_area['_embedded']['ua:scores']['categories'][10]['score_out_of_10']\n economy = urban_area['_embedded']['ua:scores']['categories'][11]['score_out_of_10']\n taxation = urban_area['_embedded']['ua:scores']['categories'][12]['score_out_of_10']\n internet_access = urban_area['_embedded']['ua:scores']['categories'][13]['score_out_of_10']\n leisure_and_culture = urban_area['_embedded']['ua:scores']['categories'][14]['score_out_of_10']\n tolerance = urban_area['_embedded']['ua:scores']['categories'][15]['score_out_of_10']\n outdoors = urban_area['_embedded']['ua:scores']['categories'][16]['score_out_of_10']\n\n ua = UrbanArea.find_or_create_by(name: urban_area_name, state: urban_area_state)\n\n UrbanArea.update(ua.id, housing: housing,\n cost_of_living: cost_of_living,\n startups: startups,\n venture_capital: venture_capital,\n travel_connectivity: travel_connectivity,\n commute: commute,\n business_freedom: business_freedom,\n safety: safety,\n healthcare: healthcare,\n education: education,\n environmental_quality: environmental_quality,\n economy: economy,\n taxation: taxation,\n internet_access: internet_access,\n leisure_and_culture: leisure_and_culture,\n tolerance: tolerance,\n outdoors: outdoors)\n\n city = City.find_or_create_by(name: city_name, urban_area_id: ua.id)\n City.update(city.id, population: city_population)\n city\n end\nend",
"def stats; end",
"def stats; end",
"def get_aditional_data\n require 'hpricot'\n require 'open-uri'\n doc = Hpricot(open(\"http://gc.kls2.com/airport/#{iata_code}\",\n \"User-Agent\" => \"Ruby\"))\n self.lat = doc.at(\"abbr.latitude\")['title'].to_f\n self.lng = doc.at(\"abbr.longitude\")['title'].to_f\n self.city = doc.at(\"span.locality\").inner_html\n self.country = doc.at(\"span.country-name\").inner_html\n self.name = doc.at(\"td.fn\").inner_html.gsub(/<[^>]+>/,'')\n end",
"def show\n @citystatistic = Citystatistic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @citystatistic }\n end\n end",
"def build_status city_or_county, state, num_killed, num_injured, url\n status = \"#{city_or_county}, #{state}: \"\n\n if num_killed.zero? && num_injured.zero?\n status.concat('no one was hurt. ')\n elsif num_killed.zero?\n status.concat(\"#{num_injured} \")\n .concat('person'.pluralize(num_injured))\n .concat(' injured. ')\n elsif num_injured.zero?\n status.concat(\"#{num_killed} \")\n .concat('person'.pluralize(num_killed))\n .concat(' killed. ')\n else\n status.concat(\"#{num_killed} \")\n .concat('person'.pluralize(num_killed))\n .concat(' killed and ')\n .concat(\"#{num_injured} \")\n .concat('person'.pluralize(num_injured))\n .concat(' injured. ')\n end\n\n status.concat(\"Full report: #{url}\")\n end",
"def get_localities(query)\n p query_escaped = CGI::escape(query)\n @url = \"#{URLBASE}/feed/search.ashx?key=#{KEY}&q=#{query_escaped}&format=#{FORMAT}&num_of_days=2\"\n\n rawdata = ''\n open(@url).each do |line|\n rawdata << line\n end\n data = JSON.parse(rawdata)\n return data[\"search_api\"][\"result\"]\n \n# @city = data[0][\"areaName\"][0][\"value\"]\n# @country = data[0][\"country\"][0][\"value\"]\n# @latitude = data[0][\"latitude\"]\n# @longitude = data[0][\"longitude\"]\n# @population = data[0][\"population\"]\n# @weatherUrl = data[0][\"weatherUrl\"][0][\"value\"]\n end",
"def summary_site\n \t\tAPI.get_site_wordcount\n \tend",
"def extract_countries_and_regions\n infile, result, *others = params\n out_file_name = \"countries_and_regions.csv\"\n\n puts; print \"Extracting countries and regions from #{infile}\"\n\n col_filter = \"COUNTRIES:4-6+REGIONS:18\"\n\n Sycsvpro::Collector.new(infile: infile,\n outfile: out_file_name,\n cols: col_filter).execute\n\n puts; puts \"You can find the collection result in #{out_file_name}\"\nend",
"def cities_for_solr\n\t\t # if there is a default_contactinfo for that role_contactinfo contactinfo\n\t\t # initialize contactinfo based on default_contactinfo fields and then\n\t\t # index the contactinfo field to default\n \tdefault_contactinfo = get_default_contactinfo\n\t\t contactinfo.initialize_contactinfo_associated_with_another_contactinfo( default_contactinfo ) unless default_contactinfo.blank?\n\t\t \n return \"#{FinderHelper.strip(contactinfo.locality)} - #{FinderHelper.strip(contactinfo.suburb)} \"\n end",
"def import_trending_topic_pois_from_foursquare(city)\n #clientFoursquare.trending_venues('40.7,-74')\n lng = city.longitude.longitude.to_s('F')\n ll = city.latitude.to_s('F')+\",\"+lng\n #returns most cheched places\n @@clientFoursquare.trending_venues(ll, radius: 1500)\n \n end",
"def collect_places_information\n ### Places information\n mark_data_places_information = Array.new\n places_information = @case_details[:case][:system][:places]\n\n mark_data_places_information << 'Answer the following about each places present in the evidence on the system'\n places_information.each do | place_category, place_information |\n mark_data_places_information << place_category.capitalize\n place_information.each { | key, value | mark_data_places_information << \"-#{key.capitalize}::#{value}\" }\n mark_data_places_information << ''\n end\n\n return mark_data_places_information\n end",
"def getHubCity()\n vertex = 0\n city = \"\"\n @parse.map{ |airport|\n if(airport[\"destinations\"].length > vertex)#if target has more vertex swap\n city = airport[\"name\"]\n vertex =airport[\"destinations\"].length\n end\n }\n \n puts \"The city with more connections is \" + city + \" with #{vertex}\"\n end",
"def continent; end",
"def get_weather\n @single_city_data['weather']\n end",
"def getCampusLandingPageData(unit, attrs)\n return {\n :pub_count => ($statsCampusPubs.keys.include? unit.id) ? $statsCampusPubs[unit.id] : 0,\n :view_count => 0,\n :opened_count => 0,\n :journal_count => ($statsCampusJournals.keys.include? unit.id) ? $statsCampusJournals[unit.id] : 0,\n :unit_count => ($statsCampusOrus.keys.include? unit.id) ? $statsCampusOrus[unit.id] : 0\n }\nend",
"def get_city\n page = Nokogiri::HTML(open(\"http://annuaire-des-mairies.com/val-d-oise.html\"))\n villes =[]\n page.xpath('//*[@class=\"lientxt\"]').each do |ville|\n villes << ville.text\n end\n return villes\n end",
"def save_as_csv\n result = get_result_all_city()\n begin\n CSV.open(\"db/city.csv\", \"wb\") do |csv|\n result.each do |city|\n convert = city.to_a\n csv << convert[0]\n end\n end\n rescue => exception\n puts \"Some errors have orcurred!\"\n end\n end",
"def fetch_weather\n\t response = HTTParty.get(\"http://api.wunderground.com/api/cdb75d07a23ad227/#{date}/q/#{location}/#{cityfixed}.xml\")\n\t parse_response(response)\n\tend",
"def summary(weather_info)\n\tweather_info[\"currently\"][\"summary\"]\nend",
"def city_name\n\t\treturn \"Mysore\"\n\tend",
"def generateStats(metros, routes)\n getLongestFlight(routes)\n getShortestFlight(routes)\n getAverageFlight(routes)\n\n getLargestCity(metros)\n getSmallestCity(metros)\n getAverageCity(metros)\n\n getContinentsServed(metros)\n getHubCities(routes)\n end",
"def stats\n ## TODO:\n end",
"def biggest_population_city\n\n max_population = -1\n max_city = \"\"\n\n @query.get_graph.each_key do |city|\n population = get_city_info(city,\"population\")\n if population > max_population\n max_population = population\n max_city = \"#{get_city_info(city,\"name\")}\"\n end\n end\n\n return max_city\n end",
"def generate_historic_locations\n api = API.new\n current_date = Date.new(2019, 04, 12)\n output = {}\n coordinates_only = []\n csv = []\n while current_date <= Date.new(2021, 12, 31) # Date.today - 7\n puts \"Fetching date details for #{current_date}\"\n result = api.where_at(date: current_date)\n if result\n output[current_date] = result\n coordinates_only << [\n result[:lat],\n result[:lng]\n ]\n csv << [\n result[:lat],\n result[:lng],\n current_date.strftime(\"%Y-%m-%d\") + \" - \" + result[:city],\n \"#FFFF00\"\n ].join(\",\")\n end\n\n current_date += 1\n end\n\n File.write(\"historic_locations.json\", JSON.pretty_generate(output))\n File.write(\"historic_locations_coordinates_only.json\", JSON.pretty_generate(coordinates_only))\n File.write(\"historic_locations.csv\", csv.join(\"\\n\"))\n puts \"Successfully generated ./historic_locations.json\"\nend",
"def details\n @period = Period.month(Time.current)\n months = -(Reports::MAX_MONTHS_OF_DATA - 1)\n chart_range = (@period.advance(months: months)..@period)\n @period_range = Range.new(@period.advance(months: -5), @period)\n\n regions = if @region.facility_region?\n [@region]\n else\n [@region, @region.facility_regions].flatten\n end\n @repository = Reports::Repository.new(regions, periods: @period_range, reporting_schema_v2: RequestStore[:reporting_schema_v2])\n chart_repo = Reports::Repository.new(@region, periods: chart_range, reporting_schema_v2: RequestStore[:reporting_schema_v2])\n\n @chart_data = {\n patient_breakdown: PatientBreakdownService.call(region: @region, period: @period),\n ltfu_trend: ltfu_chart_data(chart_repo, chart_range)\n }\n\n if @region.facility_region?\n @recent_blood_pressures = paginate(\n @region.source.blood_pressures.for_recent_bp_log.includes(:patient, :facility)\n )\n end\n end",
"def get_city_names(cityName)\n dial_book.each do |dbkey, dbval|\n if dial_book[dbkey] == dial_book[cityName]\n get_area_code(dial_book, )\n end\n end\nend",
"def index\n @sights = Sight.all\n p '---------------------'\n iran = Country.find_by_title_fa( 'ایران')\n p @inner_sights = City.where(country_id: iran.id)\n \n end",
"def weather\n zipcode = self.city.yahoo_zipcode\n weather = Weather.lookup(zipcode, Weather::Units::CELSIUS)\n return {\n title: weather.title, \n temp: \"#{weather.condition.temp.to_s} 度\",\n condition: weather.condition.text\n }\n end",
"def index\n @page_title = 'Cities'\n @pagy, @cities = pagy(City.includes(:state).all, items: @per_page)\n @number_of_cities = City.all.count\n end",
"def dailySummary(weather_info)\n\tweather_info[\"daily\"][\"summary\"]\nend",
"def view_stats_all\n data = {\n :name => \"Company Views\",\n :pointInterval => 1.day * 1000,\n :pointStart => 1.weeks.ago.at_midnight.to_i * 1000,\n :data => (1.weeks.ago.to_date..Date.today).map{ |date|\n Impression.where(\n \"created_at > ? AND created_at < ? AND action_name = ? AND controller_name = ?\",\n date.at_beginning_of_day,\n date.tomorrow.at_beginning_of_day,\n 'stat_show',\n 'companies'\n ).select{ |impression| impression.action_name == \"stat_show\"}.count\n }\n }\n respond_with data\n end",
"def call_from_ranking(ranked_city)\n\n site_link = 'https://airnow.gov/'\n\n #call scraper class method to access html of page based ranking\n @doc = AirQualityIndex::Scraper.new.nationwide_scraper_more_info(site_link.concat(ranked_city.link))\n\n #return aqi information for ranked city\n self.aqi_info_validation_return(self.doc, ranked_city)\n end",
"def forecast(city)\n response = RestClient.get \"http://api.openweathermap.org/data/2.5/forecast?q=#{city}&units=metric\"\n if !city\n return\n end\n response_hash = JSON.parse response\n status = response_hash.empty?\n status = !status\n if status\n list = response_hash[\"list\"]\n message = \"City: #{response_hash[\"city\"][\"name\"]}\\n\"\n list.each do |str|\n str_date = str[\"dt_txt\"]#.split(\" \")\n #date = str_date[0]\n #time = str_date[1]\n message += \"Date: #{str_date}\\n\" \n message += \"Temp: #{str[\"main\"][\"temp\"]}\\n\"\n message += \"Max Temp: #{str[\"main\"][\"temp_max\"]}\\n\"\n message += \"Min Temp: #{str[\"main\"][\"temp_min\"]}\\n\"\n end\n else\n message = \"Sorry your request could not be processed please try again\\n\"\n end\n puts message\n message\nend",
"def show\n @weather = Wunderground.get_weather(@tourney.city)\n end",
"def weatherapp(city)\n\n url = URI(\"https://community-open-weather-map.p.rapidapi.com/weather?q=#{@city}&lat=0&lon=0&callback=test&id=2172797&lang=null&units=%22metric%22%20or%20%22imperial%22&mode=xml%2C%20html\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = 'community-open-weather-map.p.rapidapi.com'\n \n response = http.request(request)\n temp = (response.read_body)['test']\n # puts JSON.parse(response.read_body)['tempmin']\n # puts JSON.parse(response.read_body)['temp_max']\n\n puts response.read_body['coord']\n return response.read_body\n end",
"def city\n @root.xpath('./ns:City/text()').to_s\n end",
"def all_unique_city_values\n sparql = \"\n SELECT DISTINCT ?city\n WHERE \n {\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?org <http://data.artsapi.com/def/arts/locationCity> ?city .\n }\n }\"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| r[\"city\"][\"value\"] }\n end",
"def cities_and_populations\n state_zipcode_populations = zipcode_dump.group_by { |zipcode| zipcode[\"state\"] }[@state_name]\n {\n @state_name => state_zipcode_populations.group_by { |state| state[\"city\"] }.map do |city, city_populations|\n {\n \"city\" => city,\n \"population\" => city_populations.map { |zipcode| zipcode[\"pop\"] }.reduce(:+)\n }\n end\n }\nend",
"def my_weather\n location = my_location\n weather_for \"#{location['city']}, #{location['region_code']}\"\nend",
"def city\r\n\t\t\t@city ||= json[\"cit\"].to_s.capitalize\r\n\t\tend",
"def stats\n @regions = current_volunteer.admin_regions\n region_ids = @regions.collect{ |region| region.id }.join(',')\n @logs_per_volunteer_year =\n Log.joins(:log_parts, :volunteers).\n select('volunteers.id, volunteers.name, sum(weight), count(DISTINCT logs.id)').\n where(\"complete AND region_id IN (#{region_ids}) and logs.when > ?\", Date.today-12.months).\n group('volunteers.id, volunteers.name').order('sum DESC')\n @logs_per_volunteer_month =\n Log.joins(:log_parts, :volunteers).\n select('volunteers.id, volunteers.name, sum(weight), count(DISTINCT logs.id)').\n where(\"complete AND region_id IN (#{region_ids}) and logs.when > ?\", Date.today-1.month).\n group('volunteers.id, volunteers.name').order('sum DESC')\n\n @lazy_volunteers =\n Volunteer.select('volunteers.id, name, email, count(*) as count, max(\"when\") as last_date').\n joins(:logs, :log_volunteers).\n where(\"volunteers.id=log_volunteers.volunteer_id and logs.region_id IN (#{current_volunteer.admin_region_ids.join(',')})\").\n group('volunteers.id, name, email')\n end",
"def city\n fetch('world_cup.cities')\n end",
"def stats\n end",
"def stats\n end",
"def city_loop\n\t#loop through cities\n\t@cities.each do |t|\n\t\tputs \"#{t} is a town in Scotland\"\n\tend\n\nend",
"def summarize_reports(places, range)\n stats = {}\n \n places.each do |place|\n \treports = place.reports(range)\n \t\n \tstats[place.title] = {\n \t\t:mod_mal => percentage(reports, :malnourished?, :moderate),\n \t\t:sev_mal => percentage(reports, :malnourished?, :severe),\n \t\t:oedema => percentage(reports, :oedema),\n \t\t:diarrhea => percentage(reports, :diarrhea)\n \t}\n end\n \n stats\n end",
"def business_summary(lat, lon, bname)\n ret = {\n hours: nil,\n formatted_hours: nil\n }\n return ret if @client.nil?\n\n radius = 100 # improve result to get the correct one\n latlng = lat.to_s + ',' + lon.to_s\n response = @client.search_venues(ll: latlng, radius: radius, query: bname)\n if response.venues.length == 0\n response = @client.search_venues(ll: latlng, query: bname)\n end\n\n if response.venues.length > 0\n hours = @client.venue_hours(response.venues[0].id)\n sum = @client.venue(response.venues[0].id)\n\n ret = {\n hours: hours.hours,\n formatted_hours: sum.hours\n } unless hours.nil? || sum.nil?\n end\n ret\n end",
"def stats\n \n end",
"def fetch_stations\n log(' - Fetching station list...', false)\n results = {}\n response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv')\n CSV.new(response, headers: true).each do |row|\n results[row['CRS Code']] ||= {}\n results[row['CRS Code']][:name] = row['Station Name']\n end\n log('DONE')\n results\nend",
"def show\n if @city.statistics.size > 2\n sdate = @city.statistics.keys[1].to_date\n edate = @city.statistics.keys.last.to_date\n stime = Time.new(sdate.year, sdate.month, sdate.day, 0, 0, 0, @city.zone)\n etime = Time.new(edate.year, edate.month, edate.day, 0, 0, 0, @city.zone)\n\n data = @city.statistics.values[1...-1].map{|s| s[:total]}\n interval = 1.day\n\n @count = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Count\")\n f.xAxis(type: \"datetime\", maxZoom: (etime - stime).to_i)\n f.series(\n name: \"count\", \n yAxis: 0, \n data: data,\n pointStart: stime,\n pointInterval: interval\n )\n\n f.yAxis [\n {:title => {:text => \"count\", :margin => 70}, min: 0 },\n ]\n\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n\n distributions = @city.statistics.values[1...-1].map{|s| s[:distribution]}\n distribution_data = distributions.inject([]) do |res, d|\n d.each_with_index do |c, i|\n res[i] ||= []\n res[i] << c\n end\n res\n end\n distribution_data.each{ |d| d.extend(DescriptiveStatistics) }\n\n @distribution = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Distribution\")\n f.xAxis(\n categories: 24.times.map{ |h| (\"%02d\" % h) + \":00\" }\n )\n f.series(\n name: 'mean',\n yAxis: 0,\n data: distribution_data.map(&:mean)\n )\n f.series(\n name: 'standard eviation',\n yAxis: 0,\n data: distribution_data.map(&:standard_deviation)\n )\n f.yAxis [\n {min: 0}\n ]\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 150, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n end\n end",
"def city\n fetch('dune.cities')\n end",
"def get_data(locality)\n File.open(DATA_DIR+normalize_locality(locality),\"r\").each do |line|\n data = line.split(\"\\t\")\n\n @observation_time = data[0]\n @cloudcover = data[7]\n @humidity = data[4]\n @precip_mm = data[6]\n @presure = data[5]\n @temp_c = data[2]\n @temp_f = data[3]\n @visibility = data[8]\n @weather_code = data[1]\n @weather_desc = data\n @weather_icon_url = data[13][0..-2]\n @winddir_16_point = data[9]\n @winddir_degree = data[10]\n @windspeed_kmph = data[11]\n @windspeed_miles = data[12]\n end\n @locality = normalize_locality(locality)\n end",
"def index\n neo = Neography::Rest.new\n r = neo.execute_query(\"START n=node(*) RETURN n;\")\n r[\"data\"].shift # first node is wacky\n @cities = r[\"data\"].map { |node|\n OpenStruct.new(node[0][\"data\"].merge(id: node[0][\"self\"].match(/node\\/(\\d+)$/)[1].to_i))\n }\n end",
"def get_city\n @single_city_data[\"name\"]\n end"
] |
[
"0.70277655",
"0.6519229",
"0.64871705",
"0.6361573",
"0.6277916",
"0.6140002",
"0.61096627",
"0.61096627",
"0.61081153",
"0.61061937",
"0.61061937",
"0.61061937",
"0.61061937",
"0.60661817",
"0.60499763",
"0.6043724",
"0.5992022",
"0.5991582",
"0.59725887",
"0.59559923",
"0.5953851",
"0.590155",
"0.5898106",
"0.5883618",
"0.58812267",
"0.587324",
"0.5871363",
"0.586991",
"0.5850726",
"0.5847292",
"0.5829089",
"0.5827588",
"0.5818134",
"0.5787834",
"0.57823694",
"0.57780606",
"0.5753305",
"0.5745898",
"0.5744369",
"0.5732405",
"0.5725048",
"0.5721929",
"0.57185155",
"0.571068",
"0.5706595",
"0.57050455",
"0.5700986",
"0.5700986",
"0.5700086",
"0.5694058",
"0.56909215",
"0.56882095",
"0.5685481",
"0.5683082",
"0.5659422",
"0.565583",
"0.5655437",
"0.56280386",
"0.5621735",
"0.5618762",
"0.5611189",
"0.56076455",
"0.5600898",
"0.5598506",
"0.5589812",
"0.55859566",
"0.55802697",
"0.5569538",
"0.5562468",
"0.55601925",
"0.55508465",
"0.5549419",
"0.55487406",
"0.5548159",
"0.5541526",
"0.5540483",
"0.5539982",
"0.5539912",
"0.55390835",
"0.55389",
"0.55376965",
"0.5536444",
"0.5535434",
"0.5532589",
"0.5527935",
"0.55277294",
"0.552483",
"0.55240285",
"0.5523874",
"0.5523874",
"0.5516166",
"0.5513638",
"0.5510283",
"0.55100864",
"0.5509701",
"0.5509674",
"0.550592",
"0.5498256",
"0.5496324",
"0.54958105"
] |
0.73081815
|
0
|
Created On: 21/11/2014 Purpose: To get country name for listen song ++
|
def get_country(device_access_id)
DeviceAccess.find(device_access_id).access_country
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def country_name\n cc = carmen_country\n\n cc ? \"#{cc.name}\" : ''\n end",
"def get_country_name_lib country_code\n country = Carmen::Country.coded(country_code)\n if country\n country.name\n else\n \"N/A\"\n end\n end",
"def country_name\n country = ISO3166::Country[country_code]\n # country.translations[I18n.locale.to_s] || country.name\n # country.name\n end",
"def country_name(multilingual = false)\n if self.country\n country_data = ISO3166::Country[self.country]\n\t\t\tif country_data and multilingual\n\t\t\t country_data.translations[I18n.locale.to_s] || country_data.name\n\t\t\telsif country_data\n\t\t\t country_data.name\n\t\t\telse\n\t\t\t self.country\n\t\t\tend\n else\n \"\"\n end\n end",
"def country\n 'United Kingdom'\n end",
"def country(code, name); end",
"def country_name\n ISO3166::Country[country_code].name if country_code.present?\n end",
"def get_country_name\n subdivision = Geonames::WebService.country_subdivision @latitude, @longitude\n subdivision.country_name\n end",
"def country_name\n countryfull = ISO3166::Country[country]\n countryfull.translations[I18n.locale.to_s] || countryfull.name\n end",
"def country\n client.places.get_countries.select{|hash| hash[\"cid\"] == @params[:country].to_i}.first[:title]\n end",
"def country_name\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end",
"def country_name\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end",
"def country_name\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end",
"def countries(data)\n my_hash = JSON.parse(data)\n conv_name = my_hash[0]['conventional_short_form']\n puts conv_name\nend",
"def get_country_name( code )\n # Strip and lowercase code\n new_code = code.strip.downcase\n # Find country by code. If not found, default to empty string.\n country = $COUNTRIES.find do |record|\n record[:code] == new_code.downcase\n end || ''\n\n return country.length > 0 ? \"The country you selected is #{country[:name]}.\" :\n 'That country code is not in our database.'\nend",
"def country_name\n iso_country = ISO3166::Country[country] # `country` should be code like 'AU'\n iso_country.translations[I18n.locale.to_s] || iso_country.name\n end",
"def get_movie_country( the_country_num )\n @countryInfos = CountryInfo.all\n @countryInfos.each{ |country_info|\n if country_info.country_id === the_country_num\n country_info.country_name\n end\n }\n end",
"def get_country_name country_code\n country = Country.find(\n :first,\n :conditions => [\"LOWER(Code) = ?\", country_code]\n )\n if country\n country.Name\n else\n \"N/A\"\n end\n end",
"def country_name(country_code)\n country = ISO3166::Country[country_code]\n country.name\n end",
"def country_name(country_code)\n cache_for = Rails.env.production? ? 8.hours : 1.minute\n Rails.cache.fetch(country_code, expires_in: cache_for, race_condition_ttl: 10) do\n country_info = LocationInfo::Country.where(\"alpha2 = ?\",country_code)\n country_name = country_info.present? ? country_info.first[:harman_name] : \"\"\n country_name\n end # Rails.cache.fetch(country_code, expires_in: cache_for, race_condition_ttl: 10) do\n end",
"def get_verbose_name\n country_desc = (self.country_code.nil? || (self.country_code == \"I\")) ? \"\" :\n \" #{self.country} (#{self.country_code})\"\n get_full_name + country_desc\n end",
"def country\n 'Australia'\n end",
"def country\n data['country']\n end",
"def represented_country; end",
"def country; end",
"def country; end",
"def country; end",
"def pbGetCountry()\n getUserGeoID=Win32API.new(\"kernel32\",\"GetUserGeoID\",\"l\",\"i\") rescue nil\n if getUserGeoID\n return getUserGeoID.call(16)\n end\n return 0\nend",
"def get_country\n @single_city_data[\"sys\"][\"country\"]\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def language_in(country_name)\n params = {query: {fullText: 'true'}}\n response = HTTParty.get(\"#{COUNTRIES_BASE_URL}/#{country_name}\", params)\n json_response = JSON.parse(response.body)\n json_response.first['languages'].first['iso639_1']\n end",
"def country\n @country ||= IsoCountryCodes.find(alpha2)\n end",
"def country\n query_root_node(\"gdacs:country/text()\", @@NAMESPACES)\n end",
"def country_code; end",
"def country_code; end",
"def country\n location[2] || location[1]\n end",
"def country\n self[:C]\n end",
"def spanish_name\n self[5]\n end",
"def get_country_code\n Geonames::WebService.country_code @latitude, @longitude\n end",
"def title_with_country\n # Remove special country values (e.g. 'DIT HQ')\n countries = opportunity.countries.where.not(id: [198, 199, 142, 200])\n if source('post') && !countries.empty? && countries.map(&:region_id).include?(18)\n opportunity.title\n else\n country = if countries.size > 1\n 'Multi Country'\n else\n countries.map(&:name).join\n end\n\n if country.present?\n \"#{country} - #{opportunity.title}\"\n else\n opportunity.title\n end\n end\n end",
"def french_name\n self[4]\n end",
"def french_name\n self[4]\n end",
"def english_name\n self[3]\n end",
"def english_name\n self[3]\n end",
"def get_country(str)\n data = check_local_db(str)\n\n if data.nil? \n data = Geocoder.search(str)\n\n #has to parse through geocode data to find correct result\n data.first.address_components.each do |obj|\n data = obj[\"short_name\"] if obj[\"types\"][0] == \"country\"\n end\n\n save_to_db(str, data)\n end\n\n return data\n end",
"def best_guess_at_country\n return self.country if !self.country.nil?\n\n extension_possibilities = []\n extension_possibilities << \".#{self.uri.to_s.gsub(/^.+organisations\\/.+\\-/, '')}\"\n extension_possibilities << self.uri.to_s.gsub(/^.+organisations\\/[A-z]+/, '').gsub(/\\-/, '.')\n extension_possibilities << self.uri.to_s.match(/\\-[A-z]+\\-[A-z]+$/)[0].gsub(/\\-/, '.') rescue ''\n mapping = ArtsAPI::COUNTRIES_MAPPING\n\n result = nil\n extension_possibilities.each { |ex| result = mapping[ex] if mapping.has_key?(ex) }\n\n if !result.nil?\n self.country = result\n self.save\n end\n\n result\n end",
"def registered_country; end",
"def country\n self.well_info.country\n end",
"def short_country_name(name)\n if name.include? ' '\n temp = name.split(' ')\n temp[0][0] + temp[1][0]\n else\n name[0..2].upcase\n end\nend",
"def short_country_name(name)\n if name.include? ' '\n temp = name.split(' ')\n temp[0][0] + temp[1][0]\n else\n name[0..2].upcase\n end\nend",
"def country_code\n end",
"def get_iso_country(country)\n #Kinda redundant but downcasing first makes the hardcoding a bit more obvious\n country = country.downcase\n\n if country == \"bosnia-herzogovnia\"\n country = \"bosnia and herzogovnia\"\n elsif country == \"russia\"\n country = \"russian federation\"\n elsif country == \"laos\"\n country = \"lao peoples democratic republic\"\n elsif country == \"iran\"\n country = \"islamic republic of iran\"\n elsif country == \"taiwan\"\n country = \"province of china taiwan\"\n elsif country == \"north korea\"\n country = \"democratic people's republic of korea\"\n elsif country == \"south korea\"\n country = \"republic of korea\"\n elsif country == \"basque spain\"\n country = \"spain\"\n elsif country == \"macedonia\"\n country = \"the former yugoslav republic of macedonia\"\n elsif country == \"tanzania\"\n country = \"united republic of tanzania\"\n elsif country == \"vietnam\"\n country = \"viet nam\"\n elsif country == \"venezuela\"\n country = \"bolivarian republic of venezuela\"\n elsif country == \"syria\"\n country = \"syrian arab republic\"\n elsif country == \"rep.dem.congo\"\n country = \"congo\"\n elsif country == \"dagestan\"\n country = \"russian federation\"\n elsif country == \"adygea\"\n country = \"russian federation\"\n elsif country == \"karachaevo circassia\"\n country = \"russian federation\"\n elsif country == \"tartarstan\"\n country = \"russian federation\"\n #elsif country == \"ivory coast\"\n # This seems like the wrong way of doing this but not sure how else to guarentee the match\n #country = \"CÃTE D'IVOIRE\".downcase\n end\n\n country = normalize(country)\n \n @@iso_country_codes.xpath(\"//ISO_3166-1_Entry\").each do |code|\n n_country = normalize(code.xpath(\"ISO_3166-1_Country_name\")[0].content)\n\n if (country.upcase == n_country.upcase)\n return code.xpath(\"ISO_3166-1_Alpha-2_Code_element\")[0].content\n end\n end\n return \"ZZ\"\n end",
"def hecho_en\n 'china'\n end",
"def get_country_name_from_code(country_code)\n if country_code.present?\n country = ISO3166::Country[country_code]\n country.translations[I18n.locale.to_s] || country.name\n end\n end",
"def normalize_country\n c = @data_object.add_country.strip\n\n c = c.downcase.gsub(/[\\. ]/, '').sub(/^the/, '')\n \n if US_MAP[c]\n @data_object.add_country = USA\n end\n\n end",
"def return_official_player_name(entry)\n\t\tcase entry\n\t\t\twhen /benz/\n\t\t\t\t\"benzema\"\n\t\t\twhen /brui|bruy/\n\t\t\t\t\"bruyne\"\n\t\t\twhen /cour/\n\t\t\t\t\"courtois\"\n\t\t\twhen /jong/\n\t\t\t\t\"de jong\"\n\t\t\twhen /ligt/\n\t\t\t\t\"de ligt\"\n\t\t\twhen /depa/\n\t\t\t\t\"depay\"\n\t\t\twhen /gnab/\n\t\t\t\t\"gnabri\"\n\t\t\twhen /grav/\n\t\t\t\t\"gravenberg\"\n\t\t\twhen /hav/\n\t\t\t\t\"havertz\"\n\t\t\twhen /immo/\n\t\t\t\t\"immobile\"\n\t\t\twhen /ins/\n\t\t\t\t\"insigne\"\n\t\t\twhen /kane/\n\t\t\t\t\"kane\"\n\t\t\twhen /kant/\n\t\t\t\t\"kante\"\n\t\t\twhen /lewa/\n\t\t\t\t\"lewandowski\"\n\t\t\twhen /luk/\n\t\t\t\t\"lukaku\"\n\t\t\twhen /mba|mapp|mpab/\n\t\t\t\t\"mbappe\"\n\t\t\twhen /mor/\n\t\t\t\t\"morata\"\n\t\t\twhen /moun/\n\t\t\t\t\"mount\"\n\t\t\twhen /rash/\n\t\t\t\t\"rashford\"\n\t\t\twhen /rona/\n\t\t\t\t\"ronaldo\"\n\t\t\twhen /san/\n\t\t\t\t\"sane\"\n\n\t\tend\n\tend",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_codes; end",
"def country_code\n end",
"def country_code\n cc = carmen_country\n\n cc ? \"#{cc.code.upcase}\" : nil\n end",
"def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end",
"def countries\n document.search(\"h5[text()='Country:'] ~ a[@href*=/country/']\").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []\n end",
"def get_countries\n doc = Nokogiri::HTML(open('https://www.britannica.com/topic/list-of-countries-1993160'))\n countries_extracted = doc.css(\"li a\").text.split('Britannica')[1].split(' geography')[0].rstrip\n @processed_countries = countries_extracted.split(/(?<!\\s)(?=[A-Z])/)\n end",
"def country\n \tself.contry\n end",
"def country\n @country\n end",
"def get_country(affi_string)\n cleared_affi_string = country_exclude(affi_string)\n $affi_countries.each do |country|\n if cleared_affi_string.include?(country)\n return country\n end\n end\n return nil\nend",
"def get_name(region)\n url = 'https://uinames.com/api/'\n uri= URI(url)\n response = Net::HTTP.get(uri)\n result = JSON.parse(response)\n result[\"name\"]\n \nend",
"def country\n ISO3166::Country[@country_code]\n end",
"def get_filmName_en\n \t\tresponse = JSON.parse HTTParty.get(self.url).to_json\n \t\tfilmName_en = response[\"filmName_en\"]\n \t\treturn filmName_en\n \tend",
"def country_str(specimens)\r\n v = {} \r\n v[\"country not specified\"] = []\r\n specimens.each do |s|\r\n if !s.ce.blank? && !s.ce.geog.blank? && !s.ce.geog.country.blank? && !s.ce.geog.country.name.blank?\r\n if v[s.ce.geog.country.name].nil?\r\n v[s.ce.geog.country.name] = [s]\r\n else\r\n v[s.ce.geog.country.name] << s\r\n end\r\n else\r\n v[\"country not specified\"] << s\r\n end\r\n end\r\n v.delete(\"country not specified\") if v[\"country not specified\"].size == 0 \r\n is = []\r\n v.keys.sort.each do |c|\r\n txt = \"#{c.upcase}: \"\r\n txt << sex_str(v[c])\r\n txt += \". \"\r\n txt += inst_str(v[c]) + \".\"\r\n is << txt\r\n end\r\n is.join(\" \") \r\n end",
"def state_country_name\n [state_abbr_name, country.try(:name)].compact.join(', ')\n end",
"def state_country_name\n [state_abbr_name, country.try(:name)].compact.join(', ')\n end",
"def country\n if(@country_code.to_i == 280)\n IsoCountryCodes.find(276) #since 1990 we use 176 for whole germany, 280 was for \"west germany\" WTF\n else\n IsoCountryCodes.find(@country_code)\n end\n end",
"def country\n query = create_query(\n :Location, :regexp_search, regexp: \"#{params[:country]}$\"\n )\n show_selected_locations(query, link_all_sorts: true)\n end",
"def country_shortcuts\n COUNTRIES\n end",
"def polyglot_language_name\n language.name.split[0].downcase\n end",
"def english_name\n if self.lang == 'enUS'\n card = self\n else\n card = Card.where(:card_id => card_id, :lang => 'enUS').first\n end\n card.name\n end",
"def country\n params['country']\n end",
"def country_code\n @root.xpath('./ns:CountryCode/text()').to_s\n end",
"def user_country\n USER_COUNTRY[country]\n end",
"def country\n RAILS_DEFAULT_LOGGER.debug(\"profile.country -- returning #{setting(:company_country)}\")\n \n setting(:company_country).to_s\n end",
"def guess_name(country)\n first_names = nil\n last_names = nil\n \n rnd_first = rand(NAME_FREQUENCY_MAX)\n rnd_last = rand(NAME_FREQUENCY_MAX)\n \n first_names = PlayerName.first_names_c(country).where(\"frequency > ?\", rnd_first)\n last_names = PlayerName.last_names_c(country).where(\"frequency > ?\", rnd_last)\n \n return {\n :first_name => first_names.offset(rand(first_names.count)).first.name_str,\n :second_name => nil,\n :last_name => last_names.offset(rand(last_names.count)).first.name_str,\n :pseudonym => nil\n }\n end",
"def country_code\n if self.uk?\n UK_COUNTRY_CODE\n else\n IE_COUNTRY_CODE\n end\n end",
"def country_fr()\n @request_data = {\n\t\t\t\"type\"\t\t=> \"home\",\n \"ip\" => \"178.251.201.141\",\n \"session\" => \"new\",\n \"cuid\" => \"new\",\n \"lang\" => \"en\",\n \"site\" => \"ctshirts\",\n \"currentURI\" => \"http://www.ctshirts.co.uk\",\n \"previousURI\" => \"http://www.ctshirts.co.uk\",\n \"clientToken\" => \"677ab692r2t3u4t\", \n \"recContent\" => \"refCodeOnly\",\n }\n @json_request = \"\"\n @response_times = []\n\t\tend",
"def get_state_name_lib(country_code, state_code)\n country = Carmen::Country.coded(country_code)\n state_name = N/A\n if country\n state = country.subregions.coded(state_code)\n if state\n state_name = state.name\n end\n end\n state_name\n end",
"def country\n @country || @default_country || 'GB'\n end",
"def country_code\n @country_code.to_s\n end",
"def get_countries\n \tresponse = invoke(\"web:GetCountries\", :soap_action => :none)\n\n \tnode = response.document.xpath('//ns:GetCountriesResult', ns)[0]\n \tparse_country_description(node)\n end",
"def getCountriesObjName\r\n\t\t\treturn \"mfiforce__Countries__c\"\r\n\t\tend",
"def local_name(languages)\r\n ret = nil\r\n if languages\r\n lrs = languages.split(\",\")\r\n lrs.each do |lr|\r\n code = lr.split(\";\")[0]\r\n locale = locales.find(:first, :conditions => [\"code = ?\", code])\r\n ret = locale.name if locale\r\n break if ret\r\n end\r\n end\r\n ret || self.name\r\n end"
] |
[
"0.7214127",
"0.720626",
"0.70597464",
"0.7027749",
"0.7016789",
"0.6992105",
"0.6971549",
"0.6963176",
"0.69252384",
"0.684945",
"0.6767812",
"0.6767812",
"0.6767812",
"0.6766055",
"0.6739447",
"0.6689148",
"0.66586477",
"0.6643237",
"0.66182166",
"0.6593655",
"0.65789783",
"0.6557854",
"0.65451276",
"0.65274787",
"0.64799374",
"0.64799374",
"0.64799374",
"0.6469459",
"0.6469372",
"0.64273286",
"0.64273286",
"0.64273286",
"0.64273286",
"0.64273286",
"0.64273286",
"0.64273286",
"0.64273286",
"0.64265656",
"0.6399401",
"0.6391816",
"0.6351109",
"0.6351109",
"0.6334616",
"0.63275373",
"0.6311715",
"0.6310915",
"0.6301944",
"0.6296956",
"0.6296956",
"0.62851524",
"0.62851524",
"0.62780935",
"0.62672853",
"0.62636614",
"0.62580836",
"0.6246888",
"0.6246888",
"0.6243318",
"0.62373775",
"0.6229401",
"0.6220338",
"0.6207334",
"0.6191987",
"0.61744523",
"0.61744523",
"0.61744523",
"0.61744523",
"0.61744523",
"0.61744523",
"0.6174265",
"0.6166517",
"0.61456823",
"0.6140788",
"0.613799",
"0.60867983",
"0.6081928",
"0.60488033",
"0.60442597",
"0.60303116",
"0.6025358",
"0.60218066",
"0.6009405",
"0.6009405",
"0.6006206",
"0.59857666",
"0.59834695",
"0.59781176",
"0.59760815",
"0.5968729",
"0.59453684",
"0.59370184",
"0.5929092",
"0.5925582",
"0.59195846",
"0.59191185",
"0.59185493",
"0.5914953",
"0.5901005",
"0.58888495",
"0.58886534",
"0.58849055"
] |
0.0
|
-1
|
Created On: 21/11/2014 Purpose: To get count of listen for a particaular country ++
|
def get_listen_count(device_access_id,listen_medias)
listen_medias.where(:device_access_id => device_access_id).count rescue nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count_population_of_uk(collection_of_countries)\n total_population = 0\n for country in collection_of_countries\n total_population += country[:population]\n end\n return total_population\nend",
"def count_population(country)\n population = 0\n for country in country\n population += country[:population]\n end\n return population\nend",
"def country_count\n varietal_array = []\n # wine_array = [\"Malbec\", \"Merlot\", \"Syrah\", 'Cabernet Sauvignon', 'Pinot Noir', 'Grenache', 'Sangiovese', 'Tempranillo', 'Montepulcia', 'Petite Syrah', 'Chardonnay', 'Sauvignon blanc', 'Pinot Gris', 'Riesling', 'Semillon', 'Gewurztraminer', 'Chenin Blanc', 'Gruner Veltliner', 'Torrontes']\n variety = Wine.where(variety: params[:variety])\n # , \"Pinot Noir\", \"Merlot\", \"Malbec\", \"Syrah\",\"Chardonnay\",\"Sauvignon blanc\",\"Pinot Gris\",\"Riesling\",\"Pinot Noir\"]\n \n countries = []\n count_array = []\n new_hash = {}\n\n countries = variety.map do |wine| \n wine.country\n end \n\n \n count_array = countries.each_with_object(Hash.new(0)) {|k, v| v[k] += 1}\n new_array = []\n\n count_array.keys.each do |country| \n if country\n hash = {:country => country, :value => count_array[country]}\n new_array.push(hash)\n end\n end\n\n new_hash = {:countries => new_array}\n render json: new_hash\n end",
"def count \n puts \"Tu as scrappé #{@result_scrap.count} élémént(s)\"\n return @result_scrap.count\n end",
"def subscriber_count\n return @count if @count\n\n conditions = [{:field => \"date\", :op => \"lt\", :value => id},\n {:field => \"interests-#{MAILCHIMP_SETTINGS[:grouping_id]}\", \n :op => \"none\", \n :value => \"Free Subscription\"}]\n\n @count = api.campaign_segment_test MAILCHIMP_SETTINGS[:list_id], \n :match => \"all\", \n :conditions => conditions \n end",
"def varietal_count\n varietal_array = []\n # wine_array = [\"Malbec\", \"Merlot\", \"Syrah\", 'Cabernet Sauvignon', 'Pinot Noir', 'Grenache', 'Sangiovese', 'Tempranillo', 'Montepulcia', 'Petite Syrah', 'Chardonnay', 'Sauvignon blanc', 'Pinot Gris', 'Riesling', 'Semillon', 'Gewurztraminer', 'Chenin Blanc', 'Gruner Veltliner', 'Torrontes']\n country_iso_array = IsoCountryCodes.for_select.to_h\n variety = Wine.where(variety: params[:variety])\n # , \"Pinot Noir\", \"Merlot\", \"Malbec\", \"Syrah\",\"Chardonnay\",\"Sauvignon blanc\",\"Pinot Gris\",\"Riesling\",\"Pinot Noir\"]\n \n countries = []\n count_array = []\n new_hash = {}\n\n countries = variety.map do |wine| \n if wine.country === \"US\"\n country = \"United States of America\"\n country_iso_array[country]\n elsif wine.country === \"England\"\n country = \"United Kingdom of Great Britain and Northern Ireland\"\n country_iso_array[country]\n else \n country_iso_array[wine.country]\n end\n end \n\n \n count_array = countries.each_with_object(Hash.new(0)) {|k, v| v[k] += 1}\n new_array = []\n\n count_array.keys.each do |iso| \n if iso \n hash = {:country => iso, :value => count_array[iso]}\n new_array.push(hash)\n end\n end\n\n new_hash = {:isoCodes => new_array}\n render json: new_hash\n end",
"def offense_counts; end",
"def offense_counts; end",
"def count_places\n COUNT_PLACES\n end",
"def sporters_by_country\n \tresult = { }\n \tCountry.all.map do |c|\n \t\tresult[c.name] = c.sporters.count\n \tend\n \trender json: [{name: 'Count', data: result}]\n end",
"def participants_count(name)\n text = self.span(:class=>\"s3d-search-result-name\",:text=>name).parent.parent.parent.link(:title=>/\\d+.participant/).text\n text[/\\d+/].to_i\n end",
"def play_count_country_vice(country_lists,device_accesses,listen_medias,sorted_array = [])\n @device_accesses = device_accesses\n @listen_medias = listen_medias\n country_lists.each do |country_name|\n id_lists = @device_accesses.where(:access_country => country_name).map(&:id)\n add_count=[]\n id_lists.each do |id|\n add_count << @listen_medias.where(device_access_id: id).count\n end\n sorted_array << [country_name,add_count.sum]\n end\n sorted_array\n play_hash = Hash[*sorted_array.flatten]\n sorted_play_hash = play_hash.sort_by {|_key, value| value}.reverse\n end",
"def genre_count(term)\n #count the genres in object.get_genres\n genres = Hash.new(0)\n object.get_genres(term).each do |genre|\n case\n when genre.include?(\"rap\")\n genres[:rap]+=1\n when genre.include?(\"pop\")\n genres[:pop]+=1\n when genre.include?(\"country\")\n genres[:country]+=1\n when genre.include?(\"indie\")\n genres[:indie]+=1\n when genre.include?(\"hip\")\n genres[\"hip hop\"]+=1\n when genre.include?(\"rock\")\n genres[:rock]+=1\n when genre.include?(\"jazz\")\n genres[:jazz]+=1\n when genre.include?(\"instrumental\")\n genres[:instrumental]+=1\n when genre.include?(\"r&b\")\n genres[\"r&b\"]+=1\n else\n genres[:misc] +=1\n end\n end\n genres\n end",
"def number_of_senator\n\ta = Legislator.where(\"title=?\",\"Sen\")\n\tputs \"Senators:\" +\"#{a.count}\"\nend",
"def subscribers_count\n subscribers_as_people.uniq.count\n end",
"def gpx_airport_count(gpx, airport_to_find)\n airports = Hash.from_xml(gpx).dig(\"gpx\", \"wpt\")\n count = airports.select{|a| a[\"description\"] == airport_to_find.city}.size\n end",
"def zone_count\n da_zones=zones\n count = da_zones.count\n da_zones.each{ |z| count += z.zone_count }\n count\n end",
"def count_by(geo, results)\n totals = results.each_with_object(Hash.new(0)) do |res,counts|\n # binding.pry\n next unless [\"us\",\"ca\"].include?(res.country)\n counts[res.send(geo.to_sym)] += 1\n end\n puts \"TOTAL: #{totals.values.inject(:+)}\"\n\n totals = totals.sort_by { |geo,count| -count }\n\n puts \"Total groups by #{geo.to_s}: \"\n totals.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend",
"def count; end",
"def count; end",
"def count; end",
"def count_geographic_occurrences_of_users(users)\n users\n .filter_map { |u| ISO3166::Country[u.try(:organisation).try(:country)] }\n .reduce(Hash.new(0)) { |result, c| result[c] += 1; result }\n .map { |c, z| { name: c.iso_short_name, lat: c.geo[\"latitude\"], lon: c.geo[\"longitude\"], z: z } }\n end",
"def active_sen \n\tstates = Legislator.uniq.pluck(:state) #print out the state if pluck only will print out multiple same state like \"CA\"\n\t#ordering of state begin \n\tarray_of_count = []\n states.each do |state|\n array_of_count << [state, Legislator.where(state: state).count]\n states.each do |state|\n puts \"#{state}: #{ Legislator.where(title: \"Sen\", state: state).count}\"+ \" Sen\" + \" #{ Legislator.where(title: \"Rep\", state: state).count }\" + \" Rep\"\n end \n end\nend",
"def countries_of_members_data(country_name = false)\n data = [['Country', 'Users']]\n members.group(:country).where.not(country: [nil, '']).select('country, COUNT(*) AS number_of_users').each{|i| data << [country_name ? ISO3166::Country.new(i.country).try(:name) : i.country, i.number_of_users] }\n data\n end",
"def cult_population\n by_cult.count\n end",
"def find_total_population(countries) #function\n population = 0\n\n for country in countries\n population += country[:population]\n country[:population] = 0\n end\n\n return population\n\n end",
"def get_country_statistics_report(country_list, device_access)\n @country_hash = {}\n country_list.each do |country|\n country_count = device_access.where(:access_country => country).count\n @country_hash[country] = country_count \n end\n country_stat = @country_hash.sort_by {|_key, value| value}.reverse\n hash = Hash[*country_stat.flatten]\n end",
"def visits_count\n day_bounds = TimeUtils.day_bounds date\n day_start = ActiveRecord::Base.connection.quote(day_bounds[0])\n day_end = ActiveRecord::Base.connection.quote(day_bounds[1])\n\n row = ActiveRecord::Base.connection.select_one <<~SQL\n SELECT sum(visitor) as total_visitors FROM\n (SELECT 1 as visitor FROM encounter\n WHERE encounter_datetime BETWEEN #{day_start} AND #{day_end}\n AND voided = 0\n GROUP BY patient_id) AS visitors\n SQL\n\n row['total_visitors'] || 0\n end",
"def results_by_country\n \tresult = Country.all.map do |c|\n \t\tplaces = { }\n \t\t(1..6).each do |place|\n \t\t\tplaces[place] = c.sporters.joins(:competition_results).where(\"competition_results.place = #{place}\").count\n \t\tend\n \t\t{\n \t\t\tname: c.name,\n \t\t\tdata: places\n \t\t}\n \tend\n \trender json: result\n end",
"def country_id\n\t\t\tCountry.count + 1\n\t\tend",
"def find_origin(table_of_umpires)\n ipl_umpires = Hash.new(0)\n table_of_umpires.each do |table_row|\n ipl_umpires[table_row['Nationality']] += 1 if table_row['Nationality'] != 'India'\n end\n ipl_umpires\nend",
"def count_contestants_by_hometown(data, hometown)\n counter = 0\n data.each do |season, person| \n person.each do |person_data|\n if person_data[\"hometown\"] == hometown\n counter += 1\n end \n end\n end\n counter\nend",
"def count_contestants_by_hometown(data, hometown)\n counter = 0\n data.each do |season_hash, info|\n info.each do |detail|\n if detail[\"hometown\"] == hometown\n counter += 1 \n end\n end\n end\n return counter\nend",
"def count_members\n @band.count\n end",
"def cult_population\n my_followers.count\n end",
"def count_contestants_by_hometown(data, hometown)\n counter = 0 # COUNTER VALUE HAS TO BE HERE\n data.each do |season, season_array|\n season_array.each do |into_array|\n if into_array[\"hometown\"] == hometown\n counter += 1\n # binding.pry\n end \n end \n end\n counter\nend",
"def summary_region(region)\n \t\tAPI.get_regional_wordcount(region)\n \tend",
"def compute_occupied_places\n application_letters.where(status: true).count\n end",
"def country_counts(opts={ })\n unless (leftovers = opts.keys - VALID_COUNT_OPTIONS).empty?\n raise \"Invalid keys: #{leftovers.join(', ')}\"\n end\n\n params = []\n clauses = []\n sql = \"SELECT country, SUM(install_count), SUM(update_count) FROM reports\"\n\n if opts[:from]\n clauses << \"report_date >= ?\"\n params << format_date(opts[:from])\n end\n\n if opts[:to]\n clauses << \"report_date <= ?\"\n params << format_date(opts[:to])\n end\n\n if opts[:country]\n clauses << \"country = ?\"\n params << opts[:country]\n end\n\n sql << \" WHERE \" unless clauses.empty?\n sql << clauses.join(\" AND \") unless params.empty?\n sql << \" GROUP BY country ORDER BY country\"\n\n @db.execute(sql, params).map do |row|\n OpenStruct.new({\n :country => row[0],\n :install_count => row[1].to_i,\n :update_count => row[2].to_i\n })\n end\n end",
"def kml_airport_count(kml, airport_to_find)\n airports = Hash.from_xml(kml).dig(\"kml\", \"Document\", \"Folder\").find{|f| f[\"name\"] == \"Airports\"}.dig(\"Placemark\")\n count = airports.select{|a| a[\"description\"] == airport_to_find.city}.size\n end",
"def count\n @data['count']\n end",
"def counts\n reply.documents[0][COUNTS]\n end",
"def num_attendees\n # store a integer that represents the number\n # whenever an attendee is created ->\n # Event.all ( search for the event, incremement number of attendees)\n number_of_attendees = Location.all.select do |location|\n location.event == self\n end.length\n end",
"def count_no\n rsvp.no.count\n end",
"def get_countries\n \tresponse = invoke(\"web:GetCountries\", :soap_action => :none)\n\n \tnode = response.document.xpath('//ns:GetCountriesResult', ns)[0]\n \tparse_country_description(node)\n end",
"def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend",
"def count_YZ\nend",
"def count_contestants_by_hometown(data, hometown)\n answer_counter = 0\n data.each do |season_key, season_data|\n season_data.each_with_index do |contestant|\n contestant.each do |key, value|\n if value == hometown\n answer_counter += 1\n end\n end\n end\n end\n answer_counter\nend",
"def o_ucount_notify\n User.bot.lobby_speak(\"#{linked_name}さんが本日#{today_total_o_ucount}問解きました\")\n end",
"def count\n end",
"def count\n end",
"def get_count(input)\n input.count('aeiou')\nend",
"def get_searchproduct_count_anonymous\n\t\tresponse_search = Partay.get('http://shoponline.tescolotus.com/api/v1/search/products?query=Sugar&page=1&sortBy=Relevance', :headers => {'Content-Type' => 'application/json', 'language' => 'en-gb', 'region' => 'TH'})\n\t\tsearch_result=JSON(response_search)\n\t\tself.total_product_count(JSON(search_result)[\"pageInformation\"][\"totalCount\"])\n\t\tputs total_search_count\n\n\tend",
"def count_contestants_by_hometown(data, hometown)\n home_town = 0\n data.each do |season_iteration, stats|\n stats.each do |town|\n if town[\"hometown\"] == hometown\n home_town = home_town + 1\n end\n end\n end\n return home_town\nend",
"def counts\r\n @counts\r\n end",
"def subscriber_count\n raise NotImplementedError, \"please implement 'subscriber_count'\"\n end",
"def find_res_count\n res_count = 0\n self.listings.each do |listing|\n res_count += listing.reservations.where(:status => \"accepted\").count\n end\n return res_count\n end",
"def total_members_by(geo, results)\n totals = results.each_with_object(Hash.new(0)) do |res,counts|\n next unless [\"us\",\"ca\"].include?(res.country)\n counts[res.send(geo.to_sym)] += res.members.to_i\n end\n puts \"TOTAL: #{totals.values.inject(:+)}\"\n \n totals = totals.sort_by { |geo,count| -count }\n puts \"Total members by #{geo.to_s}: \"\n totals.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend",
"def check_for_country(msg, data)\n (0..data.length - 1).each do |i|\n # If a matching country is found:\n next unless msg.downcase.include? data[i].name.downcase\n\n # Set session variable to store country\n session['country_index'] = i\n\n # Figure out sets available for that country\n set_names = data[i].sets.collect { |x| x.name.capitalize }.join(', ')\n session['country_sets'] = set_names\n return true\n end\n\n # User did not ask for a country\n false\nend",
"def joke_count # {{{\n\n @log.message :debug, \"Entering count function\"\n\n jokes = Joke.all\n sources = Hash.new\n\n sources[ \"Total\" ] = jokes.length\n sources[ \"Manually Entered\" ] = 0\n\n jokes.each do |j|\n source = j.source\n\n if( source == nil )\n sources[ \"Manually Entered\" ] += 1\n else\n sources[ source ] = 0 if sources[ source ].nil?\n sources[ source ] += 1\n end\n end\n\n sources\n end",
"def cult_population\n # First, get all of the followers that belong to this cult, then count how many there are\n self.followers.count\n end",
"def count; info['doc_count']; end",
"def probable_country (spots)\n countries = Hash.new(0)\n spots.each do |spot|\n countries[spot.country] += 1\n end\n \n # get the country with max spots\n countries.max_by{|_key, value| value}.first\n end",
"def count_contestants_by_hometown(data, hometown)\n all_seasons(data).reduce(0) do |sum, contestant|\n if contestant[\"hometown\"] == hometown \n sum + 1 \n else \n sum \n end\n end\nend",
"def count_addresses\n self.people.collect { |a| a.address }.count\n end",
"def nombre_enfants\n \n enfants = 0\n \n self.membres.each {\n |m|\n enfants += (age_at(Date.today, m.date_de_naissance) > 12 ? 0:1)\n }\n\n return enfants\n \n end",
"def count_occurrences(vehicles)\n occurences = {}\n\n vehicles.each do |vehicle|\n occurences[vehicle] = vehicles.count(vehicle)\n end\n\n occurences.each do |vehicle, count|\n puts \"#{vehicle} => #{count}\"\n end\nend",
"def ascertain(k, v)\n\t\t\tif self.general_info.include? k\n\t\t\t\tself.result.count{ |p| p[k] == v.downcase }\t\t\t\t\n\t\t\telse\n\t\t\t\t#self.result.map{ |p| p['participant_information'].select{ |i| i['desc'].strip.downcase == k.split('_').join(' ').downcase and i['info'].strip.downcase == v.downcase } }.flatten.size\n\t\t\t\tget_participant_info(k, v).size\n\t\t\tend\n\t\tend",
"def phonetic_coverage\n 1 - phones_in_word_list/@initial_phones.to_f\n end",
"def joinees_count\n self.joinees.count\n end",
"def countries\n document[\"nationality\"].collect {|nation| nation[\"$\"]} rescue nil\n end",
"def secoes(zona)\n\n \tsecoes = 0\n\n @logistica[\"ze\"][zona.numero][\"mun\"].each do |nmun, log_mun|\n log_mun[\"local\"].each do |nlocal, log_local|\n secoes += log_local[\"secoes\"]\n end\n end\n \n return secoes\n end",
"def ab_counts(experiment, alternative)\n record = VanityExperiment.retrieve(experiment)\n participants = VanityParticipant.where(experiment_id: experiment.to_s, seen: alternative).count\n converted = VanityParticipant.where(experiment_id: experiment.to_s, converted: alternative).count\n conversions = record.vanity_conversions.where(alternative: alternative).sum(:conversions)\n\n {\n participants: participants,\n converted: converted,\n conversions: conversions,\n }\n end",
"def registered_country; end",
"def select_inicia_ABC(names)\n imp= names.count{|contar|contar if contar[0] =='A'|| contar[0] =='B'|| contar[0] =='C'} \n print \"La cantidad de nombres en que inician con A,B o C es #{imp} \\n\"\nend",
"def getCount(s)\n s.count('aeiou')\nend",
"def count\n render :xml => \"<count>#{VoiceGatewayMessage.count}</count>\"\n end",
"def count\n self.wordcounts.map(&:count).inject(0, :+)\n end",
"def count\n self.at('/RETS/COUNT')['Records'].to_i\n end",
"def index \n @project = Project.find(params[:project_id])\n @persons = @project.persons\n \n @persons_by_country = Hash.new \n @project.persons.count(:group => 'time_offset').each do |key,value|\n @persons_by_country[CITIES_MAP[key]] = value\n end\n \n @persons_by_followers = @project.persons.count(:order => 'followers_count ASC', :group => 'ROUND(LN(followers_count),0)')\n @persons_by_friends = @project.persons.count(:order => 'friends_count ASC', :group => 'ROUND(LN(friends_count),0)')\n @persons_by_tweets = @project.persons.count(:order => 'statuses_count ASC', :group => 'ROUND(LN(statuses_count),0)')\n @persons_by_activity = @project.persons.count(:order => 'last_activity DESC', :group => \"DATE(last_activity)\")\n @persons_by_join = @project.persons.count(:order => 'acc_created_at DESC', :group => \"DATE(acc_created_at)\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @people }\n end\n end",
"def track_count\n @ole.TrackCount\n end",
"def country; end",
"def country; end",
"def country; end",
"def counts(select, where, group) #location = {}, type = nil, report\n \"<p>There are <span class=\\\"special\\\">#{count(select, where, group).to_s}</span> reports to dig into!</p>\"\n end",
"def agreed_with_community\n responses = self.responses\n count = 0\n responses.each do |response|\n #count += 1 if response.verdict == response.question.get_community_verdict\n count += 1 if response.question.get_community_verdict(response.verdict)\n end\n return count\n end",
"def represented_country; end",
"def count\n @map.count\n end",
"def pickup_count(from, to, rental_location_code=nil, include_journal=false)\n\n conditions = {:date_from.gte => from,\n :date_from.lte => to,\n :status => [:confirmed, :in_progress, :done]}\n conditions.store(:rental_location_code, rental_location_code) if rental_location_code\n\n count = BookingDataSystem::Booking.count(conditions: conditions)\n\n if include_journal\n sql = <<-SQL\n select count(*)\n from cal_event c_e\n join cal_event_type c_e_t on c_e_t.id = c_e.event_type_id \n join cal_calendar c on c.id = c_e.calendar_id\n where c_e.from >= ? and c_e.from < ? and c_e_t.name = ? and c.name = ?\n SQL\n count += repository.adapter.select(sql, from, to+1, 'booking_journal', 'booking_pickup').first.to_i\n end \n\n return count\n\n end",
"def get_number_of_incidents(status)\n return -1 unless [nil, \"resolved\", \"acknowledged\", \"triggered\"].include? status\n\n root_ca = '/etc/ssl/certs'\n uri = URI.parse \"#{@pagerduty_url}/api/v1/incidents/count\"\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field('Authorization', \"Token token=#{@pagerduty_api_token}\")\n request.set_form_data({\"status\" => status})\n\n if(File.directory?(root_ca) && http.use_ssl?)\n http.ca_path = root_ca\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n http.verify_depth = 5\n else\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n response = http.request(request)\n json = JSON.parse(response.body)\n\n json[\"total\"].to_i\nend",
"def count_ai_battler\n count = -1\n @battle_info.parties.each do |bank|\n count += bank.size\n end\n log_debug(\"Found #{count} AI\")\n return count\n end",
"def subscription_count\n @subs.size\n end",
"def get_countries\n doc = Nokogiri::HTML(open('https://www.britannica.com/topic/list-of-countries-1993160'))\n countries_extracted = doc.css(\"li a\").text.split('Britannica')[1].split(' geography')[0].rstrip\n @processed_countries = countries_extracted.split(/(?<!\\s)(?=[A-Z])/)\n end",
"def company_count\n return 0 unless answer_id\n Card.search left_id: answer_id,\n right: { type_id: WikirateCompanyID },\n return: :count\nend",
"def count\n call_client(:count)\n end",
"def word_counter(mots,dictionnaire)\n words = word_counter.downcase.split(\" \")\n #puts words => [\"howdy\",....\"going?\"]\n frequencies = Hash.new(0)\n words.each{ |mot| \n if mot.include?(dictionnaire) #si le mot est dans le dictionnaire\n frequencies[mot] += 1 #si oui\n end\n \n }\n puts frequencies\nend",
"def count_people(query={})\n self.simple_client.get(\"/api/v1/people/count?#{query.to_query}\")[\"count\"]\n end",
"def frequency\n \n end",
"def visits_by_country\n City.joins(:visits)\n .where(visits: {short_url_id: self.id})\n .group(\"cities.country\").count\n end",
"def count_contestants_by_hometown(data, hometown)\n count_of_contestants_from_hometown = 0\n data.each do |season_in_hash, contestant_array|\n contestant_array.each do |contestant|\n if contestant[\"hometown\"] == hometown\n count_of_contestants_from_hometown += 1\n end\n end\n end\n count_of_contestants_from_hometown\nend",
"def combien_handle_4lettres_Aude(journaliste)\n \tcount = 0\n \tjournaliste.each do |aude|\n \t\tif aude.match(/[a][u][d][e]/)\n \t\tcount +=1\n \tend\nend\n \tputs \"Reponse : \"\n\tputs \"Il y en a #{count}\"\n \tputs \" \"\nend"
] |
[
"0.6421422",
"0.629735",
"0.6288689",
"0.6136678",
"0.60464084",
"0.59708214",
"0.59680533",
"0.59680533",
"0.5947769",
"0.58873403",
"0.5849091",
"0.5822298",
"0.5814649",
"0.5788905",
"0.57696223",
"0.57113224",
"0.5710575",
"0.56750715",
"0.5668011",
"0.5668011",
"0.5668011",
"0.5666778",
"0.56472075",
"0.5646924",
"0.56279474",
"0.5616235",
"0.5608239",
"0.5577647",
"0.55741364",
"0.55681926",
"0.5567736",
"0.55445415",
"0.55409014",
"0.5537015",
"0.5529372",
"0.5523527",
"0.5521088",
"0.55083907",
"0.550463",
"0.5499425",
"0.5498731",
"0.54834116",
"0.5478182",
"0.54780185",
"0.5465374",
"0.5447672",
"0.54465646",
"0.5442607",
"0.5435607",
"0.5433489",
"0.5433489",
"0.5433011",
"0.54321265",
"0.5418071",
"0.5408099",
"0.5406663",
"0.5404271",
"0.5401387",
"0.5400892",
"0.5399802",
"0.5397719",
"0.53941363",
"0.5386792",
"0.53837466",
"0.53719896",
"0.53607166",
"0.5357277",
"0.53564584",
"0.5347698",
"0.5346307",
"0.53419685",
"0.5339258",
"0.53338665",
"0.5328832",
"0.53222114",
"0.5319738",
"0.53158283",
"0.53153837",
"0.53151727",
"0.531069",
"0.53094494",
"0.53068054",
"0.53068054",
"0.53068054",
"0.5305476",
"0.53043586",
"0.53013307",
"0.52975816",
"0.5297093",
"0.52928543",
"0.5290837",
"0.52879953",
"0.5286392",
"0.52830935",
"0.5281",
"0.5279359",
"0.52766836",
"0.5272046",
"0.5270215",
"0.52580446",
"0.52542263"
] |
0.0
|
-1
|
Created On: 20/12/2014 Purpose: To get song by id ++
|
def find_media_by_id(message_id)
UploadedMedium.find(message_id)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def songs\n Song.find_by_album(@id)\n end",
"def current_song\n Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def get_artist(id)\n @connection.get \"artists/#{id}\"\n end",
"def show\n @song = Song.find(params[:id])\n\n end",
"def set_song_id\n @song_id = SongId.find(params[:id])\n end",
"def set_song\n @song = Song.friendly.find(params[:id])\n end",
"def find_song\n if params[:id].nil?\n redirect_to root_path\n else\n @song = Song.find(params[:id])\n end\n end",
"def song\n fetch('cowboy_bebop.song')\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def show\n @song = Song.find(params[:id])\n end",
"def show\n @song = Song.find(params[:id])\n end",
"def play(song)\n # artist = Artist.find_by(id: song.artist_id)\n puts \"Playing #{song}\"\n end",
"def get_song_by_number(number)\n songs.find_by_song_number(number)\n end",
"def set_song\n @song = Song.find(params[:id])\n end",
"def set_song\n @song = Song.find_by id: params[:id], title: params[:title]\n end",
"def set_rapper_song\n @rapper_song = RapperSong.find(params[:id])\n end",
"def set_song\n @song = Song.find(params[:id])\n @artist = @song.artist\n end",
"def set_song\n @song = Song.find(params[:song_id])\n end",
"def [](key)\n return @songs[key] if key.kind_of?(Integer)\n return @songs.find { |aSong| aSong.name == key }\n end",
"def show\n @single_song = Song.where(id: params[:id])\n render :show\n end",
"def song\n fetch('bossa_nova.songs')\n end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def get_song_url_by_id(id)\n resp = get_stream_auth_by_songid(id)\n \"http://#{resp['ip']}/stream.php?streamKey=#{resp['stream_key']}\"\n end",
"def get_track(id)\n return @tracks.find {|s| s.track_id == id}\n end",
"def show\n @music = Music.friendly.find(URI.unescape(params[:id]))\n # select random genre from all the music\n # create a client object with your app credentials\n client = Soundcloud.new(:client_id => 'd99d78670c7f1d537d0ae3d67a7be95c')\n @embed_info = client.get('/oembed', :url => @music.song_api,:auto_play => true)\n end",
"def books\n Book.where(\"songs ? :id\", id: self.id.to_s)\n end",
"def play_song_with_id(id)\n # Check if we need a new Grooveshark session\n if session_expired?\n init_grooveshark\n end\n \n begin\n @mutex.synchronize do\n unless @child.nil? then\n execute_tuner_command(\"stop\")\n end\n while !@child.nil? do\n sleep 1\n end\n url = @grooveshark_client.get_song_url_by_id(id)\n @child = fork do\n STDIN.reopen(@read_io)\n `mplayer -really-quiet \"#{url}\"`\n exit\n end\n Thread.new {\n Process.waitpid(@child)\n @child = nil\n }\n end\n rescue Exception\n return {\"success\" => false}.to_json\n end\n return {\"success\" => true}.to_json\n end",
"def getSong\n\t\tid = params[:songId]\n\t\tresult = GetSongFromSpotify.build.call(id)\n\t\trender json: result\n\tend",
"def song(id, global = false, ext = '.ogg')\n a = global ? @global_songs : @songs\n return a[id] if a[id]\n s = @prefix + @song_dir + id.to_s.split(@separator).join('/') + ext\n song = Gosu::Song.new s\n a[id] = song\n end",
"def next_song(set_as_playing = false)\n @mode = :user\n \n play_id, filename, title, song_id = nil\n begin\n # this query will get a song which was cut off while playing first, and failing that, will get the next song on the queue which hasn't been played\n play_id, filename, title, song_id = db.get_first_row \"select id, filename, title, song_id from rubedo_plays where queued_at IS NOT NULL order by queued_at asc limit 1\"\n return nil unless play_id\n rescue\n log.error \"Error at some point during finding #{'(and setting) ' if set_as_playing}next song. Filename was: #{filename}\\n#{$!}\" if log\n return nil\n end\n\n mark_start!(play_id, song_id) if set_as_playing\n \n [play_id, filename, title]\n end",
"def show\n @song = Song.find(params[:id])\n @yt_id = YoutubeSearch.search(\"#{@song.name} #{@song.artist.name}\").first['video_id']\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @song }\n end\n end",
"def get_it_object_by_id(source_id, playlist_id, track_id, database_id)\n @ole.GetITObjectByID(source_id, playlist_id, track_id, database_id)\n end",
"def show\n @song = Song.find(params[:id], :include=>[:artist, :album])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end",
"def add_song(song)\n return if Song.find_by_id(song).nil?\n songs << song\n end",
"def set_songbook\n @songbook = Songbook.includes(:songs).find(params[:id])\n end",
"def songs\n \t@songs = Album.find(params[:id])\n songs = RSpotify::Track.search(@songs.name)\n \t@songs = songs.map do |s_songs|\n \tSong.new_from_spotify_song(s_songs)\n end\n render json: {data:@songs}\n end",
"def show\n # @song = Song.where(id: params[:id])\n # @playlist = Userplaylist.where(song_id: params[:id])\n @user = User.find(session[:user_id])\n @song = Song.find(params[:id])\n @playlist = Userplaylist.where(song: @song)\n\n end",
"def set_song\n @song = @user.songs.find(params[:id])\n end",
"def songs_found\n get_songs\n return @songs\n end",
"def get_track(spotify_id)\n content = HTTParty.get('http://ws.spotify.com/lookup/1/.json?uri=' + URI.escape(\"spotify:track:#{spotify_id}\"))\n if !content.body.empty?\n Oj.load(content.body)\n else\n flash[:notice] = 'Error with Spotify! Try again in 10 seconds!'\n end\n end",
"def item_find\n find(playlist_url(@response.old_index))\n end",
"def add_song_by_name(name)\nartist = Song.new(name)\nadd_song(artist)\nend",
"def find_album_by_id(client, album_id)\n client.api(:album, :show, album_id)\nend",
"def id\n return @artist_data[\"id\"]\n end",
"def song_plays\n SongPlay.where(:song_path => path)\n end",
"def update_song\n head :ok\n end",
"def set_song_list\n @song_list_song = SongListSong.find(params[:id])\n end",
"def get_tracks(*ids)\n song_list = []\n ids.each do |id|\n song_list << @tracks.find {|s| s.track_id == id}\n end\n return song_list.compact\n end",
"def get_songs_ids\n if @song_ids\n return @song_ids\n else\n return get_songs.map { |x| x[IDX_SONG_ID] }\n end\n end",
"def songs\n # @@songs.select { |song| song.name == @name }\n @songs\n end",
"def set_base_song\n @base_song = BaseSong.find(params[:id])\n end",
"def songs\n Song.all\n end",
"def set_playlist_song\n @playlist_song = PlaylistSong.find(params[:id])\n end",
"def artist_show_song\r\n\r\n\t\t#@artist = Artist.find(params[:id])\r\n\t\tsearchString = params[:url_slug]\r\n\t\t@artist = Artist.find_by_url_slug(searchString)\r\n\t\t@song = @artist.song.find.by_url_slug(params[:song_name])\r\n\r\n\t\trespond_to do |format|\r\n\t\t\tformat.html # show.html.erb\r\n\t\t\tformat.xml { render :xml => @artist }\r\n\t\tend\r\n\tend",
"def all_songs\n end",
"def song_ids\n @song_ids ||= input[\"songs\"].map{|song| song[\"id\"]}\nend",
"def set_song\n @song = @current_user.songs.find(params[:id])\n end",
"def songs \n @songs\n end",
"def show\n client_playlist = Soundcloud.new(:client_id => Rails.application.secrets.soundcloud_client_id,\n :client_secret => Rails.application.secrets.soundcloud_secret,\n :username => Rails.application.secrets.soundcloud_username,\n :password => Rails.application.secrets.soundcloud_password)\n client_track = SoundCloud.new(:client_id => Rails.application.secrets.soundcloud_client_id)\n # create an array of track ids\n track_url = Post.find(params[:id]).try(:track_url)\n # puts track_url.inspect\n embed_info = client_track.get('/oembed', :url => track_url)\n @song = embed_info['html']\n @track_id = client_track.get('/resolve', :url => track_url).id\n @playlists = client_playlist.get(\"/me/playlists\")\n end",
"def find_playlist\n @playlist = Playlist.find(params[:id])\n end",
"def show\n @song_id = get_song_id(@heart.beats)\n end",
"def get_artist\n Artist.find(params[:id])\n end",
"def songs\n @songs\n end",
"def songs\n @songs\n end"
] |
[
"0.73457235",
"0.6991399",
"0.6824254",
"0.6824254",
"0.6824254",
"0.678731",
"0.6772796",
"0.67342347",
"0.6730125",
"0.6723889",
"0.67143404",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.66962284",
"0.6694708",
"0.66798484",
"0.66798484",
"0.6654426",
"0.66164374",
"0.65776616",
"0.65764475",
"0.6556261",
"0.6529474",
"0.6485619",
"0.64276564",
"0.6420798",
"0.64192015",
"0.6377328",
"0.6377328",
"0.6377328",
"0.6377328",
"0.6377328",
"0.6377328",
"0.6377328",
"0.6377328",
"0.6352994",
"0.6334399",
"0.63291377",
"0.63123995",
"0.6304148",
"0.6301944",
"0.6296632",
"0.6281678",
"0.62606966",
"0.62606156",
"0.6258777",
"0.62529033",
"0.6245471",
"0.6245353",
"0.62392336",
"0.62175065",
"0.6190932",
"0.6189035",
"0.6178636",
"0.6159654",
"0.6147696",
"0.61412364",
"0.6133222",
"0.6131332",
"0.6127537",
"0.6121873",
"0.6116424",
"0.61134",
"0.6108571",
"0.61066806",
"0.6105965",
"0.6099479",
"0.6097158",
"0.60889244",
"0.60866594",
"0.6082753",
"0.6064143",
"0.60615855",
"0.6056276",
"0.6055194",
"0.6044968",
"0.6044968"
] |
0.0
|
-1
|
Created On: 05/01/2014 Purpose: To get listen media count country vice ++
|
def play_count_country_vice(country_lists,device_accesses,listen_medias,sorted_array = [])
@device_accesses = device_accesses
@listen_medias = listen_medias
country_lists.each do |country_name|
id_lists = @device_accesses.where(:access_country => country_name).map(&:id)
add_count=[]
id_lists.each do |id|
add_count << @listen_medias.where(device_access_id: id).count
end
sorted_array << [country_name,add_count.sum]
end
sorted_array
play_hash = Hash[*sorted_array.flatten]
sorted_play_hash = play_hash.sort_by {|_key, value| value}.reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count_media\n general_data['nb_media']\n end",
"def media_object_count\n @media_object_count ||= MediaObject.where(\"collection_ssim\" => name).count\n end",
"def get_listen_count(device_access_id,listen_medias)\n listen_medias.where(:device_access_id => device_access_id).count rescue nil\n end",
"def view_count\n internal_video.view_count\n end",
"def count\n render :xml => \"<count>#{VoiceGatewayMessage.count}</count>\"\n end",
"def track_count\n @ole.TrackCount\n end",
"def num_of_tracks\n\t\t@tracks.count\t \n\tend",
"def track_count\n self.tracks.count\n end",
"def counts\n reply.documents[0][COUNTS]\n end",
"def count_members\n @band.count\n end",
"def song_count\n # @artist = self\n # @artist.songs.count\n self.songs.count\n end",
"def song_count\n self.lib.songs.count\n end",
"def songs_count\n value = 0\n packs.each do |pack|\n value += pack.songs.count\n end\n value += songs.count\n end",
"def track_count\n return @tracks.length\n end",
"def count; info['doc_count']; end",
"def song_count\n return @songs.count\n end",
"def songs_count\n \t@songs.count\n end",
"def song_count\n @song_count = 0 if @song_count.nil?\n @song_count\n end",
"def subscription_count\n @subs.size\n end",
"def count_item\n count = 0\n @g_net.each do |followers|\n count += 1 unless !followers or followers.empty?\n end\n count\n end",
"def song_count\n self.songs.count\n end",
"def count \n puts \"Tu as scrappé #{@result_scrap.count} élémént(s)\"\n return @result_scrap.count\n end",
"def country_count\n varietal_array = []\n # wine_array = [\"Malbec\", \"Merlot\", \"Syrah\", 'Cabernet Sauvignon', 'Pinot Noir', 'Grenache', 'Sangiovese', 'Tempranillo', 'Montepulcia', 'Petite Syrah', 'Chardonnay', 'Sauvignon blanc', 'Pinot Gris', 'Riesling', 'Semillon', 'Gewurztraminer', 'Chenin Blanc', 'Gruner Veltliner', 'Torrontes']\n variety = Wine.where(variety: params[:variety])\n # , \"Pinot Noir\", \"Merlot\", \"Malbec\", \"Syrah\",\"Chardonnay\",\"Sauvignon blanc\",\"Pinot Gris\",\"Riesling\",\"Pinot Noir\"]\n \n countries = []\n count_array = []\n new_hash = {}\n\n countries = variety.map do |wine| \n wine.country\n end \n\n \n count_array = countries.each_with_object(Hash.new(0)) {|k, v| v[k] += 1}\n new_array = []\n\n count_array.keys.each do |country| \n if country\n hash = {:country => country, :value => count_array[country]}\n new_array.push(hash)\n end\n end\n\n new_hash = {:countries => new_array}\n render json: new_hash\n end",
"def tracking_total_count\n link_tracking.count\n end",
"def audio_file_count\n @audio_file_list.length\n end",
"def counts\r\n @counts\r\n end",
"def count_population_of_uk(collection_of_countries)\n total_population = 0\n for country in collection_of_countries\n total_population += country[:population]\n end\n return total_population\nend",
"def count\n @data['count']\n end",
"def subscriber_count\n subscribers.size\n end",
"def count_population(country)\n population = 0\n for country in country\n population += country[:population]\n end\n return population\nend",
"def subscriber_count\n return @count if @count\n\n conditions = [{:field => \"date\", :op => \"lt\", :value => id},\n {:field => \"interests-#{MAILCHIMP_SETTINGS[:grouping_id]}\", \n :op => \"none\", \n :value => \"Free Subscription\"}]\n\n @count = api.campaign_segment_test MAILCHIMP_SETTINGS[:list_id], \n :match => \"all\", \n :conditions => conditions \n end",
"def played_count\n @ole.PlayedCount\n end",
"def offense_counts; end",
"def offense_counts; end",
"def news artist\n url = \"http://developer.echonest.com/api/v4/artist/news?api_key=#{ECHONEST_API_KEY}&format=json&name=#{artist}&results=#{RESULTS}\"\n result = parseURL url\n result[\"response\"][\"total\"]\nend",
"def photo_count\r\n infoxml = get_info\r\n return infoxml.at('photos/count').inner_text.to_i\r\n end",
"def number_of_songs()\n return songs.length\n end",
"def number_of_songs()\n return songs.length\n end",
"def user_song_uploads_total\r\n self.user_song_uploads.count\r\n end",
"def nbSongs(xml)\n nbSongs = 0\n xml.xpath(\"//TrackNumber\").each { |track| nbSongs = nbSongs + 1}\n return nbSongs\nend",
"def member_count\n attach_info\n @member_count\n end",
"def count_songs\n @songs.size\n end",
"def total_duration()\n\ttotal_duration\t= 0;\n\t# go thru each track\n\t@jspf['track'].each do |track|\n\t\ttotal_duration += track['duration'];\n\tend\n\t# return the total_duration\n\treturn\ttotal_duration;\nend",
"def count; end",
"def count; end",
"def count; end",
"def genre_count(term)\n #count the genres in object.get_genres\n genres = Hash.new(0)\n object.get_genres(term).each do |genre|\n case\n when genre.include?(\"rap\")\n genres[:rap]+=1\n when genre.include?(\"pop\")\n genres[:pop]+=1\n when genre.include?(\"country\")\n genres[:country]+=1\n when genre.include?(\"indie\")\n genres[:indie]+=1\n when genre.include?(\"hip\")\n genres[\"hip hop\"]+=1\n when genre.include?(\"rock\")\n genres[:rock]+=1\n when genre.include?(\"jazz\")\n genres[:jazz]+=1\n when genre.include?(\"instrumental\")\n genres[:instrumental]+=1\n when genre.include?(\"r&b\")\n genres[\"r&b\"]+=1\n else\n genres[:misc] +=1\n end\n end\n genres\n end",
"def number_of_tracklists\n tracklists.size\n end",
"def following_profiles_count\n stream_ids = favorites.streams.pluck(:favable_id).uniq\n return Stream.where(:id => stream_ids).pluck(:profile_id).uniq.count\n end",
"def cult_population\n my_followers.count\n end",
"def channels_count\n channels.count\n end",
"def total_movies\n search_by_text('всего фильмов').to_i\n end",
"def total_up_votes\r\n self.song_up_votes.size\r\n end",
"def peer_count\n make_promise(@core.web3.JS[:net], 'getPeerCount')\n end",
"def get_DocumentCount()\n \t return @outputs[\"DocumentCount\"]\n \tend",
"def zone_count\n da_zones=zones\n count = da_zones.count\n da_zones.each{ |z| count += z.zone_count }\n count\n end",
"def count(stat, count, sample_rate=1); send stat, count, 'c', sample_rate end",
"def total_shows\n self.shows.count\n end",
"def get_count\n user_page = Habr::open_page(Habr::Links.userpage(@userslug))\n # get text with favs count\n user_page.css(\".left .count\").first.text.to_i\n end",
"def retrieve_message_count_from_server\n response = retrieve_messages_from_server(1)\n response[\"count\"]\n end",
"def votes_cast_count\n total_votes\n end",
"def phones_in_word_list\n @word_list.inject(0) do |m, word|\n m += word.unanlayzed_phone_count\n end\n end",
"def fanscnt\n \tobject.user_location_favs.size\n\n end",
"def album_count\n return @albums.length\n end",
"def summary_site\n \t\tAPI.get_site_wordcount\n \tend",
"def photos_count (rober_data)\n camera_count = {}\n \n rober_data[\"photos\"].each do |photo|\n photo[\"camera\"].each do |k, v|\n if k == \"name\"\n if camera_count.include? v\n camera_count[v] += 1\n else\n camera_count[v] = 1\n end\n end\n end\n end\n camera_count\nend",
"def count\n end",
"def count\n end",
"def total_songs\r\n self.master_song_relationships.count + self.user_song_uploads.count\r\n end",
"def subscriptions_count\n subscriptions.count\n end",
"def get_country_statistics_report(country_list, device_access)\n @country_hash = {}\n country_list.each do |country|\n country_count = device_access.where(:access_country => country).count\n @country_hash[country] = country_count \n end\n country_stat = @country_hash.sort_by {|_key, value| value}.reverse\n hash = Hash[*country_stat.flatten]\n end",
"def count\n self.at('/RETS/COUNT')['Records'].to_i\n end",
"def record_count\n\t\t# TODO\n\tend",
"def varietal_count\n varietal_array = []\n # wine_array = [\"Malbec\", \"Merlot\", \"Syrah\", 'Cabernet Sauvignon', 'Pinot Noir', 'Grenache', 'Sangiovese', 'Tempranillo', 'Montepulcia', 'Petite Syrah', 'Chardonnay', 'Sauvignon blanc', 'Pinot Gris', 'Riesling', 'Semillon', 'Gewurztraminer', 'Chenin Blanc', 'Gruner Veltliner', 'Torrontes']\n country_iso_array = IsoCountryCodes.for_select.to_h\n variety = Wine.where(variety: params[:variety])\n # , \"Pinot Noir\", \"Merlot\", \"Malbec\", \"Syrah\",\"Chardonnay\",\"Sauvignon blanc\",\"Pinot Gris\",\"Riesling\",\"Pinot Noir\"]\n \n countries = []\n count_array = []\n new_hash = {}\n\n countries = variety.map do |wine| \n if wine.country === \"US\"\n country = \"United States of America\"\n country_iso_array[country]\n elsif wine.country === \"England\"\n country = \"United Kingdom of Great Britain and Northern Ireland\"\n country_iso_array[country]\n else \n country_iso_array[wine.country]\n end\n end \n\n \n count_array = countries.each_with_object(Hash.new(0)) {|k, v| v[k] += 1}\n new_array = []\n\n count_array.keys.each do |iso| \n if iso \n hash = {:country => iso, :value => count_array[iso]}\n new_array.push(hash)\n end\n end\n\n new_hash = {:isoCodes => new_array}\n render json: new_hash\n end",
"def media_content_rating_japan\n return @media_content_rating_japan\n end",
"def subscribers_count\n subscribers_as_people.uniq.count\n end",
"def view_count_of_videos\n self.view_count\n end",
"def subscriber_count\n raise NotImplementedError, \"please implement 'subscriber_count'\"\n end",
"def stats\n\t\t@counts\n\tend",
"def get_raw_counts phrase, ngram_model=0, separator=\" \"\n ngram_model_inferred = ngram_model==0 ? phrase.split(separator).count : ngram_model\n return @ngram_counts[ngram_model_inferred][phrase]\n end",
"def get_searchproduct_count_anonymous\n\t\tresponse_search = Partay.get('http://shoponline.tescolotus.com/api/v1/search/products?query=Sugar&page=1&sortBy=Relevance', :headers => {'Content-Type' => 'application/json', 'language' => 'en-gb', 'region' => 'TH'})\n\t\tsearch_result=JSON(response_search)\n\t\tself.total_product_count(JSON(search_result)[\"pageInformation\"][\"totalCount\"])\n\t\tputs total_search_count\n\n\tend",
"def contributors_share\n ps = 0.0\n self.recording_ipis.each do |recording_ipi|\n ps += recording_ipi.share\n end\n ps\n end",
"def get_word_freq\n speech_links = get_links_to_speeches\n word_freq = Hash.new(0)\n \n speech_links.each do |link|\n speech_page = link.click\n if (speech_obj = speech_page.at SPEECH_DIV_IDENTIFIER)\n speech = speech_obj.text\n words = speech.split(' ')\n words.each{ |word| word_freq[clean_str(word)] += 1 }\n end\n end\n\n word_freq.sort_by{ |x,y| y }.reverse\n end",
"def total_record_count\n ldpath = config.total_count_ldpath\n service_uri = RDF::URI.new(config.service_uri)\n return I18n.t(\"qa.linked_data.search.total_not_reported\") unless ldpath && service_uri\n prefixes = config.prefixes\n ldpath_program = ldpath_service.ldpath_program(ldpath: ldpath, prefixes: prefixes)\n values = ldpath_service.ldpath_evaluate(program: ldpath_program, graph: graph, subject_uri: service_uri)\n values.map!(&:to_i)\n values.first || I18n.t(\"qa.linked_data.search.total_not_reported\")\n end",
"def media_content_rating_australia\n return @media_content_rating_australia\n end",
"def count(filter=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\t# Media entry filter\n\t\t\tclient.add_param(kparams, 'filter', filter);\n\t\t\tclient.queue_service_action_call('mixing', 'count', 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 rtsp_statistics\n super\n end",
"def photos_count(info_count)\n x = info_count.inject(Hash.new(0)) { |h, e| h[e] += 1 ; h }\nend",
"def sporters_by_country\n \tresult = { }\n \tCountry.all.map do |c|\n \t\tresult[c.name] = c.sporters.count\n \tend\n \trender json: [{name: 'Count', data: result}]\n end",
"def subscribers_count\n response = connection_wrapper {\n @faraday.get '/subscribers_count/', token_hash\n }\n response.body['result']\n end",
"def count(filter=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\t# Media entry filter\n\t\t\tclient.add_param(kparams, 'filter', filter);\n\t\t\tclient.queue_service_action_call('media', 'count', 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 get_affiliations_count\r\n @summary.affiliations_count\r\n end",
"def count\n @count\n end",
"def media_content_rating_canada\n return @media_content_rating_canada\n end",
"def phonetic_coverage\n 1 - phones_in_word_list/@initial_phones.to_f\n end",
"def message_count\n\t s = status\n\t\t\ts[:message_count]\n\t end",
"def here_now_count\n fetch unless @json.has_key?(\"hereNow\")\n @json[\"hereNow\"][\"count\"]\n end",
"def count\n self.wordcounts.map(&:count).inject(0, :+)\n end",
"def o_ucount_notify\n User.bot.lobby_speak(\"#{linked_name}さんが本日#{today_total_o_ucount}問解きました\")\n end",
"def count\n @count\n end"
] |
[
"0.6876442",
"0.63025284",
"0.628603",
"0.6176559",
"0.61061996",
"0.6085936",
"0.6083711",
"0.6083323",
"0.6051409",
"0.6039257",
"0.5981409",
"0.5979366",
"0.59754515",
"0.5953041",
"0.59466374",
"0.5913393",
"0.59101397",
"0.58907956",
"0.5866429",
"0.5863772",
"0.58630204",
"0.5855679",
"0.582673",
"0.5810052",
"0.58096683",
"0.5775061",
"0.57484293",
"0.57242095",
"0.57207114",
"0.571224",
"0.57071066",
"0.56949085",
"0.5688297",
"0.5688297",
"0.5687834",
"0.5687151",
"0.56844145",
"0.56844145",
"0.5680393",
"0.56712437",
"0.5648971",
"0.563783",
"0.5636329",
"0.5630274",
"0.5630274",
"0.5630274",
"0.5626153",
"0.55990946",
"0.5592634",
"0.5587007",
"0.55728924",
"0.5571205",
"0.5571065",
"0.55695075",
"0.55664605",
"0.55631244",
"0.552578",
"0.55138415",
"0.5508706",
"0.5507302",
"0.5505907",
"0.5502119",
"0.5500509",
"0.549751",
"0.54946536",
"0.5485581",
"0.5480007",
"0.5480007",
"0.54760635",
"0.54698515",
"0.54619133",
"0.54528284",
"0.5451043",
"0.544766",
"0.54473764",
"0.5443758",
"0.54397094",
"0.54326934",
"0.5431868",
"0.54308784",
"0.5429453",
"0.5425628",
"0.5418616",
"0.54116327",
"0.54112166",
"0.54100156",
"0.5403689",
"0.54027694",
"0.5400543",
"0.53900546",
"0.53880864",
"0.53871316",
"0.5379975",
"0.536629",
"0.53626883",
"0.53615505",
"0.53615284",
"0.5360671",
"0.53573966",
"0.53554374"
] |
0.6455097
|
1
|
Created On: 05/01/2014 Purpose: To get state from city ++
|
def get_city_state(city)
DeviceAccess.where(access_city: city).last.access_state rescue nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def state(city)\n city = append_country(city)\n request = Request.new(:query => city, :output => \"json\")\n response = JSON.parse(request.execute!)\n if response[\"Status\"][\"code\"] == 200\n response[\"Placemark\"][0][\"AddressDetails\"][\"Country\"][\"AdministrativeArea\"][\"AdministrativeAreaName\"]\n else\n Geocode.unknown_state\n end\n rescue\n Geocode.unknown_state\n end",
"def find_state_for_city(cityName)\n @cities.each do |x, y|\n \ty.each do |z|\n\t\t\tif z == cityName\n\t\t\t\tputs \"That #{cityName} is part of a state called #{x}\"\n\t \tend\n\t end\n\tend\nend",
"def find_state_for_city(user_city)\n found = false\n $states.each do |statekey, stateinfo|\n if stateinfo[1].map{|x| x.downcase}.include?(user_city.downcase)\n found = statekey\n end\n end\n if found \n puts \"Ah #{user_city} is in #{found}\"\n else\n puts \"we didnt find your city, try again sucka!\"\n end\nend",
"def cities\n CS.get :us, :ca\n end",
"def state_list\n @state_list=State.find_all_by_country_id(params[:city][:value])\n end",
"def find_city\n\t\t\tif params[:country_id] && params[:state_id] && params[:city_id]\n\t\t\t\t# Walk the tree \n\t\t\t\tcity_category = Category.find_by_parent_uuid_and_url_part(@state.uuid, params[:city_id].downcase)\n\t\t\t\t@city = City.find(:first, :conditions => { :category_id => city_category.id })\n\t\t\tend\n\t\tend",
"def find_city\n\t\t\tif params[:country_id] && params[:state_id] && params[:city_id]\n\t\t\t\t# Walk the tree \n\t\t\t\tcity_category = Category.find_by_parent_uuid_and_url_part(@state.uuid, params[:city_id].downcase)\n\t\t\t\t@city = City.find(:first, :conditions => { :category_id => city_category.id })\n\t\t\tend\n\t\tend",
"def show\n @state = State.find(@city.state_id)\n end",
"def city\n fetch('dune.cities')\n end",
"def citystate\n @cs = ''\n\n if !self.city.nil?\n @cs += self.city\n end\n\n if @cs.length && !self.state.nil?\n @cs += ', '\n end\n\n if !self.state.nil?\n @cs += self.state\n end\n return @cs\n end",
"def state_or_province\n end",
"def find_state\n\t\t\t@state = Category.find_by_parent_uuid_and_url_part(@country.uuid, params[:state_id].downcase) if params[:country_id] && params[:state_id]\n\t\tend",
"def find_state\n\t\t\t@state = Category.find_by_parent_uuid_and_url_part(@country.uuid, params[:state_id].downcase) if params[:country_id] && params[:state_id]\n\t\tend",
"def city_state_name\n [city.to_s.titleize, state_abbr_name].compact.join(', ')\n end",
"def city_state_name\n [city.to_s.titleize, state_abbr_name].compact.join(', ')\n end",
"def find_city(map, state)\n# map == hash, state == key, checks whether key \"state\" exists in the hash \"map\"\n if map.include? state\n # if the key exists, it returns the value for the key \"state\" of the hash \"map\"\n return map[state]\n else\n # if the key does not exist in the hash, then return \"Not found.\"\n return \"Not found.\"\n end\nend",
"def city_state_name\n [city, state_abbr_name].join(', ')\n end",
"def city_state_name\n [city, state_abbr_name].join(', ')\n end",
"def find_city_and_state(zip)\r\n \r\n puts 'finding ' + zip.to_s\r\n \r\n # stores result\r\n result = nil\r\n \r\n # need to pad zeros in front of the zip \r\n padded_zip = sprintf '%05d', (zip)\r\n \r\n # load the user agent.\r\n a = Mechanize.new { |agent|\r\n agent.user_agent = @user_agent\r\n }\r\n \r\n # convert url to the zip\r\n actual_url = self.replace_zip_in_url(padded_zip)\r\n \r\n # go to page and fetch the string.\r\n a.get(actual_url) do |p|\r\n \r\n # check if the sorry zip code does not exist. node exist.\r\n error_nodes = p.search('//div[@class=\"noresults-container\"]').length\r\n \r\n # need to check if the zip is valid.\r\n if error_nodes == 0\r\n # you basically want the first result.\r\n # so break after you grab it.\r\n p.search('//div[@id=\"result-cities\"]/p[@class=\"std-address\"]').each do |addr|\r\n city_state_str = self.city_state_as_hash(padded_zip, addr.text)\r\n #puts city_state_str.inspect\r\n result = city_state_str\r\n break\r\n end\r\n else\r\n puts 'not a valid zip'\r\n end\r\n end\r\n \r\n # return results.\r\n # either a nil or a hash containig zip, city, state\r\n result\r\n end",
"def city\n fetch('world_cup.cities')\n end",
"def city; end",
"def city; end",
"def city; end",
"def city; end",
"def city; end",
"def city; end",
"def city(params={})\n address.cities(params).select { |city| city.ref == self.city_ref }.first.result\n end",
"def where(place)\n\tstates = {\n\t\t\"Oregon\" => \"OR\",\n\t\t\"Alabama\" => \"AL\",\n\t\t\"New Jersey\" => \"NJ\",\n\t\t\"Colorado\" => \"CO\"\n\t}\n\tcapitals_cities = {\n\t\t\"OR\" => \"Salem\",\n\t\t\"AL\" => \"Montgomery\",\n\t\t\"NJ\" => \"Trenton\",\n\t\t\"CO\" => \"Denver\"\n\t}\n\tif capitals_cities.has_value?(place)\n\t\tputs states.key(capitals_cities.key(place))\n\telse\n\t\tputs \"Unknown capital city\"\n\tend\nend",
"def state_or_province\n end",
"def state\n country = ISO3166::Country[country_residence]\n if country.try(:subdivisions?)\n country.subdivisions[state_code].try(:[], \"name\")\n else\n state_code\n end\n end",
"def load_city(row, state)\n\t\tcity_name = city row\n\t\tcity_obj = City.find_by_name(city_name)\n\t\t\n\t \tunless city_obj\n\t \t\tcity_obj = City.new({name: city(row), state: state})\n\t \t\tcity_obj.save\n \t\tend\n \t\treturn city_obj\n \tend",
"def state\n address.state\n end",
"def get_city\n @single_city_data[\"name\"]\n end",
"def stay_city\n # cities = Country.all.map{|country|country.cities}\n # cities.map{|city|city.name}\n end",
"def city_state_zip\n city + \", \" + state + \" \" + zip\n end",
"def city\n \"Mesa\"\n end",
"def get_city_names(cityName)\n dial_book.each do |dbkey, dbval|\n if dial_book[dbkey] == dial_book[cityName]\n get_area_code(dial_book, )\n end\n end\nend",
"def public_location\n\t\tself.city.capitalize + \", \" + self.state.upcase\n\tend",
"def getCity\n @city\n end",
"def city\n fetch('dnd.cities')\n end",
"def city_name\n\t\treturn \"Mysore\"\n\tend",
"def state_province_field\n $tracer.trace(format_method(__method__))\n\treturn ToolTag.new(@tag.find.span.className(create_ats_regex_string(\"ats-state\")).find.input, format_method(__method__))\n end",
"def read_city(offset, hostname = '', ip = '') #:nodoc:\n return nil if offset == 0\n record = atomic_read(FULL_RECORD_LENGTH, offset+index_size)\n return unless (record && record.size == FULL_RECORD_LENGTH)\n\n # The country code is the first byte:\n code = record[0]\n code = code.ord if code.respond_to?(:ord)\n record = record[1..-1]\n @iter_pos += 1 unless @iter_pos.nil?\n\n spl = record.split(\"\\x00\", 4)\n # Get the region code:\n region_code = spl[0]\n @iter_pos += (region_code.size + 1) unless @iter_pos.nil?\n\n # Get the city:\n city = spl[1]\n @iter_pos += (city.size + 1) unless @iter_pos.nil?\n # set the correct encoding in ruby 1.9 compatible environments:\n city = city.force_encoding('iso-8859-1').encode('utf-8') if city.respond_to?(:force_encoding)\n\n # Get the postal code:\n postal_code = spl[2]\n @iter_pos += (postal_code.size + 1) unless @iter_pos.nil? || postal_code.nil?\n\n record = spl[3]\n\n # Get the latitude/longitude:\n if (record && record[0,3])\n latitude = (le_to_ui(record[0,3].unpack('C*')) / 10000.0) - 180\n record = record[3..-1]\n\n @iter_pos += 3 unless @iter_pos.nil?\n else\n latitude = ''\n end\n\n if (record && record[0,3])\n longitude = le_to_ui(record[0,3].unpack('C*')) / 10000.0 - 180\n record = record[3..-1]\n\n @iter_pos += 3 unless @iter_pos.nil?\n else\n longitude = ''\n end\n\n # UNTESTED\n if (record &&\n record[0,3] &&\n @database_type == Edition::CITY_REV1 &&\n CountryCode[code] == \"US\")\n\n dmaarea_combo = le_to_ui(record[0,3].unpack('C*'))\n dma_code = (dmaarea_combo / 1000)\n area_code = (dmaarea_combo % 1000)\n\n @iter_pos += 3 unless @iter_pos.nil?\n else\n dma_code, area_code = nil, nil\n end\n\n City.new(\n hostname, # Requested hostname\n ip, # Ip address as dotted quad\n CountryCode[code], # ISO3166-1 code\n CountryCode3[code], # ISO3166-2 code\n CountryName[code], # Country name, per IS03166\n CountryContinent[code], # Continent code.\n region_code, # Region code (called region_name, unfortunately)\n city, # City name\n postal_code, # Postal code\n latitude,\n longitude,\n dma_code,\n area_code,\n (TimeZone[\"#{CountryCode[code]}#{region_code}\"] || TimeZone[\"#{CountryCode[code]}\"]),\n lookup_region_name(CountryCode[code], region_code) # Real region name\n )\n end",
"def capital_city\n fetch('nation.capital_city')\n end",
"def test_get_geocode_city_state\n valid_geocode_request = @base_url+\"?\"+@geocode_city_state+\"&\"+@api_key\n server_response = http_request(:get, valid_geocode_request)\n\n response_body = server_response.body\n formatted_address = JSON.parse(response_body)[\"results\"][0][\"formatted_address\"]\n status = JSON.parse(response_body)[\"status\"]\n assert_requested(:get, valid_geocode_request, times: 1)\n assert_equal \"San Francisco, CA, USA\", formatted_address\n assert_equal \"OK\", status\n end",
"def location\n country = Carmen::Country.coded(self.country)\n if country.present? && self.state.present?\n location = country.subregions? ? country.subregions.coded(self.state).name : self.state\n location += \", \"\n else\n location = ''\n end\n country.present? ? location + country.name : nil\n end",
"def get_area_code(hashbook, city)\n hashbook[city]\nend",
"def state_or_province\n decode hash[\"StateOrProvince\"]\n end",
"def city_state_country(addr, opts = { :zip => true})\n addr = addr.airport if(addr.airport? && addr.airport )\n zip = addr.zip if opts[:zip] and addr.respond_to?('zip')\n ci_st_co = [addr.city, addr.state, zip, addr.country].delete_if{ |a| a.blank? }\n ci_st_co.join(', ').sub(/, United States$/, '')\n end",
"def cities\n gallaries.map{|place| place.city}\n\n end",
"def test_fun_city_locs\n\t@city = GoldRush::new\n\tassert_equal \"El Dorado Canyon\", @city.dorado.location\n\tassert_equal \"Midas\", @city.midas.location\n\tassert_equal \"Virginia City\", @city.virginia.location\n\tassert_equal \"Nevada City\", @city.nevada.location\n\tassert_equal \"Coloma\", @city.coloma.location\n\tassert_equal \"Angels Camp\", @city.angels.location\n\tassert_equal \"Sutter Creek\", @city.sutter.location\n end",
"def city_address\n \"#{city}, #{state} #{zip}\"\n end",
"def getCityInfo(city)\r\n result = @vertex.find{ |code, cname| (code == city || cname.name == city)}\r\n\r\n if result.nil?\r\n puts \"There is no such city in CSAir.\"\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n else\r\n result[1].printVertex\r\n puts \"\"\r\n connectedCities(result[1].code)\r\n puts \"\"\r\n puts \"Please input 1 for list of all the cities CS Air travels to\"\r\n puts \"Please input 2 for specific information about a city in the CS Air network\"\r\n puts \"Please input 3 for the other statistics\"\r\n puts \"Please input 4 to Visualize CSAir's route map\"\r\n puts \"Please input 5 to exit\"\r\n end\r\n end",
"def set_city_state\n @city_state = CityState.find(params[:id])\n end",
"def geograpy(city, state)\n puts \"#{city} is the capital of #{state}.\"\nend",
"def state_full_name(state_code,flag = false)\n state = {\n 'AL' => 'Alabama',\n 'AK' => 'Alaska',\n 'AS' => 'America Samoa',\n 'AZ' => 'Arizona',\n 'AR' => 'Arkansas',\n 'CA' => 'California',\n 'CO' => 'Colorado',\n 'CT' => 'Connecticut',\n 'DE' => 'Delaware',\n 'DC' => 'District of Columbia',\n 'FM' => 'Micronesia1',\n 'FL' => 'Florida',\n 'GA' => 'Georgia',\n 'GU' => 'Guam',\n 'HI' => 'Hawaii',\n 'ID' => 'Idaho',\n 'IL' => 'Illinois',\n 'IN' => 'Indiana',\n 'IA' => 'Iowa',\n 'KS' => 'Kansas',\n 'KY' => 'Kentucky',\n 'LA' => 'Louisiana',\n 'ME' => 'Maine',\n 'MH' => 'Islands1',\n 'MD' => 'Maryland',\n 'MA' => 'Massachusetts',\n 'MI' => 'Michigan',\n 'MN' => 'Minnesota',\n 'MS' => 'Mississippi',\n 'MO' => 'Missouri',\n 'MT' => 'Montana',\n 'NE' => 'Nebraska',\n 'NV' => 'Nevada',\n 'NH' => 'New Hampshire',\n 'NJ' => 'New Jersey',\n 'NM' => 'New Mexico',\n 'NY' => 'New York',\n 'NC' => 'North Carolina',\n 'ND' => 'North Dakota',\n 'OH' => 'Ohio',\n 'OK' => 'Oklahoma',\n 'OR' => 'Oregon',\n 'PW' => 'Palau',\n 'PA' => 'Pennsylvania',\n 'PR' => 'Puerto Rico',\n 'RI' => 'Rhode Island',\n 'SC' => 'South Carolina',\n 'SD' => 'South Dakota',\n 'TN' => 'Tennessee',\n 'TX' => 'Texas',\n 'UT' => 'Utah',\n 'VT' => 'Vermont',\n 'VI' => 'Virgin Island',\n 'VA' => 'Virginia',\n 'WA' => 'Washington',\n 'WV' => 'West Virginia',\n 'WI' => 'Wisconsin',\n 'WY' => 'Wyoming'\n }\n code = if flag\n state.key(state_code).present? ? state.key(state_code) : state_code\n else\n state[state_code.upcase].present? ? state[state_code] : state_code\n end\n return code \n end",
"def city\n @city\n end",
"def city(city_name)\n\t\tfind_city = -> city {\n\t\t\tcity.name == city_name\n\t\t}\n\t\t@zomato.cities.find(&find_city)\n\tend",
"def set_city\n @state = State.find(params[:state]).decorate rescue nil\n @city = City.find(params[:state] + '/' + params[:id]).decorate rescue nil\n raise ActionController::RoutingError.new('Not Found') if (@city.nil?)\n end",
"def get_state_name_lib(country_code, state_code)\n country = Carmen::Country.coded(country_code)\n state_name = N/A\n if country\n state = country.subregions.coded(state_code)\n if state\n state_name = state.name\n end\n end\n state_name\n end",
"def city_scraper\n #Id,Id2,Geography,Target Geo Id,Target Geo Id2,Geographical Area,Geographical Area,,,Total area,Water area,Land area,Population,Housing units\n #0400000US01,01,Alabama,1600000US0107000,0107000,\"Alabama - PLACE - Birmingham city, Alabama\",\"Birmingham city, Alabama\",242820,111927,151.95,2.04,149.92,1619.7,746.6\n # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 \n @states = Array.new\n @cities = Array.new\n \n count = 0\n state_name = \"\"\n CSV.foreach(\"data/DEC_10_SF1_GCTPH1.ST13.csv\") do |row|\n count = count + 1\n city_name = \"\"\n population = 0\n elevation = 0\n lat_dir = \"\"\n lat_deg = 0\n lat_min = 0\n lat_sec = 0\n lon_dir = \"\"\n lon_deg = 0\n lon_min = 0\n lon_sec = 0\n if(row[2] == row[5])\n #its a state\n puts \"State: #{row[2]}\"\n state_name = row[2]\n state = State.new(:name => row[2])\n if(@states.length == 51)\n break\n end\n @states << state\n next\n end\n \n geographical_area = CSV.parse(row[6])\n city_name = geographical_area[0][0]\n if(city_name.match(/(part)/))\n #puts \"skipping #{city_name}\"\n next\n end\n \n city_name = city_name.downcase.gsub(/ city/,'').gsub(/ town/,'').gsub(/ village/,'').gsub(/ cdp/,'').gsub(/ borough/,'').gsub(/ municipality/,'').gsub(/ and/,'')\n city_name.strip.capitalize!\n city_name = city_name.capitalize\n #puts \"#{city_name} #{count}\"\n \n city_name_uri = URI.escape(city_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n state_name_uri = URI.escape(state_name, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))\n city_html = Net::HTTP.get(URI.parse(\"http://www.geonames.org/search.html?q=#{city_name_uri}%2C+#{state_name_uri}&country=US\"))\n #puts \"http://www.geonames.org/search.html?q=#{city_name}%2C+#{state_name}&country=US\"\n @city_doc = Hpricot(city_html)\n \n @city_doc.search(\"//table[@class='restable']\") do |table|\n tr_count = 0\n table.search(\"//tr\") do |tr|\n #puts \"in tr search\"\n tr_count = tr_count + 1\n if(tr_count < 3)\n next\n end\n #puts \"in tr search 2\"\n td_count = 0\n tr.search(\"//td\") do |td|\n #puts \"in td search\"\n td_count = td_count + 1\n if(td_count < 4)\n next\n end\n if(td_count == 4)\n td.search(\"//small\") do |small|\n #population = \"#{small.match(/\\\\d+/)[1]}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n #puts td_count\n #puts \"#{small.inner_html}\"\n #puts \"!!!!!!!!!!!!!!!!!!\"\n pop_elev = small.inner_html\n #population = \"#{pop_elev.match(/\\d+,\\d*/)}\".gsub(/,/,'')\n elevation = \"#{pop_elev.match(/\\d+m/)}\".gsub(/m/,'')\n #puts population\n #puts elevation\n end\n end\n if(td_count == 5)\n lat_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lat_deg = matches[0][0]\n lat_min = matches[1][0]\n lat_sec = matches[2][0]\n end\n if(td_count == 6)\n lon_dir = td.inner_html[0]\n matches = td.inner_html.scan(/(\\d+)/)\n lon_deg = matches[0][0]\n lon_min = matches[1][0]\n lon_sec = matches[2][0]\n end\n end\n break\n \n end \n end\n city = City.new(\n :name => city_name,\n :states_id => @states.length,\n :total_area => row[9],\n :water_area => row[10],\n :land_area => row[11],\n :population => row[7],\n :population_density => row[12],\n :lat_deg => lat_deg,\n :lat_min => lat_min,\n :lat_sec => lat_sec,\n :lat_dir => lat_dir,\n :lon_deg => lon_deg, \n :lon_min => lon_min,\n :lon_sec => lon_sec,\n :lon_dir => lon_dir,\n :elevation => elevation)\n \n @cities << city\n if(count % 10 == 0)\n puts count\n end\n end\n \n @states.each do |state|\n state.save\n end\n \n @cities.each do |state|\n state.save\n end\n \n end",
"def country\n city.country\n end",
"def city_name\r\n self.city.name\r\n end",
"def city\r\n\t\t\t@city ||= json[\"cit\"].to_s.capitalize\r\n\t\tend",
"def office_state_province\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"stateProvince\")\n end",
"def office_state_province_code\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"stateProvinceCode\")\n end",
"def bystate(str)\n arr = str.to_s.delete(',').split(\"\\n\").sort\n answer = []\n lastState = ''\n lookup = [\n ['AZ','Arizona'],\n ['CA', 'California'],\n ['ID', 'Idaho'],\n ['IN', 'Indiana'], \n ['MA', 'Massachusetts'],\n ['OK', 'Oklahoma'], \n ['PA', 'Pennsylvania'],\n ['VA', 'Virginia']]\n lookup.each do |abbreviation, name|\n while arr.find { |e| /#{abbreviation}/ =~ e } \n foundString = arr.find { |e| (/#{abbreviation}/ =~ e)}\n foundReplaced = \"\\r\\n..... \" + foundString.gsub(/#{abbreviation}/, \"\") + name\n \n if lastState == ''\n answer.concat(Array.new(1, (name + foundReplaced)))\n elsif lastState == name\n answer.concat(Array.new(1, (foundReplaced)))\n else\n answer.concat(Array.new(1, (\"\\r\\n \" + name + \"\\r\\n..... \" + foundString.gsub(/#{abbreviation}/, name))))\n end\n arr = arr.reject{|i| i == foundString}\n lastState = name\n end\n end\n answer.join(\"\")\nend",
"def cities\n galleries.map do |gallery|\n gallery.city\n end\n #undefined method `city' for \"New York\":String\n end",
"def find_city(name)\n city get('city_search', :q => name)['city'][0]['geoname_id']\n end",
"def states\n [\n ['Alabama', 'AL'],\n ['Alaska', 'AK'],\n ['Arizona', 'AZ'],\n ['Arkansas', 'AR'],\n ['California', 'CA'],\n ['Colorado', 'CO'],\n ['Connecticut', 'CT'],\n ['Delaware', 'DE'],\n ['District of Columbia', 'DC'],\n ['Florida', 'FL'],\n ['Georgia', 'GA'],\n ['Hawaii', 'HI'],\n ['Idaho', 'ID'],\n ['Illinois', 'IL'],\n ['Indiana', 'IN'],\n ['Iowa', 'IA'],\n ['Kansas', 'KS'],\n ['Kentucky', 'KY'],\n ['Louisiana', 'LA'],\n ['Maine', 'ME'],\n ['Maryland', 'MD'],\n ['Massachusetts', 'MA'],\n ['Michigan', 'MI'],\n ['Minnesota', 'MN'],\n ['Mississippi', 'MS'],\n ['Missouri', 'MO'],\n ['Montana', 'MT'],\n ['Nebraska', 'NE'],\n ['Nevada', 'NV'],\n ['New Hampshire', 'NH'],\n ['New Jersey', 'NJ'],\n ['New Mexico', 'NM'],\n ['New York', 'NY'],\n ['North Carolina', 'NC'],\n ['North Dakota', 'ND'],\n ['Ohio', 'OH'],\n ['Oklahoma', 'OK'],\n ['Oregon', 'OR'],\n ['Pennsylvania', 'PA'],\n ['Puerto Rico', 'PR'],\n ['Rhode Island', 'RI'],\n ['South Carolina', 'SC'],\n ['South Dakota', 'SD'],\n ['Tennessee', 'TN'],\n ['Texas', 'TX'],\n ['Utah', 'UT'],\n ['Vermont', 'VT'],\n ['Virginia', 'VA'],\n ['Washington', 'WA'],\n ['West Virginia', 'WV'],\n ['Wisconsin', 'WI'],\n ['Wyoming', 'WY']\n ]\n end",
"def states #NOTE: This should return and array of name_desc_value structs. Fix asap.\r\n states = [\r\n [ \"Alabama\", \"AL\" ],\r\n [ \"Alaska\", \"AK\" ],\r\n [ \"Arizona\", \"AZ\" ],\r\n [ \"Arkansas\", \"AR\" ],\r\n [ \"California\", \"CA\" ],\r\n [ \"Colorado\", \"CO\" ],\r\n [ \"Connecticut\", \"CT\" ],\r\n [ \"Delaware\", \"DE\" ],\r\n [ \"Florida\", \"FL\" ],\r\n [ \"Georgia\", \"GA\" ],\r\n [ \"Hawaii\", \"HI\" ],\r\n [ \"Idaho\", \"ID\" ],\r\n [ \"Illinois\", \"IL\" ],\r\n [ \"Indiana\", \"IN\" ],\r\n [ \"Iowa\", \"IA\" ],\r\n [ \"Kansas\", \"KS\" ],\r\n [ \"Kentucky\", \"KY\" ],\r\n [ \"Louisiana\", \"LA\" ],\r\n [ \"Maine\", \"ME\" ],\r\n [ \"Maryland\", \"MD\" ],\r\n [ \"Massachusetts\", \"MA\" ],\r\n [ \"Michigan\", \"MI\" ],\r\n [ \"Minnesota\", \"MN\" ],\r\n [ \"Mississippi\", \"MS\" ],\r\n [ \"Missouri\", \"MO\" ],\r\n [ \"Montana\", \"MT\" ],\r\n [ \"Nebraska\", \"NE\" ],\r\n [ \"Nevada\", \"NV\" ],\r\n [ \"New Hampshire\", \"NH\" ],\r\n [ \"New Jersey\", \"NJ\" ],\r\n [ \"New Mexico\", \"NM\" ],\r\n [ \"New York\", \"NY\" ],\r\n [ \"North Carolina\", \"NC\" ],\r\n [ \"North Dakota\", \"ND\" ],\r\n [ \"Ohio\", \"OH\" ],\r\n [ \"Oklahoma\", \"OK\" ],\r\n [ \"Oregon\", \"OR\" ],\r\n [ \"Pennsylvania\", \"PA\" ],\r\n [ \"Rhode Island\", \"RI\" ],\r\n [ \"South Carolina\", \"SC\" ],\r\n [ \"South Dakota\", \"SD\" ],\r\n [ \"Tennessee\", \"TN\" ],\r\n [ \"Texas\", \"TX\" ],\r\n [ \"Utah\", \"UT\" ],\r\n [ \"Vermont\", \"VT\" ],\r\n [ \"Virginia\", \"VA\" ],\r\n [ \"Washington\", \"WA\" ],\r\n [ \"West Virginia\", \"WV\" ],\r\n [ \"Wisconsin\", \"WI\" ],\r\n [ \"Wyoming\", \"WY\" ]\r\n ]\r\n return states\r\n end",
"def get_country\n @single_city_data[\"sys\"][\"country\"]\n end",
"def cities_in_state\n cities = State.find(params[:id]).cities.order(name: :asc)\n\n render json: cities.to_json(), status: :ok\n end",
"def get_area_code(dial_book, city_name)\n # @type [String]\n area_code = ''\n\n # @type [String]\n normalized_city_name = normalize_city_name(city_name)\n\n dial_book.each_key do |city_name_dial|\n if normalize_city_name(city_name_dial) == normalized_city_name\n area_code = dial_book[city_name_dial]\n break\n end\n end\n\n area_code\nend",
"def city_name_search(city)\r\n\t\tcity_name = city\r\n\t\tunless city_name.nil?\r\n\t\t\tcity_name = \"San%20Jose\"\r\n\t\tend\r\n\t\t#replace white spaces.\r\n\t\tcity_name.gsub(\" \", \"%20\")\r\n\t\tapi_key = \"vr7UJMGlyK75TAnqbjZzLff4RzhNHEG2\" #Thao's key. Move this later to env section.\r\n\t\trsc_url = \"https://api.sandbox.amadeus.com/v1.2/points-of-interest/\"\r\n\t\trsc_url_api = \"yapq-search-text?apikey=#{api_key}\"\r\n\t\trsc_url_city = \"&city_name=#{city_name}\"\r\n\t\t#/v1.2/points-of-interest/yapq-search-text?apikey=vr7UJMGlyK75TAnqbjZzLff4RzhNHEG2&city_name=Boston\r\n\t\tget_url = \"#{rsc_url}#{rsc_url_api}#{rsc_url_city}\"\r\n\t\tresponse = Faraday.get get_url\r\n\tend",
"def get_city_names(dial_book) \n dial_book.keys\nend",
"def lookUp(name, city)\n \n if city.has_key?(name) == TRUE\n puts \"The city code is #{city[name]}\"\n \n else puts \"Sorry wrong city\" \n end\nend",
"def show \n @city_chars = @state.city_chars.find(:all, :order => 'start_char ASC')\n \n unless params[city_char_parameter]\n redirect_to(\n state_rewrite_url(\n create_rewrite_hash(@state.rewrite).merge({\n city_char_parameter => @city_chars.first.start_char.upcase\n })\n ), :status => :moved_permanently\n )\n return\n end\n \n unless @city_char = @city_chars.find{|cc| cc.start_char.upcase == params[city_char_parameter].to_s.upcase}\n raise ActiveRecord::RecordNotFound\n end\n \n @facebook_tags['og:type'] = 'state_province'\n @facebook_tags['og:url'] = state_rewrite_url(create_rewrite_hash(@state.rewrite))\n @facebook_tags['og:locality'] = @state.name\n @facebook_tags['og:region'] = @state.name\n \n @twitter_tags['twitter:url'] = state_rewrite_url(create_rewrite_hash(@state.rewrite))\n \n @page_header_tags_configurator.set_state(@state)\n end",
"def get_city_name(city_name)\n city_name.keys\nend",
"def by_state\n \tdata = City.where('state_id = ?', params[:state_id]).order(:name)\n \trespond_to do |format|\n \t\tformat.json {render :json => data, :status => 200}\n \tend\n end",
"def city_state_lookup(location, debug: false)\n city_state_lookup_request_xml = SerializeCityStateLookupRequest.call(location: location, login: login)\n request = build_request(api: :city_state_lookup, xml: city_state_lookup_request_xml, debug: debug)\n\n client.post(request).bind do |response|\n ParseCityStateLookupResponse.call(response: response, request: request)\n end\n end",
"def office_city\n self.dig_for_string(\"agentSummary\", \"office\", \"officeAddress\", \"city\")\n end",
"def state_province_selector\n $tracer.trace(format_method(__method__))\n\t tag = ToolTag.new(@tag.find.select.className(create_ats_regex_string(\"ats-usstate\")), format_method(__method__))\n return CommonSelector.new(tag)\n end",
"def lookup(city)\n puts $dial_book[city]\nend",
"def get_city_index(city)\n index = -1\n if city == 'Enumerable Canyon'\n index = 0\n elsif city == 'Monkey Patch City'\n index = 1\n elsif city == 'Duck Type Beach'\n index = 2\n elsif city == 'Matzburg'\n index = 3\n elsif city == 'Nil Town'\n index = 4\n elsif city == 'Hash Crossing'\n index = 5\n elsif city == 'Dynamic Palisades'\n index = 6\n end\n\n return nil if index == -1\n index\n end",
"def city_code\n @city_code.to_s\n end",
"def city\n data['City']\n end",
"def getPopulationCity(code)\n @parse.map{ |airport| \n if( airport[\"population\"] == code) \n return airport[\"name\"]\n end\n }\n end",
"def enter_city_pair\n\n end",
"def profile_home(city,state)\n if !city.blank?\n address = city.humanize\n if !state.blank?\n address << \", \" \n address << state.humanize\n end\n return address \n end \n end",
"def get_cities\n cities = {}\n doc = nil\n retry_if_exception do\n doc = Nokogiri::HTML( easy_curl(@host_url) )\n end\n return [] if not doc\n a_cities = doc.css(\"ul[class='s-dropdown afh-dd-city'] li a\")\n a_cities.each do |city|\n city_name = city.text\n city_code = city['href'].scan(/\\w+(?=\\/changecity)/).pop\n next if not city_code\n cities[city_code] = city_name\n end\n cities\nend",
"def city(city)\n x = @cities.select { |c| c.city == city }\n x[0]\n end",
"def city\n ::City.find_by(contabilium_id: self.IdCiudad)\n end",
"def getAreaCode(city_name, dial_book)\n \n areaCode = dial_book.select { |k, v| k == city_name }\n \n areaCode.select { |k, v| return v} # Return just the area code\n \nend",
"def city\n return @city\n end",
"def find_city(lat,lng)\n if Geocoder::Calculations.distance_between([lat,lng], [40.698390,-73.98843]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [40.76813,-73.96439]) < 20\n \"newyork\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76423,-122.47743]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [37.76912,-122.42593]) < 20\n \"sanfrancisco\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.85887,2.30965]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [48.86068,2.36389]) < 20\n \"paris\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [51.51,-0.13]) < 20\n \"london\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.57664,-46.69787]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [-23.55838,-46.64362]) < 20\n \"saopaulo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.64446,139.70695]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [35.70136,139.73991]) < 20\n \"tokyo\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.06901,-118.35904]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.07499,-118.28763]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [34.02663,-118.45998]) < 20\n \"losangeles\"\n elsif\n Geocoder::Calculations.distance_between([lat,lng], [50.07832,14.41619]) < 20\n \"prague\"\n else\n \"unknown\"\n end\n end",
"def get_area_code(cities, city_name)\n if !cities.key?(city_name)\n puts \"\\nInvalid city. Please try again.\"\n else\n puts \"\\n#{city_name} is #{cities[city_name]}\"\n end\nend",
"def test_state_and_country\n a = Address.find(1)\n assert_equal('AL', a.state_code)\n assert_equal('Alabama', a.state_name)\n assert_equal('United States', a.country_name)\n end",
"def current_city_text\n city = ChinaCity.get(self.city)\n city = ChinaCity.get(self.province) if %w(市辖区 县).include?(city)\n city\n end",
"def city(restrictions={state: [], zip_code: []})\n city = nil\n state = restrictions[:state].is_a?(Array) and !restrictions[:state].blank? ? restrictions[:state] : []\n zip_codes = restrictions[:zip_code].is_a?(Array) and !restrictions[:zip_code].blank? ? restrictions[:zip_code] : []\n\n unless @config[:location_db][:adapter].eql?(:none)\n city = find_location(state,zip_codes)[\"#{@config[:location_db][:column_mapping][:city]}\"]\n end\n\n city = Faker::Address.city if city.blank?\n\n city\n end"
] |
[
"0.78866184",
"0.7468075",
"0.7364859",
"0.7095594",
"0.70820695",
"0.69557536",
"0.69557536",
"0.694709",
"0.69435513",
"0.6941228",
"0.6898114",
"0.6890261",
"0.6890261",
"0.6845333",
"0.6845333",
"0.68107957",
"0.68089175",
"0.68089175",
"0.6795827",
"0.67792064",
"0.6767021",
"0.6767021",
"0.6764635",
"0.6764635",
"0.6764635",
"0.6764635",
"0.6726622",
"0.6715416",
"0.6706677",
"0.6687836",
"0.6655541",
"0.6648718",
"0.661122",
"0.65969557",
"0.65556794",
"0.6555418",
"0.6554557",
"0.6552747",
"0.6546873",
"0.65271384",
"0.64941764",
"0.649235",
"0.64822745",
"0.6448833",
"0.64464873",
"0.6434032",
"0.64245313",
"0.63979185",
"0.63820344",
"0.6377754",
"0.6373773",
"0.63732374",
"0.6369068",
"0.6366256",
"0.63636154",
"0.63633364",
"0.6344024",
"0.6330103",
"0.63298374",
"0.62973577",
"0.62957895",
"0.62803984",
"0.62790257",
"0.62765664",
"0.6271901",
"0.6250118",
"0.62476075",
"0.6240075",
"0.62382",
"0.6230358",
"0.622204",
"0.6220239",
"0.6197896",
"0.61948925",
"0.6194167",
"0.61935073",
"0.6192036",
"0.6187896",
"0.6183392",
"0.6179621",
"0.61783403",
"0.6153987",
"0.61534935",
"0.6151489",
"0.6146303",
"0.61413723",
"0.61403817",
"0.6131915",
"0.6130873",
"0.6125261",
"0.61223525",
"0.612154",
"0.6120979",
"0.6111819",
"0.6105552",
"0.6104101",
"0.6100329",
"0.60921913",
"0.60871446",
"0.60815376"
] |
0.75993824
|
1
|
Performs a GET request to _uri_ using _request_headers_, and yields the response as the status code, headers and body.
|
def get(uri, request_headers)
raise NotImplementedError
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get(uri, request_headers)\n request('get', uri, request_headers) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def get(uri, request_headers)\n request('get', uri, request_headers)\n end",
"def http_get(request_uri)\n response = http.request(Net::HTTP::Get.new(request_uri))\n yield response.body if response.code == \"200\"\n end",
"def perform_get(uri, request_headers: {}, chunk_size: 1024 * 1024 * 5)\n status_code, header_hash, socket = get_status_headers_and_body_socket(uri, request_headers: request_headers)\n body_bytes_received = 0\n \n # Yield the status and headers once with an empty response\n # so that the client can bail out of the request even before the body\n # starts to arrive\n return body_bytes_received unless yield(status_code, header_hash, '')\n \n # We are using read_nonblock, and it allows a buffer to be passed in.\n # The advantage of passing a buffer is that the same Ruby string is\n # reused for all the reads, and only the string contents gets reallocated.\n # We can reduce GC pressure this way.\n body_buf = ''\n \n # ...and then just read the body, without any buffering, using a non-blocking read\n while !socket.eof?\n begin\n data = socket.read_nonblock(chunk_size, body_buf)\n body_bytes_received += data.bytesize\n continue_reading = yield(status_code, header_hash, body_buf)\n return body_bytes_received unless continue_reading \n rescue IO::WaitReadable\n IO.select([socket], [], SOCKET_TIMEOUT)\n retry\n end\n end\n \n body_bytes_received\n ensure\n socket.close if socket && !socket.closed?\n end",
"def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end",
"def make_get_request url, headers = []\n make_request url, headers: headers\n end",
"def get(url, headers)\n conn = create_connection_object(url)\n\n http = conn.get(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end",
"def get(url, headers: {}, params: {}, options: {}, &block)\n url = encode_query(url, params)\n\n request = Net::HTTP::Get.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options, &block)\n end",
"def get(options={}, &block)\n response = http.get_uri(options, &block)\n handle_response(response)\n end",
"def http_get(path, headers = { })\n clear_response\n path = process_path(path)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def get(url, headers = {})\n do_request Net::HTTP::Get, url, headers\n end",
"def get(url, headers={})\n do_request(\"get\", url, nil, headers)\n end",
"def get(url, headers = {})\n request(:get, url, headers)\n end",
"def get(url, headers = {})\n request(:get, url, headers)\n end",
"def do_get(uri = \"\", query: {}, headers: {}, n_http: false)\n url_query = query.size > 0 ? \"?\" + query.map {|k, v| \"#{k}=#{v}\"}.join(\"&\") : \"\"\n Timeout.timeout(@timeout) do\n con = n_http ? @connection_net_http : @connection\n con.get do |req|\n req.url(uri + url_query)\n headers.map { |key, value| req.headers[key] = value }\n end\n end\n rescue Faraday::Error::ConnectionFailed, Timeout::Error => e\n msg = \"Error trying to send a GET to #{uri + url_query} \"\\\n \"the reason: #{e.message}\"\n $lxca_log.error(HEADER_MESSAGE + ' do_get', msg)\n Faraday::Response.new\n end",
"def send_get(url)\r\n result = @client.get(self.target_uri(url))\r\n raise \"Invalid status #{result.http_status} from server #{@host}:#{@port}\" if(result.http_status != '200')\r\n if block_given?\r\n yield(result.http_body)\r\n else\r\n result.http_body\r\n end\r\n end",
"def get(url, headers={})\n RestClient.get url, headers\n end",
"def get\n begin\n response = Net::HTTP.get_response(URI.parse(uri))\n rescue => e\n raise InterfaceError, \"#{e.message}\\n\\n#{e.backtrace}\"\n end\n response.code == '200' ? response.body : response_error(response)\n end",
"def get(path, headers = {})\n request = Net::HTTP::Get.new(path)\n @default_headers.merge(headers).each do |key, value|\n request[key] = value\n end\n @http.request(request)\n end",
"def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def get_with_binary_response(relative_path, request_headers, request_parameters, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n\n request_headers = [] if request_headers.nil?\n add_generic_headers('GET', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.get(uri, request_headers) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = process_binary_response(status_code, content, headers, context) do |h, c|\n yield h, c\n end\n end\n throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)\n end",
"def GET(uri, type, range, credentials, &block)\n get = Net::HTTP::Get.new(uri.path)\n get[\"Accept\"] = type\n get[\"Range\"] = \"bytes=#{range.min}-#{range.max}\" unless range.nil?\n\n response = submit(get, uri, credentials, &block)\n\n case response\n when Net::HTTPOK, Net::HTTPPartialContent\n return response.body\n when Net::HTTPNoContent\n return nil\n when Net::HTTPMovedTemporarily\n new_conn = redirect(response[\"location\"])\n raise ConnectionRedirectError.new(new_conn)\n else\n report_error(\"GET\", uri.path, response, credentials)\n end\n end",
"def get(uri, query = {}, &block) \n request(:get, uri, query, &block)\n end",
"def make_request\n\t\t\tresponse = nil\n\t\t\tif self.respond_to? :headers\n\t\t\t\turi = URI.parse(request_string)\n\n\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\thttp.set_debug_output $stderr if @test_request\n\t\t\t\thttp.use_ssl = true\n\t\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n\t\t\t\trequest = Net::HTTP::Get.new(uri.request_uri)\n\t\t\t\theaders.each do |k,v|\n\t\t\t\t\trequest[k] = v\n\t\t\t\tend\n\n\t\t\t\tresponse = http.request(request).body\n\t\t\telse\n\t\t\t\t$stderr.puts(request_string) if @test_request\n\n\t\t\t\tresponse = open(request_string)\n\t\t\tend\n\n\t\t\treturn process_response(response)\n\t\tend",
"def get(relative_path, request_headers, request_parameters, response_type, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n\n request_headers = [] if request_headers.nil?\n add_generic_headers('GET', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.get(uri, request_headers) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = content.read.force_encoding('UTF-8')\n end\n process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)\n end",
"def http_get(url, headers = nil)\r\n if @debug\r\n puts \"Url:\"\r\n puts url\r\n puts \"Headers:\"\r\n puts headers\r\n puts \"Method: get\"\r\n end\r\n return headers ? HTTParty.get(url, :headers => headers) : HTTParty.get(url)\r\n end",
"def get(uri)\r\n request(Net::HTTP::Get.new(uri)) \r\n end",
"def get(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n Response.new(@client[url].get headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def request(verb, uri, query={})\n verb == :get ? query_get = query : query_post = query\n uri = connection.build_url(uri, query_get)\n\n response = connection.run_request(verb, uri, query_post, headers) do |request|\n yield request if block_given?\n end\n response = Response.new(response)\n \n case response.status\n when 301, 302, 303, 307\n request(verb, response.headers['location'], query)\n when 200..299, 300..399\n response\n end\n end",
"def get(resource, headers = {})\n prepare_request(:get, resource, nil, headers)\n end",
"def send_get(uri)\n _send_request('GET', uri, nil)\n end",
"def get(request_uri)\n url = base_uri + request_uri\n logger.debug(\"GET #{url}\")\n\n uri = URI.parse(url)\n\n response = http_request(:get, uri)\n\n parse_body(response)\n end",
"def request(uri, request = nil)\n # TODO: Possibly use SAX parsing for large request bodies (?)\n\n request ||= Net::HTTP::Get.new(uri.request_uri)\n\n connection.request(uri, sign(uri, request)) do |response|\n case response\n when Net::HTTPNotFound\n return nil\n\n when Net::HTTPSuccess\n if block_given?\n yield(response)\n else\n return response.body\n end\n\n else\n raise Error.from_xml(response.body)\n\n end\n end\n end",
"def make_get_request(uri)\n response = Net::HTTP.get_response(uri)\n response.is_a?(Net::HTTPSuccess) ? response.body : nil\nend",
"def get_wrapper(url, headers)\n [parse_response(RestClient.get(resource + url, headers)), true]\n rescue RestClient::Exception => e\n [parse_error(e.response), false]\n end",
"def http_get(uri)\n req = Net::HTTP::Get.new uri\n @additional_headers.keys.each do |k|\n req[k] = @additional_headers[k]\n end\n #STDERR.puts \"Trace: #{caller[0]} req: #{req.inspect}\"\n temp_uri = URI.parse(self.polldaddy)\n body=''\n Net::HTTP.start(temp_uri.hostname, temp_uri.port, proxyhost, proxyport) do |http|\n http.request(req) do |res|\n res.read_body do |segment|\n body << segment # this will retrieve the parts if the response is chunked\n end\n end\n end\n body#.tap{|t| STDERR.puts \"Trace: #{caller[1]}: returning #{t}\"}\n end",
"def get(path, headers = {})\n process :get, path, headers\n end",
"def get(uri, options = {})\n build_response(request.get(uri, build_request_options({:input => options.to_params})))\n end",
"def get(path, query = { }, headers = { })\n clear_response\n path = process_path(path, query)\n @success_code = 200\n @response = http.get(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def make_request(url,headers,query)\n c = HTTPClient.new\n c.get_content(url,query,headers)\nend",
"def http_get(url)\n response = client.get(url, follow_redirect: true)\n\n raise HTTPClient::BadResponseError, response.reason unless HTTP::Status.successful?(response.status)\n\n response\n end",
"def headers_fetch(uri)\n # Fetch the result at that location\n if (loc = ensure_uri(uri)).relative?\n headers_fetch(relative_uri(uri))\n else\n response = Net::HTTP.start(loc.host, loc.port) do |http|\n headers = @cookie ? {'Cookie' => @cookie} : {}\n http.head(loc.path, headers)\n end\n end\n end",
"def get(url, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.get(url, http_options, &block)\n else\n RestClient.get(url, http_options)\n end\n end",
"def do_get(uri = \"\", query = {})\n url_query = query.size > 0 ? \"?\" + query.map {|k, v| \"#{k}=#{v}\"}.join(\"&\") : \"\"\n @connection.get(uri + url_query)\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase connection\", \"Error trying to send a GET to #{uri + url_query}\"\n Faraday::Response.new\n end",
"def get(uri, opts = {}, &block)\n initialize_socket(uri, opts)\n HttpStream::get(uri, opts, &block)\n rescue IOError => e\n raise e unless @intentional_termination\n end",
"def get(path, options={}, &block)\n uri = URI.join(@endpoint, path)\n headers = options.delete(:headers)\n query = options.delete(:query)\n\n if query\n uri.query = URI.encode_www_form(query)\n end\n\n request = Net::HTTP::Get.new uri.request_uri, headers\n @http.request request, &block\n end",
"def get(uri, *args)\n response = Faraday.new(request_options(args)) do |faraday|\n faraday.headers['Content-Type'] = 'application/json-patch+json'\n faraday.adapter Faraday.default_adapter\n faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?\n end.get(uri)\n\n raise Error, response.body unless response.status == 200\n\n parse_api_response(response.body).merge('headers' => response.headers)\n end",
"def get_status_headers_and_body_socket(uri, request_headers: {})\n uri = URI(uri.to_s)\n raise ('Only plain HTTP is supported (%s)' % uri) unless uri.scheme == 'http'\n raise \"Unknown host\" unless uri.host\n \n # Some reading on what might be usable here:\n # http://www.mikeperham.com/2009/03/15/socket-timeouts-in-ruby/\n socket = TCPSocket.open(uri.host, uri.port || 80)\n socket.write(\"GET #{uri.request_uri} HTTP/1.1\\r\\n\")\n \n # AWS signs the Host: header, so introducing port 80 into it \"just because\" is a bad idea\n if uri.port && uri.port.to_i != 80\n socket.write(\"Host: %s:%d\\r\\n\" % [uri.host, uri.port])\n else\n socket.write(\"Host: %s\\r\\n\" % uri.host)\n end\n socket.write(\"Connection: close\\r\\n\") # Do not request keepalive\n \n # Write all the request headers\n request_headers.each { |k, v| socket.write(\"%s: %s\\r\\n\" % [k,v]) }\n \n # Terminate the request\n socket.write(\"\\r\\n\")\n \n # First read anything that might be related to the headers, up to and including \\r\\n\\r\\n.\n # Once that one is encountered - stash the remaining part we have read, and parse the headers\n headers_buf = read_ahead_headers(socket)\n status_code, header_hash = parse_status_and_headers(headers_buf)\n [status_code, header_hash, socket]\n end",
"def perform_request url\n response = self.class.get(url)\n raise NotFound.new(\"404 Not Found\") if response.respond_to?(:code) && response.not_found?\n raise InvalidAPIResponse.new(response[\"status\"][\"message\"]) if response.is_a?(Hash) && response[\"status\"]\n\n response\n end",
"def get\n response = Net::HTTP.get_response(endpoint_uri)\n case response\n when Net::HTTPSuccess, Net::HTTPRedirection\n return response.body\n else \n raise response.body\n end\n end",
"def get(parameters = {}, headers = {}, &block)\n build_get(parameters, headers, &block).invoke\n end",
"def fetch\n endpoint = URI(uri)\n Net::HTTP.get(endpoint)\n rescue *@errors => e\n pp e\n nil\n end",
"def request_with_headers(url, headers = {}, https = false)\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = https\n\n request = Net::HTTP::Get.new(uri.path)\n\n headers.each do |header|\n request[header[0].to_s] = header[1]\n end\n\n response = http.request(request)\n\n return response\n end",
"def get_response(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n http.start do |http|\n resp, body = http.get([uri.path, uri.query].join('?'))\n end\n end",
"def get(params = {})\n response = prepare_response(make_url(params).open('User-Agent' => USER_AGENT).read)\n check_error(response)\n return parse_response(response)\n rescue OpenURI::HTTPError => e\n check_error(prepare_response(e.io.read))\n raise\n end",
"def request_async uri\n options = Kronk.config[:no_uri_options] ? @options : options_for_uri(uri)\n\n rdir = options[:follow_redirects]\n\n handler = Proc.new do |resp, err|\n next yield(resp, err) if err\n\n resp.parser = options[:parser] if options[:parser]\n resp.stringify_opts = options\n\n if resp.redirect? && (rdir == true || Fixnum === rdir && rdir > 0)\n Cmd.verbose \"Following redirect to #{resp.location}\"\n\n rdir = rdir - 1 if Fixnum === rdir\n opts = options_for_uri resp.location\n resp.follow_redirect_async(opts, &handler)\n\n else\n @responses = [resp]\n @response = resp\n @diff = nil\n\n yield resp if block_given?\n\n resp\n end\n end\n\n if IO === uri\n Cmd.verbose \"Reading IO #{uri}\"\n Response.from_async_io(uri, &handler)\n\n elsif StringIO === uri\n Cmd.verbose \"Reading IO #{uri}\"\n handler.call Response.new(uri)\n\n elsif File.file? uri.to_s\n Cmd.verbose \"Reading file: #{uri}\\n\"\n handler.call Response.read_file(uri)\n\n else\n req = Request.new uri, options\n Cmd.verbose \"Retrieving URL: #{req.uri}\\n\"\n conn = req.retrieve_async(&handler)\n conn.callback{ Kronk.history << uri }\n end\n\n rescue => e\n yield nil, e\n end",
"def make_get_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Get.new(@uri.request_uri)\n @response = http.request(request)\n end\n @response.body\n end",
"def get *args, &block\n response = self.class.get *args, &block\n raise WebserverError, response.code unless response.code == 200\n response\n end",
"def get *args, &block\n response = self.class.get *args, &block\n raise WebserverError, response.code unless response.code == 200\n response\n end",
"def hnl_http_get(uri, include_http_response = false)\n # setup the request\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n\n # make the request\n response = http.request(request)\n\n # and return the result\n return [JSON.parse(response.body)[\"response\"], response] if include_http_response\n JSON.parse(response.body)[\"response\"]\n end",
"def get(headers = {}, path = '', parameters = {})\n full_path = [path, URI.encode_www_form(parameters)].join(PARAM_STARTER)\n uri = URI.parse(\"#{@url}#{full_path}\")\n request = Net::HTTP::Get.new(uri.request_uri)\n request.body = nil\n send_request(uri, request, headers)\n end",
"def get(request)\n do_request(request) { |client| client.http_get }\n end",
"def process_request(uri)\n request = Net::HTTP::Get.new(uri)\n connection = Net::HTTP.start(uri.hostname, uri.port, use_ssl: https?(uri))\n\n connection\n .request(request)\n .tap(&method(:validate_response!))\n end",
"def get(url, query = nil, headers = nil)\n headers = headers ? @headers.merge(headers) : @headers\n #Log.t(\"GET: #{url}\\n#{query.inspect}\\n#{headers.inspect}\")\n content = @client.get_content(URI.join(@base, url), query, headers) rescue ''\n Nokogiri::HTML(content)\n end",
"def get\n @response = Net::HTTP.get_response(URI(@url))\n end",
"def get(uri, params = {})\n send_request(uri, :get, params)\n end",
"def get(url, headers = {})\n http :get, \"#{url}.json\", headers\n end",
"def make_request(uri)\n request = Net::HTTP::Get.new uri\n\n request[\"Authorization\"] = \"Basic #{credentials}\"\n request[\"Content-Type\"] = \"application/json\"\n request[\"Accept\"] = \"application/json\"\n\n Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|\n http.request request\n end\n end",
"def get(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpGetWithEntity, url, options, &block\n end",
"def get(path, options={})\n response = request(path, :get, options)\n validate response\n parsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def fetch\n def get_response url\n self.status = response = nil\n begin\n uri = URI.parse(url)\n if uri.host &&\n uri.port &&\n (http = Net::HTTP.new(uri.host, uri.port)) &&\n (request = Net::HTTP::Get.new(uri.request_uri))\n response = http.request(request)\n self.status = response.code.to_i\n else # Invalid URL\n self.status = 400\n end\n rescue Exception => e\n # If the server doesn't want to talk, we assume that the URL is okay, at least\n case e\n when Errno::ECONNRESET\n self.status = 401\n else\n self.status = -1 # Undifferentiated error during fetch, possibly a parsing problem\n end\n end\n response\n end\n\n # get_response records the status of the last HTTP access in self.status\n tried = {}\n next_try = url\n until tried[next_try]\n tried[next_try] = true\n response = get_response next_try\n case status\n when 200\n return response.body\n when 301, 302 # Redirection\n next_try = response.header[\"location\"]\n when 401 # Unauthorized\n next_try.sub! /^https/, 'http'\n end\n end\n end",
"def http_get(uri:, additional_headers: {}, debug: false)\n return nil if uri.blank?\n\n HTTParty.get(uri, options(additional_headers: additional_headers,\n debug: debug))\n rescue URI::InvalidURIError => e\n handle_uri_failure(method: \"BaseService.http_get #{e.message}\",\n uri: uri)\n nil\n rescue HTTParty::Error => e\n handle_http_failure(method: \"BaseService.http_get #{e.message}\",\n http_response: nil)\n nil\n end",
"def request(method, uri, request_headers, body = nil)\n request_headers = convert_from_sdk_headers(request_headers)\n request_id = SecureRandom.uuid\n content_type = request_headers[CONTENT_TYPE]\n\n info = { headers: request_headers, content_type: content_type }\n info[:body] = body unless body.nil?\n\n log_request(request_id, method.upcase, uri, info)\n\n start_time = Time.now\n begin\n response_headers = nil\n response_status_code = nil\n response_content_type = nil\n response_body = ''\n\n if body.is_a? Ingenico::Connect::SDK::MultipartFormDataObject\n multipart_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|\n response_headers = headers\n response_status_code = status_code\n response_content_type = r_content_type\n unless binary_content_type? response_content_type\n response_body = r_body.read.force_encoding('UTF-8')\n r_body = StringIO.new(response_body)\n end\n\n yield status_code, headers, r_body\n end\n else\n raw_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|\n response_headers = headers\n response_status_code = status_code\n response_content_type = r_content_type\n unless binary_content_type? response_content_type\n response_body = r_body.read.force_encoding('UTF-8')\n r_body = StringIO.new(response_body)\n end\n\n yield status_code, headers, r_body\n end\n end\n\n log_response(request_id, response_status_code, start_time,\n headers: response_headers, body: response_body,\n content_type: response_content_type)\n rescue HTTPClient::TimeoutError => e\n log_error(request_id, start_time, e)\n raise Ingenico::Connect::SDK::CommunicationException, e\n rescue HTTPClient::KeepAliveDisconnected, HTTPClient::RetryableResponse => e # retry these?\n log_error(request_id, start_time, e)\n raise Ingenico::Connect::SDK::CommunicationException, e\n rescue StandardError => e\n log_error(request_id, start_time, e)\n raise Ingenico::Connect::SDK::CommunicationException, e\n end\n end",
"def get(uri)\n begin\n @connection.get(uri)\n rescue *CONNECTION_ERRORS => e\n warn \"#{uri}: #{e}\"\n Faraday::Response.new\n end\n end",
"def get(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('get')\n end\n end",
"def get(path)\n req = Net::HTTP::Get.new(@base_url + path)\n response = handle_request(req)\n response.each {|k,v| puts \"#{k}: #{v}\"}\n response\n end",
"def get(uri)\n response = Unirest.get uri\n response.body\n end",
"def get(query_url,\r\n headers: {})\r\n HttpRequest.new(HttpMethodEnum::GET,\r\n query_url,\r\n headers: headers)\r\n end",
"def fetch(path, &block)\n path = path[1..-1] if path[0] == '/'\n path = '/'+ URI.encode_www_form_component(path)\n get(path) do |request, http|\n http.request(request) do |resp|\n case resp\n when Net::HTTPSuccess\n if block_given? then\n resp.read_body(&block)\n else\n resp.read_body do |chunk|\n $stdout.write chunk\n end\n end\n else\n showHttpError(request, resp)\n end\n end\n nil\n end\n end",
"def get_response(url = nil, headers = nil)\n options = {:headers => headers}.merge(ssl_option)\n Typhoeus::Request.get(url || default_url, options)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get(uri)\n req = requestor(Net::HTTP::Get.new(build_uri(uri)))\n parse req.body\n end",
"def get(request_opts = {})\n store_result(http(request_opts).get(resolved_path))\n end",
"def get(params = {})\n request! do\n api[url.path + to_query(params)].get(API_HEADERS)\n end\n end",
"def get_response_from(uri)\n http = Net::HTTP.new(uri.host, uri.port)\n http.read_timeout = http.open_timeout = SimpliTest.config[:settings][\"HTTP_TIMEOUT\"] || 3\n request = Net::HTTP::Get.new(uri.request_uri)\n if uri.scheme == 'https'\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n http.request(request)\n end",
"def do_get url\n\t\turi = URI.parse(url)\n\t\tNet::HTTP.get_response(uri)\n\tend",
"def retrieve_http(options)\n file_size = options.fetch(:file_size)\n headers = options.fetch(:headers)\n url = options.fetch(:url)\n retrieved = 0\n\n request = Typhoeus::Request.new(url.to_s, method: :get, headers: headers)\n request.on_headers do |response|\n raise DownloadError.new(\"#{self.class}: Failed to download #{url}: Status Code: #{response.code}\", response) unless response.code == 200\n end\n request.on_body do |chunk|\n retrieved += chunk.bytesize\n yield(chunk, retrieved, file_size)\n end\n request.run\n end",
"def request(verb, uri, options = {})\n client = HTTP::Client.new(headers: headers)\n client = client.via(*proxy) if proxy\n handle_response(client.request(verb, uri, options))\n end",
"def send_get_request(path, options = {})\n # we try to send the request. if it fails due to auth, we need the returned scope\n # thats why we first try to do it without auth, then reusing the scope from the response\n response = self.class.get(path, options)\n # need auth\n case (response.code)\n when 200\n # just continue\n when 401\n authenticate(response)\n response = self.class.get(path, options)\n else\n end\n unless response.code == 200\n throw \"Could not finish request, status #{response.code}\"\n end\n response\n end",
"def fetch_http(uri, last_modified = nil, head = false, depth = 0)\n fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get\n # beginning of change\n response = request uri, fetch_type, last_modified do |req|\n headers.each {|k, v| req.add_field(k, v) } if headers\n end\n # end of change\n\n case response\n when Net::HTTPOK, Net::HTTPNotModified then\n response.uri = uri if response.respond_to? :uri\n head ? response : response.body\n when Net::HTTPMovedPermanently, Net::HTTPFound, Net::HTTPSeeOther,\n Net::HTTPTemporaryRedirect then\n raise FetchError.new(\"too many redirects\", uri) if depth > 10\n\n location = URI.parse response[\"Location\"]\n\n if https?(uri) && !https?(location)\n raise FetchError.new(\"redirecting to non-https resource: #{location}\", uri)\n end\n\n fetch_http(location, last_modified, head, depth + 1)\n else\n raise FetchError.new(\"bad response #{response.message} #{response.code}\", uri)\n end\n end",
"def get path, header={}, body_string_or_hash=\"\"\n env.http 'GET', path, header, body_string_or_hash\n end",
"def get(path, options = {}, &block)\n execute('GET', path, options, nil, &block)\n end",
"def api_get(uri)\n res = HTTParty.get(uri)\n [res.code, res.body]\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get\n url = prefix + \"get\"\n return response(url)\n end",
"def get(name, &block)\n request(uri(name), &block)\n end",
"def get\n check_response( @httpcli.get(@endpoint) )\n end",
"def get\n subclass(:Response).new connection.get do |req|\n req.url uri\n end\n end",
"def do_request()\n uri = URI.parse(API_BASE_URL + build_request_path())\n response = Net::HTTP.get_response(uri)\n response.body\n end"
] |
[
"0.8128832",
"0.7283325",
"0.7272881",
"0.7233882",
"0.6944454",
"0.68937844",
"0.67199636",
"0.67113477",
"0.66166735",
"0.6604979",
"0.6603799",
"0.6600014",
"0.65047157",
"0.65047157",
"0.6456498",
"0.6437246",
"0.6387827",
"0.63743985",
"0.63442594",
"0.6340831",
"0.6326154",
"0.6318423",
"0.6315326",
"0.6301816",
"0.6294295",
"0.6287224",
"0.62662345",
"0.6262337",
"0.62122184",
"0.6206066",
"0.6205571",
"0.619366",
"0.61899143",
"0.6181025",
"0.6174509",
"0.61356777",
"0.612866",
"0.61197156",
"0.6118667",
"0.6106055",
"0.60967714",
"0.6090249",
"0.6086666",
"0.60782504",
"0.60386264",
"0.6034903",
"0.60321075",
"0.60243547",
"0.60096216",
"0.60034317",
"0.6000963",
"0.5994978",
"0.5983699",
"0.5978348",
"0.59718305",
"0.59609646",
"0.5957651",
"0.5953567",
"0.59268564",
"0.5924514",
"0.5911054",
"0.5906401",
"0.59045345",
"0.5881594",
"0.5859966",
"0.58588755",
"0.58082885",
"0.5804444",
"0.5799809",
"0.57991004",
"0.57975525",
"0.57860947",
"0.5782245",
"0.5778714",
"0.5778474",
"0.5777249",
"0.57705283",
"0.57690924",
"0.5766854",
"0.57382226",
"0.57251847",
"0.57251847",
"0.5719619",
"0.5718646",
"0.5717405",
"0.5716444",
"0.57103586",
"0.57032126",
"0.5701009",
"0.569332",
"0.56908256",
"0.5688323",
"0.5678214",
"0.567672",
"0.5667355",
"0.5667355",
"0.5663435",
"0.56622714",
"0.56556135",
"0.56541234"
] |
0.67944586
|
6
|
Performs a DELETE request to _uri_ using _request_headers_, and yields the response as the status code, headers and body.
|
def delete(uri, request_headers)
raise NotImplementedError
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete(uri, request_headers)\n request('delete', uri, request_headers) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def delete(uri, request_headers)\n request('delete', uri, request_headers)\n end",
"def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end",
"def delete(url, headers)\n conn = create_connection_object(url)\n\n http = conn.delete(:head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end",
"def delete_request(uri)\n http = build_http(uri)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers())\n return http.request(request)\n end",
"def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def delete(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('delete')\n end\n end",
"def delete(uri = nil)\n requestor(Net::HTTP::Delete.new(build_uri(uri)))\n end",
"def http_delete(path, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def delete(uri)\r\n request(Net::HTTP::Delete.new(uri)) \r\n end",
"def do_delete(uri = '')\n build_request(:delete, uri)\n end",
"def delete(uri, options = {})\n build_response(request.delete(uri, build_request_options({:input => options.to_params})))\n end",
"def delete(path, options={})\n url = build_url path, options\n headers = options[:headers] || {}\n # nothing returned in response body for DELETE\n Response.new(@client[url].delete headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def make_delete_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Delete.new(@uri.request_uri)\n @response = http.request(request)\n end\n @response.body\n end",
"def delete_request(uri, token = nil, manage_errors = true)\n request = Net::HTTP::Delete.new(uri.request_uri, initheader = build_headers(token))\n return do_request(uri, request, manage_errors)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete(url, headers: {}, params: {}, options: {})\n url = encode_query(url, params)\n\n request = Net::HTTP::Delete.new(url, @default_headers.merge(headers))\n\n execute_streaming(request, options: options)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete(relative_path, request_headers, request_parameters, response_type, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n add_generic_headers('DELETE', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.delete(uri, request_headers) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = content.read.force_encoding('UTF-8')\n end\n process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)\n end",
"def DELETE(uri, credentials)\n delete = Net::HTTP::Delete.new(uri.path)\n\n response = submit(delete, uri, credentials)\n\n case response\n when Net::HTTPNoContent\n # Success, carry on...\n true\n else\n report_error(\"DELETE\", uri.path, response, credentials)\n end\n end",
"def delete(url, headers={})\n RestClient.delete url, headers\n end",
"def delete(url, headers = {})\n request(:delete, url, headers)\n end",
"def delete(url, headers = {})\n request(:delete, url, headers)\n end",
"def delete(uri, params = {})\n send_request(uri, :delete, params)\n end",
"def delete_with_binary_response(relative_path, request_headers, request_parameters, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n add_generic_headers('DELETE', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.delete(uri, request_headers) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = process_binary_response(status_code, content, headers, context) do |h, c|\n yield h, c\n end\n end\n throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)\n end",
"def send_delete_request(path)\n response = self.class.delete(path)\n # need auth\n case (response.code)\n when 200\n # just continue\n when 401\n authenticate(response)\n response = self.class.delete(path)\n else\n end\n if response.code != 200 && response.code != 202\n throw \"Could not finish request, status #{response.code}\"\n end\n response\n end",
"def delete(request)\n do_request(request) { |client| client.http_delete }\n end",
"def delete(uri, parameters)\n response = Unirest.delete uri, parameters: parameters\n response.body\n end",
"def delete(headers = {}, path = '', parameters = {})\n full_path = [path, URI.encode_www_form(parameters)].join(PARAM_STARTER)\n uri = URI.parse(\"#{@url}#{full_path}\")\n request = Net::HTTP::Delete.new(uri.request_uri)\n request.body = nil\n send_request(uri, request, headers)\n end",
"def delete(status, headers, env)\n [204, headers, destroy]\n end",
"def delete options={}, &block\n handle_exceptions do\n Chimps.log.info(\"DELETE #{url}\")\n Response.new(super(options, &block))\n end\n end",
"def delete(url, headers={})\n begin\n request(:delete, url, nil, headers)\n rescue VeritableError => e\n if not e.respond_to? :http_code or not e.http_code == \"404 Resource Not Found\"\n raise e\n end\n end\n end",
"def delete(url, options = {}, &block)\n run! Request.new(url, :delete, options.slice(:headers, :params, :payload), &block)\n end",
"def delete(path, headers: {}, query: {})\n (headers, query) = preprocess(headers, query)\n respond_with super(path, headers: headers, query: query)\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete(url, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.delete(url, http_options, &block)\n else\n RestClient.delete(url, http_options)\n end\n end",
"def delete(url = nil, params = nil, headers = nil)\n run_request(:delete, url, nil, headers) { |request|\n # Original line from Faraday::Connection#delete method\n # request.params.update(params) if params\n\n # Monkey patch\n request.body = params if params\n\n yield(request) if block_given?\n }\n end",
"def delete(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'DELETE', params)\n\n log \"DELETE \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :delete, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end",
"def delete(path, headers = {})\n request(:delete, path, nil, merge_default_headers(headers))\n end",
"def delete(url, headers={}, redirect_limit=max_redirects)\n # parse the URL\n uri = URI.parse(url)\n\n debug(\"DELETE #{uri} #{headers.inspect}\")\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Delete.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n when Net::HTTPRedirection then\n raise Net::HTTPFatalError.new(\"Too many redirects\", response) if redirect_limit == 0\n delete_raw(response['location'], headers, redirect_limit - 1)\n else\n KineticHttpResponse.new(response)\n end\n rescue StandardError => e\n KineticHttpResponse.new(e)\n end\n end",
"def delete(path, params = {}, env = {}, &block)\n env[:request_method] = \"DELETE\"\n mock_request(path, params, env, &block)\n end",
"def delete(uri, opts = {}, &block)\n initialize_socket(uri, opts)\n HttpStream::delete(uri, opts, &block)\n rescue IOError => e\n raise e unless @intentional_termination\n end",
"def delete(url, options = {}, &block)\n options = treat_params_as_query(options)\n request HttpDeleteWithEntity, url, options, &block\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def delete(path, headers: {}, query: {})\n headers = @default_headers.merge(headers)\n\n response = @http.delete(full_path(path, query: query), headers)\n ensure_success!(response)\n parse_response(response)\n end",
"def delete(request)\n _request(request) { |client, options| client.delete options }\n end",
"def delete(path, options={})\n response = request(path, :delete, options)\n validate response\n parsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def delete(url, headers={}, http_options={})\n # determine the http options\n redirect_limit = http_options[:max_redirects] || max_redirects\n gateway_retries = http_options[:gateway_retry_limit] || gateway_retry_limit\n gateway_delay = http_options[:gateway_retry_delay] || gateway_retry_delay\n\n # parse the URL\n uri = URI.parse(url)\n\n # build the http object\n http = build_http(uri)\n # build the request\n request = Net::HTTP::Delete.new(uri.request_uri, headers)\n\n # send the request\n begin\n response = http.request(request)\n # handle the response\n case response\n # handle 302\n when Net::HTTPRedirection then\n if redirect_limit == -1\n HttpResponse.new(response)\n elsif redirect_limit == 0\n raise Net::HTTPFatalError.new(\"Too many redirects\", response)\n else\n delete(response['location'], headers, http_options.merge({\n :max_redirects => redirect_limit - 1\n }))\n end\n # handle 502, 503, 504\n when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut then\n if gateway_retries == -1\n HttpResponse.new(response)\n elsif gateway_retries == 0\n Kinetic::Platform.logger.info(\"HTTP response: #{response.code} #{response.message}\")\n raise Net::HTTPFatalError.new(\"#{response.code} #{response.message}\", response)\n else\n Kinetic::Platform.logger.info(\"#{response.code} #{response.message}, retrying in #{gateway_delay} seconds\")\n sleep(gateway_delay)\n delete(url, headers, http_options.merge({\n :gateway_retry_limit => gateway_retries - 1\n }))\n end\n when Net::HTTPUnknownResponse, NilClass then\n Kinetic::Platform.logger.info(\"HTTP response code: 0\")\n e = Net::HTTPFatalError.new(\"Unknown response from server\", response)\n HttpResponse.new(e)\n else\n Kinetic::Platform.logger.info(\"HTTP response code: #{response.code}\")\n HttpResponse.new(response)\n end\n rescue Net::HTTPBadResponse => e\n Kinetic::Platform.logger.info(\"HTTP bad response: #{e.inspect}\")\n HttpResponse.new(e)\n rescue StandardError => e\n Kinetic::Platform.logger.info(\"HTTP error: #{e.inspect}\")\n HttpResponse.new(e)\n end\n end",
"def delete(url, headers: {}, options: {})\n request_without_payload(:delete, url, headers, options)\n end",
"def delete\n ensure_client && ensure_uri\n response = @client.rest_delete(@data['uri'], { 'Accept-Language' => 'en_US' }, @api_version)\n @client.response_handler(response)\n true\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end",
"def delete(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::DELETE,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end",
"def delete(path, headers = {})\n with_auth { request(:delete, path, nil, build_request_headers(headers, :delete, build_uri(path))) }\n end",
"def delete(path)\n uri = build_uri(path)\n\n request = Net::HTTP::Delete.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end",
"def delete(uri, options = {})\n execute(uri, :delete, options)\n end",
"def delete(path, query = { }, headers = {})\n clear_response\n path = process_path(path, query)\n @success_code = 204\n @response = http.delete(path, headers)\n parse_response? ? parsed_response : response.body\n end",
"def delete(url, resource_name, options = {})\n build_response(resource_name) do\n connection.delete do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end",
"def delete(path, headers = {})\n process :delete, path, headers\n end",
"def delete(path, options = {})\n request = Net::HTTP::Delete.new(request_uri(path))\n make_request(request, options.merge(no_callbacks: true))\n end",
"def delete(parameters = {}, headers = {}, &block)\n build_delete(parameters, headers, &block).invoke\n end",
"def delete(request_opts = {})\n store_result(http(request_opts).delete(resolved_path))\n end",
"def assert_deletes(api_path, &block)\n headers = DEFAULT_HEADERS\n stub_request(:delete, uri(api_path))\n .with(headers: headers)\n .to_return(body: dummy_response, status: 200)\n yield block\n assert_requested(:delete, uri(api_path), headers: headers)\n WebMock.reset!\n end",
"def delete(name)\n request(uri = uri(name), Net::HTTP::Delete.new(uri.request_uri))\n end",
"def delete_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_stream_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def delete_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_stream_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def delete_endpoint request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_endpoint_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def delete_data_stream request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_data_stream_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def delete\n request(:delete)\n end",
"def delete(path, opts = {}, &block)\n request(:delete, path, opts, &block)\n end",
"def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def delete_via_redirect(path, parameters = {}, headers = {})\n delete path, parameters, headers\n follow_redirect! while redirect?\n status\n end",
"def delete(url)\n do_request(\"delete\", url)\n end",
"def delete request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, _body, query_string_params = transcode_delete_request request_pb\n response = @client_stub.make_delete_request(\n uri: uri,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def delete request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, _body, query_string_params = transcode_delete_request request_pb\n response = @client_stub.make_delete_request(\n uri: uri,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def delete(request, adapter = nil)\n request = Request.new :url => request if request.kind_of? String\n \n with request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.delete request\n end\n end",
"def delete request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def delete_request(client)\n begin\n client.delete\n rescue OpenSSL::SSL::SSLError => e\n raise \"SSLError occurred when calling REST service; #{e}\"\n rescue RestClient::Exception => e # if the request failed, RestClient will throw an error. We want to retrieve that error and the response within\n puts \"RestClient::Exception hit when calling REST service\"\n puts e\n puts e.response\n return e.response\n rescue => e\n raise \"Unexpected error occurred when calling REST service; #{e}\"\n end\n end",
"def delete(path, params = {}, request_options = {})\n request(:delete, path, params)\n end",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def delete(request)\n request.method = :delete\n request.call\n end",
"def delete(path, request_options = {}, resource_options = {})\n response(:delete, resource(resource_options)[path], request_options)\n end",
"def delete(request, adapter = nil)\n request = Request.new :url => request if request.kind_of? String\n\n with_adapter :delete, request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.delete request\n end\n end",
"def destroy\n @http_request.destroy\n respond_to do |format|\n format.html { redirect_to http_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @http_request.destroy\n respond_to do |format|\n format.html { redirect_to http_requests_url }\n format.json { head :no_content }\n end\n end",
"def delete(*args)\n request(:delete, *args)\n end",
"def delete(resource_path, headers: {}, prefix: API_PREFIX)\n request(method: :delete, resource_path: resource_path, headers: headers, prefix: prefix)\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end",
"def delete request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/regions/#{request_pb.region}/routers/#{request_pb.router}\"\n\n query_string_params = {}\n query_string_params[\"requestId\"] = request_pb.request_id.to_s if request_pb.request_id && request_pb.request_id != \"\"\n\n response = @client_stub.make_delete_request(\n uri: uri,\n params: query_string_params,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end",
"def delete_statefile request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_statefile_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end"
] |
[
"0.84675074",
"0.75101465",
"0.72348315",
"0.72215664",
"0.71293646",
"0.70354813",
"0.70114565",
"0.69902164",
"0.69068295",
"0.6894834",
"0.68893176",
"0.68887526",
"0.6877825",
"0.6868859",
"0.67808986",
"0.6766005",
"0.67232084",
"0.67232084",
"0.67203397",
"0.67067575",
"0.67067575",
"0.67026967",
"0.6681817",
"0.66576946",
"0.6649387",
"0.6649387",
"0.6638506",
"0.6630123",
"0.66155946",
"0.65935236",
"0.65409887",
"0.6537164",
"0.65107197",
"0.65088385",
"0.64756054",
"0.6474933",
"0.6431652",
"0.6421477",
"0.6414967",
"0.63948387",
"0.63947827",
"0.6389744",
"0.6372596",
"0.63658047",
"0.6340009",
"0.6321652",
"0.6301425",
"0.6299081",
"0.62876296",
"0.62762165",
"0.62679744",
"0.62669533",
"0.6266824",
"0.6262041",
"0.62561655",
"0.62307173",
"0.6222602",
"0.62180746",
"0.6202073",
"0.6200392",
"0.6157139",
"0.6110902",
"0.6088961",
"0.6088359",
"0.60794616",
"0.6072877",
"0.6060646",
"0.6050208",
"0.6050208",
"0.60412645",
"0.6024896",
"0.6016493",
"0.59996545",
"0.59994316",
"0.59981394",
"0.599037",
"0.5975923",
"0.59660685",
"0.5959293",
"0.5959293",
"0.59591806",
"0.5955063",
"0.5947285",
"0.59227824",
"0.58830464",
"0.58744574",
"0.5850226",
"0.58397734",
"0.58342475",
"0.5825019",
"0.5825019",
"0.5823838",
"0.58218586",
"0.57975227",
"0.57975227",
"0.57975227",
"0.57975227",
"0.57860714",
"0.5781446",
"0.57742745"
] |
0.7330648
|
2
|
Performs a POST request to _uri_ using _request_headers_ and _body_, and yields the response as the status code, headers and body.
|
def post(uri, request_headers, body)
raise NotImplementedError
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def post(uri, request_headers, body)\n request('post', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def post(uri, request_headers, body)\n request('post', uri, request_headers, body)\n end",
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def request(post_body, headers)\n request = Net::HTTP::Post.new(endpoint_uri.path, headers)\n authenticate(request) if username\n request.body = post_body\n response = @client.request(request)\n { status: response.code.to_i, body: response.body, content_type: response.content_type }\n end",
"def request(post_body, headers)\n response = @client.post(endpoint, post_body, headers)\n return { :status => response.status, :body => response.content, :content_type => response.contenttype }\n end",
"def post_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Post.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end",
"def post(url, body, headers)\n conn = create_connection_object(url)\n\n http = conn.post(:body => body,\n :head => add_authorization_to_header(headers, @auth))\n\n action = proc do\n response = Response.new(http.response.parsed, http)#.response.raw)\n yield response if block_given?\n end\n\n http.callback &action\n http.errback &action \n end",
"def post(url, headers, body)\n request(:post, url, headers, body)\n end",
"def post\n RestClient.post(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def post(uri, body)\n RestClient.post(uri, body, :content_type => 'text/xml;charset=\"utf-8\"', :accept => 'text/xml') do |_response, _request, result|\n auth_string = result.header['www-authenticate']\n auth_data = Hash[*auth_string.scan(/(?<k>[a-z]+)=\"(?<v>[^\"]*)\"/).flatten]\n\n request_authorization = gen_auth_digest('POST', uri, body, auth_data)\n\n RestClient.post(uri, body, :'Authorization' => request_authorization, :content_type => 'text/xml;charset=\"utf-8\"', :accept => 'text/xml') do |response, _request, _result|\n return response\n end\n end\n end",
"def do_post(uri = \"\", body = \"\")\n @connection.post do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Error trying to send a POST to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_post\", \"Request sent: #{body}\"\n Faraday::Response.new\n end",
"def post(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end",
"def post_response(url, body, headers = {})\n logger.debug \"POST (response) #{url}\"\n uri = normalize_url(url)\n\n req = Net::HTTP::Post.new(uri.request_uri)\n headers.each {|k,v| req.add_field k, v}\n assign_body(req, body)\n\n http = authenticate_request(uri, req)\n response = http.request(req)\n logger.debug \"POSTED (#{response.code}) #{url}\"\n response\n end",
"def post url, body, headers = {}\n http_request(url, Net::HTTP::Post, body, headers)\n end",
"def submit(request, uri, credentials, &block)\n\n credentials.authenticate(request) unless credentials.nil?\n\n response = nil\n begin\n @http.request(uri, request) do |r|\n r.read_body(&block)\n response = r\n end\n response\n rescue InternalHTTPError => e\n raise ConnectionError.new(e)\n end\n end",
"def post(body)\n body = body.to_s\n request = Net::HTTP::Post.new(@uri.path)\n request.content_length = body.size\n request.body = body\n request['Content-Type'] = @http_content_type\n\n # Server will disconnect @http_inactivity seconds after receiving previous client\n # response, unless it receives the post we are now sending.\n # Net::HTTP defaults to 60 seconds, which would not always be appropriate.\n # In particular, the default would not work if @http_wait is > 60!\n if @initial_post == true\n read_timeout = @http_connect\n @initial_post = false\n elsif @previous_send == Time.at(0)\n read_timeout = @http_inactivity + 1\n else\n read_timeout = (Time.now - @previous_send).ceil + @http_inactivity\n end\n\n opts = {\n :read_timeout => read_timeout, # wait this long for a response\n :use_ssl => @use_ssl # Set SSL/no SSL\n }\n opts[:verify_mode] = @verify_mode if @use_ssl # Allow caller to defeat certificate verify\n\n Jabber::debuglog(\"#{@protocol_name} REQUEST (#{@pending_requests + 1}/#{@http_requests}) with timeout #{read_timeout}:\\n#{request.body}\")\n response = @http.start(@uri.host, @uri.port, nil, nil, nil, nil, opts ) { |http|\n http.request(request)\n }\n Jabber::debuglog(\"#{@protocol_name} RESPONSE (#{@pending_requests + 1}/#{@http_requests}): #{response.class}\\n#{response.body}\")\n\n unless response.kind_of? Net::HTTPSuccess\n # Unfortunately, HTTPResponses aren't exceptions\n # TODO: rescue'ing code should be able to distinguish\n raise Net::HTTPBadResponse, \"#{response.class}\"\n end\n\n body = REXML::Document.new(response.body).root\n if body.name != 'body' and body.namespace != 'http://jabber.org/protocol/httpbind'\n raise REXML::ParseException.new('Malformed body')\n end\n body\n end",
"def post\n @response_body = make_request(\"#{api_url}#{endpoint}\", request_body.to_json)\n puts \"GLIMR POST: #{endpoint} - #{request_body.to_json}\" if ENV.key?('GLIMR_API_DEBUG')\n end",
"def post(uri, query = {}, &block)\n request(:post, uri, query, &block)\n end",
"def do_post(uri = '', body = '', multipart = false)\n build_request(:post, uri, body, multipart)\n end",
"def post(url, body, headers = {})\n do_request Net::HTTP::Post, url, headers, body\n end",
"def post(url, body, headers: {}, params: {}, options: {}, &block)\n raise ArgumentError, \"'post' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Post.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'post' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options, &block)\n end",
"def post(path, body, headers: nil)\n request_url = request_url_for_path(path)\n\n Rails.logger.info(\"Url: #{request_url}, body: #{body.to_json}, headers: #{headers}\")\n return HTTParty.post(request_url, body: body.to_json, headers: headers.merge({ 'Content-Type': 'application/json' }).stringify_keys)\n end",
"def request(method, uri, request_headers, body = nil)\n request_headers = convert_from_sdk_headers(request_headers)\n request_id = SecureRandom.uuid\n content_type = request_headers[CONTENT_TYPE]\n\n info = { headers: request_headers, content_type: content_type }\n info[:body] = body unless body.nil?\n\n log_request(request_id, method.upcase, uri, info)\n\n start_time = Time.now\n begin\n response_headers = nil\n response_status_code = nil\n response_content_type = nil\n response_body = ''\n\n if body.is_a? Ingenico::Connect::SDK::MultipartFormDataObject\n multipart_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|\n response_headers = headers\n response_status_code = status_code\n response_content_type = r_content_type\n unless binary_content_type? response_content_type\n response_body = r_body.read.force_encoding('UTF-8')\n r_body = StringIO.new(response_body)\n end\n\n yield status_code, headers, r_body\n end\n else\n raw_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|\n response_headers = headers\n response_status_code = status_code\n response_content_type = r_content_type\n unless binary_content_type? response_content_type\n response_body = r_body.read.force_encoding('UTF-8')\n r_body = StringIO.new(response_body)\n end\n\n yield status_code, headers, r_body\n end\n end\n\n log_response(request_id, response_status_code, start_time,\n headers: response_headers, body: response_body,\n content_type: response_content_type)\n rescue HTTPClient::TimeoutError => e\n log_error(request_id, start_time, e)\n raise Ingenico::Connect::SDK::CommunicationException, e\n rescue HTTPClient::KeepAliveDisconnected, HTTPClient::RetryableResponse => e # retry these?\n log_error(request_id, start_time, e)\n raise Ingenico::Connect::SDK::CommunicationException, e\n rescue StandardError => e\n log_error(request_id, start_time, e)\n raise Ingenico::Connect::SDK::CommunicationException, e\n end\n end",
"def post(body = '', headers = {}, parameters = {}, &block)\n build_post(body, headers, parameters, &block).invoke\n end",
"def post(uri, body, opts = {}, &block)\n initialize_socket(uri, opts)\n HttpStream::post(uri, body, opts, &block)\n rescue IOError => e\n raise e unless @intentional_termination\n end",
"def post(path, headers, body, &callback)\n request('POST', path, headers, body, &callback)\n end",
"def post_request(uri, body, token)\n http = build_http(uri)\n request = Net::HTTP::Post.new(uri.request_uri, initheader = build_headers(token))\n request.body = body\n return http.request(request)\t\t\n end",
"def send!\n request = Net::HTTP::Post.new(uri.path, headers)\n request.body = @body\n request.content_type = @@content_type\n response = Net::HTTP.start(uri.host, uri.port) do |http|\n http.request(request)\n end\n ok?(response)\n end",
"def post(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('post')\n end\n end",
"def run_request(method, url, body, headers)\n if !METHODS.include?(method)\n raise ArgumentError, \"unknown http method: #{method}\"\n end\n\n # Resets temp_proxy\n @temp_proxy = proxy_for_request(url)\n\n request = build_request(method) do |req|\n req.options = req.options.merge(:proxy => @temp_proxy)\n req.url(url) if url\n req.headers.update(headers) if headers\n req.body = body if body\n yield(req) if block_given?\n end\n\n builder.build_response(self, request)\n end",
"def _api_call(uri, body=nil)\n # Create the request\n res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http|\n req = Net::HTTP::Post.new(uri)\n req['Content-Type'] = 'application/json'\n req.body = body\n\n http.request(req)\n end\n\n case res\n when Net::HTTPSuccess\n puts \"Crossbar::HTTP - Response Body: #{res.body}\" if self.verbose\n return JSON.parse(res.body, {:symbolize_names => true})\n else\n raise \"Crossbar::HTTP - Code: #{res.code}, Error: #{res.message}\"\n end\n end",
"def request(\n method,\n path,\n headers = nil,\n body = nil,\n api_version = EasyPost::InternalUtilities::Constants::API_VERSION\n )\n # Remove leading slash from path.\n path = path[1..] if path[0] == '/'\n\n uri = URI.parse(\"#{@base_url}/#{api_version}/#{path}\")\n headers = @config[:headers].merge(headers || {})\n serialized_body = JSON.dump(EasyPost::InternalUtilities.objects_to_ids(body)) if body\n open_timeout = @config[:open_timeout]\n read_timeout = @config[:read_timeout]\n request_timestamp = Time.now\n request_uuid = SecureRandom.uuid\n\n if EasyPost::Hooks.any_subscribers?(:request)\n request_context = EasyPost::Hooks::RequestContext.new(\n method: method,\n path: uri.to_s,\n headers: headers,\n request_body: body,\n request_timestamp: request_timestamp,\n request_uuid: request_uuid,\n )\n EasyPost::Hooks.notify(:request, request_context)\n end\n\n # Execute the request, return the response.\n\n response = if @custom_client_exec\n @custom_client_exec.call(method, uri, headers, open_timeout, read_timeout, serialized_body)\n else\n default_request_execute(method, uri, headers, open_timeout, read_timeout, serialized_body)\n end\n response_timestamp = Time.now\n\n if EasyPost::Hooks.any_subscribers?(:response)\n response_context = {\n http_status: nil,\n method: method,\n path: uri.to_s,\n headers: nil,\n response_body: nil,\n request_timestamp: request_timestamp,\n response_timestamp: response_timestamp,\n client_response_object: response,\n request_uuid: request_uuid,\n }\n\n # If using a custom HTTP client, the user will have to infer these from the raw\n # client_response_object attribute\n if response.is_a?(Net::HTTPResponse)\n response_body = begin\n JSON.parse(response.body)\n rescue JSON::ParseError\n response.body\n end\n response_context.merge!(\n {\n http_status: response.code.to_i,\n headers: response.each_header.to_h,\n response_body: response_body,\n },\n )\n end\n\n EasyPost::Hooks.notify(:response, EasyPost::Hooks::ResponseContext.new(**response_context))\n end\n\n response\n end",
"def post(path, body: {}, headers: nil)\n response = conn.post do |req|\n build_request(req, path: path, body: body, headers: headers)\n end\n puts response.body\n response.body unless response.blank?\n end",
"def do_post(request, out_stream)\n raise Error.new(\"HTTPS over a proxy is not supported.\") if !@use_http and @proxy_host\n\n reset_response_data()\n\n request.basic_auth(@user_name, @api_key)\n request.add_field('User-Agent', @user_agent)\n\n while true\n begin\n return exec_request(request, out_stream)\n rescue Error => err\n if (err.getCode() == '502' or err.getCode() == '503') and @retry_count > @retry\n @retry += 1\n sleep(@retry * 0.1)\n else\n raise\n end\n end\n end\n end",
"def post(url, body = nil, headers = nil)\n faraday_response = faraday.post(url, body, headers) do\n _1.options[:proxy] = random_proxy\n end\n Response.new(faraday_response)\n end",
"def send_request(body)\n status = false\n data = false\n code = \"\"\n\n Net::HTTP.start(\"#{@subdomain}.#{@options[:host]}\", 80) do |http|\n req = Net::HTTP::Post.new(@options[:pathname])\n\n req.content_type = 'application/atom+xml'\n req.content_length = body.size - 20 # Currently a bug with the Pomegranate API I believe\n req.body = body\n\n if authentication_set?\n req.ntlm_auth(@username, @options[:domain], @password)\n end\n\n response = http.request(req)\n\n code = response.code\n\n if code == \"201\"\n data = parse_xml(response.body)\n else\n break\n end\n end\n\n {:code => code, :data => data}\n end",
"def make_post_request(route:, headers: nil, body: nil)\n post route, params: body, headers: headers\nend",
"def post(body)\n request = Net::HTTP::Post.new(bind_uri)\n request.body = body\n request.content_length = request.body.size\n request[\"Content-Type\"] = \"text/xml; charset=utf-8\"\n\n Jabber.debug(\"Sending POST request - #{body.strip}\")\n\n response = Net::HTTP.new(domain, port).start { |http| http.request(request) }\n\n Jabber.debug(\"Receiving POST response - #{response.code}: #{response.body.inspect}\")\n\n unless response.is_a?(Net::HTTPSuccess)\n raise Net::HTTPBadResponse, \"Net::HTTPSuccess expected, but #{response.class} was received\"\n end\n\n response\n end",
"def post(uri, params = {})\n send_request(uri, :post, params)\n end",
"def post(auth, body)\n status = nil\n headers = { 'Content-Type' => 'application/json' }\n\n begin\n payload = JSON.generate body\n request = Net::HTTP::Post.new(@path, headers)\n request['authorization'] = auth\n\n response = nil\n\n if self.class.stub\n status = 200\n logger.debug \"stubbed request to #{@path}: auth = #{auth}, payload = #{payload}\"\n else\n res = @http.request(request, payload)\n status = res.code.to_i\n if status < 500\n response = JSON.parse(res.body)\n else\n response = res.body\n end\n end\n rescue Exception => e\n logger.error e.message\n e.backtrace.each { |line| logger.error line }\n status = -1\n response = \"Connection error: #{e}\"\n end\n\n Response.new status, response\n end",
"def post(path, body = '', headers = {})\n headers = { 'Content-Type' => 'application/json' }.merge(headers)\n request(:post, path, body, merge_default_headers(headers))\n end",
"def post(relative_path, request_headers, request_parameters, request_body, response_type, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n\n body = nil\n if request_body.is_a? MultipartFormDataObject\n request_headers.push(RequestHeader.new('Content-Type', request_body.content_type))\n body = request_body\n elsif request_body.is_a? MultipartFormDataRequest\n multipart = request_body.to_multipart_form_data_object\n request_headers.push(RequestHeader.new('Content-Type', multipart.content_type))\n body = multipart\n elsif !request_body.nil?\n request_headers.push(RequestHeader.new('Content-Type', 'application/json'))\n body = @marshaller.marshal(request_body)\n else\n # Set the content-type, even though there is no body, to prevent the httpClient from\n # adding a content-type header after authentication has been generated.\n request_headers.push(RequestHeader.new('Content-Type', 'text/plain'))\n end\n\n add_generic_headers('POST', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.post(uri, request_headers, body) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = content.read.force_encoding('UTF-8')\n end\n process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)\n end",
"def post(path, body = '', headers = {})\n with_auth { request(:post, path, body.to_s, build_request_headers(headers, :post, build_uri(path))) }\n end",
"def post(_endpoint_path, _body, _extra_headers = {})\n response\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts JSON.pretty_generate(result)\n result\nend",
"def post_request(uri, params)\n begin\n \n # Request the data and return it\n doc = Nokogiri::HTML(open(uri, params.merge(:allow_redirections => :safe)))\n return doc.text\n #\n # Rescue in the case of a 404 or a redirect\n # \n # TODO - this should really log into the task?\n rescue OpenURI::HTTPError => e \n TapirLogger.instance.log \"Error, couldn't open #{uri} with error #{e}\"\n rescue Timeout::Error => e\n TapirLogger.instance.log \"Timeout! #{e}\"\n rescue OpenSSL::SSL::SSLError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue Net::HTTPBadResponse => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue EOFError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue SocketError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue SystemCallError => e\n TapirLogger.instance.log \"Unable to connect: #{e}\"\n rescue ArgumentError => e\n TapirLogger.instance.log \"Argument Error #{e}\"\n rescue Encoding::InvalidByteSequenceError => e\n TapirLogger.instance.log \"Encoding error: #{e}\"\n rescue Encoding::UndefinedConversionError => e\n TapirLogger.instance.log \"Encoding error: #{e}\"\n #rescue RuntimeError => e\n # TapirLogger.instance.log \"Unknown Error: #{e}\"\n end\n # Default to sending nothing \n false\n end",
"def run_request(method, url, body, headers); end",
"def request(method, uri, options = {})\n opts = @default_options.merge(options)\n headers = opts.headers\n proxy = opts.proxy\n \n if opts.form\n body = URI.encode_www_form(opts.form)\n headers['Content-Type'] ||= 'application/x-www-form-urlencoded'\n end\n\n request = Request.new method, uri, headers, proxy, body\n\n opts.callbacks[:request].each { |c| c.call(request) }\n response = perform request\n opts.callbacks[:response].each { |c| c.call(response) }\n\n format_response method, response, opts.response\n end",
"def post(path, body = nil, options = {})\n request = Net::HTTP::Post.new(request_uri(path))\n request.body = body\n make_request(request, options)\n end",
"def post(path, options={})\n response = request(path, :post, options)\n validate response\n parsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def perform_awsdirect_request(uri, body)\n res = nil\n req = get_abs_post_request(uri)\n\n if req\n req.body = body\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.read_timeout = 120\n\n puts \"sending request body:\"\n puts body\n puts \"to uri: #{uri}\"\n puts\n\n res = http.request(req)\n puts \"response code: #{res.code}\" unless res.nil?\n puts \"response body: #{res.body}\" unless res.nil?\n puts\n else\n puts \"Unable to complete the specified ABS request\"\n end\n\n res\n end",
"def request(endpoint, body, content_type, retry_limit: 0)\n http_rate_limiter.shift if rate_limit_enabled?\n\n request_options = {\n read_timeout: read_timeout,\n idempotent: true,\n retry_limit: retry_limit.to_i,\n expects: [200, 201],\n method: :post,\n body: body,\n headers: { 'Content-Type' => content_type }\n }\n\n begin\n retries ||= 0\n http_connection(endpoint).request(request_options)\n rescue Excon::Error::Timeout => e\n retries += 1\n retry if retries <= retry_limit\n raise e\n end\n end",
"def post()\n return @http.request(@req)\n end",
"def perform_get(uri, request_headers: {}, chunk_size: 1024 * 1024 * 5)\n status_code, header_hash, socket = get_status_headers_and_body_socket(uri, request_headers: request_headers)\n body_bytes_received = 0\n \n # Yield the status and headers once with an empty response\n # so that the client can bail out of the request even before the body\n # starts to arrive\n return body_bytes_received unless yield(status_code, header_hash, '')\n \n # We are using read_nonblock, and it allows a buffer to be passed in.\n # The advantage of passing a buffer is that the same Ruby string is\n # reused for all the reads, and only the string contents gets reallocated.\n # We can reduce GC pressure this way.\n body_buf = ''\n \n # ...and then just read the body, without any buffering, using a non-blocking read\n while !socket.eof?\n begin\n data = socket.read_nonblock(chunk_size, body_buf)\n body_bytes_received += data.bytesize\n continue_reading = yield(status_code, header_hash, body_buf)\n return body_bytes_received unless continue_reading \n rescue IO::WaitReadable\n IO.select([socket], [], SOCKET_TIMEOUT)\n retry\n end\n end\n \n body_bytes_received\n ensure\n socket.close if socket && !socket.closed?\n end",
"def post path_and_params, post_body\n start if not @pid\n @lock.synchronize do\n @last_use = Time.new.to_f\n\n # Make request to xtractr\n Net::HTTP.start('localhost', @port) do |http|\n http.request_post \"/#{path_and_params}\", post_body do |response|\n headers = {}\n response.each_header {|name,val| headers[name] = val}\n return response.code.to_i, headers, response.body\n end\n end\n end\n end",
"def http_post_request(req_body)\n\t\t#New http request (uri library deals with port and host on its own when parsing the url)\n\t\thttp = Net::HTTP.new(@uri.host, @uri.port)\n\t\t#Original api url get does not need SSL (bad solution but any other way would not seem to work properly)\n\t\tif caller[1][/`.*'/].nil? or not (caller[1][/`.*'/][1..-2] == \"initialize\")\n\t\t\t#Https security stuff (don't need security when getting initial api url)\n\t\t\thttp.use_ssl = true\n\t\t\thttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\t\tend\n\t\t#Post request using uri\n\t\trequest = Net::HTTP::Post.new(@uri.request_uri)\n\t\t#Sets request to use basic authentication using the given username and api_key\n\t\trequest.basic_auth(@username, @api_key)\n\t\t#Sets request to use json content type\n\t\trequest.content_type = \"application/json\"\n\t\t#Sets request body to json file passed\n\t\trequest.body = req_body\n\t\t#Executes setup request and returns body\n\t\thttp.request(request).body\n\tend",
"def post(path, form_data)\n req = Net::HTTP::Post.new(path)\n req.set_form_data(form_data)\n request(req){|res| yield res }\n end",
"def send\n http = Net::HTTP.new(@uri.host, @uri.port)\n http.read_timeout = @http_timeout\n\n # Output request XML if debug flag is set\n if debug == true\n logger.info \"Request URL: #{@uri.to_s}\"\n logger.info \"Request Timeout: #{@http_timeout}\"\n logger.info \"Request headers: #{headers}\"\n logger.info \"Request body: #{body}\"\n end\n\n if @uri.port == 443\n http.use_ssl = true\n http.ssl_timeout = @http_timeout\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n post = Net::HTTP::Post.new(@uri.path, headers)\n post.body = body\n post.content_type = 'text/xml'\n\n response = http.start { |http| http.request(post) }\n\n if debug == true\n logger.info \"Response: #{response}\"\n end\n\n if response.is_a? Net::HTTPInternalServerError\n logger.info \"#{response.class.to_s}: #{response.message}\"\n return Hashie::Mash.new({})\n end\n\n @response = Hashie::Mash.new(Response.new(self, response))\n end",
"def post_data(body)\r\n raise ConfigError, 'no json_records' if body.empty?\r\n # Create REST request header\r\n header = get_header(body.bytesize)\r\n # Post REST request \r\n response = RestClient.post(@uri, body, header)\r\n\r\n return response\r\n end",
"def dropbox_post(url, headers: {}, payload: nil)\n raise ArgumentError, \"missing keyword: payload\" unless payload\n\n require \"net/https\"\n require \"uri\"\n\n headers = {\n \"Authorization\" => \"Bearer #{config[\"token\"]}\",\n \"Content-Type\" => \"application/json\"\n }.merge(headers)\n\n unless payload.nil? || payload.is_a?(String)\n payload = JSON.generate(payload)\n end\n\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n\n http.post(uri.path, payload, headers).tap do |response|\n log { \"POST #{url}\" }\n\n unless payload.nil? || payload.is_a?(String)\n log { \" PAYLOAD --> #{payload}\" }\n end\n\n log { \" RESPONSE --> #{response.body}\" }\n\n return yield response\n end\n end",
"def http_post(payload)\n LOGGER.info(\"Sending POST request to #{@collector_uri}...\")\n LOGGER.debug(\"Payload: #{payload}\")\n destination = URI(@collector_uri)\n http = Net::HTTP.new(destination.host, destination.port)\n request = Net::HTTP::Post.new(destination.request_uri)\n if destination.scheme == 'https'\n http.use_ssl = true\n end\n request.body = payload.to_json\n request.set_content_type('application/json; charset=utf-8')\n response = http.request(request)\n LOGGER.add(is_good_status_code(response.code) ? Logger::INFO : Logger::WARN) {\n \"POST request to #{@collector_uri} finished with status code #{response.code}\"\n }\n\n response\n end",
"def post(path, body, args = {})\n client = new(path, args)\n response = client.send(:request) do |uri|\n req = Net::HTTP::Post.new(uri)\n req.body = body\n req\n end\n response\n end",
"def post(options={}, &block)\n response = http.post_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n end",
"def post(endpoint, body, headers = {})\n headers = { accept: :json, content_type: :json }.merge(headers)\n @rest_resource[endpoint].post body, headers\n end",
"def make_request(request)\n raw_response = Net::HTTP.start(endpoint_uri.host, endpoint_uri.port) do |http|\n http.request_post(endpoint_uri.path, request.content, request.headers)\n end\n\n response = client.response(request, raw_response.body)\n\n # Sometimes Chrome sends a 500 with a valid SOAP fault in it, sometimes we see a 503 with a html\n # message in the body. In the first case, the above line will raise a LOLSoapFault. If we get\n # here, there was some other HTTP error, so raise that.\n raw_response.value # raises HTTP exception if not a 2xx response\n\n response\n end",
"def send\n http = EM::HttpRequest.new(@uri).post(@request_options)\n\n http.callback do\n process(http.response)\n end\n\n http.errback do\n fail(http.error)\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{uri}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend",
"def post(request)\n do_request(request) { |client| client.http_post request.body }\n end",
"def post(path, options={})\n url = build_url path, options\n body = options[:body]\n headers = options[:headers] || {}\n if body\n # the body for a POST will always be app/json, so no need\n # to waste cycles in build_payload\n body = Yajl.dump body\n headers.merge! :content_type => \"application/json\"\n end\n Response.new(@client[url].post body, headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'text/xml'\n request['Accept-Language'] = locale if locale\n request.body = body\n\n response = http.request(request)\n\n Response.new(response, uri)\n end",
"def post *args, &block\n response = self.class.post *args, &block\n raise WebserverError, response.code unless response.code == 200\n response\n end",
"def post(body, request_configuration=nil)\n raise StandardError, 'body cannot be null' if body.nil?\n request_info = self.to_post_request_information(\n body, request_configuration\n )\n error_mapping = Hash.new\n error_mapping[\"4XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n error_mapping[\"5XX\"] = lambda {|pn| MicrosoftGraph::Models::ODataErrorsODataError.create_from_discriminator_value(pn) }\n return @request_adapter.send_async(request_info, nil, error_mapping)\n end",
"def post(url, options = {}, &block)\n run! Request.new(url, :post, options.slice(:headers, :params, :payload), &block)\n end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n puts result[:result]\n result\nend",
"def send_post_request(body)\n response = HTTParty.post(\n url.to_str,\n :body => body.to_json,\n :headers => { 'Content-Type' => 'application/json' },\n :basic_auth => auth,\n verify: false\n )\n\n logger.debug(\n \"POST Request to Turbulence: \\n\" +\n \"\\tURL: #{url.to_str}\\n\" +\n \"\\tAUTH: #{auth}\\n\" +\n \"\\tBODY: #{body.to_json}\"\n )\n\n unless response.success?\n raise \"Request to turbulence(#{url.to_str}) failed, \\n\" +\n \"\\tauth: #{auth.inspect}, \\n\" +\n \"\\tBody: #{body}, \\n\" +\n \"\\tResponse: #{response.body}\"\n end\n response_body = JSON.parse(response.body)\n return response_body[\"ID\"]\n end",
"def post_with_binary_response(relative_path, request_headers, request_parameters, request_body, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n\n body = nil\n if request_body.is_a? MultipartFormDataObject\n request_headers.push(RequestHeader.new('Content-Type', request_body.content_type))\n body = request_body\n elsif request_body.is_a? MultipartFormDataRequest\n multipart = request_body.to_multipart_form_data_object\n request_headers.push(RequestHeader.new('Content-Type', multipart.content_type))\n body = multipart\n elsif !request_body.nil?\n request_headers.push(RequestHeader.new('Content-Type', 'application/json'))\n body = @marshaller.marshal(request_body)\n else\n # Set the content-type, even though there is no body, to prevent the httpClient from\n # adding a content-type header after authentication has been generated.\n request_headers.push(RequestHeader.new('Content-Type', 'text/plain'))\n end\n add_generic_headers('POST', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.post(uri, request_headers, body) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = process_binary_response(status_code, content, headers, context) do |h, c|\n yield h, c\n end\n end\n throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)\n end",
"def post options={}, &block\n handle_exceptions do\n Chimps.log.info(\"POST #{url}\")\n Response.new(super(encoded_body, options, &block))\n end\n end",
"def http_post(path, data, headers = {})\n clear_response\n path = process_path(path)\n @success_code = 201\n @response = http.post(path, data, headers)\n parse_response? ? parsed_response : response.body\n end",
"def post(resource, body = \"\", headers = {})\n prepare_request(:post, resource, body, headers)\n end",
"def post(uri, parameters = nil)\n response = Unirest.post uri, parameters: parameters\n response.body\n end",
"def http_post_request(url, body = nil)\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = body || ''\n response = http.request(request)\n return response.body\n end",
"def post(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'POST', params)\n\n log \"POST \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :post, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end",
"def post(url, options = {}, &block)\n request HttpPost, url, options, &block\n end",
"def post(uri, query = T.unsafe(nil), headers = T.unsafe(nil)); end",
"def execute_request(request, client:)\n connection = build_connection(request.url, client: client)\n\n headers = request.headers.dup\n\n body = request.body\n\n resp = connection.run_request(request.verb.downcase, request.url, body, headers)\n\n {\n status: Integer(resp.status),\n message: resp.reason_phrase,\n headers: Simple::HTTP::Headers.new(resp.headers.to_hash),\n body: resp.body\n }\n end",
"def http_post(uri, data)\n RestClient.post uri, data\n end",
"def do_request(request, response)\n body = make_request(request)\n\n # Always 200. A simplification, but fine for user\n # error messages.\n response.status = 200\n response['Content-Type'] = 'text/html' \n response.body = body\n end",
"def post(uri, query = {}, headers = {})\n return request_with_entity(:post, uri, query, headers) if String === query\n\n node = {}\n # Create a fake form\n class << node\n def search(*args); []; end\n end\n node['method'] = 'POST'\n node['enctype'] = 'application/x-www-form-urlencoded'\n\n form = Form.new(node)\n\n Mechanize::Util.each_parameter(query) { |k, v|\n if v.is_a?(IO)\n form.enctype = 'multipart/form-data'\n ul = Form::FileUpload.new({'name' => k.to_s},::File.basename(v.path))\n ul.file_data = v.read\n form.file_uploads << ul\n elsif v.is_a?(Form::FileUpload)\n form.enctype = 'multipart/form-data'\n form.file_uploads << v\n else\n form.fields << Form::Field.new({'name' => k.to_s},v)\n end\n }\n post_form(uri, form, headers)\n end",
"def post_process\n [status, headers, body]\n end",
"def post_process\n [status, headers, body]\n end",
"def do_POST(request, response)\n\n @aspecto_repeater.repeat request\n @bugsnag_repeater.repeat request\n\n # Turn the WEBrick HttpRequest into our internal HttpRequest delegate\n request = Maze::HttpRequest.new(request)\n\n content_type = request['Content-Type']\n if %r{^multipart/form-data; boundary=([^;]+)}.match(content_type)\n boundary = WEBrick::HTTPUtils::dequote($1)\n body = WEBrick::HTTPUtils.parse_form_data(request.body, boundary)\n hash = {\n body: body,\n request: request,\n response: response\n }\n else\n # \"content-type\" is assumed to be JSON (which mimics the behaviour of\n # the actual API). This supports browsers that can't set this header for\n # cross-domain requests (IE8/9)\n digests = check_digest request\n hash = {\n body: JSON.parse(request.body),\n request: request,\n response: response,\n digests: digests\n }\n end\n if @schema\n schema_errors = @schema.validate(hash[:body])\n hash[:schema_errors] = schema_errors.to_a\n end\n add_request(hash)\n\n # For the response, delaying if configured to do so\n response_delay_ms = Server.response_delay_ms\n if response_delay_ms.positive?\n $logger.info \"Waiting #{response_delay_ms} milliseconds before responding\"\n sleep response_delay_ms / 1000.0\n end\n\n set_response_header response.header\n response.status = post_status_code\n rescue JSON::ParserError => e\n msg = \"Unable to parse request as JSON: #{e.message}\"\n if Maze.config.captured_invalid_requests.include? @request_type\n $logger.error msg\n Server.invalid_requests.add({\n reason: msg,\n request: request,\n body: request.body\n })\n else\n $logger.warn msg\n end\n rescue StandardError => e\n if Maze.config.captured_invalid_requests.include? @request_type\n $logger.error \"Invalid request: #{e.message}\"\n Server.invalid_requests.add({\n invalid: true,\n reason: e.message,\n request: {\n request_uri: request.request_uri,\n header: request.header,\n body: request.inspect\n }\n })\n else\n $logger.warn \"Invalid request: #{e.message}\"\n end\n end",
"def request(method, uri, headers, body, opts)\n # Create the client\n client = Net::HTTP.new(uri.host, uri.port)\n\n # Use SSL if requesting a secure connection\n if uri.scheme == 'https'\n client.use_ssl = true\n client.verify_mode = OpenSSL::SSL::VERIFY_PEER\n client.ca_file = opts[:cacert] if opts[:cacert]\n client.cert = OpenSSL::X509::Certificate.new(File.read(opts[:cert])) if opts[:cert]\n client.key = OpenSSL::PKey::RSA.new(File.read(opts[:key])) if opts[:key]\n end\n\n # Build the request\n request = Net::HTTP.const_get(method).new(uri.request_uri, headers)\n\n # Build the query if there's data to send\n request.body = body if body\n\n # Send the request\n client.request(request)\n rescue StandardError => e\n raise TaskHelper::Error.new(\n \"Failed to connect to #{uri}: #{e.message}\",\n 'http_request/connect-error'\n )\n end",
"def post_http_content\n res = Net::HTTP.post_form(uri, params)\n\n raise HTTPError.new(\"invalid #{res.code} response\") unless res.is_a?(Net::HTTPSuccess)\n\n res.body\n end",
"def post\n resource.post(request, response)\n end",
"def send_request(uri, request, tokens)\n begin\n request = parse_uri(uri, request, tokens)\n @raw_client.send_request(@sequence, writer_serialize(request))\n ensure\n increase_sequence\n end\n end",
"def post_json(path, body)\n uri = build_uri(path)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n result = JSON.parse(response.body)\n puts result\n result\nend",
"def perform\n args = {\n :method => method,\n :url => url,\n :headers => headers,\n :timeout => 120,\n :open_timeout => 30\n }\n args[:payload] = payload.to_json if payload\n\n Response.new RestClient::Request.execute(args)\n rescue RestClient::Exception => e\n response = e.response\n\n if e.is_a?(RestClient::RequestTimeout)\n response = JSON.generate({:error => {:cause => 'REQUEST_TIMEDOUT'}})\n end\n\n ErrorResponse.new response\n end",
"def http_post\n req = Net::HTTP::Post.new @uri.request_uri, request_headers\n req.set_form_data params\n req.basic_auth @proxy_user, @proxy_pass if @proxy_pass && @proxy_user\n req\n end",
"def http_post(*args)\n url = args.shift\n c = Curl::Easy.new url\n yield c if block_given?\n c.http_post *args\n c\n end",
"def post(path, params = {}, env = {}, &block)\n env[:request_method] = \"POST\"\n mock_request(path, params, env, &block)\n end"
] |
[
"0.80565345",
"0.7182403",
"0.7010327",
"0.6918774",
"0.67139757",
"0.66820157",
"0.6675218",
"0.65462756",
"0.65375584",
"0.64841384",
"0.6434788",
"0.6405759",
"0.6327829",
"0.6323234",
"0.62895983",
"0.6263509",
"0.6226",
"0.620429",
"0.6193551",
"0.6170154",
"0.6164982",
"0.6157946",
"0.61430246",
"0.6140228",
"0.6103027",
"0.6072962",
"0.6004536",
"0.5985416",
"0.5979923",
"0.5915476",
"0.5911962",
"0.590721",
"0.5904183",
"0.5903128",
"0.5894854",
"0.58915883",
"0.58822244",
"0.5863152",
"0.5857821",
"0.5849113",
"0.58419967",
"0.582007",
"0.5812211",
"0.57971203",
"0.57950956",
"0.5792246",
"0.57503587",
"0.57411355",
"0.5732277",
"0.56934005",
"0.56884134",
"0.5669493",
"0.5659571",
"0.56560296",
"0.56514525",
"0.56387365",
"0.5630341",
"0.5625495",
"0.5625256",
"0.56250733",
"0.56222564",
"0.56090015",
"0.5608762",
"0.55976707",
"0.55946463",
"0.5587559",
"0.5583954",
"0.55832124",
"0.5570951",
"0.5567221",
"0.55579495",
"0.55533326",
"0.5545715",
"0.5531506",
"0.55296534",
"0.5514588",
"0.5492416",
"0.5489027",
"0.5487601",
"0.5487531",
"0.5487061",
"0.54709065",
"0.5461553",
"0.545097",
"0.5447527",
"0.54458046",
"0.5441096",
"0.5440634",
"0.5438133",
"0.5438133",
"0.54346246",
"0.5421065",
"0.5414306",
"0.54091054",
"0.54044783",
"0.5402269",
"0.54009944",
"0.54005736",
"0.5399559",
"0.53913456"
] |
0.6462328
|
10
|
Performs a PUT request to _uri_ using _request_headers_ and _body_, and yields the response as the status code, headers and body.
|
def put(uri, request_headers, body)
raise NotImplementedError
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def put(uri, request_headers, body)\n request('put', uri, request_headers, body) do |response_status_code, response_headers, response_body|\n yield response_status_code, response_headers, response_body\n end\n end",
"def put(uri, request_headers, body)\n request('put', uri, request_headers, body)\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def put_request(uri, body, token = nil, manage_errors = true)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body.to_json\n return do_request(uri, request, manage_errors) \n end",
"def do_put(uri = \"\", body = \"\")\n @connection.put do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n req.body = body\n end\n rescue Faraday::Error::ConnectionFailed => e\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Error trying to send a PUT to #{uri}\"\n $lxca_log.error \"XClarityClient::XclarityBase do_put\", \"Request sent: #{body}\"\n Faraday::Response.new\n end",
"def put(body = nil, headers = {}, path = '')\n uri = URI.parse(\"#{@url}#{path}\")\n request = Net::HTTP::Put.new(uri.request_uri)\n request.body = body\n send_request(uri, request, headers)\n end",
"def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, body, headers)\n end",
"def do_put(uri = '', body = '')\n build_request(:put, uri, body)\n end",
"def put options={}, &block\n handle_exceptions do\n Chimps.log.info(\"PUT #{url}\")\n Response.new(super(encoded_body, options, &block))\n end\n end",
"def put(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('put')\n end\n end",
"def http_put(request, response)\n body = request.body_as_stream\n path = request.path\n\n # Intercepting Content-Range\n if request.header('Content-Range')\n # An origin server that allows PUT on a given target resource MUST send\n # a 400 (Bad Request) response to a PUT request that contains a\n # Content-Range header field.\n #\n # Reference: http://tools.ietf.org/html/rfc7231#section-4.3.4\n fail Exception::BadRequest, 'Content-Range on PUT requests are forbidden.'\n end\n\n # Intercepting the Finder problem\n expected = request.header('X-Expected-Entity-Length').to_i\n if expected > 0\n # Many webservers will not cooperate well with Finder PUT requests,\n # because it uses 'Chunked' transfer encoding for the request body.\n #\n # The symptom of this problem is that Finder sends files to the\n # server, but they arrive as 0-length files in PHP.\n #\n # If we don't do anything, the user might think they are uploading\n # files successfully, but they end up empty on the server. Instead,\n # we throw back an error if we detect this.\n #\n # The reason Finder uses Chunked, is because it thinks the files\n # might change as it's being uploaded, and therefore the\n # Content-Length can vary.\n #\n # Instead it sends the X-Expected-Entity-Length header with the size\n # of the file at the very start of the request. If this header is set,\n # but we don't get a request body we will fail the request to\n # protect the end-user.\n\n # Only reading first byte\n first_byte = body.read(1)\n unless first_byte\n fail Exception::Forbidden, 'This server is not compatible with OS/X finder. Consider using a different WebDAV client or webserver.'\n end\n\n # The body needs to stay intact, so we copy everything to a\n # temporary stream.\n\n new_body = StringIO.new\n new_body.write(first_byte)\n IO.copy_stream(body, new_body)\n new_body.rewind\n\n body = new_body\n end\n\n if @server.tree.node_exists(path)\n node = @server.tree.node_for_path(path)\n\n # If the node is a collection, we'll deny it\n unless node.is_a?(IFile)\n fail Exception::Conflict, 'PUT is not allowed on non-files.'\n end\n\n etag = Box.new\n return false unless @server.update_file(path, body, etag)\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 204\n else\n # If we got here, the resource didn't exist yet.\n etag = Box.new\n unless @server.create_file(path, body, etag)\n # For one reason or another the file was not created.\n return false\n end\n etag = etag.value\n\n response.update_header('Content-Length', '0')\n response.update_header('ETag', etag) if etag\n response.status = 201\n end\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end",
"def put_request(uri, body, token)\n http = build_http(uri)\n request = Net::HTTP::Put.new(uri.request_uri, initheader = build_headers(token))\n request.body = body\n return http.request(request)\t\t\n end",
"def put(path, body = '', headers = {})\n with_auth { request(:put, path, body.to_s, build_request_headers(headers, :put, build_uri(path))) }\n end",
"def put(body = '', headers = {}, parameters = {}, &block)\n build_put(body, headers, parameters, &block).invoke\n end",
"def make_put_request\n options = {\n use_ssl: true,\n cert: OpenSSL::X509::Certificate.new(@certificate),\n key: OpenSSL::PKey::RSA.new(@key),\n ca_file: @uw_ca_file,\n verify_mode: OpenSSL::SSL::VERIFY_PEER\n }\n Net::HTTP.start(@uri.host, @uri.port, options) do |http|\n request = Net::HTTP::Put.new(@uri.request_uri)\n request.body = @request_text\n @response = http.request(request)\n end\n puts \"Response is: #{get_response_code}\"\n puts \"Body is: #{@response.body}\"\n @response.body\n end",
"def put(url, body, headers: {}, params: {}, options: {})\n raise ArgumentError, \"'put' requires a string 'body' argument\" unless body.is_a?(String)\n url = encode_query(url, params)\n\n request = Net::HTTP::Put.new(url, @default_headers.merge(headers))\n request.body = body\n request.content_length = body.bytesize\n\n raise ArgumentError, \"'put' requires a 'content-type' header\" unless request['Content-Type']\n\n execute_streaming(request, options: options)\n end",
"def put(path, body: {}, headers: nil)\n response = conn.put do |req|\n build_request(req, path: path, body: body, headers: headers)\n end\n puts response.body\n response.body unless response.blank?\n end",
"def put(uri, body, opts = {}, &block)\n initialize_socket(uri, opts)\n HttpStream::put(uri, body, opts, &block)\n rescue IOError => e\n raise e unless @intentional_termination\n end",
"def put(uri, params = {})\n send_request(uri, :put, params)\n end",
"def put(path, options={})\n response = request(path, :put, options)\n validate response\n responsed_response = parse response\n data = { headers: response.headers, body: parsed_response }\n end",
"def put(_status, headers, env)\n check_precondition!(env)\n\n if exists?\n update(env['rack.input'], env['CONTENT_TYPE'])\n headers = update_headers(headers)\n [200, headers, self]\n else\n create(env['rack.input'], env['CONTENT_TYPE'])\n [201, update_headers(headers), self]\n end\n end",
"def put(url, options = {}, &block)\n run! Request.new(url, :put, options.slice(:headers, :params, :payload), &block)\n end",
"def put(endpoint, params = {})\n\n path = build_connect_url(endpoint)\n headers = build_headers(endpoint, 'PUT', params)\n\n log \"PUT \" + path + \" \" + params.to_s\n log headers.to_s\n\n begin\n response = RestClient::Request.execute(method: :put, url: path, payload: params.to_json, headers: headers, timeout: 15)\n rescue RestClient::ExceptionWithResponse => e\n log e.http_code.to_s + \" \" + e.response.to_s\n return e.response\n end\n\n log response.code.to_s + \" \" + response.to_s\n\n response\n\n end",
"def put(path, headers: {}, query: {}, payload: {})\n (headers, query, payload) = preprocess(headers, query, payload)\n respond_with super(path, headers: headers, query: query, payload: payload)\n end",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def put(uri, parameters)\n response = Unirest.put uri, parameters: parameters\n response.body\n end",
"def put(resource_path, body:, headers: {}, prefix: API_PREFIX)\n request(method: :put, resource_path: resource_path, headers: headers, body: body, prefix: prefix)\n end",
"def put(path, options={})\n url = build_url path, options\n body, mime = build_payload options\n headers = (options[:headers] || {}).merge :content_type => mime\n Response.new(@client[url].put body, headers)\n rescue RestClient::Exception => e\n Response.new e.response\n end",
"def put(resource, body = \"\", headers = {})\n prepare_request(:put, resource, body, headers)\n end",
"def put(request_uri, data = nil)\n url = base_uri + request_uri\n logger.debug(\"PUT #{url}\")\n\n uri = URI.parse(url)\n\n response = http_request(:put, uri, data)\n\n parse_body(response)\n end",
"def put(path, params = {}, env = {}, &block)\n env[:request_method] = \"PUT\"\n mock_request(path, params, env, &block)\n end",
"def put(path, headers = {})\n process :put, path, headers\n end",
"def put(options={}, &block)\n response = http.put_uri(options.merge(:body => serialize), &block)\n handle_response(response)\n self\n end",
"def put(path, body_params = {})\n debug_log \"PUT #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def put(url, options = {}, &block)\n request HttpPut, url, options, &block\n end",
"def put(relative_path, request_headers, request_parameters, request_body, response_type, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n\n body = nil\n if request_body.is_a? MultipartFormDataObject\n request_headers.push(RequestHeader.new('Content-Type', request_body.content_type))\n body = request_body\n elsif request_body.is_a? MultipartFormDataRequest\n multipart = request_body.to_multipart_form_data_object\n request_headers.push(RequestHeader.new('Content-Type', multipart.content_type))\n body = multipart\n elsif !request_body.nil?\n request_headers.push(RequestHeader.new('Content-Type', 'application/json'))\n body = @marshaller.marshal(request_body)\n else\n # Set the content-type, even though there is no body, to prevent the httpClient from\n # adding a content-type header after authentication has been generated.\n request_headers.push(RequestHeader.new('Content-Type', 'text/plain'))\n end\n add_generic_headers('PUT', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.put(uri, request_headers, body) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = content.read.force_encoding('UTF-8')\n end\n process_response(response_body, response_status_code, response_headers, response_type, relative_path, context)\n end",
"def raw_put(path, body, options = {})\n # Allow format override\n format = options.delete(:format) || @format\n # Clear cache\n expire_matching \"#{parent_path(path)}.*\"\n # Create PUT request\n put = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", \n :verbose => DEBUG,\n :method => \"put\",\n :body => body,\n :headers => { :'Content-type' => options[:content_type] || content_type(format) }\n )\n # Send request\n do_request(put, format)\n end",
"def put(request)\n do_request(request) { |client| client.http_put request.body }\n end",
"def put(url, payload, options={}, &block)\n http_options = options.merge(@basic_options)\n if block_given?\n RestClient.put(url, payload, http_options, &block)\n else\n RestClient.put(url, payload, http_options)\n end\n\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def put(url, body = {})\n call(url: url, action: :put, body: body)\n end",
"def put(request)\n _request(request) { |client, options| client.put options }\n end",
"def make_put_request(url, data)\n headers = {\n \"Content-Type\" => \"application/json\",\n }\n\n response = HTTParty.put(url, body: data.to_json, headers: headers)\n\n if response.success?\n response\n else\n puts \"Request failed with response code: #{response.code}\"\n puts \"Response message: #{response.message}\"\n nil\n end\nend",
"def put(uri, options = {})\n if options[:multipart]\n form_input = build_multipart_data(options)\n build_response(request.put(uri, build_request_options({\"CONTENT_TYPE\" => \"multipart/form-data, boundary=Mack-boundary\", \"CONTENT_LENGTH\" => form_input.size, :input => form_input})))\n else\n build_response(request.put(uri, build_request_options({:input => options.to_params})))\n end\n end",
"def put(url, payload, headers={})\n RestClient.put url, payload, headers\n end",
"def PUT(uri, data, type, credentials)\n put = Net::HTTP::Put.new(uri.path)\n put.content_type = type\n\n set_upload_body(put, data)\n\n response = submit(put, uri, credentials)\n\n case response\n when Net::HTTPOK, Net::HTTPAccepted\n # We've either set a parameter or started a run so we get 200 or 202\n # back from the server, respectively. Return true to indicate success.\n true\n when Net::HTTPCreated\n # We've uploaded data so we get 201 back from the server. Return the\n # uri of the created resource.\n URI.parse(response['location'])\n when Net::HTTPNoContent\n # We've modified data so we get 204 back from the server. Return the\n # uri of the modified resource.\n uri\n when Net::HTTPServiceUnavailable\n raise ServerAtCapacityError.new\n else\n report_error(\"PUT\", uri.path, response, credentials)\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def http_put(uri:, additional_headers: {}, data: {}, basic_auth: nil, debug: false)\n return nil if uri.blank?\n\n opts = options(additional_headers: additional_headers, debug: debug)\n opts[:body] = data\n opts[:basic_auth] = basic_auth if basic_auth.present?\n HTTParty.put(uri, opts)\n rescue URI::InvalidURIError => e\n handle_uri_failure(method: \"BaseService.http_put #{e.message}\", uri: uri)\n nil\n rescue HTTParty::Error => e\n handle_http_failure(method: \"BaseService.http_put #{e.message}\", http_response: nil)\n nil\n end",
"def put(url, payload, headers={})\n payload = MultiJson.encode(payload)\n headers = headers.merge({:content_type => 'application/json'})\n request(:put, url, payload, headers)\n end",
"def do_PUT(req, res)\n perform_proxy_request(req, res) do |http, path, header|\n http.put(path, req.body || '', header)\n end\n end",
"def put(path, options = {})\n request(:put, parse_query_and_convenience_headers(path, options))\n end",
"def put(*args)\n request :put, *args\n end",
"def request_put(path)\n\ttimestamp = Time.now.utc.iso8601\n\tauth = create_hmac_auth(\"PUT\", path, timestamp)\n\t\n\turi = URI($baseUrl + path)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.add_field(\"x-hp-hmac-authentication\", auth)\n\trequest.add_field(\"x-hp-hmac-date\", timestamp)\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend",
"def put(query_url,\r\n headers: {},\r\n parameters: {})\r\n HttpRequest.new(HttpMethodEnum::PUT,\r\n query_url,\r\n headers: headers,\r\n parameters: parameters)\r\n end",
"def put_async(body = '', headers = {}, parameters = {}, &block)\n @asynchronous_backend.execute(build_put(body, headers, parameters, &block))\n end",
"def put(*args)\n request(:put, *args)\n end",
"def http_put(url, params, &request_modifier)\n uri = URI.parse url\n req = Net::HTTP::Put.new uri.path\n req.set_form_data(params)\n request_modifier && (request_modifier.call req)\n\n session = (Net::HTTP.new uri.host, uri.port)\n case res = session.start { |http| http.request req }\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n else\n res.error!\n end\n end",
"def put(object, url, headers={})\n do_request(\"put\", url, object, headers)\n end",
"def put(path, options = {}, raw = false)\n request(:put, path, options, raw)\n end",
"def put(path, request_options = {}, resource_options = {})\n response(:put, resource(resource_options)[path], request_options)\n end",
"def put(params)\n bucket = params[:bucket]\n object = params[:object]\n value = params[:value]\n content_type = params[:content_type]\n cb = params[:cb]\n date = generate_date\n sign_string = generate_signed_string('PUT', 'private', bucket, object, content_type)\n signature = generate_signature(sign_string)\n auth = generate_auth(signature)\n headers = generate_put_headers(date, auth, 'private', content_type, value.size)\n path = \"/\" << object\n\n @req_options = {:method => :put, :head => headers, :path => path, :body => value}\n @cb = cb if cb\n @bucket = bucket\n try_request\n self\n end",
"def put(path, options = {}, signature = false, raw = false, unformatted = false, no_response_wrapper = self.no_response_wrapper, signed = sign_requests)\n request(:put, path, options, signature, raw, unformatted, no_response_wrapper, signed)\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.host, uri.port) do |http|\n response = http.request request\n response.value\n\n doc = REXML::Document.new response.body\n \n doc = strip_class_attributes(yield doc)\n \n request2 = method.new uri\n request2.content_type = 'application/xml'\n auth_admin(request2)\n\n request2.body=doc.to_s\n \n response2 = http.request request2\n response.value\n\n end\n \nend",
"def put(*args)\n request, adapter = request_and_adapter_from(args)\n\n with_adapter :put, request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.put request\n end\n end",
"def put(path, params={})\n RestClient.put request_base+path, params\n end",
"def put(path, options={}, raw=false)\n request(:put, path, options, raw)\n end",
"def put_with_binary_response(relative_path, request_headers, request_parameters, request_body, context)\n connection = @session.connection\n request_parameter_list = request_parameters &&\n request_parameters.to_request_parameters\n uri = to_absolute_uri(relative_path, request_parameter_list)\n request_headers = [] if request_headers.nil?\n\n body = nil\n if request_body.is_a? MultipartFormDataObject\n request_headers.push(RequestHeader.new('Content-Type', request_body.content_type))\n body = request_body\n elsif request_body.is_a? MultipartFormDataRequest\n multipart = request_body.to_multipart_form_data_object\n request_headers.push(RequestHeader.new('Content-Type', multipart.content_type))\n body = multipart\n elsif !request_body.nil?\n request_headers.push(RequestHeader.new('Content-Type', 'application/json'))\n body = @marshaller.marshal(request_body)\n else\n # Set the content-type, even though there is no body, to prevent the httpClient from\n # adding a content-type header after authentication has been generated.\n request_headers.push(RequestHeader.new('Content-Type', 'text/plain'))\n end\n add_generic_headers('PUT', uri, request_headers, context)\n\n response_status_code, response_headers, response_body = nil\n connection.put(uri, request_headers, body) do |status_code, headers, content|\n response_status_code = status_code\n response_headers = headers\n response_body = process_binary_response(status_code, content, headers, context) do |h, c|\n yield h, c\n end\n end\n throw_exception_if_necessary(response_body, response_status_code, response_headers, relative_path)\n end",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def _http_put resource, path\n uri = ::URI.parse(resource.auth_uri)\n path = _path uri, path\n request = Net::HTTP::Put.new(path)\n _build_request resource, request\nend",
"def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end",
"def put(path, opts = {}, &block)\n request(:put, path, opts, &block)\n end",
"def put(url, resource_name, options = {})\n build_response(resource_name) do\n connection.put do |req|\n req.url url\n req.body = options.to_json\n end\n end\n end",
"def update(body, params = {}, header = {})\n request = requester.new(:put, \"#{to_url}/#{id}\", body, params, header)\n parameters(request.resource)\n end",
"def put(*args)\n request, adapter = request_and_adapter_from(args)\n \n with request, adapter do |adapter|\n yield adapter.client if block_given?\n adapter.put request\n end\n end",
"def perform_put(path, options = {})\n perform_request(:put, path, options)\n end",
"def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end",
"def put(url, payload, headers: {}, options: {})\n request_with_payload(:put, url, payload, headers, options)\n end",
"def request_put(file, content_type)\n\turi = URI($amazon_upload_url)\n\n\trequest = Net::HTTP::Put.new(uri)\n\trequest.body_stream = File.open(file)\n\trequest.add_field(\"Content-Type\", content_type)\n\trequest.add_field('Content-Length', File.size(file))\n\n\tresponse = Net::HTTP.start(uri.host, uri.port,\n\t\t:use_ssl => uri.scheme == 'https',\n\t\t:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|\n\t\thttp.request(request)\n\tend\n\n\treturn response\nend",
"def assert_puts(api_path, payload = nil, type = nil, &block)\n headers = DEFAULT_HEADERS.merge(extra_headers(payload, type))\n payload = 'null' if payload.nil?\n stub_request(:put, uri(api_path))\n .with(body: payload, headers: headers)\n .to_return(body: dummy_response, status: 200)\n yield block\n assert_requested(:put, uri(api_path), headers: headers)\n WebMock.reset!\n end",
"def run\n\t\treq = Net::HTTP::Put.new(uri.path)\n\t\treq.body = query_string\n\t\tres = Net::HTTP.start(url.host, url.port) { |http|\n\t\t http.request(req)\n\t\t}\n\t\tres.body\n\tend",
"def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end",
"def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end",
"def put(path, args={})\n inject_token_auth_headers!(args)\n response = self.class.put(request_url(path), args)\n update_token_auth_headers(response)\n return response\n end",
"def put(request, response)\n @resource.put(request, response)\n end",
"def send_put_request endpoint, params={}, api_key=nil, ssl=false\n uri = URI.parse(endpoint)\n\n Net::HTTP.start(uri.host, uri.port) do |http|\n http.use_ssl = true if ssl\n request = Net::HTTP::Put.new(uri.request_uri)\n request['authorization'] = \"Token token=#{api_key}\" if api_key\n request.set_form_data(params)\n http.request request\n end\n end",
"def put(path, params={}, options={})\n request(:put, api_path(path), params, options)\n end",
"def put(path, options={})\n request :put, path, options\n end",
"def put(request, response)\n NotImplemented\n end",
"def put(request, response)\n NotImplemented\n end",
"def put(path: nil, payload:, headers: {}, query: {}, auth_method: nil)\n execute(\n method: :put,\n path: path,\n headers: headers,\n query: query,\n payload: payload,\n auth_method: auth_method\n )\n end",
"def put url, object = nil\n request url, HTTP::Put, object\n end",
"def put(request_opts = {})\n store_result(http(request_opts).put(resolved_path, @attrs, @etag))\n end",
"def put(request)\n request.method = :put\n request.call\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def put\n conn = @client.authorized_connection(url: @client.object_api_url)\n res = conn.put do |req|\n req.headers['Content-Type'] = \"application/json\"\n req.url resource_uri\n req.body = raw.to_json\n end\n if res.success?\n data = JSON.parse(res.body)\n self.class.new(data, @client)\n else\n nil\n end\n end",
"def put url, payload\n RestClient::Request.execute(:method => :put, :url => url, :payload => payload, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(path, options = {})\n request(:put, path, options)\n end",
"def put(url, vars={})\n send_request url, vars, 'PUT'\n end"
] |
[
"0.8164694",
"0.7322047",
"0.7021131",
"0.6972987",
"0.6937349",
"0.6726393",
"0.6649403",
"0.66086787",
"0.65919816",
"0.65412843",
"0.6510794",
"0.6457573",
"0.6450972",
"0.6409057",
"0.6383077",
"0.6381225",
"0.6372494",
"0.632024",
"0.6271922",
"0.6230719",
"0.619325",
"0.6165057",
"0.615653",
"0.61406434",
"0.6123507",
"0.6112195",
"0.6112163",
"0.60814255",
"0.6054131",
"0.60397923",
"0.6004991",
"0.59802103",
"0.59620196",
"0.5944213",
"0.5943574",
"0.59356993",
"0.593486",
"0.59129775",
"0.59113353",
"0.58862305",
"0.5872022",
"0.5855819",
"0.58377093",
"0.58111846",
"0.5800565",
"0.58002156",
"0.57519543",
"0.5730176",
"0.57235485",
"0.57215905",
"0.5717167",
"0.5706738",
"0.56901836",
"0.5687664",
"0.56875515",
"0.5680942",
"0.56798553",
"0.5676147",
"0.5668906",
"0.56629133",
"0.5656178",
"0.56525195",
"0.56521773",
"0.56503034",
"0.56144774",
"0.5605978",
"0.5601402",
"0.55796224",
"0.5579551",
"0.5575732",
"0.5575732",
"0.55720264",
"0.5561076",
"0.55343527",
"0.55336463",
"0.5520106",
"0.5519964",
"0.5516148",
"0.5494106",
"0.5489882",
"0.5489521",
"0.5489521",
"0.548234",
"0.5478409",
"0.5467511",
"0.546378",
"0.5462722",
"0.5458885",
"0.5458885",
"0.5455752",
"0.54429424",
"0.54391634",
"0.5438388",
"0.5433132",
"0.5424401",
"0.5397333",
"0.538935",
"0.5379785",
"0.5379785",
"0.5367639"
] |
0.7125491
|
2
|
GET /username_cookies/1 GET /username_cookies/1.json
|
def show
@username_cookie = UsernameCookie.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @username_cookie }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_cookies\n if cookies.signed[:name].present? && cookies.signed[:email].present?\n render json: { allow: true, name: cookies.signed[:name], email: cookies.signed[:email] }\n else\n render json: { allow: false }\n end\n end",
"def new\n @username_cookie = UsernameCookie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @username_cookie }\n end\n end",
"def get_cookies\n {\n method: \"Page.getCookies\"\n }\n end",
"def http_cookie\n http.cookie\n end",
"def get_userid\n request.cookies['userid']\n end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies(cookies); end",
"def create_cookies(username, password)\r\n\t\tcookies.signed[:username] = { \r\n\t \t\tvalue: username,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\t \tcookies.signed[:pwd] = {\r\n\t \t\tvalue: password,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\tend",
"def cookie_named(name); end",
"def collect_cookies_from_response; end",
"def get_accesses_cookie\n create_accesses_cookie if cookies[:accesses].nil\n JSON.parse(cookies[:accesses])\n end",
"def create\n @username_cookie = UsernameCookie.new(params[:username_cookie])\n\n respond_to do |format|\n if @username_cookie.save\n format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully created.' }\n format.json { render json: @username_cookie, status: :created, location: @username_cookie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @username_cookie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cookies\n test_cookies\n end",
"def cookies\n request.cookies\n end",
"def cookieMe\n if user_signed_in?\n cookies[:user_id] = current_user.id\n cookies[:user_token] = current_user.salt\n cookies[:user_username] = current_user.username\n cookies[:language] = current_user.language\n elsif !user_signed_in?()\n cookies.delete :user_id\n cookies.delete :user_token\n cookies.delete :user_username\n end\n end",
"def auth_cookie\n cookies[:auth]\n end",
"def cookies\n call_once\n @cookies\n end",
"def get_w_cookie(api)\n\t\t\tparams = set_default_params_w_cookie(api[:params])\n\t\t\tquery = hash_to_querystring(params)\n\t\t\turl = \"#{api[:path]}?#{query}\"\n\t\t\tresponse = @http.get(url,cookie_hash)\n\t\t\tputs \"#{response.code} - #{response.message}: #{api[:path]} \"\n\t\t\tcheck_cookie(response)\n\t\t\treport_error(response)\n\t\t\tresponse\n\t\tend",
"def cookies\n HTTY::CookiesUtil.cookies_from_string @headers[COOKIES_HEADER_NAME]\n end",
"def show_cookies\n if request.post? || params[:who] == 'peter'\n ls = cookies[LIFESIZE_COOKIE]\n if ls\n @cookie_value = JSON.pretty_generate(JSON.parse(Crypt.decrypt(ls)))\n else\n @cookie_value = \"lifesize cookie not set\"\n end\n @screen_cookie_value = cookies[SCREEN_COOKIE] ? cookies[SCREEN_COOKIE] : \"Screen cookie not set\"\n render :show_cookies\n else\n render :noaccess\n end\n end",
"def get_cookie(name)\n browser.cookie_named(name)\n end",
"def get_cookie\n cookies[GeventAnalysis::Application::CONSTS[:cookie_name]]\n end",
"def index\n for i in 1..200\n #cookies[\"cookie \"+i.to_s] = { value: \"Guru \"+i.to_s, secure: true}\n end\n end",
"def cookies\n request.cookies\n end",
"def cookies\n controller.send(:cookies)\n end",
"def cookie_info\n authenticated_crowd_call(:get_cookie_info)\n end",
"def cookieMe\n if user_signed_in?\n cookies[:user_id] = current_user.id\n cookies[:user_token] = current_user.salt\n cookies[:user_username] = current_user.username\n cookies[:language] = current_user.language\n elsif !user_signed_in?()\n cookies.delete :user_id\n cookies.delete :user_token\n cookies.delete :user_username\n end\n end",
"def login(username)\n res = HTTParty.post(URL+'login.php', body: { username: username,\n password: 'Password1'},\n follow_redirects: false)\n return res.headers[\"set-cookie\"].split(\"=\")[1]\nend",
"def cookies; @cookies ||= CookieJar.new; end",
"def auth_get(path)\n\t\theader = {\n\t\t\t\"Cookie\" => \"JSESSIONID=#{@cookies['JSESSIONID']}\",\n\t\t}\n\t\treturn @conn.get(path, header)\n\tend",
"def cookies\n rack_request.cookies\n end",
"def cookies\n @request.cookies\n end",
"def destroy\n @username_cookie = UsernameCookie.find(params[:id])\n @username_cookie.destroy\n\n respond_to do |format|\n format.html { redirect_to username_cookies_url }\n format.json { head :no_content }\n end\n end",
"def get_cookie\n resp = @cookie\n if @atl_token != \"\"\n resp = resp + \"; atl.xsrf.token=#{@atl_token}\"\n end\n puts \"Using cookie: #{resp}\".yellow\n resp\n end",
"def cookies\n @controller.send(:cookies)\n end",
"def show\n @cooky = Cookie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cooky }\n end\n end",
"def hubssolib_get_secure_cookie_data(name)\n return HubSsoLib::Crypto.decode_object(cookies[name], request.remote_ip)\n end",
"def get_cookie\n self.headers[\"Cookie\"]\n end",
"def cookies\n request.cookies\n end",
"def cookied_user\n cookies[:auth] and User.find_by_auth_token(cookies[:auth])\n end",
"def youtrack_login username, password, http\n\t# First, login to youtrack given above credentials\n\tlogin_url = \"/youtrack/rest/user/login\"\n\tputs \"Logging into Youtrack as root...\"\n\trequest = Net::HTTP::Post.new(login_url)\n\trequest.body = \"login=#{username}&password=#{password}\"\n\trequest[\"Connection\"] = \"keep-alive\"\n\trequest[\"Content-Type\"] = \"application/x-www-form-urlencoded\"\n\tresponse = http.request(request)\n\tputs \"Success!\"\n\t# Save cookies for subsequent API requests\n\tcookies = response['set-cookie']\n\treturn cookies\nend",
"def cookies() @_cookies ||= ::Merb::Cookies.new(request.cookies, @_headers) end",
"def generate_cookie(username, password)\n uri = URI.parse('https://ww1.shiftnote.com/login')\n request = Net::HTTP::Post.new(uri)\n request.content_type = 'application/x-www-form-urlencoded'\n request.set_form_data(\n 'FullSite' => 'False',\n 'ReturnUrl' => '',\n 'username' => username,\n 'Password' => password,\n 'Submit' => 'Submit',\n 'remember' => 'true'\n )\n\n req_options = {\n use_ssl: uri.scheme == 'https'\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n # response.code\n raise Errors::InvalidCredentials, 'The provided credentials are invalid, please try again.' if response.body.include?(\"There was no match for the username and password provided, please try again!\")\n\n @cookie = response.header['Set-Cookie']\n end",
"def cookie\n @cookie ||= Coca::AuthCookie.new(cookies, scope)\n end",
"def get_cookie\n txid = get_txid\n response = send('q' => 'cookie', 'txid' => txid)\n raise 'wrong txid in reply' if response['txid'] and response['txid'] != txid\n response['cookie']\n end",
"def getCookie()\n return @cookie\n\tend",
"def load_cookie_jar_json(jar, data)\n VkMusic.log.info('cookie_reader') { 'Loading JSON cookies' }\n JSON.parse(data).each_pair do |k, v|\n jar.add(URI('https://m.vk.com'), HTTP::Cookie.new(k, v))\n end\n end",
"def create_accesses_cookie\n cookies[:accesses] = {}.to_json\n end",
"def verify_cookie\n render_api_response(Result::Base.success(data: {\n client_token: CacheManagement::ClientToken.new([params[:client_token_id]]).fetch[params[:client_token_id]]\n }))\n end",
"def get_useful_cookies res\r\n set_cookie = res.headers['Set-Cookie']\r\n # Parse the Set-Cookie header\r\n parsed_cookies = CGI::Cookie.parse(set_cookie)\r\n\r\n # Clean up the cookies we got by:\r\n # * Dropping Path and Expires from the parsed cookies -- we don't care\r\n # * Dropping empty (reset) cookies\r\n %w(Path Expires).each do |ignore|\r\n parsed_cookies.delete ignore\r\n parsed_cookies.delete ignore.downcase\r\n end\r\n parsed_cookies.keys.each do |name|\r\n parsed_cookies[name].reject! { |value| value == '\"\"' }\r\n end\r\n parsed_cookies.reject! { |name,values| values.empty? }\r\n\r\n # the cookies always seem to start with CFAUTHORIZATION_, but\r\n # give the module the ability to log what it got in the event\r\n # that this stops becoming an OK assumption\r\n unless parsed_cookies.empty?\r\n vprint_status \"Got the following cookies after authenticating: #{parsed_cookies}\"\r\n end\r\n cookie_pattern = /^CF/\r\n useful_cookies = parsed_cookies.select { |name,value| name =~ cookie_pattern }\r\n if useful_cookies.empty?\r\n vprint_status \"No #{cookie_pattern} cookies found\"\r\n else\r\n vprint_status \"The following cookies could be used for future authentication: #{useful_cookies}\"\r\n end\r\n useful_cookies\r\n end",
"def cookie_name\n super\n end",
"def cookies(path=\"/\")\n _cookies(path_to_array(path))\n end",
"def login_sample()\n login_json = {\n :username => $username,\n :password => $password,\n :accessrights => $api_key\n }\n\n client = RestClient::Resource.new \"https://#{$hostname}/live/api/v3/\", :headers => {}, :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n\n request = login_json.to_json\n response = client['login'].post request, { :content_type => 'application/json' }\n\n client.options[:headers][:cookies] = response.cookies\n\n p ''\n p 'Login'\n p response\n client\nend",
"def get_cookie(name)\n @driver.manage.cookie_named(name)\n end",
"def get_all_cookies\n browser.all_cookies\n end",
"def raw_cookie\n env_table[\"HTTP_COOKIE\"]\n end",
"def set_cookie\n puts \"hello\"\n # puts @order.as_json\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n puts cookies[:name] = current_admin.name\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n end",
"def set_cookies_for_user(resource)\n cookies[:c_user] = {value: resource.email, expires: 2.year.from_now}\n end",
"def cookie\n { :value => Crypt.encrypt(cookie_value), :expires => 1.year.from_now }\n end",
"def grab_cookies\n cookie = []\n Capybara.current_session.driver.cookies.each do |key, value|\n cookie.push(key + '=' + value.value)\n end\n cookie\nend",
"def cookies # :doc:\n request.cookie_jar\n end",
"def raw_cookie\n @raw_cookie ||= controller.cookies[\"fbs_#{self.facebook_api_key}\"]\n end",
"def cookie_path; end",
"def initialize(req, key = APP_COOKIE)\n @cookie_key = key\n if req.cookies[cookie_key]\n @cookie = JSON.parse(req.cookies[cookie_key])\n else\n @cookie = {}\n end\n end",
"def raw_cookie2\n env_table[\"HTTP_COOKIE2\"]\n end",
"def cookie\n self[HttpClient::SET_COOKIE]\n end",
"def cookie_value\n @screen_data.to_json\n end",
"def cookies\n controller.respond_to?(:cookies, true) ? controller.send(:cookies) : nil\n end",
"def remember(user)\nuser.remember\ncookies.permanent.signed[:user_id] = user.id\ncookies.permanent[:remember_token] = user.remember_token\nend",
"def get_cookie(my_env,key)\r\n cookies = Hash.new\r\n if my_env.has_key?('rack.request.cookie_hash')\r\n if my_env['rack.request.cookie_hash'].has_key?(key)\r\n return(my_env['rack.request.cookie_hash'][key])\r\n else\r\n return(nil)\r\n end\r\n end\r\n end",
"def login_from_cookie\nuser = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\nif user && user.remember_token?\ncookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }\nself.current_user = user\nend\nend",
"def login(url, username, password)\n token = get_token(url)\n response = https_post url, \"authenticity_token=#{}&user[login]=#{username}&user[password]=#{password}\", token[0], token[1]\n raise \"No redirect occured: server did not accept the request.\" unless response[0][\"status\"] == \"302\"\n \n return response[0]['set-cookie'].split(';')[0]\n end",
"def retrieve_cookie(response, cookie_name)\n value = response.headers['set-cookie'].scan(/#{cookie_name}=[a-zA-Z0-9]+/).first\n value = value[cookie_name.length+1..-1] if value\n end",
"def cookie_jar; end",
"def cookie_jar; end",
"def cookie_jar; end",
"def cookie_jar; end",
"def cookie\n # 'frontend=aaa'\n nil\n end",
"def sso_cookie_content\n return nil if @current_user.blank?\n\n {\n 'patientIcn' => (@current_user.mhv_icn || @current_user.icn),\n 'mhvCorrelationId' => @current_user.mhv_correlation_id,\n 'signIn' => @current_user.identity.sign_in.deep_transform_keys { |key| key.to_s.camelize(:lower) },\n 'credential_used' => sso_cookie_sign_credential_used,\n 'expirationTime' => @session_object.ttl_in_time.iso8601(0)\n }\n end",
"def [] key\n @request.cookies[key]\n end",
"def cookies # :doc:\n request.cookie_jar\n end",
"def get_user_data\n user_data = nil\n \n if cookies.has_key?(:user_data) && cookies[:user_data].to_s != ''\n user_data = string_to_hash(cookies[:user_data])\n end\n user_data\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\nend",
"def add_to_cookie key, value\n cookie_hash = get_accesses_cookie\n cookie_hash[key] = value\n cookies[:accesses] = cookie_hash.to_json\n end",
"def cookies\n # renders static page\n end",
"def get_current_logged_in_user \n get(\"/users.json/current\")\nend",
"def get_current_logged_in_user \n get(\"/users.json/current\")\nend",
"def cookie_value; end",
"def cookie_named(name)\n driver.manage.cookie_named(name)\n end",
"def cookies\n @agent.cookie_jar.to_a\n end",
"def cookie_name\n \"reviewer_session_#{study.accession}\".to_sym\n end",
"def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end",
"def slack_auth_cookie\n payload = {\n signin: '1',\n crumb: slack_auth_crumb,\n email: SLACK_EMAIL,\n password: SLACK_PASSWORD\n }\n\n user_agent = 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) ' \\\n 'AppleWebKit/537.36 (KHTML, like Gecko) ' \\\n 'Chrome/59.0.3071.115 Safari/537.36'\n\n cookies = RestClient::Request.execute(\n method: :post,\n url: SLACK_URL,\n payload: payload,\n user_agent: user_agent\n ) { |response| response.cookies }\n\n cookies\n end",
"def get_cookie(data)\n if data['set-cookie']\n t = []\n data['Set-Cookie'].split(\", \").map{|c|\n tmp = c.scan(/([a-zA-Z0-9_\\-\\.]*=[^;]*)/).flatten\n tmp.delete_if{|cc| cc.downcase.include?(\"path\")}\n tmp.delete_if{|cc| cc.downcase.include?(\"expires\")}\n tmp.delete_if{|cc| cc.downcase.include?(\"domain\")}\n t << tmp\n }\n if t.length == 1\n @cookie = @cookie + t.join(\"; \")\n else\n @cookie = t.join(\"; \")\n end\n end\n end"
] |
[
"0.666682",
"0.661203",
"0.65926945",
"0.6536844",
"0.64701635",
"0.64571476",
"0.64571476",
"0.64571476",
"0.64571476",
"0.64571476",
"0.64571476",
"0.64571476",
"0.63908243",
"0.6372121",
"0.63702923",
"0.6334846",
"0.6296664",
"0.6284103",
"0.62789625",
"0.6268361",
"0.62238723",
"0.621511",
"0.61990845",
"0.6171975",
"0.61679935",
"0.6159837",
"0.6149614",
"0.6147529",
"0.6132633",
"0.6123917",
"0.6112095",
"0.6106279",
"0.60972583",
"0.60952246",
"0.60776573",
"0.6059491",
"0.60474515",
"0.6041155",
"0.6037726",
"0.602992",
"0.60050756",
"0.5990599",
"0.59778744",
"0.59714204",
"0.596849",
"0.59672713",
"0.5962817",
"0.595239",
"0.5950032",
"0.5929588",
"0.5917388",
"0.59098566",
"0.5875897",
"0.58739984",
"0.5846447",
"0.5843573",
"0.5836413",
"0.58293855",
"0.5825765",
"0.582173",
"0.58158726",
"0.58114004",
"0.5799513",
"0.578221",
"0.5781509",
"0.5771685",
"0.5737976",
"0.57342756",
"0.5732357",
"0.57294273",
"0.57254654",
"0.57229215",
"0.57147235",
"0.56951475",
"0.56869125",
"0.5682366",
"0.56819904",
"0.5676882",
"0.56702584",
"0.56618583",
"0.56618583",
"0.56618583",
"0.56618583",
"0.564683",
"0.5642737",
"0.5641526",
"0.56410754",
"0.56356615",
"0.56353194",
"0.5633404",
"0.56295764",
"0.5626581",
"0.5626581",
"0.5622634",
"0.562214",
"0.56125057",
"0.5609736",
"0.5609709",
"0.5608314",
"0.5607879"
] |
0.71412313
|
0
|
GET /username_cookies/new GET /username_cookies/new.json
|
def new
@username_cookie = UsernameCookie.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @username_cookie }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @username_cookie = UsernameCookie.new(params[:username_cookie])\n\n respond_to do |format|\n if @username_cookie.save\n format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully created.' }\n format.json { render json: @username_cookie, status: :created, location: @username_cookie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @username_cookie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @cooky = Cookie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cooky }\n end\n end",
"def create_cookies(username, password)\r\n\t\tcookies.signed[:username] = { \r\n\t \t\tvalue: username,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\t \tcookies.signed[:pwd] = {\r\n\t \t\tvalue: password,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\tend",
"def create\n \tcookies.signed[:username] = params[:session][:username]\n \tredirect_to messages_path\n end",
"def create\n @cooky = Cookie.new(params[:cooky])\n\n respond_to do |format|\n if @cooky.save\n format.html { redirect_to @cooky, notice: 'Cookie was successfully created.' }\n format.json { render json: @cooky, status: :created, location: @cooky }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\t\tcookies[:sign_up] = { value: \"XJ-122\", expires: 1.hour.from_now }\n\t\tsuper\n\tend",
"def create\n @cooky = Cookie.new(cooky_params)\n\n respond_to do |format|\n if @cooky.save\n format.html { redirect_to @cooky, notice: 'Cookie was successfully created.' }\n format.json { render :show, status: :created, location: @cooky }\n else\n format.html { render :new }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @username_cookie = UsernameCookie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @username_cookie }\n end\n end",
"def create\n @city = City.new(city_params)\n @city.city_hash = generate_unique_hash\n cookies[:city_hash] = @city.city_hash\n cookies[:city_hash] = { :value => @city.city_hash, :expires => 168.hour.from_now }\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if Rails.env == 'development'\n Rails.logger.debug \"Cookies:\\n\" + cookies.to_yaml\n Rails.logger.debug \"Session:\\n\" + session.to_yaml\n end\n \n @user_session = UserSession.new(params[:user_session])\n\n respond_to do |format|\n if @user_session.save\n @user_session.user.reset_appearance!\n \n # Make sure any stale forum logins are cleared\n cookies[\"Vanilla\"] = {:value => \"\", :domain => \".worlize.com\"}\n cookies[\"Vanilla-Volatile\"] = {:value => \"\", :domain => \".worlize.com\"}\n\n # default_url = enter_room_url(@user_session.user.worlds.first.rooms.first.guid)\n default_url = enter_room_url(Room.gate_room_guid)\n\n format.html { redirect_back_or_default(default_url) }\n format.json do\n render :json => {\n :success => true,\n :redirect_to => get_redirect_back_or_default_url(default_url)\n }\n end\n else\n format.html { render :action => \"new\" }\n format.json do\n render :json => {\n :success => false\n }\n end\n end\n end\n end",
"def new\n if session && session[:current_user_id]\n @user = User.find_by_id(session[:current_user_id])\n end\n @user ||= User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @user = User.new\n\n render json: @user\n end",
"def new\n @reserved_username = ReservedUsername.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reserved_username }\n end\n end",
"def new\n p session\n if session[:user].nil? \n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n else \n respond_to do |format|\n format.html { redirect_to_back }\n format.json { head :ok }\n end\n end\n \n \n end",
"def create\n # respond_to do |format|\n # if @user_session.save\n # format.html { redirect_to @user_session, notice: 'User session was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user_session }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @user_session.errors, status: :unprocessable_entity }\n # end\n # end\n\n #binding.pry\n user = User.get_user(user_session_params[:username], user_session_params[:password])\n if user != nil\n session = UserSession.login(user)\n response = {\n html: '',\n json: { username: user.username, token: session.key, status: 200 }\n }\n end\n respond_to do |format|\n if user != nil\n cookies[:auth] = {\n value: response[:json],\n expires: 1.year.from_now\n }\n format.html { render text: response[:html] }\n format.json { render json: response[:json] }\n else\n format.html { render text: '', status: :unauthorized }\n format.json { render text: '', status: :unauthorized }\n end\n end\n\n\n end",
"def create_accesses_cookie\n cookies[:accesses] = {}.to_json\n end",
"def create\n @metal = Metal.new(metal_params)\n respond_to do |format|\n if @metal.save\n if cookies[:new]\n response.set_cookie(:new,\n :value => cookies[:new].to_i + 1\n )\n else\n @show_message = true;\n # set the visited cookie\n response.set_cookie(:new,\n :value => 1,\n :expires => Time.now + (60 * 60 * 2)\n )\n\n end\n format.html { redirect_to @metal, notice: 'Metal was successfully created.' }\n format.json { render :show, status: :created, location: @metal }\n else\n format.html { render :new }\n format.json { render json: @metal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n if params[:create_user] == '1' or session[:id]\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n else\n flash[:error] = \"You will need to Sign In to view this page.\"\n redirect_to :controller => 'system', :action => 'index'\n end\n end",
"def new\n @user = User.new\n render :json => @user\n end",
"def new\n @user_session ||= UserSession.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_session }\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_api_cookie_key\n 'ost_kit_new_api_cookies'\n end",
"def generate_cookie(username, password)\n uri = URI.parse('https://ww1.shiftnote.com/login')\n request = Net::HTTP::Post.new(uri)\n request.content_type = 'application/x-www-form-urlencoded'\n request.set_form_data(\n 'FullSite' => 'False',\n 'ReturnUrl' => '',\n 'username' => username,\n 'Password' => password,\n 'Submit' => 'Submit',\n 'remember' => 'true'\n )\n\n req_options = {\n use_ssl: uri.scheme == 'https'\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n # response.code\n raise Errors::InvalidCredentials, 'The provided credentials are invalid, please try again.' if response.body.include?(\"There was no match for the username and password provided, please try again!\")\n\n @cookie = response.header['Set-Cookie']\n end",
"def clone_user\n user = User.find params[:id]\n cookies[:auth_token] = user.auth_token\n redirect_to root_path\n end",
"def create\n session[:username] = params[:username]\n redirect_to root_path\n end",
"def new\n @profile = Profile.new\n @profile.user_id = session[:user_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile }\n end\n end",
"def new\n @user = User.new\n if session[:cas_user]\n @user.gtusername = session[:cas_user]\n @user.type = \"Student\"\n end\n\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 @user = User.new\n @authorized_user = User.find(session[:user_id])\n @page_title = 'Регистрация нового пользователя'\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n @site = Site.new\n @profile_id = Profile.where(:username=>session[:username]).first.id\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end",
"def create\n object={\n :name=>params[:name],\n :email=>params[:email],\n :uid=>params[:uid]\n }\n newUser=User.create(object)\n cookies[:current_user]=newUser.id\n redirect_to \"/home\"\n end",
"def new\n @auth_token = session[:auth_token]\n @auth_secret = session[:auth_secret]\n @username = session[:username]\n\n if @username.empty? or @auth_token.empty? or @auth_secret.empty?\n redirect_to '/auth/twitter'\n end\n\n @user = User.new(:username => @username, :auth_token => @auth_token,\n :auth_secret => @auth_secret)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def create\n user = User.from_omniauth(request.env['omniauth.auth'])\n if params[:remember_me]\n cookies[:auth_token] = { value: user.auth_token,\n expires: 1.weeks.from_now.utc }\n else\n # browser doesn't delete session cookies if session restore used\n cookies[:auth_token] = { value: user.auth_token,\n expires: 30.minutes.from_now.utc }\n end\n redirect_to user_path(user), notice: \"Welcome #{user.nickname}\"\n end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def new\n @user = user.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new\n session[:current] = 'menu_clients'\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @user = User.new\n @action = \"new\"\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 @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n render :new\n endl\n\n def create\n user = User.find_by_credentials(\n params[:user][:user_name],\n params[:user][:password]\n )\n\n if user.nil?\n flash.now[:errors] = [\"Invalid username or password\"]\n render :new\n else\n login!(user)\n redirect_to cats_url\n end\n end\n\n def destroy\n logout!\n redirect_to new_session_url\n end\n\nend",
"def new_carnival(no_reward=false)\n @current_carnival_user = CarnivalUser.create_new(params[:i], params[:c],no_reward)\n set_carnival_user_cookie(@current_carnival_user.id.to_s)\n end",
"def new\n @user_session = UserSession.new\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def create \n user = User.find_by(username: params[\"user\"][\"username\"]).try(:authenticate, params[\"user\"][\"password\"])\n\n if user \n session[:user_id] = user.id\n render json: {\n status: :created,\n logged_in: :true,\n user: user\n }\n else\n render json: { status: 401 }\n end\n\n end",
"def new\n @note = Note.new\n if (params[:username] != current_user.username)\n redirect_to new_user_note_path(current_user)\n return\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @note }\n end\n end",
"def create\n u = params[:username]\n p = params[:password]\n user_session = UserSession.new(:login => u, :password => p, :remember_me => true)\n if not user_session.save then\n return render :text => \"error\", :status => 401\n end\n\n ret = { :user => User.find_by_username_or_email(user_session.login) }\n ret[:redir] = URI.parse(session.delete(:return_to)).path if session.include? :return_to\n restful ret\n end",
"def new\n if signed_in?\n redirect_to user_path(current_user)\n else\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end\n end",
"def get_cookies\n if cookies.signed[:name].present? && cookies.signed[:email].present?\n render json: { allow: true, name: cookies.signed[:name], email: cookies.signed[:email] }\n else\n render json: { allow: false }\n end\n end",
"def new\n unless can? :login, User\n render(:file => 'public/401', :format => :html, :status => :unauthorized) and return\n end\n\n case\n when params[:only_dtu]\n logger.info \"Overriding shunt cookie with value from params. Using DTU CAS\"\n session[:only_dtu] = true\n when params[:public]\n logger.info \"Overriding shunt cookie with value from params. Using local user\"\n session[:public] = true\n when cookies[:shunt] == 'dtu'\n logger.info \"Shunt cookie set to 'dtu'. Shunting directly to DTU CAS\"\n session[:only_dtu] = true\n when cookies[:shunt_hint] == 'dtu'\n logger.info \"Shunt hint cookie set to 'dtu'. Shunting with hint to DTU CAS\"\n session[:prefer_dtu] = true\n when current_user.campus? && !current_user.walk_in?\n logger.info \"Campus request. Shunting with hint to DTU CAS\"\n session[:prefer_dtu] = true\n end\n\n # store given return url in session also, since omniauth-cas in\n # test mode does not pass url parameter back to sessions_controller#create\n url = session[:return_url] = params[:url] || '/'\n\n redirect_to \"#{omniauth_path(:cas)}?#{{ :url => url }.to_query }\"\n end",
"def cookies(cookies); end",
"def new\n @login_key = LoginKey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @login_key }\n end\n end",
"def create\n user = User.find_by_credentials(params[:user][:name], params[:user][:password])\n if user \n #rails creates session cookie for us, session is a hash\n #generate new session token and set our session to that token\n login!(user)\n redirect_to chirps_url\n else\n # flash used for collecting errors \n # flash - lasts for now and the next response cycle, usually for redirects\n # flash.now - only persist for this response, usually for render\n\n #we want errors to render once but not again on refresh\n flash[:errors] = [\"Invalid username/password\"]\n # render :new\n redirect_to new_session_url\n end\n end",
"def create\n unless ubiquo_users?\n UbiquoUser.create_first(params[:login],params[:password])\n end\n self.current_ubiquo_user = UbiquoUser.authenticate(params[:login],\n params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n self.current_ubiquo_user.remember_me\n cookies[:auth_token] = {\n :value => self.current_ubiquo_user.remember_token ,\n :expires => self.current_ubiquo_user.remember_token_expires_at\n }\n end\n flash.discard\n redirect_back_or_default(ubiquo.home_path)\n else\n flash[:error] = t 'ubiquo.auth.login_invalid'\n render :action => 'new'\n end\n end",
"def new\n if logged_in?\n redirect_to \"overview\"\n end\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def create\n\t\t@user = User.new(params[:user])\n\t\t\n\t\trespond_to do |format|\n\t\t\tif @user.save\n\t\t\t\tcookies[:user_id] = @user.id\n\t\t\t\t# TODO: redirect to last page they were on\n\t\t\t\tformat.html { redirect_to root_url }\n\t\t\t\tformat.json { render json: @user, status: :created, location: @user}\n\t\t\telse # save fails due to validation error -> shows errors\n\t\t\t\tformat.html { render action: \"new\" }\n\t \tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def new\n @credito = Credito.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @credito }\n end\n end",
"def add_token_to_cookie(cookies)\n token = SecureRandom.urlsafe_base64()\n @user.update(token: token)\n cookies['token'] = token\n create_return_object()\n end",
"def new\n @inspiration = Inspiration.new\n if signed_in? && Project.find(params[:pid]).user_id == User.find_by_remember_token(cookies[:remember_token]).id\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inspiration }\n end\n else\n redirect_to \"/\"\n end\n end",
"def new\n @bookmark = Bookmark.new\n @bookmark.user_id= session[:user_id]\n @bookmark.origin='database-created'\n @bookmark.url='http://'\n @bookmark.folder=[\" \"]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookmark }\n end\n end",
"def create_cookie name_value_pair, options_string\r\n command 'createCookie', name_value_pair, options_string\r\n end",
"def new\n @user = User.new\n\t@user.name\n\t\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def cookie_named(name); end",
"def new\n @uniqueid = Uniqueid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @uniqueid }\n end\n end",
"def new\n authenticate_user!\n\n @testimonial = Testimonial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @testimonial }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n end\n end",
"def new2\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def test_new_view\n get :new\n assert_response :redirect\n assert_redirected_to user_new_path(:cookie_test => \"true\")\n\n get :new, :params => { :cookie_test => \"true\" }, :session => { :cookie_test => true }\n assert_response :success\n\n assert_select \"html\", :count => 1 do\n assert_select \"head\", :count => 1 do\n assert_select \"title\", :text => /Sign Up/, :count => 1\n end\n assert_select \"body\", :count => 1 do\n assert_select \"div#content\", :count => 1 do\n assert_select \"form[action='/user/new'][method='post']\", :count => 1 do\n assert_select \"input[id='user_email']\", :count => 1\n assert_select \"input[id='user_email_confirmation']\", :count => 1\n assert_select \"input[id='user_display_name']\", :count => 1\n assert_select \"input[id='user_pass_crypt'][type='password']\", :count => 1\n assert_select \"input[id='user_pass_crypt_confirmation'][type='password']\", :count => 1\n assert_select \"input[type='submit'][value='Sign Up']\", :count => 1\n end\n end\n end\n end\n end",
"def new\n \n respond_to do |format|\n # unregistered users or admin can create new users\n if session[:user_id].nil? || User.find(session[:user_id]).status == 'admin'\n @user = User.new\n \n format.html # new.html.erb\n format.json { render json: @user }\n else\n @user = User.find(session[:user_id])\n format.html { redirect_to @user, notice: 'loged in as ' + @user.lname }\n format.json { render json: @user, status: :in, location: @user }\n end\n end\n end",
"def new\n p 'new called'\n @user = User.new\n\n p \"#{@user}\"\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def index\n for i in 1..200\n #cookies[\"cookie \"+i.to_s] = { value: \"Guru \"+i.to_s, secure: true}\n end\n end",
"def new\n @login = Login.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @login }\n end\n end",
"def get_cookies\n {\n method: \"Page.getCookies\"\n }\n end",
"def create\n if @user = login(params[:email], params[:password], params[:remember])\n render json: {:ok => true, :user => {:id => @user.id, :username => @user.username, :email => @user.email}}\n else\n render json: {:ok => false}, status: :unprocessable_entity\n end\n end",
"def new\n @client = Client.new\n @account = current_user.account\n @user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def cookies() @_cookies ||= ::Merb::Cookies.new(request.cookies, @_headers) end",
"def generate_cookie\n cookies[:credit_request] = SecureRandom.hex(32)\n end",
"def new\n\n respond_to do |format|\n format.html\n format.json {render json: 'login'}\n end\n end",
"def new\n\n respond_to do |format|\n format.html\n format.json {render json: 'login'}\n end\n end",
"def create\n self.current_person = Person.authenticate(params[:login], params[:password])\n if logged_in?\n if params[:remember_me] == \"1\"\n current_person.remember_me unless current_person.remember_token?\n cookies[:auth_token] = { value: self.current_person.remember_token , expires: self.current_person.remember_token_expires_at }\n end\n flash[:notice] = t('sessions.create.access_granted')\n redirect_back_or_default(root_path)\n else\n flash.now[:error] = t('sessions.create.access_denied')\n render action: 'new'\n end\n end",
"def cookies; @cookies ||= CookieJar.new; end",
"def initialize(req, key = APP_COOKIE)\n @cookie_key = key\n if req.cookies[cookie_key]\n @cookie = JSON.parse(req.cookies[cookie_key])\n else\n @cookie = {}\n end\n end",
"def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n session[:username] = @user.username\n session[:name] = @user.name\n session[:id] = @user.id\n format.html { redirect_to home_url, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @users = User.all\n render json: @users\n end",
"def new\n \n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n \n end",
"def new\n @user = User.new\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 @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def new_user\n system('clear')\n File.open(userdata, 'w') { |f| f.write([].to_json) } unless File.exist?(userdata)\n puts 'Welcome! Please register for an account to continue.'.colorize(:light_green)\n username = @prompt.ask('Username >')\n raise RequirementError.new, 'Requirements not met' if username.match?(/[!@#$%^&*(),.?\":{}|<>]/)\n\n new_user_password(username)\n rescue RequirementError\n puts 'Username cannot contain special characters. Please try again!'.colorize(:light_red)\n new_user\n end",
"def new\n @user = ::User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end",
"def create\n @cookie_watcher = CookieWatcher.new(cookie_watcher_params)\n\n respond_to do |format|\n if @cookie_watcher.save\n format.html { redirect_to @cookie_watcher, notice: 'Cookie watcher was successfully created.' }\n format.json { render :show, status: :created, location: @cookie_watcher }\n else\n format.html { render :new }\n format.json { render json: @cookie_watcher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n if(params[\"session\"] == 'nil')\n session[:mailid] = nil\n end\n @loginuser = Loginuser.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loginuser }\n end\n \n end",
"def create\n @node = Node.new(params[:node])\n\n respond_to do |format|\n if @node.save\n cookies[:last_node_id] = @node.id \n format.html { redirect_to @node, notice: 'node created!' }\n format.json { render json: @node, status: :created, location: @node }\n else\n format.html { render action: \"new\" }\n format.json { render json: @node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = User.authenticated_user(params[:family_name], params[:user_name], params[:password])\n\n if user\n session[:user_id] = user.id\n unless params[:family_name] == 'visitor'\n if params[:remember_me]\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent.signed[:auto_login_token] = user.auto_login_token\n end\n end\n flash.notice = 'ログインしました。'\n respond_to do |format|\n format.html { redirect_to :root }\n format.json { head 201 }\n end\n else\n flash.alert = 'ログイン名またはパスワードが正しくありません。'\n respond_to do |format|\n format.html { redirect_to :root }\n format.json { head 401 }\n end\n end\n end",
"def new\n @bidding = Bidding.new\n @item = Item.find(cookies[:remember_item_token])\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bidding }\n end\n end",
"def create\n\t\tuser = User.from_sso(cookies[:UTEP_SE], cookies[:UTEP_SA])\n\t\tlog_in(user) if user\n\t\tredirect_to root_url\n\tend",
"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 @title = \"Signup\"\n @user = User.new\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\tif(filters)\n\t\t#Revisamos que no haya iniciado sesion\n\t\tif(session[:user_id])\n\t\t\tflash[:error] = \"Acceso denegado\"\n\t\t\tredirect_to home_path\n\t\t\treturn\n\t\tend\n\tend\n \n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end"
] |
[
"0.7236221",
"0.7074697",
"0.6533255",
"0.6389992",
"0.63502216",
"0.6290688",
"0.62468415",
"0.62126946",
"0.60776377",
"0.605743",
"0.60219675",
"0.6008606",
"0.6006027",
"0.5994231",
"0.597861",
"0.5970128",
"0.59373",
"0.5927919",
"0.59244573",
"0.5918984",
"0.5918651",
"0.59096134",
"0.5897835",
"0.5882909",
"0.58542895",
"0.5836651",
"0.5831335",
"0.5804015",
"0.580092",
"0.57996684",
"0.5796302",
"0.5775553",
"0.5775029",
"0.5775029",
"0.5775029",
"0.5775029",
"0.5775029",
"0.5775029",
"0.5775029",
"0.57738537",
"0.5740135",
"0.5739816",
"0.5739172",
"0.5737791",
"0.5731296",
"0.57132286",
"0.5707383",
"0.5700455",
"0.56944436",
"0.5666552",
"0.5665841",
"0.56597966",
"0.5656585",
"0.5651272",
"0.56493247",
"0.56492245",
"0.56460994",
"0.5640151",
"0.5637692",
"0.56325155",
"0.5632356",
"0.5625037",
"0.56237936",
"0.56234485",
"0.56165415",
"0.5612081",
"0.5611571",
"0.56019235",
"0.5601428",
"0.5596023",
"0.559298",
"0.5588972",
"0.5588168",
"0.55829954",
"0.5582618",
"0.55784225",
"0.55755085",
"0.557483",
"0.55725694",
"0.5568206",
"0.5568206",
"0.5567329",
"0.55644697",
"0.5563713",
"0.5556521",
"0.5549538",
"0.5543912",
"0.5536966",
"0.5536966",
"0.55359876",
"0.553582",
"0.55339444",
"0.5528124",
"0.5523545",
"0.55210274",
"0.55185914",
"0.5516779",
"0.550797",
"0.55039996",
"0.5502694"
] |
0.7941485
|
0
|
POST /username_cookies POST /username_cookies.json
|
def create
@username_cookie = UsernameCookie.new(params[:username_cookie])
respond_to do |format|
if @username_cookie.save
format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully created.' }
format.json { render json: @username_cookie, status: :created, location: @username_cookie }
else
format.html { render action: "new" }
format.json { render json: @username_cookie.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_cookies(username, password)\r\n\t\tcookies.signed[:username] = { \r\n\t \t\tvalue: username,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\t \tcookies.signed[:pwd] = {\r\n\t \t\tvalue: password,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\tend",
"def create\n \tcookies.signed[:username] = params[:session][:username]\n \tredirect_to messages_path\n end",
"def cookies(cookies); end",
"def generate_cookie(username, password)\n uri = URI.parse('https://ww1.shiftnote.com/login')\n request = Net::HTTP::Post.new(uri)\n request.content_type = 'application/x-www-form-urlencoded'\n request.set_form_data(\n 'FullSite' => 'False',\n 'ReturnUrl' => '',\n 'username' => username,\n 'Password' => password,\n 'Submit' => 'Submit',\n 'remember' => 'true'\n )\n\n req_options = {\n use_ssl: uri.scheme == 'https'\n }\n\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n # response.code\n raise Errors::InvalidCredentials, 'The provided credentials are invalid, please try again.' if response.body.include?(\"There was no match for the username and password provided, please try again!\")\n\n @cookie = response.header['Set-Cookie']\n end",
"def cookie_named(name); end",
"def create\n session[:username] = params[:username]\n redirect_to root_path\n end",
"def new\n @username_cookie = UsernameCookie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @username_cookie }\n end\n end",
"def set_cookies_for_user(resource)\n cookies[:c_user] = {value: resource.email, expires: 2.year.from_now}\n end",
"def set_cookie_value\n cookie_value = User.using_client_shard(client: @client).get_cookie_value(@user.id, @user.password, @browser_user_agent)\n success_with_data({cookie_value: cookie_value, user_token_sale_state: @user.get_token_sale_state_page_name})\n end",
"def create\n # respond_to do |format|\n # if @user_session.save\n # format.html { redirect_to @user_session, notice: 'User session was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @user_session }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @user_session.errors, status: :unprocessable_entity }\n # end\n # end\n\n #binding.pry\n user = User.get_user(user_session_params[:username], user_session_params[:password])\n if user != nil\n session = UserSession.login(user)\n response = {\n html: '',\n json: { username: user.username, token: session.key, status: 200 }\n }\n end\n respond_to do |format|\n if user != nil\n cookies[:auth] = {\n value: response[:json],\n expires: 1.year.from_now\n }\n format.html { render text: response[:html] }\n format.json { render json: response[:json] }\n else\n format.html { render text: '', status: :unauthorized }\n format.json { render text: '', status: :unauthorized }\n end\n end\n\n\n end",
"def login(username)\n res = HTTParty.post(URL+'login.php', body: { username: username,\n password: 'Password1'},\n follow_redirects: false)\n return res.headers[\"set-cookie\"].split(\"=\")[1]\nend",
"def collect_cookies_from_response; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def add_token_to_cookie(cookies)\n token = SecureRandom.urlsafe_base64()\n @user.update(token: token)\n cookies['token'] = token\n create_return_object()\n end",
"def youtrack_login username, password, http\n\t# First, login to youtrack given above credentials\n\tlogin_url = \"/youtrack/rest/user/login\"\n\tputs \"Logging into Youtrack as root...\"\n\trequest = Net::HTTP::Post.new(login_url)\n\trequest.body = \"login=#{username}&password=#{password}\"\n\trequest[\"Connection\"] = \"keep-alive\"\n\trequest[\"Content-Type\"] = \"application/x-www-form-urlencoded\"\n\tresponse = http.request(request)\n\tputs \"Success!\"\n\t# Save cookies for subsequent API requests\n\tcookies = response['set-cookie']\n\treturn cookies\nend",
"def cookieMe\n if user_signed_in?\n cookies[:user_id] = current_user.id\n cookies[:user_token] = current_user.salt\n cookies[:user_username] = current_user.username\n cookies[:language] = current_user.language\n elsif !user_signed_in?()\n cookies.delete :user_id\n cookies.delete :user_token\n cookies.delete :user_username\n end\n end",
"def set_cookie\n puts \"hello\"\n # puts @order.as_json\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n puts cookies[:name] = current_admin.name\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n end",
"def set_cookie!\n cookies[:user_session] = {\n :value => token,\n :secure => controller.request.ssl?,\n :httponly => true,\n :expires => self.expires_at\n }\n end",
"def get_userid\n request.cookies['userid']\n end",
"def remember(user)\nuser.remember\ncookies.permanent.signed[:user_id] = user.id\ncookies.permanent[:remember_token] = user.remember_token\nend",
"def create\n user = User.from_omniauth(request.env['omniauth.auth'])\n if params[:remember_me]\n cookies[:auth_token] = { value: user.auth_token,\n expires: 1.weeks.from_now.utc }\n else\n # browser doesn't delete session cookies if session restore used\n cookies[:auth_token] = { value: user.auth_token,\n expires: 30.minutes.from_now.utc }\n end\n redirect_to user_path(user), notice: \"Welcome #{user.nickname}\"\n end",
"def create\n if Rails.env == 'development'\n Rails.logger.debug \"Cookies:\\n\" + cookies.to_yaml\n Rails.logger.debug \"Session:\\n\" + session.to_yaml\n end\n \n @user_session = UserSession.new(params[:user_session])\n\n respond_to do |format|\n if @user_session.save\n @user_session.user.reset_appearance!\n \n # Make sure any stale forum logins are cleared\n cookies[\"Vanilla\"] = {:value => \"\", :domain => \".worlize.com\"}\n cookies[\"Vanilla-Volatile\"] = {:value => \"\", :domain => \".worlize.com\"}\n\n # default_url = enter_room_url(@user_session.user.worlds.first.rooms.first.guid)\n default_url = enter_room_url(Room.gate_room_guid)\n\n format.html { redirect_back_or_default(default_url) }\n format.json do\n render :json => {\n :success => true,\n :redirect_to => get_redirect_back_or_default_url(default_url)\n }\n end\n else\n format.html { render :action => \"new\" }\n format.json do\n render :json => {\n :success => false\n }\n end\n end\n end\n end",
"def create_accesses_cookie\n cookies[:accesses] = {}.to_json\n end",
"def login_sample()\n login_json = {\n :username => $username,\n :password => $password,\n :accessrights => $api_key\n }\n\n client = RestClient::Resource.new \"https://#{$hostname}/live/api/v3/\", :headers => {}, :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n\n request = login_json.to_json\n response = client['login'].post request, { :content_type => 'application/json' }\n\n client.options[:headers][:cookies] = response.cookies\n\n p ''\n p 'Login'\n p response\n client\nend",
"def http_cookie\n http.cookie\n end",
"def login(url, username, password)\n token = get_token(url)\n response = https_post url, \"authenticity_token=#{}&user[login]=#{username}&user[password]=#{password}\", token[0], token[1]\n raise \"No redirect occured: server did not accept the request.\" unless response[0][\"status\"] == \"302\"\n \n return response[0]['set-cookie'].split(';')[0]\n end",
"def add_to_cookie key, value\n cookie_hash = get_accesses_cookie\n cookie_hash[key] = value\n cookies[:accesses] = cookie_hash.to_json\n end",
"def cookies() @_cookies ||= ::Merb::Cookies.new(request.cookies, @_headers) end",
"def log_in_as(user)\n post '/login', params: { 'session' => { 'name' => user.username } }\n end",
"def get_cookies\n if cookies.signed[:name].present? && cookies.signed[:email].present?\n render json: { allow: true, name: cookies.signed[:name], email: cookies.signed[:email] }\n else\n render json: { allow: false }\n end\n end",
"def serialize_from_cookie(*args); end",
"def create\n @cooky = Cookie.new(cooky_params)\n\n respond_to do |format|\n if @cooky.save\n format.html { redirect_to @cooky, notice: 'Cookie was successfully created.' }\n format.json { render :show, status: :created, location: @cooky }\n else\n format.html { render :new }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @username_cookie = UsernameCookie.find(params[:id])\n @username_cookie.destroy\n\n respond_to do |format|\n format.html { redirect_to username_cookies_url }\n format.json { head :no_content }\n end\n end",
"def cookies\n test_cookies\n end",
"def cookieMe\n if user_signed_in?\n cookies[:user_id] = current_user.id\n cookies[:user_token] = current_user.salt\n cookies[:user_username] = current_user.username\n cookies[:language] = current_user.language\n elsif !user_signed_in?()\n cookies.delete :user_id\n cookies.delete :user_token\n cookies.delete :user_username\n end\n end",
"def send_credentials\n dputs __method__.to_s\n login_req = setup_http_request($ident, @cookie, {:arg => [$CONF['user'], CGI.escape($CONF['pass'])]})\n res = @http.request(login_req)\n get_cookie(res)\n end",
"def add_cookies!(request)\n request['Cookie'] = @cookies.collect{|k, v| \"#{k}=#{v}\"}.join(\", \")\n end",
"def create\n @cooky = Cookie.new(params[:cooky])\n\n respond_to do |format|\n if @cooky.save\n format.html { redirect_to @cooky, notice: 'Cookie was successfully created.' }\n format.json { render json: @cooky, status: :created, location: @cooky }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_cookie name_value_pair, options_string\r\n command 'createCookie', name_value_pair, options_string\r\n end",
"def login_from_cookie\nuser = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])\nif user && user.remember_token?\ncookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }\nself.current_user = user\nend\nend",
"def login(username, password)\n response = post(LOGIN_SUBMIT_URL, 'fnid' => fnid, 'u' => username, 'p' => password)\n @username = username\n @password = password\n unless @cookie = response.header['set-cookie']\n raise LoginError, \"Login credentials did not work.\"\n end\n end",
"def set_cookie(name, value, attributes = {})\n cookie = Webmachine::Cookie.new(name, value, attributes).to_s\n case headers['Set-Cookie']\n when nil\n headers['Set-Cookie'] = [cookie]\n when Array\n headers['Set-Cookie'] << cookie\n end\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\nend",
"def serialize_into_cookie(record); end",
"def cookies\n request.cookies\n end",
"def remember(user)\n user.remember # Defined in the User model\n cookies[:user_id] = { value: user.id,\n expires: 20.years.from_now.utc }\n\n cookies[:remember_token] = { value: user.remember_token,\n expires: 20.years.from_now.utc }\n end",
"def log_on_user(user, session, cookies)\n cookies.permanent[TOKEN_COOKIE] = { value: user.id, httponly: true }\n @env[CURRENT_USER_KEY] = user\n end",
"def authenticate_request\n service_response = UserManagement::VerifyCookie.new(\n client: params[:client],\n cookie_value: cookies[GlobalConstant::Cookie.user_cookie_name.to_sym],\n browser_user_agent: http_user_agent\n ).perform\n\n if service_response.success?\n # Update Cookie, if required\n extended_cookie_value = service_response.data[:extended_cookie_value]\n set_cookie(\n GlobalConstant::Cookie.user_cookie_name,\n extended_cookie_value,\n GlobalConstant::Cookie.user_expiry.from_now\n ) if extended_cookie_value.present?\n\n # Set user id\n params[:user_id] = service_response.data[:user_id]\n\n # Remove sensitive data\n service_response.data = {}\n else\n # Clear cookie\n delete_cookie(GlobalConstant::Cookie.user_cookie_name)\n render_api_response(service_response)\n end\n end",
"def logout_sample(client)\n response = client['logout'].post nil\n\n client.options[:headers][:cookies] = response.cookies\n\n p ''\n p 'Logout'\n p response\nend",
"def create\n @city = City.new(city_params)\n @city.city_hash = generate_unique_hash\n cookies[:city_hash] = @city.city_hash\n cookies[:city_hash] = { :value => @city.city_hash, :expires => 168.hour.from_now }\n\n respond_to do |format|\n if @city.save\n format.html { redirect_to @city, notice: 'City was successfully created.' }\n format.json { render :show, status: :created, location: @city }\n else\n format.html { render :new }\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cookie\n { :value => Crypt.encrypt(cookie_value), :expires => 1.year.from_now }\n end",
"def store_session(res)\n my_cookie = WEBrick::Cookie.new('_rails_lite_app', @cookies.to_json)\n res.cookies << my_cookie\n end",
"def encode_to_cookie h, cookie\n cookie[@name] = encode h\n end",
"def index\n for i in 1..200\n #cookies[\"cookie \"+i.to_s] = { value: \"Guru \"+i.to_s, secure: true}\n end\n end",
"def send_cookie(name, value = nil)\n @context.add_cookie(name, value)\n end",
"def create \n user = User.find_by(username: params[\"user\"][\"username\"]).try(:authenticate, params[\"user\"][\"password\"])\n\n if user \n session[:user_id] = user.id\n render json: {\n status: :created,\n logged_in: :true,\n user: user\n }\n else\n render json: { status: 401 }\n end\n\n end",
"def cookies\n rack_request.cookies\n end",
"def set_api_cookie!\n return unless @session_object\n\n session.delete :value\n @session_object.to_hash.each { |k, v| session[k] = v }\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def grab_cookies\n cookie = []\n Capybara.current_session.driver.cookies.each do |key, value|\n cookie.push(key + '=' + value.value)\n end\n cookie\nend",
"def refresh_credentials(cookies)\n cookies['dc_logged_in'] = {:value => 'true', :expires => 1.month.from_now, :httponly => true}\n end",
"def set_userid(id)\n response.set_cookie('userid', id)\n end",
"def cookies\n HTTY::CookiesUtil.cookies_from_string @headers[COOKIES_HEADER_NAME]\n end",
"def get_cookies\n {\n method: \"Page.getCookies\"\n }\n end",
"def store_cookie variable_name\r\n command 'storeCookie', variable_name\r\n end",
"def login(username=nil,password=nil)\n cookie = get_cookie\n if username&&password\n input=\"csrfmiddlewaretoken=#{cookie[:csrf]}&username=#{username}&password=#{password}&next=%2Ffakebook%2F\"\n else\n #input=\"csrfmiddlewaretoken=#{cookie[:csrf]}&username=001104765&password=50UK7HD7&next=%2Ffakebook%2F\"\n input=\"csrfmiddlewaretoken=#{cookie[:csrf]}&username=001941553&password=SZ6192HB&next=%2Ffakebook%2F\"\n end\n post_query = get_post_query(input.length,cookie[:csrf],cookie[:session_id])\n login_query = post_query+input\n response = get(login_query)\n @login_session = response.scan(/sessionid=\\w+/).first.split(\"=\")[1] \n end",
"def cookie_watcher_params\n params.require(:cookie_watcher).permit(:name, :cookies)\n end",
"def show_cookies\n if request.post? || params[:who] == 'peter'\n ls = cookies[LIFESIZE_COOKIE]\n if ls\n @cookie_value = JSON.pretty_generate(JSON.parse(Crypt.decrypt(ls)))\n else\n @cookie_value = \"lifesize cookie not set\"\n end\n @screen_cookie_value = cookies[SCREEN_COOKIE] ? cookies[SCREEN_COOKIE] : \"Screen cookie not set\"\n render :show_cookies\n else\n render :noaccess\n end\n end",
"def cookies\n controller.send(:cookies)\n end",
"def initialize(username=ENV['LOOMIO_USER'], password=ENV['LOOMIO_PASSWORD'])\n if !username || !password || !ENV['LOOMIO_GROUP_ID']\n raise ArgumentError, \"LOOMIO_USER, LOOMIO_PASSWORD, LOOMIO_GROUP_ID environment variables must be set\"\n end\n\n user = {user:{email:username,password:password}}\n security_response = self.class.post(@@base_uri + @@sessions_uri, body: user)\n puts(security_response.value) # raises error if the request failed\n\n # parse and set security cookies based on the post call\n @security_cookies = self.parse_set_cookie(security_response.headers['set-cookie'])\n self.class.default_cookies.add_cookies(@security_cookies)\n\n # set headers used for all requests\n @headers = {\n 'Content-Type': 'application/json'\n }\n end",
"def login\n begin\n File.open(\"#{Settings.root}/tmp/cookies.txt\").read \n rescue Exception => e\n `curl --user-agent \"#{user_agent}\" -s -c #{Settings.root}/tmp/cookies.txt http://online.wsj.com/home-page` \n `curl --user-agent \"#{user_agent}\" -s -c #{Settings.root}/tmp/cookies.txt -d \"user=justin@justinrich.com&password=2p2aia5\" http://commerce.wsj.com/auth/submitlogin` \n end\n true\n end",
"def store_session(response)\n attributes = { path: \"/\", value: @cookie.to_json }\n response.set_cookie(APP_NAME, attributes)\n end",
"def show\n @username_cookie = UsernameCookie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @username_cookie }\n end\n end",
"def login_as( user )\n cookies[:auth_token] = users(user).auth_token\n end",
"def store_session(res)\n res.set_cookie(cookie_key, { value: @cookie.to_json, path: '/' })\n end",
"def add_cookies(response)\n return unless response.key?('set-cookie')\n response.get_fields('set-cookie').each do |cookie|\n (key, val) = cookie.split('; ')[0].split('=', 2)\n cookies[key] = val\n end\n end",
"def slack_auth_cookie\n payload = {\n signin: '1',\n crumb: slack_auth_crumb,\n email: SLACK_EMAIL,\n password: SLACK_PASSWORD\n }\n\n user_agent = 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) ' \\\n 'AppleWebKit/537.36 (KHTML, like Gecko) ' \\\n 'Chrome/59.0.3071.115 Safari/537.36'\n\n cookies = RestClient::Request.execute(\n method: :post,\n url: SLACK_URL,\n payload: payload,\n user_agent: user_agent\n ) { |response| response.cookies }\n\n cookies\n end",
"def cookies\n @request.cookies\n end",
"def cookies\n request.cookies\n end",
"def delete_cookie(name); end",
"def create(cookies, options = {})\n return nil if self.class.site_key.nil?\n expires = (options.delete(:expires) || 1.week.from_now).to_i # we want unix time\n cookies[:tender_email] = cookie_value(@user.email)\n cookies[:tender_expires] = cookie_value(expires)\n\n # Optionally set the user's name. This is also signed.\n if options[:name_field]\n options[:name] = @user.send(options[:name_field])\n end\n options.each do |key, value|\n cookies[:\"tender_#{key}\"] = cookie_value(value)\n end\n cookies[:tender_hash] = cookie_value(expiring_token(expires, options[:name]))\n cookies\n end",
"def remember(user)\n\tuser.remember\n\tcookies.permanent.signed[:user_id] = user.id\n\tcookies.permanent[ :remember_token] = user.remember_token\nend",
"def log_in_as(user)\n cookies[:remember_token] = user.remember_token\n end",
"def add_cookies(headers)\n cookies = headers[:cookie]\n cookies_hash = Hash.new\n return false unless cookies\n cookies.split('&').each do |string|\n k,v = string.split('=')\n cookies_hash[convert_key(k)] = v\n end\n @params[:cookie] = cookies_hash\n end",
"def build_cookie_header cookies\r\n cookies.to_a.map { |a| a.join '=' }.join '; '\r\n end",
"def log_in!(user)\n cookies[:session_token] = user.reset_token!\n end",
"def set_cookies\r\n @sec_cookie = SecureRandom.uuid\r\n @csrf_cookie = SecureRandom.uuid\r\n\r\n post_data = \"#{rand_text_alpha(5..12)},#{rand_text_alpha(5..12)},\" +\r\n \"#{@sec_cookie},#{@csrf_cookie}\"\r\n\r\n res = send_request_cgi({\r\n 'uri' => '/ForensicsAnalysisServlet/',\r\n 'method' => 'POST',\r\n 'ctype' => 'application/json',\r\n 'cookie' => \"SEC=#{@sec_cookie}; QRadarCSRF=#{@csrf_cookie};\",\r\n 'vars_get' =>\r\n {\r\n 'action' => 'setSecurityTokens',\r\n 'forensicsManagedHostIps' => \"#{rand(256)}.#{rand(256)}.#{rand(256)}.#{rand(256)}\"\r\n },\r\n 'data' => post_data\r\n })\r\n\r\n if res.nil? or res.code != 200\r\n fail_with(Failure::Unknown, \"#{peer} - Failed to set the SEC and QRadar CSRF cookies\")\r\n end\r\n end",
"def set_cookie name, value=nil, opts={}\n if Hash === value\n opts = value\n else\n opts[:value] = value\n end\n\n @response.set_cookie name, opts\n end",
"def hubssolib_get_secure_cookie_data(name)\n return HubSsoLib::Crypto.decode_object(cookies[name], request.remote_ip)\n end",
"def test_laptop_has_cookies\n end",
"def auth_cookie\n cookies[:auth]\n end",
"def remember!(cookies)\n\t\tcookie_expiration = 10.years.from_now\n\t\tcookies[:remember_me] = { :value => \"1\",\n\t\t\t\t\t\t\t\t :expires => cookie_expiration}\n\t\tself.authorization_token = secure_unique_identifier \n\t\tsave!\n\t\tcookies[:authorization_token] = {:value => authorization_token,\n\t\t\t\t\t\t\t\t\t\t :expires => cookie_expiration }\n\tend",
"def remember!(cookies)\n cookie_expiration = 10.years.from_now\n cookies[:remember_me] = {:value => \"1\",\n :expires => cookie_expiration}\n self.authorization_token = unique_identifier\n self.save!\n cookies[:authorization_token] = {\n :value => self.authorization_token,\n :expires => cookie_expiration }\n end",
"def remember!(cookies)\n cookie_expiration = 10.years.from_now\n cookies[:remember_me] = { :value => \"1\",\n :expires => cookie_expiration }\n self.authorization_token = unique_identifier\n save!\n cookies[:authorization_token] = { :value => authorization_token,\n :expires => cookie_expiration }\n end"
] |
[
"0.70282894",
"0.6747255",
"0.6416628",
"0.63507915",
"0.6194151",
"0.614814",
"0.6139925",
"0.6095302",
"0.6072791",
"0.6068868",
"0.60643744",
"0.6019987",
"0.5963435",
"0.5963435",
"0.5963435",
"0.5963435",
"0.5963435",
"0.5963435",
"0.5963435",
"0.5956143",
"0.59257454",
"0.58975405",
"0.5895513",
"0.58894026",
"0.58302355",
"0.5811854",
"0.58035624",
"0.5799242",
"0.579817",
"0.5794769",
"0.5792692",
"0.5789156",
"0.57874125",
"0.5785624",
"0.5784428",
"0.5778392",
"0.57754433",
"0.5773665",
"0.57633513",
"0.5760774",
"0.575423",
"0.5752535",
"0.5734026",
"0.5733844",
"0.5730149",
"0.57170206",
"0.57108486",
"0.56993",
"0.5696331",
"0.56915116",
"0.5685499",
"0.56815064",
"0.5674755",
"0.5673934",
"0.56726646",
"0.56598496",
"0.5655119",
"0.5646959",
"0.56398463",
"0.5636073",
"0.56314886",
"0.56276095",
"0.5626196",
"0.56117284",
"0.5611687",
"0.56007177",
"0.55940884",
"0.55917",
"0.55873346",
"0.55865294",
"0.55865043",
"0.558548",
"0.5585457",
"0.557966",
"0.557183",
"0.5564701",
"0.5563106",
"0.5547103",
"0.5541067",
"0.55381703",
"0.5534467",
"0.553345",
"0.5531741",
"0.55282134",
"0.5522577",
"0.5514778",
"0.5513276",
"0.5506636",
"0.5505989",
"0.5505452",
"0.5504372",
"0.5500633",
"0.54998106",
"0.54973006",
"0.5495868",
"0.5484964",
"0.5482804",
"0.5479807",
"0.54772055",
"0.547299"
] |
0.7165247
|
0
|
PUT /username_cookies/1 PUT /username_cookies/1.json
|
def update
@username_cookie = UsernameCookie.find(params[:id])
respond_to do |format|
if @username_cookie.update_attributes(params[:username_cookie])
format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @username_cookie.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @username_cookie = UsernameCookie.new(params[:username_cookie])\n\n respond_to do |format|\n if @username_cookie.save\n format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully created.' }\n format.json { render json: @username_cookie, status: :created, location: @username_cookie }\n else\n format.html { render action: \"new\" }\n format.json { render json: @username_cookie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cookies_for_user(resource)\n cookies[:c_user] = {value: resource.email, expires: 2.year.from_now}\n end",
"def destroy\n @username_cookie = UsernameCookie.find(params[:id])\n @username_cookie.destroy\n\n respond_to do |format|\n format.html { redirect_to username_cookies_url }\n format.json { head :no_content }\n end\n end",
"def create_cookies(username, password)\r\n\t\tcookies.signed[:username] = { \r\n\t \t\tvalue: username,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\t \tcookies.signed[:pwd] = {\r\n\t \t\tvalue: password,\r\n\t \t\texpires: 1.weeks.from_now }\r\n\tend",
"def update\n @cooky = Cookie.find(params[:id])\n\n respond_to do |format|\n if @cooky.update_attributes(params[:cooky])\n format.html { redirect_to @cooky, notice: 'Cookie was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_userid(id)\n response.set_cookie('userid', id)\n end",
"def add_to_cookie key, value\n cookie_hash = get_accesses_cookie\n cookie_hash[key] = value\n cookies[:accesses] = cookie_hash.to_json\n end",
"def cookies(cookies); end",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def remember(user)\nuser.remember\ncookies.permanent.signed[:user_id] = user.id\ncookies.permanent[:remember_token] = user.remember_token\nend",
"def remember!(cookies)\n cookies[:remember_me] = {:value => \"1\",\n :expires => COOKIE_EXPIRATION }\n \n self.authorization_token = unique_identifier\n self.save!\n cookies[:authorization_token] = {:value => self.authorization_token,\n :expires => COOKIE_EXPIRATION }\n end",
"def cookie_named(name); end",
"def remember!(cookies)\n\t\tcookie_expiration = 10.years.from_now\n\t\tcookies[:remember_me] = { :value => \"1\",\n\t\t\t\t\t\t\t\t :expires => cookie_expiration}\n\t\tself.authorization_token = secure_unique_identifier \n\t\tsave!\n\t\tcookies[:authorization_token] = {:value => authorization_token,\n\t\t\t\t\t\t\t\t\t\t :expires => cookie_expiration }\n\tend",
"def remember!(cookies)\n cookie_expiration = 10.years.from_now\n cookies[:remember_me] = {:value => \"1\",\n :expires => cookie_expiration}\n self.authorization_token = unique_identifier\n self.save!\n cookies[:authorization_token] = {\n :value => self.authorization_token,\n :expires => cookie_expiration }\n end",
"def create\n \tcookies.signed[:username] = params[:session][:username]\n \tredirect_to messages_path\n end",
"def set_api_cookie!\n return unless @session_object\n\n session.delete :value\n @session_object.to_hash.each { |k, v| session[k] = v }\n end",
"def remember!(cookies)\n cookie_expiration = 10.years.from_now\n cookies[:remember_me] = { :value => \"1\",\n :expires => cookie_expiration }\n self.authorization_token = unique_identifier\n save!\n cookies[:authorization_token] = { :value => authorization_token,\n :expires => cookie_expiration }\n end",
"def cookie_watcher_params\n params.require(:cookie_watcher).permit(:name, :cookies)\n end",
"def set_cookie_value\n cookie_value = User.using_client_shard(client: @client).get_cookie_value(@user.id, @user.password, @browser_user_agent)\n success_with_data({cookie_value: cookie_value, user_token_sale_state: @user.get_token_sale_state_page_name})\n end",
"def set_cookie\n puts \"hello\"\n # puts @order.as_json\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n puts cookies[:name] = current_admin.name\n puts \"-==-=-=-\"\n puts \"-==-=-=-\"\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\nend",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def store_cookie variable_name\r\n command 'storeCookie', variable_name\r\n end",
"def add_to_cookie_2 (id)\n cookies[:scotids] ? cookies[:scotsids] = JSON.parse(cookies[:scotsids]) << \"#{id}\" : cookies[:scotsids] = JSON.generate([\"#{id}\"])\n end",
"def remember(user)\n user.remember # Defined in the User model\n cookies[:user_id] = { value: user.id,\n expires: 20.years.from_now.utc }\n\n cookies[:remember_token] = { value: user.remember_token,\n expires: 20.years.from_now.utc }\n end",
"def add_token_to_cookie(cookies)\n token = SecureRandom.urlsafe_base64()\n @user.update(token: token)\n cookies['token'] = token\n create_return_object()\n end",
"def remember!(cookies)\n cookie_expiration = 14.days.from_now\n cookies[:remember_me] = {:value => \"1\",\n :expires => cookie_expiration}\n self.authorization_token = unique_identifier\n save!\n cookies[:authorization_token] = {:value => authorization_token,\n :expires => cookie_expiration}\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def new\n @username_cookie = UsernameCookie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @username_cookie }\n end\n end",
"def delete_cookie(cookies)\n cookies.delete('token')\n @user.update(token: '')\n end",
"def refresh_credentials(cookies)\n cookies['dc_logged_in'] = {:value => 'true', :expires => 1.month.from_now, :httponly => true}\n end",
"def index\n for i in 1..200\n #cookies[\"cookie \"+i.to_s] = { value: \"Guru \"+i.to_s, secure: true}\n end\n end",
"def put(session, context = Context.current)\n digest = session.instance_variable_get(\"@digest\")\n @cache[digest] = session\n cookie = Cookie.new(Session.cookie_name, digest)\n context.add_cookie(cookie)\n end",
"def change_cookie_token_id(id)\n\t\tself.update_attribute(\"cookie_token_id\",id)\n end",
"def set_current_user(user)\n sha1 = Digest::SHA1.hexdigest(user.id.to_s + Time.now.to_i.to_s)\n cookies[:remember_token] = { :value => sha1, :expires => 3.years.from_now }\n user.remember_token = sha1\n user.save\n @current_user = user\n end",
"def set_cooky\n @cooky = Cookie.find(params[:id])\n end",
"def set_cooky\n @cooky = Cookie.find(params[:id])\n end",
"def set_cooky\n @cooky = Cookie.find(params[:id])\n end",
"def do_write!(cookie_name, spec)\n @controller.write_cookie! cookie_name, spec.merge(same_site: self.class.cookie_same_site)\n @controller.write_cookie! \"#{cookie_name}_legacy\", spec\n end",
"def update\n respond_to do |format|\n if @cooky.update(cooky_params)\n format.html { redirect_to @cooky, notice: 'Cookie was successfully updated.' }\n format.json { render :show, status: :ok, location: @cooky }\n else\n format.html { render :edit }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cookie(name, value)\n test_cookies[name] = value\n end",
"def remember(user)\n#goes to remember method in user.rb and returns user.remember_token, and saves hashed one\n user.remember\n# saves users id\n cookies.permanent.signed[:user_id]=user.id\n# saves users cookies token\n cookies.permanent[:remember_token]=user.remember_token\n end",
"def set_cookie(name, value, attributes = {})\n cookie = Webmachine::Cookie.new(name, value, attributes).to_s\n case headers['Set-Cookie']\n when nil\n headers['Set-Cookie'] = [cookie]\n when Array\n headers['Set-Cookie'] << cookie\n end\n end",
"def delete_cookie(name); end",
"def set_cookie name, value=nil, opts={}\n if Hash === value\n opts = value\n else\n opts[:value] = value\n end\n\n @response.set_cookie name, opts\n end",
"def show\n @username_cookie = UsernameCookie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @username_cookie }\n end\n end",
"def delete_cookie name, path\r\n command 'deleteCookie', name, path\r\n end",
"def set_api_cookie!\n return unless @session_object\n\n @session_object.to_hash.each { |k, v| session[k] = v }\n end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def cookies; end",
"def set_cookie(name, value)\n @cookies[\"flexi_#{@id}_#{name}\"] = value\n return value\n end",
"def remember(user)\n\tuser.remember\n\tcookies.permanent.signed[:user_id] = user.id\n\tcookies.permanent[ :remember_token] = user.remember_token\nend",
"def cookie\n self[HttpClient::SET_COOKIE]\n end",
"def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def new_api_cookie_key\n 'ost_kit_new_api_cookies'\n end",
"def update_username(username)\n @username = username\n end",
"def setCookies(cookies)\n @fields['cookies'] = cookies\n self\n end",
"def setCookies(cookies)\n @fields['cookies'] = cookies\n self\n end",
"def set(resource)\n @cookies.signed[cookie_name] = {value: [resource.id, Time.now.to_i]}.merge(cookie_options)\n end",
"def set_cookie!\n cookies[:user_session] = {\n :value => token,\n :secure => controller.request.ssl?,\n :httponly => true,\n :expires => self.expires_at\n }\n end",
"def remember(user)\n \tuser.remember\n \tcookies.permanent.signed[:user_id]=user.id\n \tcookies.permanent[:remember_token]=user.remember_token\n end",
"def update( cookies )\n [cookies].flatten.compact.each do |c|\n self << case c\n when String\n begin\n Cookie.from_string( ::Arachni::Options.url.to_s, c )\n rescue\n Cookie.from_set_cookie( ::Arachni::Options.url.to_s, c )\n end\n\n when Hash\n Cookie.new( ::Arachni::Options.url.to_s, c ) if c.any?\n\n when Cookie\n c\n end\n end\n self\n end",
"def update_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def set_user_id\n if request.get? && current_user && cookies.signed[:user_id].blank?\n cookies.signed[:user_id] = current_user.id\n end\n end",
"def remember(user, type)\n user.remember_token = user.new_token\n user.update_attribute(:remember_digest, user.digest(user.remember_token))\n\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n cookies.permanent[:user_type] = type\n end",
"def user_remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def create\n @cooky = Cookie.new(params[:cooky])\n\n respond_to do |format|\n if @cooky.save\n format.html { redirect_to @cooky, notice: 'Cookie was successfully created.' }\n format.json { render json: @cooky, status: :created, location: @cooky }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_user(username, params)\n\t\t\t\tif @session['datastore'].has_key?(username)\n\t\t\t\t\t@session['datastore'][username] = params\n\t\t\t\tend\n\t\t\tend",
"def remember(user)\n\tuser.remember\n\tcookies.permanent.signed[:user_id] = user.id\n\tcookies.permanent[:remember_token] = user.remember_token\n end",
"def destroy\n @cooky = Cookie.find(params[:id])\n @cooky.destroy\n\n respond_to do |format|\n format.html { redirect_to cookies_url }\n format.json { head :no_content }\n end\n end",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def hubssolib_set_secure_cookie_data(name, value)\n if (@hubssolib_have_written_cookie)\n raise \"HubSsoLib: Attmept to set cookie '#{name}' more than once\"\n end\n\n @hubssolib_have_written_cookie = true\n\n # Using cookies.delete *should* work but doesn't. Set the\n # cookie with nil data instead.\n\n data = value.nil? ? nil : HubSsoLib::Crypto.encode_object(value, request.remote_ip)\n\n # No expiry time; to aid security, use session cookies only.\n\n cookies[name] = {\n :value => data,\n :path => HUBSSOLIB_COOKIE_PATH,\n :secure => true\n }\n end",
"def remember(user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.token\n end",
"def install_persistent_cookie(name, cookie)\n cookies[name] = {\n :value => cookie,\n :expires => 10.years.from_now\n }\n end",
"def update\n respond_to do |format|\n if @cookie_watcher.update(cookie_watcher_params)\n format.html { redirect_to @cookie_watcher, notice: 'Cookie watcher was successfully updated.' }\n format.json { render :show, status: :ok, location: @cookie_watcher }\n else\n format.html { render :edit }\n format.json { render json: @cookie_watcher.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_remember(user)\n user.remember_user\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def setUser\n cookies[:user_id]=current_user.id\n cookies[:is_tech]=current_user.tech\n end",
"def set_WithCookie(value)\n set_input(\"WithCookie\", value)\n end",
"def create\n session[:username] = params[:username]\n redirect_to root_path\n end",
"def login_sample()\n login_json = {\n :username => $username,\n :password => $password,\n :accessrights => $api_key\n }\n\n client = RestClient::Resource.new \"https://#{$hostname}/live/api/v3/\", :headers => {}, :verify_ssl => OpenSSL::SSL::VERIFY_NONE\n\n request = login_json.to_json\n response = client['login'].post request, { :content_type => 'application/json' }\n\n client.options[:headers][:cookies] = response.cookies\n\n p ''\n p 'Login'\n p response\n client\nend",
"def remember (user)\n user.remember\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def update\n if cookies[:edit]\n response.set_cookie(:edit,\n :value => cookies[:edit].to_i + 1\n )\n else\n @show_message = true;\n\n # set the visited cookie\n response.set_cookie(:edit,\n :value => 1,\n :expires => Time.now + (60 * 60 * 2)\n )\n\n end\n respond_to do |format|\n if @metal.update(metal_params)\n format.html { redirect_to @metal, notice: 'Metal was successfully updated.' }\n format.json { render :show, status: :ok, location: @metal }\n else\n format.html { render :edit }\n format.json { render json: @metal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def remember(user)\n user.remember # remember methode wird aufgerufen. user bekommt token und remember digest\n cookies.permanent.signed[:user_id] = user.id #we’ll use a signed cookie, which securely encrypts the cookie before placing it on the browser. we should make it permanent(expire after 20 years) as well, which we can do by chaining the signed and permanent methods\n cookies.permanent[:remember_token] = user.remember_token #der remember_token wird ebenfalls \"permanent\"\" im cookie gespeichert\n end",
"def update\n # @user is already set by correct_user\n # @user = User.find(params[:id])\n if @user.update_attributes(params[:user])\n # Handle a successful update.\n flash[:success] = \"Profile updated\"\n # log_in here makes sure token in cookie gets updated\n # If someone is using hijacked cookie, token gets updated and results in stole token not working\n log_in @user\n redirect_to @user\n else\n render 'edit'\n end\n end",
"def []=(key, value)\n changes << key\n @cookies[key] = value\n end",
"def []=(key, value)\n changes << key\n @cookies[key] = value\n end",
"def set_cookie(name, value, path = '/', httponly = true, secure = true)\n \n cookie = WEBrick::Cookie.new(name, value)\n cookie.path = path\n cookie.httponly = httponly\n cookie.secure = secure\n \n # add cookie to response header\n @header['Set-Cookie'] = cookie.to_s\n end",
"def remember(user)\n\t\tuser.remember\n\t\tcookies.permanent.signed[:user_id] = user.id \n\t\tcookies.permanent[:remember_token] = user.remember_token\t\n\tend",
"def show\n logger.debug cookies\n cookies['keywords']=params[:id]\n redirect_to root_path , status: 303\n end",
"def create\n @cooky = Cookie.new(cooky_params)\n\n respond_to do |format|\n if @cooky.save\n format.html { redirect_to @cooky, notice: 'Cookie was successfully created.' }\n format.json { render :show, status: :created, location: @cooky }\n else\n format.html { render :new }\n format.json { render json: @cooky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_cookie(name, value = nil)\n @context.add_cookie(name, value)\n end",
"def remember(user)\n user.save_remember_digest\n cookies.permanent.signed[:user_id] = user.id\n cookies.permanent[:remember_token] = user.remember_token\n end",
"def set_cookie(name, value, expires)\n (headers['Set-Cookie'] ||=[]) << (Merb::Const::SET_COOKIE % [\n name.to_s, \n ::Merb::Request.escape(value.to_s), \n # Cookie expiration time must be GMT. See RFC 2109\n expires.gmtime.strftime(Merb::Const::COOKIE_EXPIRATION_FORMAT)\n ])\n end",
"def set_cookie(env, headers, cookie)\n request = Rack::Request.new(env)\n if request.cookies[@key] != cookie[:value] || cookie[:expires]\n Utils.set_cookie_header!(headers, @key, cookie)\n end\n end"
] |
[
"0.62237877",
"0.59685695",
"0.58763754",
"0.5856852",
"0.58295923",
"0.58131045",
"0.57982934",
"0.57786036",
"0.57616216",
"0.5760699",
"0.57233286",
"0.5719673",
"0.57148725",
"0.5692965",
"0.5687843",
"0.5682418",
"0.5679484",
"0.5643379",
"0.5640627",
"0.56324404",
"0.56294763",
"0.5622418",
"0.55928224",
"0.5582068",
"0.55674005",
"0.5560581",
"0.5557788",
"0.55532444",
"0.55519414",
"0.55475855",
"0.5539238",
"0.553436",
"0.55299884",
"0.5528463",
"0.5521075",
"0.5507653",
"0.5507653",
"0.5507653",
"0.5502746",
"0.5500206",
"0.54972404",
"0.54874986",
"0.54873943",
"0.5473029",
"0.5459518",
"0.54497385",
"0.54355586",
"0.5435527",
"0.5435312",
"0.5435312",
"0.5435312",
"0.5435312",
"0.5435312",
"0.5435312",
"0.5435312",
"0.5434766",
"0.543321",
"0.5425017",
"0.54237616",
"0.54175293",
"0.5406004",
"0.53972924",
"0.53972924",
"0.5394159",
"0.5390746",
"0.53679407",
"0.5365334",
"0.53427315",
"0.53186125",
"0.5290507",
"0.52893513",
"0.5287549",
"0.5285001",
"0.52755547",
"0.52731717",
"0.52706534",
"0.52706534",
"0.52690125",
"0.526747",
"0.52537465",
"0.52533644",
"0.52523565",
"0.5251014",
"0.5249383",
"0.5244785",
"0.52440464",
"0.5242641",
"0.5236376",
"0.5232522",
"0.5229292",
"0.5227248",
"0.5227248",
"0.52263427",
"0.5225551",
"0.5214557",
"0.5211772",
"0.5210233",
"0.5205677",
"0.52016026",
"0.52006173"
] |
0.6980895
|
0
|
DELETE /username_cookies/1 DELETE /username_cookies/1.json
|
def destroy
@username_cookie = UsernameCookie.find(params[:id])
@username_cookie.destroy
respond_to do |format|
format.html { redirect_to username_cookies_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_cookie name, path\r\n command 'deleteCookie', name, path\r\n end",
"def delete_cookie name\n @response.delete_cookie name\n end",
"def delete_cookie(name); end",
"def delete_cookie(cookies)\n cookies.delete('token')\n @user.update(token: '')\n end",
"def destroy\n @cooky = Cookie.find(params[:id])\n @cooky.destroy\n\n respond_to do |format|\n format.html { redirect_to cookies_url }\n format.json { head :no_content }\n end\n end",
"def delete_all_cookies; end",
"def delete(cookie)\n # self\n end",
"def delete_cookie(name)\n driver.manage.delete_cookie(name)\n end",
"def destroy\n @cooky.destroy\n respond_to do |format|\n format.html { redirect_to cookies_url, notice: 'Cookie was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n set_cookie(\"name\" => name.to_s, \"value\" => \"\")\n end",
"def delete_cookie(cookie_name:, url:)\n {\n method: \"Page.deleteCookie\",\n params: { cookieName: cookie_name, url: url }.compact\n }\n end",
"def delete_cookie(name)\n cookie = Cookie.new(name, \"\")\n cookie.expires = 1.year.ago \n @context.add_cookie(cookie) \n end",
"def delete(username)\n perform_request({:action => \"client-delete\", :username => username})\n end",
"def delete(name)\n @control.delete_cookie(name)\n end",
"def delete(name, options = {})\n options.stringify_keys!\n set_cookie(options.merge(\"name\" => name.to_s, \"value\" => \"\", \"expires\" => Time.at(0)))\n end",
"def delete(name, options = {})\n set_cookie(name, \"\", options.merge(\"expires\" => Time.at(0)))\n end",
"def forget(user)\nuser.forget\ncookies.delete(:user_id)\ncookies.delete(:remember_token)\nend",
"def forget(user)\nuser.forget\ncookies.delete(:user_id)\ncookies.delete(:remember_token)\nend",
"def delete_cookie(name)\n browser.delete_cookie(name)\n end",
"def delete_cookie(name)\n @driver.manage.delete_cookie(name)\n end",
"def clear_cookies\n \tcookies.delete(:auth_token)\n end",
"def destroy\n session[:user_id] = nil\n head(:ok, status: :no_content) \n end",
"def delete key, opts ={}\n return if confined?\n @response.delete_cookie key, opts\n end",
"def destroy \n session.delete :user_id \n head :no_content \n end",
"def delete_cookie(name)\n $LOG.info \"deleting cookie #{name}\"\n begin\n $driver.manage.delete_cookie name\n rescue Exception => e\n $LOG.error \"error in deleting cookie #{name} \"+e.message\n raise \"Error in deleting cookie #{name} \"+e.message\n end\n end",
"def destroy\n\t\tcookies.delete 'Vanilla'\n\t\tcookies.delete 'Vanilla-Volatile'\n\t\tsuper\n\tend",
"def delete_cookie\n cookies.delete :auth_token\n end",
"def logout_sample(client)\n response = client['logout'].post nil\n\n client.options[:headers][:cookies] = response.cookies\n\n p ''\n p 'Logout'\n p response\nend",
"def delete_cookie(key, value = {})\n Rack::Utils.delete_cookie_header!(@headers, key, value)\n end",
"def deleteLogin( login_id)\n params = Hash.new\n params['login_id'] = login_id\n return doCurl(\"delete\",\"/login\",params)\n end",
"def destroy\n session.delete :user_id\n cookies.delete :user_id\n cookies.delete :auto_login_token\n respond_to do |format|\n format.html { redirect_to :root, :notice => 'ログアウトしました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n logout\n render json: {:ok => true}\n end",
"def delete key, opts ={}\n return if readonly?\n response.delete_cookie key, opts\n end",
"def destroy\n @cookie_watcher.destroy\n respond_to do |format|\n format.html { redirect_to cookie_watchers_url, notice: 'Cookie watcher was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def delete(url)\n setup_or_refresh_rest_session\n @session.delete(url: url)\n end",
"def delete(name)\n @crumbs.delete name.to_s\n set_cookie\n end",
"def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end",
"def log_out\n cookies.delete :user_id\n cookies.delete :username\n redirect_to :action => \"sign_in\"\n end",
"def log_out\n\t\tcookies.delete(:cookie_id)\n\n\tend",
"def forget!(cookies)\n cookies.delete(:remember_me)\n cookies.delete(:authorization_token)\n end",
"def forget!(cookies)\n cookies.delete(:remember_me)\n cookies.delete(:authorization_token)\n end",
"def forget!(cookies)\n cookies.delete(:remember_me)\n cookies.delete(:authorization_token)\n end",
"def forget!(cookies)\n cookies.delete(:remember_me)\n cookies.delete(:authorization_token)\n end",
"def user_delete(user_id)\n res = http_delete(:uri=>\"/users/#{user_id}\", :fields=>x_cookie)\n return res.code\n end",
"def delete_cookie(key)\n ::Rack::Utils.delete_cookie_header!(@_headers, key, {})\n end",
"def delete_cookie(key)\n ::Rack::Utils.delete_cookie_header!(@_headers, key, {})\n end",
"def test_should_delete_token_on_logout\n login_as :quentin\n get :logout\n assert_equal @response.cookies[\"auth_token\"], []\n end",
"def destroy\n @user_session = UserSession.find()\n begin\n @user_session.destroy\n \n # Log the user out of the forums also\n cookies[\"Vanilla\"] = {:value => \"\", :domain => \".worlize.com\"}\n cookies[\"Vanilla-Volatile\"] = {:value => \"\", :domain => \".worlize.com\"}\n session.delete(:signed_request)\n rescue\n end\n\n respond_to do |format|\n format.html { redirect_to(root_url) }\n format.json { render :json => { :success => true } }\n end\n end",
"def forget(user)\n user.forget\n cookies.delete(:user_id)\n cookies.delete(:remember_token)\nend",
"def delete(name)\n @cookies.reject! do |cookie|\n cookie.name == name\n end\n nil\n end",
"def destroy\n @account = Account.find_by_remember_token(cookies[:remember_token])\n @account.destroy\n respond_to do |format|\n format.html { sign_out }\n format.json { head :no_content }\n redirect_to root_url\n end\n end",
"def destroy\n cookies.signed[:current_user_id] = nil\n redirect_to new_session_path\n end",
"def destroy\n\t\tcookies.delete(:auth_token)\n\t\tredirect_to root_url\n\tend",
"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 unset\n @cookies.delete cookie_name, cookie_options\n end",
"def delete_user(username)\n\t\t\t\t@session['datastore'][username] = nil\n\t\t\tend",
"def user_logout\n res = http_delete(:uri=>\"/session\", :fields=>x_cookie)\n return res.code\n end",
"def forget (user)\n\tuser.forget\n\tcookies.delete(:user_id)\n\tcookies.delete(:remember_token)\nend",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete(path)\n uri = build_uri(path)\n\n request = Net::HTTP::Delete.new(uri.request_uri)\n set_authorisation_header(request)\n\n response = https_client(uri).request(request)\n end",
"def destroy\n session[:user_id] = nil\n response.status=(200)\n render json: {status: \"Success\", message: [\"Successfully Logged Out\"]}\n end",
"def user_delete(user_id)\n\t\tdelete_call = Curl::Easy.http_delete(\"#{@ip_address}:#{@port_2}/v2.0/users/#{user_id}\"\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['userId'] = user_id\n\t\tend\n\t\n\tend",
"def forget(user)\n cookies.delete(:user_id)\n cookies.delete(:remember_token)\n end",
"def clearcookies\n cookies.delete Prismic::PREVIEW_COOKIE\n redirect_to '/'\n end",
"def destroy\n current_user.destroy\n head 204\n end",
"def destroy\n @user=User.where(:authentication_token=>params[:api_key]).first\n @user.reset_authentication_token!\n render :json => { :message => [\"Session deleted.\"] }, :success => true, :status => :ok\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 cookies.each do |k|\n cookies.delete(k.at(0))\n end\n reset_session\n flash[:notice] = \"Kirjauduttu ulos\"\n redirect_to login_path\n end",
"def destroy\n @api_user.destroy\n\n head :no_content\n end",
"def destroy\n session_user.destroy\n render json: session_user\n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def logout\n #TODO: add extra logic if required\n delete_cookie(GlobalConstant::Cookie.user_cookie_name)\n render_api_response(Result::Base.success({}))\n end",
"def destroy\n # super\n # raise Visit.where(user_id: current_user.id status: 'waiting').inspect\n @visit = Visit.where(\"user_id = ? AND status = ?\", current_user.id, 0)\n @visit[0].update(status: 2) if @visit[0]\n \n reset_session\n cookies[:user_id] = nil\n cookies[:user_name] = nil\n redirect_to \"/login/#{params[:id]}\"\n end",
"def delete_session\n request.method = :get\n request.uri = '_session'\n Couchdbtools.execute(request)\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @session = Session.get_from_cookies(cookies)\n @session.destroy if @session\n Session.remove_from_cookies(cookies)\n\n respond_to do |format|\n format.html { redirect_to(:login) }\n format.xml { head :ok }\n end\n end",
"def uncookie_user\n cookies.delete :auth, :domain => site_domain\n end",
"def delete(url, vars={})\n send_request url, vars, 'DELETE'\n end",
"def destroy\n current_session.destroy if current_session\n\n cookies.delete(:remember_token)\n @current_user = nil\n\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Session was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n delete_from_server single_url\n end",
"def destroy\n head :unauthorized\n end",
"def destroy\n log_out\n redirected_to root_url\n end",
"def delete(url)\n do_request(\"delete\", url)\n end",
"def destroy\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n @resource.destroy\n head :no_content\n end",
"def delete_session(env, sid, options); end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n cookies[:list]=cookies[:list].gsub(\",#{@list.id}\",\"\")\n format.html { redirect_to \"/\", notice: 'List was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def forget\n user.forget\n cookies.delete(:user_id)\n cookies.delete(:remember_token)\nend",
"def destroy\n session.delete :user_id\n redirect_to root_path\n end",
"def destroy\n @user = User.find(params[:user_uuid])\n @user.destroy\n head :ok\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 forget(user)\n user.forget\n cookies.delete :id\n cookies.delete :remember_token\n end",
"def destroy\n @qa_session = @qa_session_file.qa_session\n @qa_session_file.destroy\n respond_to do |format|\n format.html { redirect_to qa_session_url(@qa_session), notice: 'qa_session file was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # Send goodbye email\n YamrsMailer.goodbye_email(@user).deliver\n @user.destroy\n cookies.delete(:auth_token)\n respond_to do |format|\n format.html { redirect_to '/', notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def delete\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person.destroy\n @application_session.destroy\n session[:cos_session_id] = nil\n render_json :status => :ok\n end",
"def delete\n request('delete').auth_required!\n end",
"def forget(user)\n\tuser.forget\n\tcookies.delete(:user_id)\n\tcookies.delete(:remember_token)\n end"
] |
[
"0.7660538",
"0.74207956",
"0.73470616",
"0.70989513",
"0.7055573",
"0.6955128",
"0.6723728",
"0.66885024",
"0.6678918",
"0.6662511",
"0.6649223",
"0.66455483",
"0.66165936",
"0.6593298",
"0.6543894",
"0.64898294",
"0.6472694",
"0.6472694",
"0.6472011",
"0.6471079",
"0.64646053",
"0.64495724",
"0.64473784",
"0.6414653",
"0.6411557",
"0.6403748",
"0.63993865",
"0.6378277",
"0.63613147",
"0.63566065",
"0.6348873",
"0.6346572",
"0.63321716",
"0.6312646",
"0.6308889",
"0.6294401",
"0.62833333",
"0.6282848",
"0.6269039",
"0.6265273",
"0.62573606",
"0.62573606",
"0.62573606",
"0.62573606",
"0.624534",
"0.6215445",
"0.6215445",
"0.6199074",
"0.61909795",
"0.6185116",
"0.618455",
"0.6180015",
"0.6175567",
"0.6167981",
"0.6162181",
"0.6162181",
"0.61228526",
"0.6119288",
"0.6117202",
"0.6112776",
"0.6112776",
"0.6107676",
"0.610678",
"0.6106505",
"0.6099105",
"0.6086731",
"0.60838807",
"0.60760474",
"0.60702246",
"0.60691154",
"0.6068515",
"0.6064816",
"0.60634124",
"0.60609674",
"0.60605276",
"0.6051837",
"0.6049949",
"0.60427517",
"0.60295326",
"0.6027312",
"0.6020243",
"0.60186964",
"0.60143924",
"0.60137606",
"0.6012794",
"0.6005541",
"0.60050625",
"0.6004644",
"0.60023206",
"0.60009444",
"0.6000608",
"0.59901845",
"0.59882796",
"0.59841335",
"0.59829694",
"0.59803087",
"0.5979996",
"0.5974263",
"0.5973105",
"0.5970531"
] |
0.76348335
|
1
|
Used when the relay's internal integrity is in doubt
|
def severe_error(note ="", excpt)
if @controller and @controller.class < ApplicationController
@controller.expires_now
@controller.head :internal_server_error,
x_error_details: 'Something is wrong with this relay. Try again later.'
end
_log_exception ERROR,note,excpt
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def transact; end",
"def transient?; end",
"def secure_subresource_integrity_context?; end",
"def secure_subresource_integrity_context?; end",
"def private; end",
"def awaken!\n\t\traise 'Not implemented'\n\tend",
"def internal?; end",
"def within_transaction; end",
"def within_transaction; end",
"def include_checksum_state\n super\n end",
"def verification_state\n super\n end",
"def resident_key?; end",
"def verify\n # nothing to do here, so just return\n end",
"def isolated; end",
"def isolated; end",
"def leeway; end",
"def leeway; end",
"def old_sync; end",
"def peer; end",
"def stores_foreign_key?; false; end",
"def stores_foreign_key?; false; end",
"def compute_integrity?(options); end",
"def compute_integrity?(options); end",
"def internal; end",
"def transfer; end",
"def transfer; end",
"def internship_passed; end",
"def vital?\n return @peer.vital?\n end",
"def is_not_pending_recovery!\n self.update_attribute(:verification_key, nil) if self.is_pending_recovery?\n end",
"def transmission; end",
"def contract; end",
"def contract; end",
"def sharded?; false; end",
"def orphan?\n false\n end",
"def bypass_valid\r\n self.persisted? #and self.bypass\r\n end",
"def semact?; false; end",
"def verify#todo\n #if its a fault, then its a no for sure\n #otherwise make sure all the fields are the right type, and are initialized etc\n true\n end",
"def refutal()\n end",
"def verify\r\n self.verified = true\r\n end",
"def validate_checksum_state\n super\n end",
"def ready_remix() end",
"def disable_referential_integrity\n yield\n end",
"def disable_referential_integrity\n yield\n end",
"def disable_referential_integrity\n yield\n end",
"def disable_referential_integrity\n yield\n end",
"def referenced; end",
"def transaction_disabled=(_arg0); end",
"def needs_rekey?; end",
"def dead?; end",
"def we_can_set_the_inverse_on_this?(record)\n false\n end",
"def verify\n end",
"def transaction_disabled; end",
"def ux_fix\n if requires_check\n self.no_dbs_policy_details = nil\n else\n self.dbs_policy_details = nil\n end\n end",
"def connection_status_crypt_request; end",
"def referenced?; end",
"def inherit_to_next_generation( next_generation )\r\n if msg.sender == @corrupt_elite\r\n @corrupt_elite = next_generation\r\n end\r\n end",
"def chargeable?; true; end",
"def verify!\n reconnect! unless active?\n end",
"def is_foreign_transaction?\n return true if @extra_details.has_key?('currencyRate')\n false\n end",
"def postConditionalGLSConnection\n# 4A107\n dataProtection = DataProtection.new\n result = (dataProtection.checkDataEncrypted('cougaar') >= 100)\n saveResult(result, \"4a107\", \"no persisted data encrypted if dataprotection is not turned on\")\n#exit 0\n\n end",
"def access_locked?; end",
"def quebecmandate\n\n end",
"def _synced?(foreign_key)\n !!_synced[foreign_key]\n end",
"def inherit_to_next_generation( next_generation )\r\n if msg.sender == @corrupt_elite\r\n @corrupt_elite = @next_generation\r\n end\r\n end",
"def isolated?; end",
"def isolated?; end",
"def sharded?; true; end",
"def verify!\n raise \"Payment details not active anymore\" if active == false\n end",
"def consigned?\n false\n end",
"def attach; end",
"def haveStolen\n @canISteal = false\n\n end",
"def distracted?\n false\n end",
"def verify_signatures?; end",
"def virgin?\n self.transactions.empty?\n end",
"def signature_verification_state\n super\n end",
"def guard_process_payment_from_created; true; end",
"def guard_process_payment_from_created; true; end",
"def transferee\n return @transferee\n end",
"def within_transaction(object); end",
"def estConsomable()\n\t\treturn false\n\tend",
"def transaction_proxy?\n false\n end",
"def signed_or_encrypted; end",
"def stores_foreign_key?\n false\n end",
"def transaction_primitive\n raise NotImplementedError\n end",
"def connection_mirror_state\n super\n end",
"def connection_mirror_state\n super\n end",
"def transaction; end",
"def transaction; end",
"def transaction; end",
"def disable_referential_integrity(&block)\n yield\n end",
"def celebration; end",
"def has_sibling?(peer); false end",
"def ridicule_faultfully_prerevision()\n end",
"def droby_dump(peer)\n raise NotImplementedError\n end",
"def destroy\n self.class.where(:id => self.id).update_all(:is_mirrored => false) if self.is_mirrored?\n super\n end",
"def usable?; end",
"def is_pending_recovery!\n self.update_attribute(:verification_key, KeyGenerator.create)\n end",
"def connection_status_crypt_response; end",
"def bookable; false end",
"def verify\n\t\tself.verified = true\n\t\tself.save\n\tend",
"def stored_offsite?\n (@trustee == true || (! billing_key.blank? && !changed?))\n end"
] |
[
"0.5725947",
"0.56816244",
"0.5655014",
"0.5654379",
"0.55838937",
"0.5581538",
"0.5505918",
"0.5470222",
"0.5470222",
"0.54588896",
"0.54393655",
"0.5422585",
"0.53821224",
"0.53698504",
"0.53698504",
"0.5353097",
"0.5353097",
"0.5349499",
"0.5347944",
"0.53330284",
"0.53330284",
"0.5324135",
"0.5324135",
"0.5307045",
"0.5305684",
"0.5305684",
"0.52994215",
"0.52926296",
"0.52825046",
"0.5259661",
"0.5256784",
"0.5256784",
"0.5250589",
"0.5247783",
"0.5241123",
"0.5228019",
"0.5214599",
"0.5213961",
"0.5208354",
"0.5202275",
"0.5197323",
"0.5190009",
"0.5190009",
"0.5190009",
"0.5190009",
"0.51758987",
"0.5172954",
"0.51716745",
"0.51671994",
"0.5166409",
"0.5160941",
"0.51534235",
"0.51521665",
"0.5151642",
"0.5143043",
"0.5142567",
"0.5140127",
"0.51388925",
"0.5138287",
"0.5128135",
"0.5116053",
"0.51071185",
"0.51066595",
"0.5105342",
"0.51019967",
"0.51019967",
"0.50983137",
"0.509326",
"0.50899905",
"0.50868475",
"0.5084591",
"0.5083108",
"0.5077826",
"0.50748336",
"0.50715375",
"0.5071101",
"0.5071101",
"0.50648624",
"0.5062308",
"0.5061112",
"0.50585985",
"0.5058339",
"0.5054227",
"0.5048357",
"0.5043335",
"0.5043335",
"0.50378966",
"0.50378966",
"0.50378966",
"0.50356513",
"0.5035145",
"0.503465",
"0.50340235",
"0.5027388",
"0.50260794",
"0.5018718",
"0.5017195",
"0.5015842",
"0.5009348",
"0.5009111",
"0.4993029"
] |
0.0
|
-1
|
This is used to log general nonZAX exceptions
|
def report(note, excpt)
# handle non-ZAX errors, such as encoding, etc.
@controller.expires_now
@controller.head @response_code,
x_error_details: 'Your request can not be completed.'
_log_exception WARN,note,excpt
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def log_error(exception); end",
"def log_exception(excp, meth = nil)\n error = warning = nil\n case excp\n when Shrine::FileNotFound then warning = 'FILE_NOT_FOUND'\n when Shrine::InvalidFile then warning = 'INVALID_FILE'\n when Shrine::AttachmentChanged then warning = 'ATTACHMENT_CHANGED'\n when Shrine::Error then error = 'unexpected Shrine error'\n else error = \"#{excp.class} unexpected\"\n end\n Log.add(error ? Log::ERROR : Log::WARN) do\n \"#{meth || __method__}: #{excp.message} [#{error || warning}]\"\n end\n end",
"def _log_exception(icon, note, excpt)\n warn \"#{icon} #{note}:\\n#{EXPT} \\xE2\\x94\\x8C#{excpt} \\xE2\\x94\\x90\"\n warn excpt.backtrace[0..7].reduce(\"\") { |s,x|\n s += \"#{EXPT} \\xE2\\x94\\x9C#{x}\\n\" } +\n \"#{EXPT} \\xE2\\x94\\x94#{BAR*25}\\xE2\\x94\\x98\"\n end",
"def catch_exceptions; end",
"def show_detailed_exceptions?; end",
"def unexpected_error(e)\n log_error(\"Unexpected error while processing request\", e)\n end",
"def exceptions; end",
"def fatal; end",
"def exceptions\n end",
"def egregious_log(exception)\n logger.fatal(\n \"\\n\\n\" + exception.class.to_s + ' (' + exception.message.to_s + '):\\n ' +\n clean_backtrace(exception).join(\"\\n \") +\n \"\\n\\n\")\n notify_airbrake(exception)\n end",
"def log_invalid_stripe_request(exception)\n # logs stripe exception\n ActiveSupport::Notifications.instrument 'anyplace.stripe_action.failed', exception\n end",
"def try_with_pretty_error_log\n yield\n rescue RuntimeError => e\n begin\n openerp_error_hash = eval(\"#{ e }\".gsub(\"wrong fault-structure: \", \"\"))\n if openerp_error_hash.is_a? Hash\n logger.error \"*********** OpenERP Server ERROR:\n #{openerp_error_hash[\"faultString\"]}\n ***********\"\n end\n rescue\n end\n raise\n end",
"def log_exceptions\n yield\n rescue Exception => e\n self.exception e\n raise e\n end",
"def log(msg)\n super(\"resque-exception - #{msg}\")\n end",
"def log_exception(e, sym=:error)\n ar = [e.message] \n ar = ar + e.backtrace\n ar.each do |element|\n puts \"#{sym} #{element}\"\n end\n if sym == :info && $dplayer_list\n $dplayer_list.each do |ch|\n if ch.level >= LEVEL_IMM\n ar.each do |element|\n ch.text_to_player element + ENDL\n end\n end\n end\n end\nend",
"def exception_details(e, msg); end",
"def log_request_response(exception = nil)\n super(exception) if exception.present?\n end",
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def report_unauthenticated_requests(e)\n ApiAuthenticator.logger.warn(\"failed request #{e.constructed_message}\")\n end",
"def log_exception(ex)\n log_error { ex.message }\n log_error { ex.backtrace[0..5].join(\"\\n\") }\n log_debug { ex.backtrace.join(\"\\n\") }\n end",
"def silence_action_dispatch_debug_exceptions_logger\n require 'loga/ext/rails/rack/debug_exceptions.rb'\n end",
"def cashboard_rescue_exception\n logger.error '^^^ CASHBOARD SPECIFIC INFO FOR ABOVE ERROR'\n logger.error '--------------------------------------------------------------------------------'\n begin\n logger.error \"URL : #{request.env['PATH_INFO']}\"\n logger.error \"BROWSER: #{request.env['HTTP_USER_AGENT']}\"\n logger.error \"IP ADDR: #{request.env['REMOTE_ADDR']}\"\n # Try to find account if it's not set\n @account ||= Account.find_by_subdomain(account_subdomain)\n if @account\n logger.error \"ACCOUNT: #{@account.subdomain}\"\n end\n if @user\n logger.error \"USER : #{@user.inspect}\\n\"\n end\n rescue\n logger.error '...An error happend logging specific errors...wtf?'\n end\n logger.error '--------------------------------------------------------------------------------'\n logger.error ''\n end",
"def log_error(ex)\n if @config.logger.respond_to?(:error)\n @config.logger.error(\"CrashHook Error: #{ex.inspect}\")\n elsif @config.logger.kind_of?(IO)\n @config.logger.puts(\"CrashHook Error: #{ex.inspect}\")\n end\n end",
"def handle_generic_error ex\n log_exception(ex)\n errors _(\"An unexpected error has occurred, details have been logged.\")\n redirect_back\n end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def skip_backtrace; end",
"def handle_exceptions_gracefully\n\n begin\n\n yield\n\n rescue => se\n\n Rails.logger.error(\"Exception in API: #{se.message} trace: #{se.backtrace}\")\n\n ExceptionNotifier.notify_exception(\n se,\n env: request.env\n )\n\n r = Result::Base.error(\n internal_id: 'ac_3',\n general_error_identifier: 'something_went_wrong'\n )\n\n return render_api_response(r)\n\n end\n\n end",
"def exception(*rest) end",
"def handle_stub_log_error(exception_data, always_raise = false)\n raise_unexpected_exception(exception_data) if always_raise || !exception_filtered?(exception_data)\n end",
"def logL\n raise \"No implemented\"\n end",
"def log_and_raise(logger, exception, message, shift=1)\n if logger.is_a?(ZTK::Logger)\n logger.shift(:fatal, shift) { \"EXCEPTION: #{exception.inspect} - #{message.inspect}\" }\n else\n logger.fatal { \"EXCEPTION: #{exception.inspect} - #{message.inspect}\" }\n end\n raise exception, message\n end",
"def exception_handler; end",
"def write_exception_to_log(ex, exception_context, timestamp, log_context = {})\n ActiveSupport::Deprecation.silence do\n log_message = \"#{exception_context}\\n#{ex.class}: (#{encode_utf8(ex.message.to_s)}):\\n \" + clean_backtrace(ex).join(\"\\n \") + \"\\n\\n\"\n\n if ex.is_a?(Warning)\n ExceptionHandling.logger.warn(\"\\nExceptionHandlingWarning (Warning:#{timestamp}) #{log_message}\", **log_context)\n else\n ExceptionHandling.logger.fatal(\"\\nExceptionHandlingError (Error:#{timestamp}) #{log_message}\", **log_context)\n end\n end\n end",
"def debug_exception_response_format=(_arg0); end",
"def debug_exception_response_format=(_arg0); end",
"def log_exception ex\n logger.error ex\n logger.error ex.class\n logger.error ex.backtrace.join(\"\\n\")\n end",
"def original_exception; end",
"def teardown_log_error_stub\n ExceptionHandling.stub_handler = nil\n return unless @exception_whitelist\n\n @exception_whitelist.each do |pattern, match|\n unless match[:expected] == match[:found]\n message = \"log_error expected #{match[:expected]} times with pattern: '#{pattern.is_a?(Regexp) ? pattern.source : pattern}' found #{match[:found]}\"\n\n if is_mini_test?\n flunk(message)\n else\n add_failure(message)\n end\n end\n end\n end",
"def processCrash; raise \"Abstract Exception: AbstractBeezwaxCrashProcessor.processCrash must be extended\"; end",
"def exception(ex, msg='')\n line = ''\n ex.backtrace.each do |l|\n line += \"\\n #{l}\"\n end\n @logger.error \"#{msg}: ** Exception thrown: #{ex.class}, backtrace follows:#{line}\"\n end",
"def enable_remote_exception_logging\n core.enable_remote_exception_logging\n end",
"def error(exception)\n logger.info \"execution failed: #{exception}\"\n end",
"def log_error(msg, res, ex)\n Puppet.err(\"%s for %s: Error %s:%s \" % [msg, res, ex.class, ex.message] )\n Puppet.err(\"Fault error message: %s\" % ex.fault.errMsg.to_s) if ex.is_a?(RbVmomi::Fault)\n end",
"def exception(ex)\n update_result(Automation::Result::Exception)\n @logger.error(format_exception(ex))\n end",
"def error(ex) [:error, ex]; end",
"def internal_server_error\n @exception = env['action_dispatch.exception']\n #TODO: log exception information you want to log here\n # after removing it from the normal logging via lograge\n render status: 500\n end",
"def exception(result = {}, log = true)\n log_exception(result) if log\n end",
"def catch_simple\n begin\n yield\n rescue => e\n Rails.logger.info e.message\n end\n end",
"def wrapped_exception; end",
"def log_error(err)\n\t\tprint_error(err)\n\n\t\twlog(err)\n\n\t\t# If it's a syntax error, log the call stack that it originated from.\n\t\tdlog(\"Call stack:\\n#{$@.join(\"\\n\")}\", 'core', LEV_1)\n\tend",
"def rescue_from(exception); end",
"def exceptions_app; end",
"def exceptions_app; end",
"def refute_exception\n yield\n rescue StandardError => e\n flunk e.message\n end",
"def underlying_exception; end",
"def log_exception(e)\n unless e.blank?\n log_error_with_timestamp e.inspect unless e.inspect.blank?\n log_error_with_timestamp e.backtrace.join(\"\\n \") unless e.backtrace.blank?\n end\nend",
"def exception_handler(ex)\n \nend",
"def disable_remote_exception_logging\n core.disable_remote_exception_logging\n end",
"def error(*args)\n log(*args)\n fail\n end",
"def puts_ex(e)\n\tputs \"\\nException: #{e}\"\n\tputs e.backtrace\t\n end",
"def backtrace_ignores; end",
"def exception(e)\n self.error \"#{e.class}: #{e.message}\" << (\"\\n#{e.backtrace.join(\"\\n\")}\" unless e.backtrace.nil?)\n end",
"def before_server_error(exception); end",
"def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend",
"def handle_generic_error(exception)\n end",
"def raise(exception); end",
"def report_internal_error(exception, original_error = nil)\n return if skip_reporting_internal_error(exception)\n\n failsafe_message = ''\n log_error(\n '[Rollbar] Reporting internal error encountered while sending data to Rollbar.'\n )\n\n configuration.execute_hook(:on_report_internal_error, exception)\n\n failsafe_message = 'build_item in exception_data'\n item = build_item('error', nil, exception, { :internal => true }, nil)\n\n failsafe_message = 'error in process_item'\n process_item(item)\n\n failsafe_message = 'error logging instance link'\n log_instance_link(item['data'])\n rescue StandardError => e\n send_failsafe(failsafe_message, e, original_error)\n log_error(item ? \"[Rollbar] Item: #{item}\" : \"[Rollbar] Exception: #{exception}\")\n end",
"def method_missing(name, *args, &block)\n $LOG.error \"Invalid method '#{name}' was called from #{self.class}! \" #+\n # \"Stacktrace: #{e.backtrace}\"\n end",
"def exc_msg_and_response(exc, response = T.unsafe(nil)); end",
"def underlying_exception=(_arg0); end",
"def event_processing_failed(exception, payload, raw_payload, dead_letter_queue_name)\n # do nothing\n end",
"def continued_exception; end",
"def log_errors!\n if AnyCable.config.debug?\n # Print error with backtrace in debug mode\n AnyCable.capture_exception do |e|\n stack = e.backtrace\n backtrace = stack ? \":\\n#{stack.take(20).join(\"\\n\")}\" : \"\"\n AnyCable.logger.error(\"#{e.message}#{backtrace}\")\n end\n else\n AnyCable.capture_exception { |e| AnyCable.logger.error(e.message) }\n end\n end",
"def print_exception(e)\n\tputs \"error: #{e.message}\"\nend",
"def exceptions_app=(_arg0); end",
"def exceptions_app=(_arg0); end",
"def stub_log_error\n ExceptionHandling.stub_handler = self\n end",
"def exception_class; end",
"def error(exception)\n log \"#{exception.message}\\n#{exception.backtrace.join(\"\\n\")}\", :error\n end",
"def log_and_raise(exception, message, shift=2)\n Base.log_and_raise(config.ui.logger, exception, message, shift)\n end",
"def stacktrace; end",
"def error(nvae)\n end",
"def test_does_not_consider_unknown_errors\n ig = ScoutApm::ErrorService::IgnoredExceptions.new(context, [\"ThisDoesNotExist\", \"IgnoredExceptionsTest::FakeError\"])\n assert ig.ignored?(FakeError.new(\"ignore this one\"))\n end",
"def log_error(exception) #:doc:\n ActiveSupport::Deprecation.silence do\n if ActionView::TemplateError === exception\n logger.fatal(exception.to_s)\n else\n logger.fatal(\n \"\\n#{exception.class} (#{exception.message}):\\n \" +\n clean_backtrace(exception).join(\"\\n \") + \"\\n\\n\"\n )\n end\n end\n end",
"def send(method, *args)\n super\n rescue StandardError => e\n args[1].debug \"#{e}\\n #{e.backtrace.first}\" # args[1] is the logger\n end",
"def raise_exception_info\n begin\n puts 'I am before the raise.'\n raise 'An error has occured.'\n puts 'I am after the raise.'\n rescue RuntimeError => e\n puts e.message\n puts e.backtrace.inspect # 打印具体的错误位置\n end\n puts 'I am after the rescue.'\nend",
"def log_error(exception) #:doc:\n ActiveSupport::Deprecation.silence do\n if ActionView::TemplateError === exception\n logger.fatal(exception.to_s)\n else\n logger.fatal(\n \"\\n\\n#{exception.class} (#{exception.message}):\\n \" +\n clean_backtrace(exception).join(\"\\n \") +\n \"\\n\\n\"\n )\n end\n end\n end",
"def original_exception=(_arg0); end",
"def log_exception(exception, extra = {})\n process_exception(exception, extra: extra)\n end",
"def log_error_to_remote(request, exception)\n if defined?(::Honeybadger) && !Honeybadger.configuration.api_key.nil?\n Honeybadger.notify_or_ignore(exception, {\n rack_env: request.env,\n environment_name: ENV[\"RACK_ENV\"]\n })\n else\n logger.debug(\"Honeybadger not configured, not sending exception there.\")\n end\n end",
"def log_exception(e)\n log_err(e.message)\n log_err(e.backtrace.join(\"\\n\"))\n end",
"def continued_exception=(_arg0); end",
"def log_error(*error_messages)\r\n options = custom_infos.extract_options!\r\n\r\n infos = []\r\n infos << \"Non-Exception Error raised when executing #{request.method} #{request.fullpath}\" if defined? request\r\n error_messages.each do |e_message|\r\n infos << \"\\t#{e_message}\"\r\n end\r\n infos << \"Error trace:\"\r\n include_trace_to info\r\n infos << \"\\n\"\r\n\r\n if options[:write_to] && options[:write_to].to_sym == :info\r\n $arb_log.error infos.join(\"\\n\")\r\n else\r\n $log.error infos.join(\"\\n\")\r\n end\r\nend",
"def log_errors!\n if AnyCable.config.debug?\n # Print error with backtrace in debug mode\n AnyCable.capture_exception do |e|\n AnyCable.logger.error(\"#{e.message}:\\n#{e.backtrace.take(20).join(\"\\n\")}\")\n end\n else\n AnyCable.capture_exception { |e| AnyCable.logger.error(e.message) }\n end\n end",
"def rescue_action(e); raise e; end"
] |
[
"0.6862617",
"0.64270955",
"0.63653624",
"0.6356976",
"0.6216813",
"0.61696357",
"0.61442095",
"0.61240125",
"0.60818774",
"0.60569966",
"0.60310954",
"0.6013101",
"0.5984913",
"0.5930575",
"0.5920844",
"0.59019554",
"0.5900062",
"0.58938634",
"0.58938634",
"0.58938634",
"0.58809775",
"0.58808637",
"0.58790314",
"0.5874067",
"0.58489347",
"0.5840741",
"0.58046323",
"0.58046323",
"0.58046323",
"0.58046323",
"0.58046323",
"0.5803346",
"0.57865125",
"0.57817525",
"0.5780663",
"0.57762176",
"0.57735467",
"0.5767085",
"0.5759358",
"0.5750914",
"0.5750914",
"0.57469267",
"0.5742386",
"0.57246995",
"0.5717946",
"0.5705925",
"0.56831354",
"0.5682956",
"0.5672729",
"0.5670475",
"0.5661293",
"0.56543237",
"0.5653769",
"0.565036",
"0.5621587",
"0.561781",
"0.56074846",
"0.5606808",
"0.5606808",
"0.56037295",
"0.5602701",
"0.55938256",
"0.5583291",
"0.55829483",
"0.55738276",
"0.55678",
"0.55627537",
"0.5559457",
"0.5544547",
"0.55319214",
"0.5513494",
"0.5501383",
"0.54949045",
"0.54947877",
"0.54934067",
"0.5491757",
"0.54844815",
"0.5478226",
"0.5477517",
"0.54757",
"0.5474936",
"0.5474936",
"0.54731333",
"0.54730165",
"0.54701567",
"0.5462898",
"0.5456082",
"0.54517376",
"0.54510635",
"0.54488933",
"0.54466",
"0.5439862",
"0.543005",
"0.54292375",
"0.54270196",
"0.5425019",
"0.542176",
"0.54209113",
"0.54191625",
"0.54116726",
"0.54114133"
] |
0.0
|
-1
|
This is used to log RbNaCl errors
|
def NaCl_error(e)
e1 = e.is_a?(RbNaCl::BadAuthenticatorError) ? 'The authenticator was forged or otherwise corrupt' : ''
e2 = e.is_a?(RbNaCl::BadSignatureError) ? 'The signature was forged or otherwise corrupt' : ''
error "#{ERROR} Decryption error for packet:\n"\
"#{e1}#{e2} "\
"#{@controller.body}"
_log_exception ERROR, "Stack trace", e
@controller.head @response_code,
x_error_details: 'Your request can not be completed.'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def log_error(exception); end",
"def log_error(error)\n ::NewRelic::Agent.logger.error(\"Error establishing connection with New Relic Service at #{control.server}:\",\n error)\n end",
"def log_error(msg)\n print_error(msg)\n\n elog(msg, 'hwbridge', error: $!)\n end",
"def log_error(err)\n\t\tprint_error(err)\n\n\t\twlog(err)\n\n\t\t# If it's a syntax error, log the call stack that it originated from.\n\t\tdlog(\"Call stack:\\n#{$@.join(\"\\n\")}\", 'core', LEV_1)\n\tend",
"def error(msg); @logger.error(msg); end",
"def error(msg) log(ERROR, \"ERROR \" << format(msg) << \", \" << caller[0][caller[0].rindex(\"/\").nil? ? 0 : caller[0].rindex(\"/\") + 1 .. -1]); end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def stderr; end",
"def record_error_metrics_and_log(error)\n NewRelic::Agent.record_metric(RESPONSE_ERROR_METRIC, 0.0)\n if error.is_a?(GRPC::BadStatus)\n NewRelic::Agent.record_metric(grpc_error_metric_name(error), 0.0)\n else\n NewRelic::Agent.record_metric(GRPC_OTHER_ERROR_METRIC, 0.0)\n end\n NewRelic::Agent.logger.warn('gRPC response error received.', error)\n end",
"def log_error(err)\n backtrace = Array(err.backtrace).flatten.compact\n\n backtrace =\n if backtrace.empty?\n ''\n else\n prefix = \"\\n \"\n prefix + backtrace.join(prefix)\n end\n\n message = \"#{err.class}: #{err.message}#{backtrace}\"\n Fluffle.logger.error message\n end",
"def write_error_info\n end",
"def error(nvae)\n end",
"def record_error_with_less_nodes\n @supervisor.increment_error_count\n\n dashes = '-' * 90\n\n @error = %{#{exception.message}\\n#{exception.backtrace.join(\"\\n\")}\n#{dashes}\\nQUEUE ELEMENT:\\n#{@element.inspect}\n#{dashes}\\nRAW PAYLOAD:\\n#{@response.inspect}\n#{dashes}\\nRAW BODY:\\n#{@response_body.inspect}\n#{dashes}\\nPARSED PAYLOAD:\\n#{@entity.inspect}}\n\n log(\"#{'=' * 90}\\nERROR processing data!#{@error}\")\nend",
"def log_errors(code_area)\n yield\n rescue => e\n ::NewRelic::Agent.logger.error(\"Caught exception in #{code_area}.\", e)\n end",
"def error(ex) [:error, ex]; end",
"def error(msg)\n log.error msg\n end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def error; end",
"def log_error(e=$!)\n logger = Log4r::Logger.new \"Mauve::HTTPServer\"\n logger.error(e)\n logger.debug(e.backtrace.join(\"\\n\")) \n end",
"def log_error(*error_messages)\r\n options = custom_infos.extract_options!\r\n\r\n infos = []\r\n infos << \"Non-Exception Error raised when executing #{request.method} #{request.fullpath}\" if defined? request\r\n error_messages.each do |e_message|\r\n infos << \"\\t#{e_message}\"\r\n end\r\n infos << \"Error trace:\"\r\n include_trace_to info\r\n infos << \"\\n\"\r\n\r\n if options[:write_to] && options[:write_to].to_sym == :info\r\n $arb_log.error infos.join(\"\\n\")\r\n else\r\n $log.error infos.join(\"\\n\")\r\n end\r\nend",
"def error\n asl_log(@aslclient, @aslmsg, ASL_LEVEL_ERR, message)\n end",
"def original_error; end",
"def original_error; end",
"def error(message)\n @module_manager.bot.log s prefix + \"\\e[31m\" + message + \"\\e[0m\"\n end",
"def error(*args)\n log(*args)\n fail\n end",
"def cr_error(s)\n # barclamp-deployer:\n # Chef::Log.error(s)\n # barclamp-crowbar:\n # Rails.logger.error(s)\n raise NotImplementedError, \"#{self.class} didn't implement error\"\n end",
"def error(text)\n GitPusshuTen::Log.error(text)\n end",
"def log_errors!\n if AnyCable.config.debug?\n # Print error with backtrace in debug mode\n AnyCable.capture_exception do |e|\n AnyCable.logger.error(\"#{e.message}:\\n#{e.backtrace.take(20).join(\"\\n\")}\")\n end\n else\n AnyCable.capture_exception { |e| AnyCable.logger.error(e.message) }\n end\n end",
"def error(*args); end",
"def log_error(msg)\n\t\tprint_error(msg)\n\n\t\telog(msg, 'meterpreter')\n\n\t\tdlog(\"Call stack:\\n#{$@.join(\"\\n\")}\", 'meterpreter')\n\tend",
"def sparkLogErrorToCerr(sync = false)\n sparkEnableLog(':cerr', 'eError', sync)\nend",
"def log_errors!\n if AnyCable.config.debug?\n # Print error with backtrace in debug mode\n AnyCable.capture_exception do |e|\n stack = e.backtrace\n backtrace = stack ? \":\\n#{stack.take(20).join(\"\\n\")}\" : \"\"\n AnyCable.logger.error(\"#{e.message}#{backtrace}\")\n end\n else\n AnyCable.capture_exception { |e| AnyCable.logger.error(e.message) }\n end\n end",
"def error(msg)\n @logger.error(format_msg(msg))\n fail(\"Middleman VCard generator failed\")\n end",
"def generate_error(args, response)\n \n puts \"Error! Check API Key and retry.\"\n puts response.body\n #File.open(\"../../../error.log\", 'a+') {|f| f.write(\"---\\n#{Time.now}\\nArgs: #{args[0]}, #{args[1]}, #{args[2]}\\n#{response.body}\\n---\\n\") }\n exit 1\n\nend",
"def log_request_error(error, url, error_code)\n Rails.logger.error(\"#{__FILE__} tried to access #{url} got: #{error.message} #{error.backtrace}\")\n log.puts \"#{error_code} #{error.message}\"\n end",
"def log_error(error)\n logger = ActiveSupport::TaggedLogging.new(Logger.new('log/rism_error.log'))\n logger.tagged(\"AGENT_SCAN (#{Time.now})\") do\n logger.error(error)\n end\n end",
"def _error(msg = nil)\n @api_error[:msg] = msg if msg\n logger.warn(@api_error[:loc]) { @api_error[:msg].message }\n end",
"def error(msg)\r\n prelog\r\n logger.error(msg)\r\n end",
"def create_profile_set_error(err)\n r_error = RaccError.new\n r_error.error_message=err\n racc_errors << r_error\n end",
"def handle_error(cmd, stderr)\n summary = \"\\rError running \\`#{cmd}\\`\"\n details = readable_curr_time << \"\\n\\n\"\n details << \"**************************************************************\\n\"\n details << \"#{summary}\\n\"\n details << \"**************************************************************\\n\"\n details << stderr << \"\\n\\n\"\n File.open(@err_path, 'a') { |file| file.write(details) }\n summary\nend",
"def error(msg)\n @logProvider.error(msg)\n end",
"def log_error(e = $!)\n (@logger ||= OMF::Base::LObject.new(self.class)).error(e)\n end",
"def error(msg) $stderr.puts(\"Error: #{msg}\") end",
"def recover_from(_error); end",
"def error_ln(message)\n write_message message, 'error', true\n end",
"def error(log)\n output.puts log if log_level <= ERROR\n end",
"def error_message; end",
"def errmsg(message); end",
"def error(exception) nil ; end",
"def error(msg)\n puts \"\\n#{@red}[Error] #{msg}!#{@ncl}\\n\"\n end",
"def stderr_received(data); end",
"def trace_errors\n getErrors.each { |e|\n puts \"(#{e.object || ''}): #{e.error}\"\n }\n end",
"def err(e)\n @logger.error(e)\n end",
"def error(*args)\n log(:error, *args)\n end",
"def compile_error(msg)\n end",
"def error(message)\n STDERR.puts message\nend",
"def recoverable_error e, msg = \"Error\", bt = []\n puts \"#{msg} at time #{clock}\"\n puts \"From \" + bt[0..2].join(\"\\n \") unless bt.empty\n puts \" ...\" if bt.length > 3\n shell.run\n end",
"def error\n end",
"def debug_error(error, req = T.unsafe(nil), text = T.unsafe(nil)); end",
"def client_error(e, client); end",
"def error_message\n if nagios_mode?\n puts \"CRIT: #{invalid_metadata_files.size} metadata files and #{invalid_packages.size} packages with invalid checksums\"\n else\n invalid_metadata_files.each do |metadata|\n msg metadata.explain_error\n end\n invalid_packages.each do |pkg|\n msg pkg.explain_error\n end\n end\n end",
"def log(msg)\n super(\"resque-exception - #{msg}\")\n end",
"def last_err\n api(\"LastErr\")\n end",
"def err\n @err\n end",
"def error( msg=nil, &block )\n\t\t\t\treturn self.debug( msg, &block ) if @force_debug\n\t\t\t\tGemserver.logger.add( Logger::ERROR, msg, @classname, &block )\n\t\t\tend",
"def server_error\n\n end",
"def LogErrors(log)\n @log_errors = log\n\n nil\n end",
"def error=(_arg0); end",
"def error=(_arg0); end",
"def error=(_arg0); end",
"def error_and_log_error(error)\n error_and_log(error.message)\n error_and_log(error.backtrace.reverse.join(\"\\n\"))\n end",
"def re_stderr\n @logdev.re_stderr\n self\n end",
"def on_error(error)\n @result << \"error: #{error}\"\n end",
"def error(message)\n log.error(message.to_s.red)\n end",
"def error_number; end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n logger.info \"\\n\\n#{@err_msg}\\n\\n\"\n end",
"def server_errors; end",
"def errors=(_); end",
"def error?; @logger.error? end",
"def config_error(path, error); end",
"def error e\n log(\"ERREUR: #{e.message}\")\n log(\"BACKTRACE ERREUR: #{e.backtrace.join(\"\\n\")}\")\n self << {error: e.message, backtrace: e.backtrace}\n end",
"def error(msg)\n $ibm_cloud_log.error(format_message(msg))\n end",
"def errors=(_arg0); end",
"def errors=(_arg0); end",
"def errors=(_arg0); end",
"def errors=(_arg0); end",
"def on_error(msg)\n end",
"def connection_error(error, req, text = T.unsafe(nil)); end"
] |
[
"0.6994573",
"0.6994573",
"0.6994573",
"0.68446594",
"0.6687502",
"0.6538153",
"0.6520196",
"0.6485055",
"0.6316911",
"0.6283917",
"0.6283917",
"0.6283917",
"0.6283917",
"0.62757564",
"0.6260574",
"0.62498915",
"0.6241743",
"0.6168145",
"0.61626107",
"0.615455",
"0.6125709",
"0.6115861",
"0.6115861",
"0.6115861",
"0.6115861",
"0.6115861",
"0.6115861",
"0.6115861",
"0.61151487",
"0.6077518",
"0.6070972",
"0.6057212",
"0.6057212",
"0.60551447",
"0.6029525",
"0.6010457",
"0.5999141",
"0.59729385",
"0.59564793",
"0.59445477",
"0.5944336",
"0.5935915",
"0.59341276",
"0.59258246",
"0.5903372",
"0.5895952",
"0.5890451",
"0.58884156",
"0.5880997",
"0.58746976",
"0.5872253",
"0.58702326",
"0.5866768",
"0.5860663",
"0.5857674",
"0.5840648",
"0.5840535",
"0.5835744",
"0.5823278",
"0.5821686",
"0.58174694",
"0.58151686",
"0.57937336",
"0.5793348",
"0.5776441",
"0.5774476",
"0.5766268",
"0.57507",
"0.57264215",
"0.5724685",
"0.5719698",
"0.5715959",
"0.5713391",
"0.57114995",
"0.57088035",
"0.57051104",
"0.5699101",
"0.56990683",
"0.56990683",
"0.56990683",
"0.5697729",
"0.56964946",
"0.5689019",
"0.56879747",
"0.5680049",
"0.5671747",
"0.5671747",
"0.5671747",
"0.56714565",
"0.56711304",
"0.5669989",
"0.56693107",
"0.5667048",
"0.56669074",
"0.56607157",
"0.56607157",
"0.56607157",
"0.56607157",
"0.56523246",
"0.5646377"
] |
0.66336143
|
5
|
=== Exception loging functions ===
|
def _log_exception(icon, note, excpt)
warn "#{icon} #{note}:\n#{EXPT} \xE2\x94\x8C#{excpt} \xE2\x94\x90"
warn excpt.backtrace[0..7].reduce("") { |s,x|
s += "#{EXPT} \xE2\x94\x9C#{x}\n" } +
"#{EXPT} \xE2\x94\x94#{BAR*25}\xE2\x94\x98"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def log_error(exception); end",
"def exceptions; end",
"def exception_handler; end",
"def catch_exceptions; end",
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def log_exception(excp, meth = nil)\n error = warning = nil\n case excp\n when Shrine::FileNotFound then warning = 'FILE_NOT_FOUND'\n when Shrine::InvalidFile then warning = 'INVALID_FILE'\n when Shrine::AttachmentChanged then warning = 'ATTACHMENT_CHANGED'\n when Shrine::Error then error = 'unexpected Shrine error'\n else error = \"#{excp.class} unexpected\"\n end\n Log.add(error ? Log::ERROR : Log::WARN) do\n \"#{meth || __method__}: #{excp.message} [#{error || warning}]\"\n end\n end",
"def exception_handler(ex)\n \nend",
"def log_exceptions\n yield\n rescue Exception => e\n self.exception e\n raise e\n end",
"def exceptions\n end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def log_exception ex\n logger.error ex\n logger.error ex.class\n logger.error ex.backtrace.join(\"\\n\")\n end",
"def log_exception(e)\n log_err(e.message)\n log_err(e.backtrace.join(\"\\n\"))\n end",
"def error(exception)\n logger.info \"execution failed: #{exception}\"\n end",
"def error(msg); @logger.error(msg); end",
"def log_exception(e)\n unless e.blank?\n log_error_with_timestamp e.inspect unless e.inspect.blank?\n log_error_with_timestamp e.backtrace.join(\"\\n \") unless e.backtrace.blank?\n end\nend",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def error(*args)\n log(*args)\n fail\n end",
"def exception(*rest) end",
"def log_exception(ex)\n log_error { ex.message }\n log_error { ex.backtrace[0..5].join(\"\\n\") }\n log_debug { ex.backtrace.join(\"\\n\") }\n end",
"def continued_exception=(_arg0); end",
"def log_exception(e)\n error(e.inspect)\n e.backtrace.each { |line| error(line) }\n end",
"def error(msg) log(ERROR, \"ERROR \" << format(msg) << \", \" << caller[0][caller[0].rindex(\"/\").nil? ? 0 : caller[0].rindex(\"/\") + 1 .. -1]); end",
"def logL\n raise \"No implemented\"\n end",
"def raise(exception); end",
"def log_e\n log\n exit\n end",
"def show_detailed_exceptions?; end",
"def error_handler(exception)\n puts exception\n end",
"def exception_details(e, msg); end",
"def continued_exception; end",
"def log_and_raise(exception, message, shift=2)\n Base.log_and_raise(config.ui.logger, exception, message, shift)\n end",
"def fatal; end",
"def exception(e)\n self.error \"#{e.class}: #{e.message}\" << (\"\\n#{e.backtrace.join(\"\\n\")}\" unless e.backtrace.nil?)\n end",
"def rescue_action(e); raise e; end",
"def log_exception(e, sym=:error)\n ar = [e.message] \n ar = ar + e.backtrace\n ar.each do |element|\n puts \"#{sym} #{element}\"\n end\n if sym == :info && $dplayer_list\n $dplayer_list.each do |ch|\n if ch.level >= LEVEL_IMM\n ar.each do |element|\n ch.text_to_player element + ENDL\n end\n end\n end\n end\nend",
"def error(ex) [:error, ex]; end",
"def rescuer\n begin\n yield\n rescue Exception => e\n # write to log files \n end\n end",
"def log_errors(code_area)\n yield\n rescue => e\n ::NewRelic::Agent.logger.error(\"Caught exception in #{code_area}.\", e)\n end",
"def exceptions_app=(_arg0); end",
"def exceptions_app=(_arg0); end",
"def log_error(err)\n\t\tprint_error(err)\n\n\t\twlog(err)\n\n\t\t# If it's a syntax error, log the call stack that it originated from.\n\t\tdlog(\"Call stack:\\n#{$@.join(\"\\n\")}\", 'core', LEV_1)\n\tend",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def error(exception) nil ; end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def rescue_action(e) raise e end",
"def log_exception (e)\n\n message =\n \"trigger() caught exception\\n\" +\n e.to_s + \"\\n\" +\n e.backtrace.join(\"\\n\")\n\n if self.respond_to?(:lwarn)\n lwarn { message }\n else\n puts message\n end\n end",
"def exception(ex, msg='')\n line = ''\n ex.backtrace.each do |l|\n line += \"\\n #{l}\"\n end\n @logger.error \"#{msg}: ** Exception thrown: #{ex.class}, backtrace follows:#{line}\"\n end",
"def stacktrace; end",
"def exceptions_app; end",
"def exceptions_app; end",
"def log_error(msg)\n\t\tprint_error(msg)\n\n\t\telog(msg, 'meterpreter')\n\n\t\tdlog(\"Call stack:\\n#{$@.join(\"\\n\")}\", 'meterpreter')\n\tend",
"def log_error(method, file, error)\n time = ''\n # Only add time for development log because production already outputs timestamp\n if Rails.env == 'development'\n time = Time.now.strftime('[%d/%m/%Y %H:%M:%S] ').to_s\n end\n logger.error \"#{time}EXCEPTION IN #{file}, method='#{method}' [#{error}]\"\nend",
"def log\n end",
"def error?; @logger.error? end",
"def error(exception)\n log \"#{exception.message}\\n#{exception.backtrace.join(\"\\n\")}\", :error\n end",
"def print_exception(e)\n\tputs \"error: #{e.message}\"\nend",
"def err(e)\n @logger.error(e)\n end",
"def log(msg)\n super(\"resque-exception - #{msg}\")\n end",
"def log(*args); end",
"def raise(*rest) end",
"def raise(*rest) end",
"def rescue_from(exception); end",
"def exception(result = {}, log = true)\n log_exception(result) if log\n end",
"def egregious_log(exception)\n logger.fatal(\n \"\\n\\n\" + exception.class.to_s + ' (' + exception.message.to_s + '):\\n ' +\n clean_backtrace(exception).join(\"\\n \") +\n \"\\n\\n\")\n notify_airbrake(exception)\n end",
"def send(method, *args)\n super\n rescue StandardError => e\n args[1].debug \"#{e}\\n #{e.backtrace.first}\" # args[1] is the logger\n end",
"def stack_trace; end",
"def cashboard_rescue_exception\n logger.error '^^^ CASHBOARD SPECIFIC INFO FOR ABOVE ERROR'\n logger.error '--------------------------------------------------------------------------------'\n begin\n logger.error \"URL : #{request.env['PATH_INFO']}\"\n logger.error \"BROWSER: #{request.env['HTTP_USER_AGENT']}\"\n logger.error \"IP ADDR: #{request.env['REMOTE_ADDR']}\"\n # Try to find account if it's not set\n @account ||= Account.find_by_subdomain(account_subdomain)\n if @account\n logger.error \"ACCOUNT: #{@account.subdomain}\"\n end\n if @user\n logger.error \"USER : #{@user.inspect}\\n\"\n end\n rescue\n logger.error '...An error happend logging specific errors...wtf?'\n end\n logger.error '--------------------------------------------------------------------------------'\n logger.error ''\n end",
"def x\n # ...\nrescue\n # ...\nend"
] |
[
"0.83688235",
"0.7384164",
"0.7289811",
"0.7277182",
"0.72172743",
"0.72172743",
"0.72172743",
"0.71197516",
"0.7119515",
"0.7119449",
"0.7061525",
"0.70557153",
"0.70557153",
"0.70557153",
"0.70557153",
"0.70557153",
"0.69271815",
"0.69201183",
"0.68651503",
"0.6862359",
"0.6856991",
"0.68332106",
"0.68332106",
"0.68332106",
"0.68332106",
"0.68332106",
"0.68332106",
"0.68332106",
"0.68332106",
"0.68278575",
"0.681645",
"0.6812078",
"0.66791874",
"0.6667249",
"0.6661969",
"0.6661116",
"0.6640032",
"0.6637566",
"0.6605396",
"0.65889984",
"0.657442",
"0.6572117",
"0.65620315",
"0.6558778",
"0.6541329",
"0.6534604",
"0.6533565",
"0.6532996",
"0.65273505",
"0.6525425",
"0.65157926",
"0.65157926",
"0.6514293",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65085465",
"0.65078783",
"0.6506003",
"0.6506003",
"0.6506003",
"0.6506003",
"0.6494326",
"0.64928555",
"0.6490991",
"0.6470835",
"0.6470835",
"0.6451004",
"0.6442681",
"0.64232343",
"0.6413724",
"0.64131516",
"0.6411203",
"0.63985616",
"0.63888514",
"0.63751364",
"0.63714254",
"0.63714254",
"0.6367229",
"0.636438",
"0.63452166",
"0.63426536",
"0.63410294",
"0.63216084",
"0.6317784"
] |
0.6842256
|
21
|
method gets data contractor
|
def get_contractor_data
@hash_contractor = {}
@hash_contractor[:name] = @driver.find_element(:css, '.oH1Huge').text
@hash_contractor[:job] = @driver.find_element(:css, '.oH2High').text
@hash_contractor[:description] = @driver.find_element(:css, 'p.notranslate[itemprop="description"]').text.gsub(/\n+/, ' ')
@hash_contractor[:skills] = @driver.find_element(:css, '.oExpandableOneLine.oSkills.oExpanded').text.gsub(' less', '')
@hash_contractor[:hourly_rate] = @driver.find_element(:css, '.oCoinsIcon+.oTxtExtra.ib').text
@hash_contractor[:rating] = @driver.find_element(:css, '.oStarIcon+.oTxtExtra.ib').text
@hash_contractor[:hours] = @driver.find_element(:css, '.oClockIcon+.oTxtExtra.ib').text.gsub(',', '')
@hash_contractor[:location] = @driver.find_element(:css, '.oTxtLrge.ib').text.downcase
@hash_contractor[:url] = @driver.current_url
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def contract; end",
"def contract; end",
"def contract; Contract.get(self.contract_id); end",
"def get_data()\t\n\tend",
"def get_contract\n if self.complete? and not self.passed_out?\n bid = self.get_current_call(Bid)\n double = self.get_current_call(Double)\n redouble = self.get_current_call(Redouble)\n declarer_bid = nil\n # Determine partnership.\n caller = self.who_called?(bid)\n partnership = [caller, Direction[(caller + 2) % 4]]\n # Determine declarer.\n self.calls.each do |call|\n if call.is_a?(Bid) and call.strain == bid.strain and partnership.include?(self.who_called?(call))\n declarer_bid = call\n break\n end\n end\n \n {\n :bid => bid,\n :declarer => declarer_bid.nil? ? nil : self.who_called?(declarer_bid),\n :double_by => double.nil? ? nil : self.who_called?(double),\n :redouble_by => redouble.nil? ? nil : self.who_called?(redouble) \n }\n else\n nil # Bidding passed out or not complete, no contract.\n end\n end",
"def data\n raise NotImplementedError\n end",
"def data\n fail NoMethodError, \"Engines need this method defined\"\n end",
"def retrieve_data\n raise 'Should implement'\n end",
"def data\n raise NoMethodError, \"Engines need this method defined\"\n end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def data; end",
"def call\n data\n end",
"def read_exclusive_data(data)\n case type\n when :miner_transaction, :issue_transaction\n @nonce = data.read_uint32\n singleton_class.send :attr_reader, :nonce\n when :claim_transaction\n count = data.read_vint\n @claims = []\n count.times do\n @claims << {\n previous_hash: data.read_hex(32),\n previous_index: data.read_uint16\n }\n end\n singleton_class.send :attr_reader, :claims\n when :enrollment_transaction\n # TODO: This should be parsed correctly (ec_point)\n @public_key = data.read_hex(33)\n singleton_class.send :attr_reader, :public_key\n when :register_transaction\n @asset_type = data.read_uint8\n @name = data.read_string\n @amount = data.read_uint64\n @issuer = data.read_hex 33\n @admin = data.read_hex 20\n when :publish_transaction\n # TODO: Refactor this into contract model?\n @function_code = data.read_hex\n @params_list = data.read_hex\n @return_type = data.read_hex 1\n @needs_storage = version >= 1 ? data.read_bool : false\n @name = data.read_string\n @code_version = data.read_string\n @author = data.read_string\n @email = data.read_string\n @description = data.read_string\n singleton_class.send :attr_reader, :function_code, :needs_storage, :name, :code_version,\n :author, :email, :description\n when :invocation_transaction\n @script = Script.read(data)\n @gas = data.read_fixed8\n end\n end",
"def get_data(currency_type)\n # Will be overriden on Currency subclasses\n end",
"def get_data(resource_type, name)\n raise NotImplementedError, :get_data\n end",
"def data\n retrieve_data\n end",
"def data() @data ||= Data.new( self ); end",
"def get_contract(*params); raise('Stub or mock required.') end",
"def get_data\n raise \"overwrite it\"\n end",
"def data(_value=nil, _repair=false)\n raise NotImplementedError.new\n end",
"def getc\n raise NotImplementedError\n end",
"def data\n @data ||= @_data.respond_to?(:call) ? @_data.call() : @_data\n end",
"def data\n DataProxy.new(self)\n end",
"def data\n @data\n end",
"def code_of_conduct; end",
"def get_data\n data = ProjectHanlon::Data.instance\n data.check_init\n data\n end",
"def data\n @data\n end",
"def data\n @data\n end",
"def data\n @data\n end",
"def get_data(key)\n raise 'The get_data method must be implemented'\n end",
"def contract_type\n return @contract_type\n end",
"def get_data\n raise \"This method should be overriden to return the JSON data for a concrete table\"\n end",
"def request_data; end",
"def data\n @data\n end",
"def data\n @data\n end",
"def data\n @data\n end",
"def service_contract_of(buyer)\n service_contracts.find_by(user_account_id: buyer.id)\n end",
"def get_data\n\t\texecute unless @result\n\t\treturn get_data_from_result(@result)\n\tend",
"def data\n @data_t\n end",
"def init_data\n end",
"def get_user_data\n raise NotImplementedError\n end",
"def data\n @data\n end",
"def data\n @datas\n end",
"def initialize_data\n end",
"def current_contract\n self.this_year.contract\n end",
"def data(*args); end",
"def data; @data ||= fetch; end",
"def getData\n\t \t@data = {'command' => @command, 'params' => @params}\n \treturn @data\n\t end",
"def data\r\n @data\r\n end",
"def data\n self[:data]\n end",
"def dalli\n @data\n end",
"def stored_data; end",
"def get_contract_current()\n self.class.get(\"/api/contracts/current\", :basic_auth => @auth)\n end",
"def set_contractor\n @contractor = Contractor.find(params[:id])\n end",
"def set_contractor\n @contractor = Contractor.find(params[:id])\n end",
"def do_data(data); end",
"def internal_data # nodoc\n _data\n end",
"def data\n @repo_data\n end",
"def contract(name)\n request(method: 'getContract', params: {name: name})\n end",
"def getc()\n #This is a stub, used for indexing\n end",
"def data\n self.load if @data.nil?\n @data\n end",
"def get()\n \n end",
"def build_all_contract_data\n Dir.chdir(CONTRACT_DATA_DIR) do\n contract_data = SUPPORTED_CONTRACT_NAMES.map do |name|\n abi, bin = Dir.glob(%W(*#{name}_abi* *#{name}_bin*))\n\n { name: name, abi_file: abi, bin_file: bin }\n end\n\n contract_data.each do |data|\n contract_name = data[:name]\n abi = File.read(data[:abi_file]).chomp\n bin = File.read(data[:bin_file]).chomp\n\n instance_variable_set(:\"@#{contract_name}_abi\", abi)\n instance_variable_set(:\"@#{contract_name}_bin\", bin)\n\n self.class.public_send(\n :attr_accessor,\n :\"#{contract_name}_abi\",\n :\"#{contract_name}_bin\"\n )\n end\n end\n end",
"def load_data\n raise NotImplementedError\n end",
"def _get_model_data(method)\n if @model.respond_to?(method)\n data = @model.send(method) \n if data\n @source.put_value(method,data)\n if method == :schema\n parsed = JSON.parse(data)\n schema_version = parsed['version']\n raise \"Mandatory version key is not defined in model schema method\" if schema_version.nil?\n @source.put_value(\"#{method}_sha1\",Digest::SHA1.hexdigest(schema_version))\n else\n @source.put_value(\"#{method}_sha1\",Digest::SHA1.hexdigest(data))\n end \n end\n end\n end",
"def data\n @market = Market.first\n end",
"def data=(_arg0); end",
"def data=(_arg0); end",
"def data=(_arg0); end",
"def data=(_arg0); end",
"def data\n nil\n end",
"def data\n @data ||= ManageData.new data: url.to_s, list: @list\n end",
"def data_builder\n AlfaBank::RestDataBuilder\n end",
"def data\n @data ||= {}\n end",
"def prepare_data\n # This method is just a stub.\n end",
"def get_owner(*params); raise('Stub or mock required.') end",
"def data\n Utils_errors::critical_error('The \"data\" method was not overridden after being included in a download class')\n end",
"def details\n data()\n end",
"def get_card_data method\n get_card.send(method) rescue nil\n end",
"def download_data\n subclass_must_define\n end",
"def set_esod_contractor\n @esod_contractor = Esod::Contractor.find(params[:id])\n end",
"def set_contractor\n @contractor = Contractor.find(session[:contractor_id])\n end",
"def initialize\n @data = Data.instance\n end",
"def data\n @data ||= DataMunger.new(loader.read, kitchen_config)\n end",
"def method_missing(method, *args, &block)\n data.send(method, *args, &block)\n end",
"def retrieve_data\n if is_fork?\n parent.data\n else\n self.read_attribute(\"data\")\n end\n end",
"def data= data \n end",
"def getc\n end",
"def getc\n end",
"def set_contract_details(contract_details_data)\n @contract_details = CompanyApi::Response::Entity::ContractDetails.new(contract_details_data)\n end"
] |
[
"0.6980366",
"0.6980366",
"0.6633981",
"0.64182204",
"0.63452804",
"0.6218668",
"0.61748636",
"0.6157236",
"0.6120974",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6112577",
"0.6077616",
"0.60388637",
"0.600765",
"0.6000587",
"0.5952163",
"0.594678",
"0.5920193",
"0.59128034",
"0.5810106",
"0.5799073",
"0.5796477",
"0.5732254",
"0.5719997",
"0.5687229",
"0.56869406",
"0.5686904",
"0.5686904",
"0.5686904",
"0.5640936",
"0.5636488",
"0.5613822",
"0.5613683",
"0.560525",
"0.560525",
"0.560525",
"0.5584914",
"0.5578807",
"0.5571998",
"0.5556952",
"0.55341136",
"0.5533944",
"0.55043036",
"0.5496134",
"0.5488841",
"0.5487454",
"0.54812866",
"0.54730886",
"0.54602355",
"0.54570186",
"0.54550755",
"0.5451152",
"0.544857",
"0.5444522",
"0.5444522",
"0.5442254",
"0.54245746",
"0.5418343",
"0.5417822",
"0.5414469",
"0.54072547",
"0.5392928",
"0.5388558",
"0.53833187",
"0.5341882",
"0.5338133",
"0.53345144",
"0.53345144",
"0.53345144",
"0.53345144",
"0.53143275",
"0.5297962",
"0.5290681",
"0.5274286",
"0.5274149",
"0.5265217",
"0.52595204",
"0.52556306",
"0.52544343",
"0.525368",
"0.52457696",
"0.5244833",
"0.52431947",
"0.52399504",
"0.5235407",
"0.52297664",
"0.52293634",
"0.52274376",
"0.52274376",
"0.5227047"
] |
0.5559329
|
49
|
method compare contractor data hashes
|
def compare_contractor_data(contractor)
message_good = "Each attribute value is equal to the corresponding attributes of a freelancer #{contractor[:name]} on a profile page:\n#{contractor}"
message_bad = "Freelancer attribute values not equal to the corresponding attributes in the shared page. Expected:\n#{contractor}\nGot:\n#{@hash_contractor}"
#hash_contractor = @hash_contractor
(contractor == @hash_contractor) ? (puts message_good) : (puts message_bad)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def test_same_hashes\r\n\t\ts = \"Addr1<Addr2(100):Addr3<Addr4(500)\"\r\n\t\ttb = Block.new(0,0,s,0.0,\"90a2\")\r\n\t\ttb.set_calculated_hash(\"90a2\")\r\n\t\t\r\n\t\tassert_equal(1, tb.compare_current_hash)\r\n\tend",
"def test_different_hashes\r\n\t\ts = \"Addr1<Addr2(100):Addr3<Addr4(500)\"\r\n\t\ttb = Block.new(0,0,s,0.0,\"90a2\")\r\n\t\ttb.set_calculated_hash(\"10b4\")\r\n\t\t\r\n\t\tassert_equal(0, tb.compare_current_hash)\r\n\tend",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def test_equal_hash\n chain = \"Person1<Person2(360):Person3<Person4(930)\"\n block = Blockchain.new(0,0,chain, 1.5,\"ch77\")\n block.setHash(\"ch77\")\n\n assert_equal(1, block.check_curr())\n end",
"def consistent_hash\n Zlib.crc32(self.to_yaml, 0)\n end",
"def verify_hash\r\n raise \"Line #{total_block_number}: hash was incorrectly calculated\" unless @current_hash == @computed_hash\r\n\r\n true\r\n end",
"def test_calc_hash\n chain = \"SYSTEM>Kurt(50)\"\n block = Blockchain.new(\"5\", \"5\", chain, \"1518892051.812065000\", \"ch78\")\n hash_value = block.getHash\n calc = hash_value.strip.eql? \"ch77\"\n\n assert_equal calc, true\n end",
"def test_calc_hash\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd19\")\r\n\t\tstringVal = tb.get_calculated_hash\r\n\t\tval = stringVal.strip.eql? \"fd18\"\r\n\t\t\r\n\t\tassert_equal val, true\r\n\tend",
"def compare_hashes_handler(hash_, file_, hash_class, _bit_size)\n # noinspection RubyStringKeysInHashInspection,RubyResolve\n hash_class_reference = {1 => Digest::SHA1, 2 => Digest::SHA2, 5 => Digest::MD5}\n # Check if hash_ is a raw hash or a csv db\n if File.file? hash_\n # hash_ is a csv database with hashes to check\n # Handler for databse\n file_object = File.open hash_, 'r'\n # All the lines of the db\n lines = file_object.readlines\n # Close the file because we don't need it anymore\n file_object.close\n # Fist line of this file is the configuration line that is the function and its bit size (if is sha2)\n hash_class, _bit_size = lines[0].strip.split('-')\n # Has_class can be transformed to int corresponding to its number\n hash_class = {\"SHA1\" => 1, \"SHA2\" => 2, \"MD5\" => 5}[hash_class]\n # When a bit size was specified transform it to int\n if _bit_size.is_a? String\n _bit_size = _bit_size.to_i\n end\n # Parameters for the setup of the hash_function\n hash_class = hash_class_reference[hash_class]\n\n #puts hash_class, chunk_size\n lines = lines[1..]\n lines.each do |line|\n file_path, hash = line.strip.split(',')\n compare file_path, hash_class, _bit_size, hash\n end\n else\n # hash_ variable is a raw hash\n # Get the hash class from the string provided\n hash_class = hash_class_reference[hash_class]\n # Compare the raw hash (hash_) with the file provided\n compare file_,hash_class, _bit_size, hash_\n end\nend",
"def verify_hash_action_notify( file )\n hash = @hasher.generate_hash( file )\n res = @dbase.search_hashes( file ) \n\n unless hash.to_s.eql?( res[\"hash\"] ) \n \n puts \"Host:\\t\\t#{res[\"host\"]}\"\n puts \"File:\\t\\t#{file}\"\n puts \"Database date:\\t#{res[\"date\"]}\"\n puts \"Current date:\\t#{Time.now}\"\n puts \"Old hash:\\t#{res[\"algo\"]},\\t#{res[\"hash\"]}\"\n puts \"New hash:\\t#{@hasher.algo},\\t#{hash.to_s}\"\n puts \"\"\n \n end\nend",
"def ==(other)\n self.to_hash == other.to_hash\n end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def check_hashes(block)\n correct = hash_block(block)\n unless correct.strip.eql? block.current_hash.strip\n puts \"Line #{block.block_number}: String '#{block.block_number}|#{block.previous_hash}|\n \t#{block.transaction_string}|#{block.timestamp_string}'\n \t hash set to #{block.current_hash.strip}, should be #{correct}\"\n return false\n end\n true\n end",
"def ==(other)\n self.hash == other.hash\n end",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def validate_hash(info)\r\n\t\t# passes in the parsed info\r\n\t\tstring_to_hash = get_string_to_hash(info)\r\n\t\tcorrect_hash = get_hash(string_to_hash)\r\n\t\t#puts string_to_hash\r\n\t\treturn correct_hash.strip == info['self_hash'].strip\r\n\tend",
"def test_previous_hash_equal\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n def block_checker.check_hex(string); true; end\r\n def block_checker.check_hash(actual, stored); true; end\r\n assert_nil @g.previous_hash( '2710', 10000, block_checker, 0)\r\n end",
"def hash(*) end",
"def hash\n end",
"def hash\n end",
"def hash\n end",
"def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def hash\n source.hash ^ target.hash\n end",
"def hash() source.hash ^ target.hash; end",
"def hash\n [cents.hash, currency.hash].hash\n end",
"def hash\n [cents.hash, currency.hash].hash\n end",
"def test_hash_mismatch\n v = Verify.new\n return_code = v.verify_second_pipeset('1as3', '2as3')\n assert_equal 2, return_code\n end",
"def hash\n values.hash ^ known_data.hash\n end",
"def hash\n data.hash\n end",
"def hash\n return @hash_code if defined? @hash_code\n @hash_code = usual_equal_object.hash\n end",
"def ==(other)\n @hash == other.to_h\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def hash\n [amount.hash, currency.hash].hash\n end",
"def ==(other)\n self.to_hash == other.to_hash\n end",
"def hash\n return name.hash ^ direction.hash ^ lhs.hash ^ rhs.hash\n end",
"def hash\n name.hash ^ provider.hash\n end",
"def ==(other)\n @hash == other.hash\n end",
"def eql?(other)\n @hash.hash == other.hash\n end",
"def git_checksum_hash(tree, prefix=nil)\n\n tree.contents.each do |obj|\n if obj.class == Grit::Blob\n item = [prefix, obj.name].join\n @currenthash[item] = Digest::MD5.hexdigest(obj.data)\n #puts \"#{item} : \" + @currenthash[item]\n else\n git_checksum_hash(obj, [prefix, obj.name, \"/\"].join)\n end\n end\n\n return @currenthash\n end",
"def test_Hash_InstanceMethods_Equality\n\t\th1 = { 'a'=>1, 'c'=>2 }\n\t\th2 = { 7=>35, 'c'=>2, 'a'=>1 }\n\t\th3 = { 'a'=>1, 'c'=>2, 7=>35 }\n\t\th4 = { 'a'=>1, 'd'=>2, 'f'=>35 }\n\t\tassert_equal(false, h1 == h2)\n\t\tassert_equal(true, h2 == h3)\n\t\tassert_equal(false, h3 == h4)\n\tend",
"def hash\n # TODO: Produce a hash (using default hash method) of the credit card's\n # serialized contents.\n # Credit cards with identical information should produce the same hash.\n self.to_s.hash\nend",
"def hash_code; end",
"def ==(other)\n hash == other.hash\n end",
"def ==(other)\n hash == other.hash\n end",
"def verify_prev_hash_match(maps)\n # special case for first line\n return false if maps[0][:id].to_i != 0\n\n # now start at the 1st line\n (1...maps.length).each do |i|\n prev_hash = maps[i][:prev_hash]\n curr_hash = maps[i - 1][:hash]\n # check that they match\n if prev_hash != curr_hash\n puts \"Line #{i}: Previous hash was #{prev_hash}, should be #{curr_hash}.\\nBLOCKCHAIN INVALID\"\n return false\n end\n # check that the length of each is not more than 4\n if prev_hash.length > 4\n puts \"Line #{i}: Previous hash #{prev_hash} is too long.\\nBLOCKCHAIN INVALID\"\n return false\n end\n if curr_hash.length > 4\n puts \"Line #{i}: Current hash #{curr_hash} is too long.\\nBLOCKCHAIN INVALID\"\n return false\n end\n # check the formatting of the hash\n prev_hash.delete!('abcdef0123456789')\n curr_hash.delete!('abcdef0123456789')\n unless prev_hash.empty?\n puts \"Line #{i}: Previous hash #{prev_hash} contains invalid characters.\\nBLOCKCHAIN INVALID\"\n return false\n end\n unless curr_hash.empty?\n puts \"Line #{i}: Current hash #{curr_hash} contains invalid characters.\\nBLOCKCHAIN INVALID\"\n return false\n end\n end\n\n # If nothing wrong, return true\n true\nend",
"def eql?(other)\n @hash == other.hash\n end",
"def test_hash_correct\n\t\n\t\tString test_array1 = '2|abb2|George>Amina(16):Henry>James(4):Henry>Cyrus(17):Henry>Kublai(4):George>Rana(1):SYSTEM>Wu(100)|1518892051.753197000|c72d'.split('|').map(&:chomp)\n\n\t\tx = test_array1[0].unpack('U*') + test_array1[1].unpack('U*') + test_array1[2].unpack('U*') + test_array1[3].unpack('U*')\n\t\tsum = 0\n\t\t# x.each { |i| puts x[i] }\n\t\t# x.delete(\"\")\n\t\tx.each { |i| sum += ((x[i].to_i ** 2000) * ((x[i].to_i + 2) ** 21) - ((x[i].to_i + 5) ** 3)) }\n\t\thash = (sum % 65536)\n\t\tputs hash.to_s(16)\n\t\t\n\t\ttest_array2 = '3|c72d|SYSTEM>Henry(100)|1518892051.764563000|7419'.split('|').map(&:chomp)\n\t\t\n\t\t# assert_equal test_str[2,2], '0|'\t\n\tend",
"def test_block_hash_match\n \tblock = \"1|1c12|SYSTEM>George(100)|1518892051.740967000|abb2\".split(\"|\")\n \tassert(@bv.block_hash_correct(block))\n end",
"def hash\n name.hash ^ version.hash\n end",
"def verify_transactions(maps)\n # hash literal same as Hash.new\n balance_map = {}\n valid = -1\n maps.each do |x|\n trans = x[:transactions].split(':')\n trans.each_with_index do |y, i|\n # verifing from address vaild/correct format\n from_addr = y[0..5]\n balance_map[from_addr] = 0 unless balance_map.key?(from_addr)\n if i == trans.length - 1\n valid = x[:id] unless from_addr == 'SYSTEM'\n else\n from_addr.delete!('0123456789')\n valid = x[:id] unless from_addr.empty?\n end\n # verifing > in position 7\n valid = x[:id] unless y[6] == '>'\n\n # verifing to address valid/correct format\n to_addr = y[7..12]\n balance_map[to_addr] = 0 unless balance_map.key?(to_addr)\n # puts balance_map[to_addr]\n to_addr.delete!('0123456789')\n valid = x[:id] unless to_addr.empty?\n valid = x[:id] unless y[13] == '('\n valid = x[:id] unless y[y.length - 1] == ')'\n\n amount_num = y[14..y.length - 2]\n balance_map[y[0..5]] -= amount_num.to_i\n balance_map[y[7..12]] += amount_num.to_i\n amount_num.delete!('0123456789')\n valid = x[:id] unless amount_num.empty?\n end\n end\n # really rubocop\n unless valid.to_i.negative?\n puts \"Line #{valid}: Could not parse transactions list.'#{maps[valid.to_i][:transactions]}'\\nBLOCKCHAIN INVALID\"\n return false\n end\n balance_map = balance_map\nend",
"def eql?(arg)\n self.hash == arg.hash\n end",
"def checksum\n Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)\n end",
"def hash\n [accounts_date, reporting_period, currency, consolidated_accounts, audit_qualification, number_of_employees, turnover, cost_of_sales, sga_plus_other_net_costs, operating_profit, interest_receivable, interest_payable, pre_tax_profit, taxation, post_tax_profit, dividends_payable, retained_profits, intangible_assets, tangible_assets, investments_and_other_assets, fixed_assets, stock, trade_debtors, other_debtors, miscellaneous_current_assets, cash, current_assets, total_assets, bank_loans_and_overdrafts, trade_creditors, miscellaneous_current_liabilities, other_short_term_finances, current_liabilities, contingent_liabilities, other_long_term_finances, total_long_term_liabilities, total_liabilities, net_assets, equity_paid_up, revaluation_reserve, sundry_reserves, profit_and_loss_account_reserve, shareholder_funds, depreciation, amortisation_of_intangibles, ebitda, working_capital, capital_employed, wages_and_salaries, directors_emoluments, audit_fees, bank_overdraft_and_long_term_loans, net_cash_flow_from_operations, net_cash_flow_before_financing, net_cash_flow_from_financing, increase_in_cash, debtor_days, exports, gross_margin_percentage, operating_profit_margin_percentage, ebitda_margin_percentage, pre_tax_profit_margin_percentage, net_margin_percentage, return_on_assets_percentage, return_on_capital_employed_percentage, return_on_equity, current_ratio, cash_to_current_liabilities_ratio, cash_to_total_assets_percentage, liquidity_ratio, gearing_percentage_on_liability_basis, gearing_percentage_on_gross_debt_basis, gearing_percentage_on_net_debt_basis, debt_to_capital_percentage, inventory_turnover_ratio, cash_to_turnover_ratio, cash_to_turnover_percentage, days_inventory_outstanding, days_sales_outstanding, days_payable_outstanding, cash_conversion_cycle, revenue_per_employee, human_capital_value_added, interest_coverage_ratio, net_debt_to_ebitda_ratio, cfo_to_sales_ratio, auditor, joint_auditor, solicitor, accountant].hash\n end",
"def ==(other)\n to_hash == other.to_hash\n end",
"def ==(other)\n to_hash == other.to_hash\n end",
"def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end",
"def combined_hash\n hashes = @contracts.map { |c| c.bth }.sort\n concatenated_hash = [payment_base.to_base58].concat(hashes).join\n Tapyrus.sha256(concatenated_hash)\n end",
"def hash\n [_hash, name, owner].hash\n end",
"def eql?(other)\n hash == other.hash\n end",
"def compare_hashes(reference, compare)\n ref = reference.to_a.flatten\n comp = compare.to_a.flatten\n if (ref.size > comp.size)\n difference = ref - comp\n else\n difference = comp - ref\n end\n Hash[*difference.flatten]\n end",
"def compare_hashes(reference, compare)\n ref = reference.to_a.flatten\n comp = compare.to_a.flatten\n if (ref.size > comp.size)\n difference = ref - comp\n else\n difference = comp - ref\n end\n Hash[*difference.flatten]\n end",
"def compare_hashes(reference, compare)\n ref = reference.to_a.flatten\n comp = compare.to_a.flatten\n if (ref.size > comp.size)\n difference = ref - comp\n else\n difference = comp - ref\n end\n Hash[*difference.flatten]\n end",
"def test_hash_match\n v = Verify.new\n return_code = v.verify_second_pipeset('as3', 'as3')\n assert_equal 0, return_code\n end",
"def eql?(other)\r\n\t\treturn hash == other.hash\r\n\tend",
"def ==(other)\n self.class==other.class && self.hash==other.hash\n end",
"def hashes_match?\n ar = @ar.clone\n\n digest_value = ar.at_css(\n 'xmlns|DigestValue',\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).content.strip\n\n ar.at_css(\n \"xmlns|Signature\",\n 'xmlns' => 'http://www.w3.org/2000/09/xmldsig#'\n ).remove\n\n actual_digest = calculate_digest(ar)\n\n if digest_value == actual_digest\n true\n else\n false\n end\n end",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash\n @hash || calculate_hash!\n end",
"def check_block_hash(curr_block)\n # rubocop:disable LineLength\n block_hash_string = curr_block.block_number + '|' + curr_block.prev_block_hash + '|' + curr_block.raw_transactions + '|' + curr_block.timestamp[0] + '.' + curr_block.timestamp[1]\n # rubocop:enable LineLength\n block_hash_string.unpack('U*')\n\n # splits the string into each character\n hash_parts = block_hash_string.split('')\n\n res = 0\n # OPTIMIZATION: store the hashes of characters so we can reuse them\n hash_parts.each do |x|\n # this returns the integer ordinal after we converted to UTF-8\n x = x.ord\n hash_array[x] = ((x**3000) + (x**x) - (3**x)) * (7**x) if hash_array[x].nil?\n res += hash_array[x]\n end\n\n # module result by constant 65536\n res = res % 65_536\n # resulting hash string in base-16\n resulting_hash = res.to_s(16)\n return unless resulting_hash != curr_block.block_hash\n\n @block_hash_error = true\n # rubocop:disable LineLength\n puts \"Line #{@curr_count}: String '#{block_hash_string}' hash set to #{curr_block.block_hash}, should be #{resulting_hash}\"\n # rubocop:enable LineLength\n puts 'BLOCKCHAIN INVALID'\n exit 1\n end",
"def test_check_hash_equal\r\n assert_equal true, @g.check_hash(1, 1)\r\n end",
"def hash\n @vbits.hash\n end",
"def mining_hash\n Utils.keccak(rlp_encode skip_keys: [:mix_hash, :nonce])\n end",
"def hash\n [airline_data, amount, avs_postcode_policy, bill_to, card_holder_name, cardnumber, csc, csc_policy, currency, duplicate_policy, expmonth, expyear, external_mpi, identifier, match_avsa, mcc6012, merchantid, sdk, ship_to, threedsecure, trans_info, trans_type].hash\n end",
"def equality_and_hashcode_from(*args)\n hashcode_prime = _equality_extract_options(args)[:hashcode_prime] || 17\n \n unless args.empty?\n\n define_method(:==) do |other|\n return true if self.equal?(other)\n return self.class == other.class &&\n args.all? { |a| self.send(a) == other.send(a) }\n end\n \n define_method(:eql?) do |other|\n return true if self.equal?(other)\n return self.class.eql?(other.class) &&\n args.all? { |a| self.send(a).eql?(other.send(a)) }\n end\n \n define_method(:hash) do\n hashcode = hashcode_prime * self.send(args[0]).hash\n args[1..args.size-1].each { |a| hashcode = hashcode_prime * ((hashcode << 2) + (hashcode >> 2)) + self.send(a).hash }\n return hashcode\n end\n\n end\n end",
"def test_nonequal_hash\n chain = \"Person1<Person2(360):Person3<Person4(930)\"\n block = Blockchain.new(0,0,chain, 1.5,\"ch77\")\n block.setHash(\"m1p0\")\n\n assert_equal(0, block.check_curr())\n end",
"def hash\n [to_d.hash, currency.hash].hash\n end",
"def check(hash)\n # not implemented\n end",
"def is_checksum_valid?(received_params)\n paytmparams = Hash.new\n\n keys = received_params.keys\n keys.each do |k|\n paytmparams[k] = received_params[k]\n end\n\n checksum_hash = paytmparams[\"CHECKSUMHASH\"]\n paytmparams.delete(\"CHECKSUMHASH\")\n\n Rails.logger.debug \"HERE\"\n Rails.logger.debug \"paytmparams #{paytmparams}\"\n Rails.logger.debug \"checksum_hash #{checksum_hash}\"\n Rails.logger.debug \"PAYTM_MERCHANT_KEY #{ENV[\"PAYTM_MERCHANT_KEY\"]}\" \n \n return new_pg_verify_checksum(paytmparams, checksum_hash, ENV[\"PAYTM_MERCHANT_KEY\"])\n end",
"def compute_checksums data\n\n digest = OpenSSL::Digest::Digest.new('sha256')\n tree_digest = OpenSSL::Digest::Digest.new('sha256')\n tree_parts = []\n\n until data.eof?\n\n chunk = data.read(1024 * 1024) # read 1MB\n tree_parts << tree_digest.update(chunk).digest\n tree_digest.reset\n\n digest.update(chunk)\n\n end\n\n data.rewind\n\n [digest.to_s, compute_tree_hash(tree_parts)]\n\n end",
"def hash\n bytes.hash\n end",
"def check_previous_hashes(block1, block2)\n unless block2.previous_hash.strip.eql? block1.current_hash.strip\n puts \"Line #{block2.block_number}: Previous hash was #{block2.previous_hash.strip},\n \tshould be #{block1.current_hash.strip}\"\n return false\n end\n true\n end",
"def hash\n [currency_code, memo, partial_auth, transaction_type, description, transaction_category_id, use_audit_log, merchant_category_code, card_id, transaction_category, cleanse_data, auth_type, mid, transaction_status_scope, location, merchant, amount, date, merchant_id].hash\n end",
"def ==(other)\n super || @hash == other.hash\n end",
"def hash # :nodoc:\n identifier.hash ^ requirement.hash\n end"
] |
[
"0.6754163",
"0.666868",
"0.65692586",
"0.65692586",
"0.65692586",
"0.65692586",
"0.65692586",
"0.65692586",
"0.65692586",
"0.63513196",
"0.63345236",
"0.6251595",
"0.6182625",
"0.61696875",
"0.61654735",
"0.6145629",
"0.6126361",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6124191",
"0.6101873",
"0.6090578",
"0.6069426",
"0.6066695",
"0.60576534",
"0.6056741",
"0.60256386",
"0.60256386",
"0.60256386",
"0.5996688",
"0.59904736",
"0.5981848",
"0.5966405",
"0.5946664",
"0.5946664",
"0.5945709",
"0.594519",
"0.5937802",
"0.5935014",
"0.5926515",
"0.5923718",
"0.5923718",
"0.5918206",
"0.5884335",
"0.58789593",
"0.5878618",
"0.5867541",
"0.58588594",
"0.5853731",
"0.58480793",
"0.58336705",
"0.5828562",
"0.5828562",
"0.5825719",
"0.58252805",
"0.5813493",
"0.5808833",
"0.5808302",
"0.5789425",
"0.5788375",
"0.5781231",
"0.5777222",
"0.5775711",
"0.5775711",
"0.57712215",
"0.5767593",
"0.57621586",
"0.5754124",
"0.5753074",
"0.5753074",
"0.5753074",
"0.5747595",
"0.57428944",
"0.57400984",
"0.57376426",
"0.5737227",
"0.5723091",
"0.5715989",
"0.5715691",
"0.5713773",
"0.5702668",
"0.57016814",
"0.5698205",
"0.5697884",
"0.56977034",
"0.56881356",
"0.5672374",
"0.56700206",
"0.56619847",
"0.56575716",
"0.56439054",
"0.5643211",
"0.5642197"
] |
0.6989397
|
0
|
method checks contractor data by keyword
|
def check_contractor_by_keyword(keyword)
match = @hash_contractor.find do |pair|
pair.last.downcase.include? keyword.downcase
end
(match == nil) ? (puts "#{@hash_contractor[:name]} dont have a #{keyword}") : (puts "The #{keyword} was include in #{match}, #{@hash_contractor[:name]}")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_keyword(candidate, keyword)\n puts \"\\n#{candidate[:name]}\\nAttributes containing '#{keyword}': \"\n candidate.each { |k, v| puts k if v.to_s.include?(keyword) }\n puts \"Attributes not containing '#{keyword}':\"\n candidate.each { |k, v| puts k unless v.to_s.include?(keyword)}\n end",
"def check_for_keyword(keyword)\n items_to_check = { job_description: job_description, skills: skills, job_title: job_title }\n items_to_check.each do |key,value|\n condition = case key\n when :skills\n \"does not\" unless value.grep keyword.capitalize \n else\n \"does not\" unless value.downcase.include? keyword.downcase\n end\n puts \"Freelancer\\'s #{name} #{key} #{condition} contains #{keyword}\"\n end\n end",
"def check_advanced_criteria(data)\t \n\t\tif data.include?(:_constructor)\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def checkData(iUserID, iComment)\n # Nothing to test\n end",
"def check\n \n end",
"def check\n \n end",
"def contractor_name_required?\n request_type.try(:code) == 'Renewal'\n end",
"def contractor_name_required?\n request_type.try(:code) == 'Renewal'\n end",
"def search(keywords)\n\n # Create key pool\n @tmp = keywords.split(\" \")\n\n # Check if data pool contain any key of key pool\n @tmp.each do |k|\n\n # Create data pool\n @tmp_data = \"#{self.id} #{self.name} #{self.link} #{self.description}\"\n\n # If contained then return true\n if(@tmp_data.include? k)\n return true\n end\n end\n\n # If not contained then return false\n return false\n end",
"def validate_keyword(keyword)\n if RESERVED_KEYWORDS.include?(keyword)\n reserved = RESERVED_KEYWORDS.collect { |key| \"'#{key}'\" }\n raise ReservedGearKeyword, \"'#{keyword}' is a reserved keyword. Reserved Keywords: #{reserved.join(', ')}.\"\n end\n\n culprit = find_by_keyword(keyword)\n\n unless culprit.nil?\n raise DuplicateGearKeyword, \"Keyword '#{keyword}' already used by #{culprit}\"\n end\n\n true\n end",
"def include_keyword?(keyword)\n return true if self.name && self.name.downcase.include?(keyword.downcase)\n return true if self.description && self.description.downcase.include?(keyword.downcase)\n \n return false\n end",
"def compare_contractor_data(contractor)\n message_good = \"Each attribute value is equal to the corresponding attributes of a freelancer #{contractor[:name]} on a profile page:\\n#{contractor}\"\n message_bad = \"Freelancer attribute values not equal to the corresponding attributes in the shared page. Expected:\\n#{contractor}\\nGot:\\n#{@hash_contractor}\"\n #hash_contractor = @hash_contractor\n (contractor == @hash_contractor) ? (puts message_good) : (puts message_bad)\n end",
"def keyword_check(kw)\n unless (@keywords || %w(a is of has)).include?(kw)\n raise RDF::ReaderError, \"unqualified keyword '#{kw}' used without @keyword directive\" if validate?\n end\n end",
"def check_for(name, criteria)\n case(name)\n when \"response_code\", \"message\"\n compare(send(name), criteria)\n else\n true\n end\n end",
"def validate_keyword!\n raise ResponseError::ArgumentError.new(\"Search keyword is missing\") if self.keywords.nil?\n raise ResponseError::ArgumentError.new(\"Search keyword is blank\") if self.keywords.empty?\n end",
"def customer_can_afford_pet(customer, pet)\n if customer[:cash] == pet[:price]\n end\n return true\nend",
"def audit_data_verify(a_data, v_data)\n found = nil\n a_data.each do |entry|\n if entry.text.match(v_data)\n found = true\n print_to_output(\"VERIFIED: Expected Audit data: '#{v_data}' is displayed.\")\n break\n end\n end\n raise \"Audit data #{v_data} was not found!\" unless found\n end",
"def check_single_data(data:, message:)\n crit_msg(message) if data\n end",
"def checkData(dbName)\n @db = @conn[dbName]\n @edorg_collection = @db[EDORG_COLLECTION]\n @edorg_collection.find.each do |row|\n type = row[TYPE_FIELD]\n body = row[BODY_FIELD]\n orgcats = body[ORGCAT_FIELD]\n\n if type == TYPE_VALUE_SCHOOL and not orgcats.include?(ORGCAT_VALUE_SCHOOL)\n puts(\"Error: missing school org cat\")\n return false\n end\n if type == TYPE_VALUE_LEA and not orgcats.include?(ORGCAT_VALUE_LEA)\n puts(\"Error: missing LEA org cat\")\n return false\n end\n if type == TYPE_VALUE_SEA and not orgcats.include?(ORGCAT_VALUE_SEA)\n puts(\"Error: missing SEA org cat\")\n return false\n end\n end\n return true\nend",
"def check(props)\n @results = nil\n name = props.item.title[/Establish (.*)/, 1]\n\n # if full title contains a name in parenthesis, check for that name too\n altname = props.item.fulltitle[/\\((.*?)\\)/, 1]\n\n if name and Server.podlingnamesearch\n for podling in Server.podlingnamesearch\n if name == podling\n @results = Server.podlingnamesearch[name]\n elsif altname == podling\n @results = Server.podlingnamesearch[altname]\n end\n end\n end\n\n Vue.forceUpdate()\n end",
"def check!\n super()\n \n if not @keyword_params.nil? and not @keyword_params.kind_of? Hash\n raise Exception::new(\"Keyword params must be Hash.\")\n end\n end",
"def contains_response_and_soln?() true ; end",
"def keyword_check(kw)\n unless (@keywords || %w(a is of has)).include?(kw)\n raise RDF::ReaderError, \"unqualified keyword '#{kw}' used without @keyword directive\" if @strict\n end\n end",
"def can_customer_afford_pet?(customer, wanted_pet)\n customer[:cash] >= wanted_pet[:price]\nend",
"def is_token_valid(token)\n return Placement[:client_id => token] != nil # just check if a there is a Placement with the given token in the database. Note how easy it is to retrieve a row with a condition and convert it to an instance of a class\nend",
"def check_keyword?(keyword)\n @keywordPairs.each do |pair|\n if pair[0] == keyword\n return true\n end\n end\n return false\n end",
"def consider(data)\n Interpreter.examine(data)\n end",
"def conditions; end",
"def conditions; end",
"def check_absorptance?()\n \n @construction.check_keyword?(\"ABSORPTANCE\") \n \n end",
"def data_satisfy?(data = {})\n jdata = JsonPath.new(['$.', json_path].join).first(data.to_json)\n return false unless jdata.present?\n mapped_conditions[cond_op.to_sym].call(jdata)\n end",
"def printSearchedListContainsKeywordOrNot(itemHash,keyword)\n keywordNotFound = Array.new()\n countFound = 0 # count for found keyword in the item.\n countNotFound = 0 # count for not found keyword in the item.\n itemHash.map do |item|\n # puts item # print the item .\n if (item[:name].downcase.include? (keyword.downcase))\n begin\n KeywordFound[countFound]={name: item[:name],Attribute: 'name'}\n countFound = countFound + 1\n end # check presence in the name.\n else\n if (item[:title].downcase.include? (keyword.downcase))\n begin\n KeywordFound[countFound]={name: item[:name],Attribute:'title'}\n countFound = countFound + 1\n end # check presence in the title.\n else\n if (item[:specialization].downcase.include? (keyword.downcase))\n begin\n KeywordFound[countFound]={name: item[:name],Attribute:'specialization'}\n countFound = countFound + 1\n end # check presence in the specialization.\n else\n if (item[:about].downcase.include? (keyword.downcase))\n begin\n KeywordFound[countFound]={name: item[:name],Attribute:'about'}\n countFound = countFound + 1\n end # check presence in the about.\n else\n if (item[:skills].downcase.include? (keyword.downcase))\n begin\n KeywordFound[countFound]={name: item[:name],Attribute:'skills'}\n countFound = countFound + 1\n end # check presence in the skills.\n else\n if (item[:devices].downcase.include? (keyword.downcase))\n begin\n KeywordFound[countFound]={name: item[:name],Attribute:'devices'}\n countFound = countFound + 1\n end # check presence in the devices.\n else\n begin\n keywordNotFound[countNotFound] = item[:name]\n countNotFound = countNotFound +1\n end # Not present, add into not found count.\n # end # (item[:platform].downcase.include? (keyword.downcase))\n end # (item[:devices].downcase.include? (keyword.downcase))\n end # (item[:skills].downcase.include? (keyword.downcase))\n end # (item[:about].downcase.include? (keyword.downcase))\n end # (item[:specialization].downcase.include? (keyword.downcase))\n end # (item[:title].downcase.include? (keyword.downcase))\n end # (item[:name].downcase.include? (keyword.downcase))\n end # printSearchedListContainsKeywordOrNot(itemHash,keyword)\n\n # Print the list of freelancer those having keyword in profile\n puts keyword + \" keyword found in below freelancer in respective attribute : \"\n for j in 0..countFound\n puts KeywordFound[j]\n end # End of for\n\n # Print the list of freelancer those not having keyword in profile\n puts keyword + \" keyword not found in below freelancer in any attribute : \"\n for i in 0..countNotFound\n puts keywordNotFound[i]\n end # End of for\n\n end",
"def match(keyword); end",
"def verify_integrity(object, entry)\n if entry.org != object[\"name\"]\n yield(\"Name must be '#{entry.org}' (is '#{object[\"name\"]}')\")\n end\n end",
"def verify_if_keyword_present_inresultPage(keyword)\n\n puts \"Verifying if title contains \"+keyword\n @@search_result_information.each do |hash|\n if hash['title'].include? keyword\n puts hash['name']+\"'s title contains searched keyword \"+keyword\n else\n puts hash['name']+\"'s title' doesn't contain searched keyword \"+keyword\n end\n end\n end",
"def might_respond_to?(data)\n data.respond_to?(:text) && !data.text.nil? && (data.user != client.self.id)\n end",
"def check_data(data, model, region, configuration)\n brand = model[:brand]\n series = model[:series]\n style = model[:style]\n province_id = region[:province_id]\n city_id = region[:city_id]\n\n case\n when data[:price].blank? || data[:price] == 0\n raise Error::InvalidPrice, @record\n when data[:mileage].blank?\n raise Error::InvalidMileage, @record\n when data[:licensed_at].blank?\n raise Error::InvalidLicensedAt, @record\n when data[:images].size <= 0\n raise Error::EmptyImages, @record\n when !Helper.valid_model?(brand)\n raise Error::InvalidBrand, @record\n when !Helper.valid_model?(series)\n raise Error::InvalidSeries, @record\n when !Helper.valid_model?(style)\n raise Error::InvalidStyle, @record\n when province_id.blank?\n raise Error::InvalidProvince, @record\n when city_id.blank?\n raise Error::InvalidCity, @record\n when configuration[:displacement].blank?\n raise Error::InvalidConfiguration, @record\n end\n end",
"def check(env, data)\n unless match(env, data)\n raise LangTypeError.new(data, self, env)\n end\n end",
"def customer_can_afford_pet(customer, desired_pet)\n customer[:cash] >= desired_pet[:price]\nend",
"def check_marc; end",
"def credential_check\n %w(partner req_id service v).all? { |k|\n # AlipayWap.logger.debug \"#{k}: #{@protocol_fields[k]}<->#{@request.protocol_fields[k]}\"\n @protocol_fields[k] == @request.protocol_fields[k].to_s\n } || raise(\"Response is not for this request\")\n end",
"def required_keywords; end",
"def check_key_data(record, ref_data, resp_data,\n exclude = nil, # exclude from db check.\n allow = nil, augment = true, # extra GET /keys items\n disallow = nil, line = nil)\n # XXX validate internally-generated db fields.\n must_exclude = [:time_constraints, :admin]\n exclude = exclude ? exclude + must_exclude : must_exclude\n # Allow skipping check_data.\n if (record && ref_data)\n check_data(record, ref_data, exclude, nil, disallow, line)\n end\n # Allow skipping reply check.\n if !resp_data\n return\n end\n\n non_db = [ \"bluetooth_address\",\n \"first_name\", \"last_name\", \"email\",\n \"user_display_name\", \"time_constraints\", \"lock_time_zone\" ]\n server_time = augment ? [:server_time] : []\n # reply splits into two sub-hashes.\n key_data = resp_data[\"key_data\"]\n key_info = resp_data[\"key_info\"]\n assert_not_nil key_data, \"key_data present\"\n assert_not_nil key_info, \"key_info present\"\n check_reply(json: key_data, model: record,\n elsewhere: non_db, allow: @@key_data_fields,\n exclude: [\"seq_no\"], augment: nil)\n # id present due to global rule in key_info, but not required\n check_reply(json: key_info, model: record,\n elsewhere: non_db, exclude: @@key_data_fields,\n augment: server_time)\n assert_equal record.lock.bluetooth_address, key_info[\"bluetooth_address\"], \"bluetooth_address\"\n assert_equal record.lock.name, key_info[\"name\"], \"name\"\n assert date_match(record.last_access, key_info[\"last_access\"]), \"last_access\"\n assert_equal record.user.account.first_name, key_info[\"first_name\"], \"first_name\"\n assert_equal record.user.account.last_name, key_info[\"last_name\"], \"last_name\"\n assert_equal record.user.account.email, key_info[\"email\"], \"email\"\n assert_equal record.user.display_name, key_info[\"user_display_name\"], \"user_display_name\"\n assert_equal record.lock.time_zone, key_info[\"lock_time_zone\"], \"time_zone\"\n # XXX admin\n\n check_key_time_constraints(record, key_data, key_info)\n\n #/locks doesn't include the same fields as /keys, so ignore these checks for GET /locks\n if (!ref_data && augment)\n # get /keys has extra fields\n admin = key_info['admin']\n auto_generated = key_info['auto_generated']\n lock_owner_key = key_info['lock_owner_key']\n assert_boolean_equal admin || lock_owner_key, auto_generated, \"auto_generated equals admin || lock_owner_key\"\n assert_boolean_equal record.lock.user_id == record.user_id, lock_owner_key, \"lock_owner_key equals record.lock.user_id == record.user_id\"\n lu = LocksUser.where(:lock_id => record.lock.id,\n :user_id => record.user_id)\n assert_boolean_equal (lu.count > 0) && lu.first.admin, admin, \"admin matches LocksUser\"\n # XXX lock_owner_display_name, sharer_display_name\n end\n end",
"def test_check_capital_contains\r\n assert_nil @g.check_capital('abDc')\r\n end",
"def valid_ecl?(data)\n return false unless data\n\n [\"amb\", \"blu\", \"brn\", \"gry\", \"grn\", \"hzl\", \"oth\"].include?(data)\nend",
"def attribute_matching(key, data, property=:long_name)\n data[\"address_components\"].each do |comp|\n return comp[property.to_s] if comp[\"types\"].include?(key)\n end\n return nil\n end",
"def verifyCicle\n $nodos.each { \n |node|\n if(node.entradas.length > 0)\n if(findCicle(node, node.operationId ,Array.new))\n return true\n end\n end\n }\n return false\nend",
"def customer_can_afford_pet(customer, pet)\n return customer[:cash] >= pet[:price]\nend",
"def scan\n sanitize\n data = get_external_data\n return unless data\n get_celebrity_status\n if self.celebrity?\n shop.send_celebrity_notification(self)\n self.status = 'celebrity'\n end\n end",
"def sell_pet_to_customer__pet_found(customer_cash, pets)\n result = pet_found(\"Arthur\")\n assert_equal([:names] ,pets)\nend",
"def checkdata_onmano(ixmano, str_log)\r\n @log.debug \"checkdata_onmano: #{ixmano}\"\r\n @mano_coll.each do |item|\r\n #p item\r\n if item[:ix] == ixmano\r\n # search the given string inside the log data\r\n item[:data].each do |data_item|\r\n #p data_item\r\n if data_item =~ /#{str_log}/\r\n @log.debug \"Found item (#{data_item}) requested on mano: #{ixmano}\"\r\n return true\r\n end\r\n end\r\n return false \r\n end\r\n end\r\n return false\r\n end",
"def matches_requirement?(query, option, requirement); end",
"def is_correct_data?(data, *expected_keys)\n return false until contains_expected_keys?(data, *expected_keys)\n filter_keys(data, *expected_keys)\n data.each do |key, value|\n return false until correct_type?(key, value)\n end\n data.each do |key, value|\n return false until corresponds_to_constraint?(key, value)\n end\n return true\nend",
"def _semantics_check(clazz, buffer)\n end",
"def parse_condition; end",
"def parse_condition; end",
"def customer_can_afford_drink(customer, beer)\n return customer[:cash] >= beer[:cost]\nend",
"def hit_condition()\n #This is a stub, used for indexing\n end",
"def get_contract_filter\n\t get_contract\n\t @tabtitle = @contract.name unless @contract.nil?\n\t true\n\tend",
"def validate_new_contract(data)\n errors = []\n\n #fields\n errors.push INVALID_CONTRACT_NAME unless GeneralValidator.validate_string data[:name]\n errors.push INVALID_CONTRACT_DESCRIPTION unless GeneralValidator.validate_string data[:description]\n errors.push INVALID_CONTRACT_EXPIRY unless GeneralValidator.validate_unix_datetime data[:expires]\n\n #arrays\n conditions_result = validate_new_conditions data[:conditions], data[:participants]\n transactions_result = validate_transactions data[:transactions]\n participants_result = validate_participants data[:participants]\n signatures_result = validate_new_contract_signatures data[:signatures]\n\n errors.concat conditions_result\n errors.concat transactions_result\n errors.concat participants_result\n errors.concat signatures_result\n\n raise ValidationError, {:valid => false, :errors => errors}.to_json if errors.count > 0\n end",
"def customer_can_afford_pet(customer, pet)\n customer[:cash] >= pet[:price]\nend",
"def valid?\n data\n end",
"def valid?\n data\n end",
"def contract; end",
"def contract; end",
"def keyword\n\t\t\tlegal = legal_record_type_id == 0 ? legal_record_type.name : custom_legal_record_type\n\t\t\talley = is_alley == 1 ? 'Hẻm' : 'Mặt tiền'\n\n\t\t\tkeyword = \n\t\t\t\t\"#{name}, #{purpose.name} #{real_estate_type.name} quận #{district.name}, #{real_estate_type.name} #{legal}, #{real_estate_type.name} #{alley}, #{alley} quận #{district.name}, #{street.name} quận #{district.name}, #{purpose.name}, #{province.name}, #{real_estate_type.name}, #{legal}\"\n\t\tend",
"def validate_keyword_on_candidates(candidates, keyword)\n puts \"Validating keywords appear on candidate's keywords.\"\n candidates.each { |candidate| validate_keyword(candidate, keyword) }\n end_section\n end",
"def check(slf, *v, &blk)\n AndContract.check_array(@contracts, slf, *v, &blk)\n end",
"def data_check(query)\n\n checked_data = {}\n\n checked_data[:tags] = tags_check(query['tags']) \n checked_data[:categories_id] = \\\n category_id_check(query['categories_id']) \n checked_data[:currentPage] = current_page_check(query['currentPage']) \n\n return checked_data\n\n end",
"def verify_get_code_by_action_bonus_data(params)\n params[:game].is_a?(Game) &&\n (params[:bonus].is_a?(TeamBonus) || params[:bonus_id].is_a?(String)) &&\n (params[:code].is_a?(Code) || params[:code_id].is_a?(String)) &&\n params[:user].is_a?(User)\n end",
"def validate_peer_data!(data)\n\t\t\t[:uuid,:host,:port].each{|k|\n\t\t\t\tdata[k] || fail(\"Peer data does not meet requirements. #{k} is a required field. See Hive documentation.\")\n\t\t\t}\n\t\t\tkeys = peer_fields.keys\n\t\t\tdata.keys.each{|k|\n\t\t\t\tkeys.include?(k) || warn(\"Provided key #{k} will not be stored with peer data\")\n\t\t\t}\n\t\t\ttrue\n\t\tend",
"def fcitycheck(vresult,vcity)\n\n\t#pick up city and country from api response body\n\tcity = vresult[\"data\"][\"request\"][0][\"query\"]\n\n\t#remove country from api response leaving only the city\n\ttruncatedcity=city[0,vcity.length]\n\t\n\t#validate that api response is for correct city\n\tif city = truncatedcity then\n\t\tputs \"--------\"\n\t\tputs \"Test 3 (Pass): Weather for #{city} is correct!\"\n\telse\n\t\tputs \"--------\"\n\t\tputs \"Test 3 (Pass): Weather for #{city} is not correct!\"\n\tend\n\t\nend",
"def check_in_result(result, type, atr, value)\n addr_obj_from_result(result).map { |adr| return (adr.send atr).casecmp(value).zero? if adr.types.include? type }.include? true\nend",
"def unsubstituable_data_criteria?(data_criteria)\n cr = data_criteria\n cr['negation'] || cr['definition'] == 'derived' || cr['type'] == 'derived' || (cr['type'] == 'characteristic' && cr['property'] == 'birthtime')\n end",
"def examine(item)\r\n \r\n end",
"def lookUp(name, city)\n \n if city.has_key?(name) == TRUE\n puts \"The city code is #{city[name]}\"\n \n else puts \"Sorry wrong city\" \n end\nend",
"def names_of_departments_with_at_least_one_contractor(departments)\nend",
"def check_by_company\n _r = false\n # global_company_breakdown returns multidimensional array containing different company in each line\n # Each line contains 5 elements: Company Id, max_order_total, max_order_price, Net amount sum by project & Item net price\n a = global_company_breakdown(purchase_order_items.joins(:project).order(:company_id))\n d = a.detect { |f| (f[1] > 0 && (f[3] > f[1])) || (f[2] > 0 && (f[4] > f[2])) }\n _r = d.nil? ? false : true\n end",
"def invisible_testSuccess(c, ci, cv, state)\n @state[COMMITMENT].any? {|terms| terms.size == 4 and terms[0] == c and terms[1] == ci}\nend",
"def condition; end",
"def verify_send_code_data(params)\n params[:game].is_a?(Game) && params[:code_string].is_a?(String) && params[:user].is_a?(User)\n end",
"def my_rents_office\n sc = SearchCondition.new(:user_id => session[:user_id],\n :city => \"Москва\", #todo: add code to process several cities in SearchCondition\n :realty_types => [\"office\",\"trading_floor\",\"warehouse\",\"catering\",\"free_app\",\"garage\",\"manufacture\",\"legal_address\",\"autoservice\",\"selling_business\"]\n )\n @entries = Entry.find_with_search_condition(sc)\n \n end",
"def check_2015_app_data key1, value\n @nasa[\"near_earth_objects\"][\"2015-09-08\"].each do |link|\n link[\"close_approach_data\"].each do |item|\n if item[key1].is_a?(value)\n return true\n end\n end\n end\n end",
"def customer_can_afford_pet?(customer_hash, wanted_pet)\n if customer_hash[:cash] >= wanted_pet[:price]\n true\n else\n false\n end\nend",
"def condition(response)\ncondition = response.condition['text']\nend",
"def check_if_approval_is_required\n check_by_families || check_by_supplier || check_by_project ||\n check_by_office || check_by_company || check_by_zone\n end",
"def hit_condition= symbol\n #This is a stub, used for indexing\n end",
"def check_values\n check_numericity\n check_zip_code\n end",
"def keyword_based_service?; end",
"def vash_valid_key?(x); self.class.option_name?(x); end",
"def check_sentence(sentence)\n\t# type here\n\t# change return\n\treturn true\nend",
"def precondition(_op)\n # gain access to operation instance methods \n op = Operation.find(_op.id)\n \n # get params\n response_request = op.input(\"Response Request Message\").val\n response_regex = op.input(\"Response Regex Format\").val\n response_tag = op.input(\"Response Tag\").val\n response_status_tag = \"Response Block status\"\n response_level = op.input(\"Response Level\").val\n \n case response_level\n when \"Plan\"\n obj = _op.plan\n response_tag += \" [#{_op.id}]\"\n response_status_tag += \" [#{_op.id}]\"\n when \"Operation\"\n obj = _op\n when \"Item\"\n obj = _op.input(\"Sample\").item\n end\n \n # library method from ControlBlock (Could this interface be improved?)\n user_response = get_user_response(op, response_request_message: response_request, response_regex: response_regex)\n \n # if the user hasn't responded yet, fail and keep downstream operations in waiting\n return false if user_response.nil?\n \n # Response recieved!\n \n # associate response to the item being passed through\n obj.associate(response_tag, user_response)\n \n # associate note on operation to indicate that you cant retroactively change response\n op.associate \"Response Block status\", \"Your response was successfully recorded as \\\"#{user_response}\\\"\"\n \n # pass input, allowing downstream operations to begin\n op.pass(\"Sample\", \"Sample\")\n\n # set status to done, so this block will not be evaluated again\n op.status = \"done\"\n op.save\n \n return true\nend",
"def contains_keyword(activity)\n keyword = %w[LET PRINT]\n activity.each do |statement|\n return true if keyword.include?(statement.upcase)\n end\n false\n end",
"def complex_condition?(condition); end",
"def validate_params(hash)\n hash.include?('title') and hash.include?('body') and hash.include?('category')\n end",
"def check_record; end",
"def congress?\n record.find do |field|\n field\n .tag\n .slice(0) == '6' &&\n field\n .subfields\n .find { |sf| sf.code == 'v' && PsulibTraject.regex_to_extract_data_from_a_string(sf.value, /Congress/i) }\n end\n end",
"def method_missing(meth, *args, &blk)\n if (matching_district=@districts.detect { |district| district.class.sym == meth })\n matching_district\n elsif (matching_industry=industries.detect { |industry| industry.class.sym == meth })\n matching_industry\n else\n super\n end\n end",
"def cache_check(compiler)\n ok = Mom::Label.new(\"cache_ok_#{self.object_id}\")\n check = build_condition(ok, compiler) # if cached_type != current_type\n check << Mom::SlotLoad.new([dynamic_call.cache_entry, :cached_type] , receiver_type_definition(compiler))\n check << Mom::ResolveMethod.new( @name , dynamic_call.cache_entry )\n check << ok\n end",
"def get_invoker(text)\n @invokers.map {|a| a if a.check text}.reject(&:!).first # reject all false\n end"
] |
[
"0.5875342",
"0.5729285",
"0.5527747",
"0.5392854",
"0.53882164",
"0.53882164",
"0.53565216",
"0.53565216",
"0.53465486",
"0.5319063",
"0.5317044",
"0.5288998",
"0.52725273",
"0.52521265",
"0.5246642",
"0.52169985",
"0.52038676",
"0.5198129",
"0.5151281",
"0.5122915",
"0.51213115",
"0.50992185",
"0.50742567",
"0.5061943",
"0.50594884",
"0.5059364",
"0.5049398",
"0.5046707",
"0.5046707",
"0.5045406",
"0.50423205",
"0.50384754",
"0.5006523",
"0.49892765",
"0.49869373",
"0.49865952",
"0.49847803",
"0.49837473",
"0.4979439",
"0.49773988",
"0.49690968",
"0.49631578",
"0.49468768",
"0.49353504",
"0.49220616",
"0.49210998",
"0.4919612",
"0.49155968",
"0.49127254",
"0.4911092",
"0.49107024",
"0.4907255",
"0.4905876",
"0.49053115",
"0.4904842",
"0.4904842",
"0.49021226",
"0.48981398",
"0.488586",
"0.48848617",
"0.48808858",
"0.48803264",
"0.48803264",
"0.4857391",
"0.4857391",
"0.484596",
"0.48407692",
"0.48387632",
"0.48365468",
"0.4829517",
"0.48278096",
"0.4824949",
"0.48144254",
"0.48106748",
"0.4805577",
"0.4801805",
"0.4800284",
"0.47993898",
"0.479363",
"0.47929585",
"0.47891712",
"0.47874585",
"0.4780332",
"0.4777648",
"0.47770306",
"0.47759953",
"0.4775415",
"0.4773232",
"0.4773224",
"0.47696567",
"0.47667992",
"0.4766388",
"0.47604337",
"0.47556883",
"0.4755502",
"0.4753193",
"0.47516796",
"0.4750703",
"0.4745619",
"0.4729046"
] |
0.7204914
|
0
|
List the sales orders under this account
|
def index
@sales_orders = @customer.sales_orders
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @sales_orders = SalesOrder.all\n end",
"def sales\n @orders = Order.where(seller: current_user.id).order(\"created_at DESC\")\n end",
"def list_orders\n Order.list(@current_user)\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def index\n @sales_order_details = SalesOrderDetail.all\n end",
"def my_sales\n @order_items = Effective::OrderItem.deep.sold_by(current_user)\n EffectiveOrders.authorized?(self, :index, Effective::Order.new(user: current_user))\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def sales\n FarMar::Sale.get_by(\"vendor\", id)\n end",
"def index\n @orders = @orders.all\n end",
"def index\n @orders = current_user.orders\n end",
"def index\n @orders = current_user.orders\n end",
"def sold_orders\n @orders = current_user.sold_orders\n end",
"def sold_orders\n @orders = current_user.sold_orders\n end",
"def index\n @sales_orders = SalesOrder.all.order(order_date: :desc)\n end",
"def index\n @sale_orders = current_company.sale_orders.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sale_orders }\n end\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == @id }\n end",
"def sales\n @orders = Order.all.where(seller: current_user).order(\"created_at DESC\")\n end",
"def sales\n @orders = Order.all.where(seller: current_user).order(\"created_at DESC\")\n puts \"hi\"\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def index\n @orders = current_user.purchases\n end",
"def sales\n Sale.find_all_by_vendor_id(@id)\n end",
"def listOrders()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n ret = []\n Order.find_each do |order|\n ret << {id: order.id, product_id: order.product_id, product_name: Product.find(order.product_id).name, user_id: order.user_id, quantity: order.quantity, price_per_unit: order.price_per_unit, int_status: order.order_status}\n end\n render json: {data: ret.to_json, reason: '', status: true}\n end",
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == id }\n end",
"def index\n @orders = Order.all\n end",
"def get_orders\n return ShopifyAPI::Order.all\n end",
"def index\n @accesory_sales = AccesorySale.all\n end",
"def index\n @orders = order.all\n end",
"def index\n @orders = Order.user_orders current_user\n end",
"def index\n @service_orders = ServiceOrder.all\n end",
"def sales(options = {})\n options[:product_id] = epages_id(options[:product_id]) if options[:product_id]\n perform_get_with_object('/sales', format_dates_options(options), Epages::SalesSummary)\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @sales = Sale.all\n end",
"def index\n @store_orders = StoreOrder.all\n end",
"def sales\n return array_of_instances(FarMar::Sale.all, \"product_id\", product_id)\n end",
"def index\n @purchase_orders = PurchaseOrders.all\n end",
"def index\n @transaction_orders = TransactionOrder.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n end",
"def index\n @purchase_orders = PurchaseOrder.all\n end",
"def index\n @purchase_orders = PurchaseOrder.all\n end",
"def index\n @purchase_orders = PurchaseOrder.all\n end",
"def index\n @purchase_orders = PurchaseOrder.all\n end",
"def index\n @purchase_orders = PurchaseOrder.all\n end",
"def index\n @orders = Order.where(user_id: current_user.id)\n end",
"def orders\n authenticated_post(\"orders\").body\n end",
"def index\n @user_orders = UserOrder.all\n end",
"def sales_orders\n case organization_type.type_value\n when 'customer'\n SoHeader.where('organization_id = ?', id).order('created_at desc')\n when 'vendor'\n SoHeader.joins(:so_lines).where('so_lines.organization_id = ?', id).order('created_at desc')\n else\n SoHeader.where('organization_id = ?', 0).order('created_at desc')\n end\n end",
"def list_orders(code)\n PsegRecurring::Order.new(@credentials).fetch_orders(code)\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def index\n @ecom_orders = EcomOrder.all\n end",
"def index # class method\n @orders = Order.all\n end",
"def index # class method\n @orders = Order.all\n end",
"def index\n @orders = Order.all\n\n @orders_this_month = Order.where(created_at: Time.now.beginning_of_month..Time.now.end_of_month)\n @sales = []\n @orders_this_month.each do |order| \n @sales.push(order.total)\n end\n @total_sales_this_month = @sales.reduce(:+)\n end",
"def sales\n @orders = Order.where(seller: current_user).order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 48)\n respond_to do |format|\n format.html\n format.csv { send_data @orders.to_csv(@orders) } \n end\n end",
"def index\n @product_sales = ProductSale.all\n end",
"def orders\n @title = \"Your Orders\"\n @orders = @customer.orders.paginate(\n :page => params[:page],\n :per_page => 10\n )\n end"
] |
[
"0.752036",
"0.718857",
"0.71228445",
"0.6865054",
"0.6795823",
"0.67306465",
"0.66761994",
"0.6625378",
"0.66157407",
"0.66115594",
"0.66115594",
"0.6540638",
"0.6540638",
"0.652416",
"0.65212643",
"0.65206635",
"0.6518269",
"0.6511002",
"0.6503947",
"0.6503932",
"0.6443859",
"0.6443194",
"0.6439753",
"0.64286405",
"0.6426792",
"0.6388962",
"0.6387549",
"0.63756883",
"0.6364278",
"0.63571495",
"0.6338625",
"0.6338625",
"0.6338625",
"0.6338625",
"0.6338625",
"0.6338625",
"0.6338625",
"0.6338593",
"0.6334186",
"0.6301322",
"0.62920845",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.6277979",
"0.62502426",
"0.62502426",
"0.62502426",
"0.62502426",
"0.62502426",
"0.62493616",
"0.6227569",
"0.6218151",
"0.62120754",
"0.6208721",
"0.6205969",
"0.62044495",
"0.62023824",
"0.62023824",
"0.62013215",
"0.6173792",
"0.6161724",
"0.61589307"
] |
0.7583141
|
0
|
Contact people under current account.
|
def contacts
@contact = @customer.contact_people.find_by_id params[:id]
# Delete contact
if @contact && params[:method] == "delete"
@store_user.my_account_log(@contact,"Delete Contact #{@contact.name}")
@contact.destroy
@customer.update_ax( :contacts => [@contact] )
redirect_to :id => nil
end
# Add or update contact
if request.post? && params[:contact]
@contact ||= @customer.contact_people.build
@contact.attributes = params[:contact]
if @contact.save
redirect_to :id => nil
else
@customer.contact_people.delete @contact
render
end
# Synchronize customer
@customer.update_ax( :contacts => [@contact] ) if @contact.errors.empty?
@store_user.my_account_log(@contact,"Add or Update Contact #{@contact.name}")
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def contactus\r\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n end",
"def contact\n\n end",
"def contact\n\n end",
"def contact \n\n end",
"def contactus\n end",
"def account\n # find the account we are grabing contacts from\n if id = params[:from_account]\n @selected_account = Sfaccount.find(id)\n end\n # super users can only add themselves.\n if current_contact.portal_privilege == AppConstants::PRIVILEGE[:super_user]\n @instruction_text = \"Your current access level is \\\"Super User\\\" and you can only subscribe 1 contact: yourself.\"\n @contacts = [current_contact]\n else\n @contacts = (@selected_account || @account).contacts\n if current_contact.portal_privilege == AppConstants::PRIVILEGE[:user_manager]\n @instruction_text = \"Your current access level is \\\"User Manager\\\" and you can subscribe other contacts from your company.\"\n end\n end\n # the current subscribers\n @subscribers = @account.watcher ? @account.watcher.contacts : []\n # set siblings if (a) this account can view child accounts and (b) it has sibling accounts\n @siblings = ((@account.portal_case_scope__c == Sfaccount::SCOPES[:children_accounts] and @account.sibling_accounts) ? @account.sibling_accounts.reject { |a| a.contacts(true).empty? } : [])\n \n end",
"def contacts\n\t\t@user = current_user\n\t\tcheck_if_myself\n\t\t@contacts = @user.contacts\n\tend",
"def first_contact\n\n mail(\n to:\n cc:\n subject: \"We will contact you soon!\"\n )\n end",
"def contacts\r\n\r\n end",
"def case\n @account = @case.account\n # find the account we are grabing contacts from. this is used in the pulldown selection menu.\n if id = params[:from_account]\n @selected_account = Sfaccount.find(id)\n end\n # super users can only add themselves.\n if current_contact.portal_privilege == AppConstants::PRIVILEGE[:super_user]\n @instruction_text = \"Your current access level is \\\"Super User\\\" and you can only subscribe 1 contact: yourself.\"\n @contacts = [current_contact]\n else\n @contacts = (@selected_account || @account).contacts\n if current_contact.portal_privilege == AppConstants::PRIVILEGE[:user_manager]\n @instruction_text = \"Your current access level is \\\"User Manager\\\" and you can subscribe other contacts from your company.\"\n end\n end\n @subscribers = @case.watcher ? @case.watcher.contacts : []\n # set siblings if (a) this account can view child accounts and (b) it has sibling accounts\n @siblings = (@account.portal_case_scope__c == Sfaccount::SCOPES[:children_accounts] and @account.sibling_accounts) ? @account.sibling_accounts.reject { |a| a.contacts(true).empty? } : []\n end",
"def contact(contact)\n @contact = contact\n\n mail(from: contact.email, subject:'Someone wants to talk to ya!')\n end",
"def contact()\n\t\t\"Please contact #{full_name()} via #{email}\"\n\tend",
"def contact(text, user)\n @text = text\n @user = user\n @person, @company, = @user.person, @user.company\n mail(:subject => \"Contact Form\", :to => AppConfig[:support_email], :from => @user.email)\n end",
"def contact; end",
"def show\r\n\t\t@contact = current_user.contacts.find(params[:id])\r\n\tend",
"def contact_owner(user)\n @user = user\n mail(to: 'christiansalas96@gmail.com', subject: 'Contact Us Form | Someone Reached Out!')\n end",
"def set_contact\n @contact = current_user.contacts.find(params[:id])\n end",
"def show\n @contact = current_user.contacts.find(params[:id])\n\n end",
"def legal_contact\n get_user legal_contact_id\n end",
"def contact_to(a)\n if user_signed_in?\n contact_link current_subject.contact_to!(a)\n else\n link_to t(\"contact.new.link\"), new_user_session_path\n end\n end",
"def contact_to(a)\n if user_signed_in?\n contact_link current_subject.contact_to!(a)\n else\n link_to t(\"contact.new.link\"), new_user_session_path\n end\n end",
"def display_one_contact\n contact = retrieve_contact_by_email\n end",
"def contact_email\n @contact = Contact.last\n mail to: \"lauren@scholarhood.ca, kurtis.elliott@ratehub.ca\"\n end",
"def set_contact\n @contact = Contact.find_by(id: params[:id], user_id: current_user.id)\n end",
"def contact\n # STUB\n end",
"def billing_contact\n get_user billing_contact_id\n end",
"def contactUs(name, email, phone, question, contact_pref)\n @contact_pref = contact_pref\n @name = name\n @email = email\n @phone = phone\n @question = question\n @greeting = @name + \" \" + \"Has a question!\"\n @subject = \"User Question\"\n\n mail to: \"bubba99207@gmail.com\", subject: @subject\n end",
"def add_contact(ownnick, person)\n return ret_fail('can not add yourself') if person == ownnick #you cant add yourself !\n\n usr = User.first(:nickname=>person)\n return ret_fail('no such user') if usr == nil #user does not exist !\n\n ownusr = User.first(:nickname => ownnick) #get own record to get the contact list\n return ret_fail('already in list') if ownusr.contacts.first(:userid => usr.id) != nil\n\n c = ownusr.contacts.new\n c.userid = usr.id\n puts usr.id\n puts c.userid\n c.authgiven = 'f'\n c.save\n\n return ret_success\nend",
"def request_contacts\n\t\tname = params[:name]\t\t\t\t\t\t\t\n\t\temail = params[:email]\n\t\ttelephone = params[:telephone]\n\t\tmessage = params[:message]\n\t\tif email.blank?\n\t\tflash[:alert] = I18n.t('request_contacts.no_email')\n\t\telse\n\t\t\tContactMailer.contact_email(email, name, telephone, message).deliver_now\n\t\t# Send an email\n\t\tflash[:notice] = I18n.t('request_contacts.email_sent')\n\t\tend\n\t\tredirect_to root_path\n\n\n\tend",
"def contact_to(a)\n if user_signed_in?\n link_to contact_status(a),\n edit_contact_path(current_subject.contact_to!(a)),\n :title => t(\"contact.new.title\",\n :name => a.name)\n else\n link_to t(\"contact.new.link\"), new_user_session_path\n end\n end",
"def app_contact\n end",
"def contact_team_members(contact_list, response, team, sender)\n message_string = team + \" needs your attention \"\n contacts = contact_list.split(\",\")\n contacts.each do |contact|\n user = user_ids.find { |user| user[:name] == contact }\n message_string.concat(\" <@#{user[:id]}>\")\n end\n write_error_to_file(sender, team)\n response.reply(message_string)\n end",
"def index\n @contacts = current_user.contacts\n end",
"def index\n @user_contact_information = current_user.user_contact_information\n end",
"def contacts(params = {})\n # contacts in this group\n @contacts = nil\n contacts!\n end",
"def accept\n Connection.accept(person_id, contact_id)\n end",
"def contact_us(record)\n @record = record\n mail(to: \"itstimetovacay@gmail.com\", subject: \"Contact Us.\")\n end",
"def contact_us contact\n @contact = contact\n mail reply_to: @contact.email, subject: with_case_number(@contact.subject)\n end",
"def user\n User.get(contact, client: @client)\n end",
"def new\r\n\t\t@contact = current_user.contacts.new\r\n\tend",
"def business_contact(contact)\n @contact = contact\n @url = \"http://localhost:3000/admin/login\"\n mail(:to => [\"trey@treytucker.com\", \"paul@bigblockdeals.com\"], \n :subject => \"New Business Contact\")\n end",
"def accept\n Connection.accept(user_id, contact_id)\n end",
"def contact_me(contact_form)\n @from = contact_form.email\n @message = contact_form.message\n @name = contact_form.name\n if contact_form.name.presence\n subject = \"Portfolio: A message from #{contact_form.name}\" \n else\n subject = \"Portfolio: A message from an unnamed visitor to your site.\"\n end\n mail from: contact_form.email,subject: subject\n end",
"def contact_customer(contact)\n @contact = contact\n mail to: \"info@manfercomunidades.com\",\n subject: \"Contacto recibido en la web\"\n end",
"def new\n @contact = current_user.contacts.new\n\n end",
"def send_thx_email\n @user = User.where(:uid => self.uid).first\n if !@user.nil? && !@user.email.nil?\n Services::Mandrill.mail(@user.email, 'PicsforPets_2013_Reportback', 'How to get puppies adopted')\n end\n end",
"def contact\n\t\t@contact\n\tend",
"def contact\n\t\t@contact\n\tend",
"def email_cory(user)\n @user_info = user_info\n mail to: \"rachavez1974@gmail.com\"\n end",
"def send_mail_to_associates\n unless self.matter_people.blank?\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end\n end",
"def send_mail_to_associates\n user = self.matter_people.assignee\n if(@is_changed && user && User.current_user!=user)\n send_notification_to_responsible(user,self,User.current_user)\n @is_changed = false\n\n true\n end\n end",
"def send_contact(name, email, company, phone, subject, message)\n @greeting = message\n\n mail to: \"prawdzik@domekmlodosci.pl\", subject: \"#{name}, #{email}, #{phone} #{\", \" + company} - #{subject}\"\n end",
"def general_account_information(person, options = {})\n @person = person\n\n mail(:to => [@person.personal_email],\n :subject => options[:subject] || \"Account information (\" + @person.email + \")\",\n :date => Time.now)\n\n end",
"def user_mailer(contact)\n @contact = contact\n\n mail(:to => \"from@example.com\", :subject => \"registered,\")\n end",
"def inquiry(member)\n @member = member\n mail to: @member.email\n end",
"def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end",
"def display_one_contact(contact)\n if contact\n puts \"Name: #{contact.name}\"\n puts \"E-mail: #{contact.email}\"\n puts \"Phone Number: #{contact.phone_number}\"\n else\n puts \"Not found!\"\n end\n end",
"def contact_confirmation(contact)\n @contact = contact\n\n mail to: \"hello@meme.menu\", subject: \"New Contact Submission\"\n end",
"def show\n @contact.read\n @contact.save\n @sender = User.find_by(pseudo: @contact.sender)\n end",
"def send_contact_email\n UserMailer.contact(self).deliver_now\n end",
"def contact(contact)\n @contact = contact\n mail to: \"yossishalem@gmail.com\", subject: 'NerEzion - You have a new message(contact)'\n end",
"def contact_name \n User.find(Membership.find(self.owner_id).user_id).name\n end",
"def display_contact\r\n\t\tputs \"ID: #{@id}\"\r\n\t\tputs \"First Name: #{@firstname}\" \r\n\t\tputs \"Last Name: #{@lastname}\"\r\n\t\tputs \"Email Address: #{@email}\"\r\n\t\tputs \"Notes on User: #{@notes}\" \r\n\tend",
"def add_contact\n\t\tcheck_if_myself(params[:user_id])\n\t\tuser = User.find(params[:user_id])\n\t\tto_add = User.find(params[:to_add_id])\n\t\tif to_add && user != to_add && !Contact.where(from_user: user.id).map {|c| c.to_user.id}.include?(to_add.id)\n\t\t\tuser.contacts.push(to_add)\n\t\t\tuser.save\n\t\t\tredirect_to contacts_page_path(id: params[:user_id])\n\t\telse\n\t\t\traise ActionController::RoutingError, 'Not Found'\n\t\tend\n\tend",
"def contact_us(contact)\n @contact = contact\n mail( to: TO, subject: \"Contact Us Request by #{@contact.name.camelcase} #{Time.current.strftime('%b %d, %Y %H:%M %p')}\")\n end",
"def contact\n # These error messages are injected into the contact form alert via JS.\n if !current_user && !check_captcha # the captcha is not used if there is a logged-in user\n render plain: \"Incorrect math question response.\", status: :bad_request\n return\n elsif params[:comment]&.blank? # name and email are optional, but comment is required\n render plain: \"Please enter a comment.\", status: :bad_request\n return\n end\n feedback_email = current_institution&.feedback_email ||\n Setting.string(Setting::Key::FEEDBACK_EMAIL)\n begin\n IdealsMailer.contact(page_url: params[:page_url],\n from_name: params[:name],\n from_email: params[:email],\n comment: params[:comment],\n to_email: feedback_email).deliver_now\n rescue => e\n LOGGER.error(\"#{e}\")\n render plain: \"An error occurred on the server. If this error \" +\n \"persists, please email us at: \" + feedback_email,\n status: :internal_server_error\n else\n render plain: \"OK\"\n end\n end",
"def index\n # only show contacts for current login user\n @user = User.find_by_id(current_user.id)\n if (!@user.nil?)\n @contacts = @user.contacts\n end\n end",
"def contact(params)\n @name = params['name']\n @email = params['email']\n @service = params['service']\n @message = params['message']\n\n mail to: \"ben@tinycodefactory.com\", subject: \"Message from #{@name}<#{@email}>\"\n end",
"def send_contact_mail(conatct_email_object)\n c= Contact.select(\"email,name\").find(conatct_email_object.contact_id)\n\n @greeting = \"Hi #{c.name}\"\n @message = conatct_email_object.message\n\n mail to: \"#{c.email}\",subject:conatct_email_object.subject\n end",
"def contacts(contact_message)\n p \"====\"\n p \"contacts\"\n p \"contacts\"\n p \"====\"\n @settings = Setting.get('contacts')\n @contact_message = contact_message\n\n mail to: @settings.emails, subject: \"Новое сообщение ##{@contact_message.id}\"\n end",
"def request_contact\n name = params[:name]\n email = params[:email]\n telephone = params[:telephone]\n message = params[:message]\n if email.blank?\n flash[:alert] = I18n.t('contact.no_email')\n else\n ContactMailer.contact_email(email,name,telephone,message).deliver_now\n flash[:notice] = I18n.t('contact.yes_email')\n end\n redirect_to root_path\n end",
"def contact_me(params)\n @params = params\n @greeting = \"Hi\"\n #mail to: \"to@example.org\"\n mail(:from => @params.personal_email,:to =>@params.personal_email, :subject => \"- EJJE -Gracias Por tu ayuda\")\n end",
"def success(user, account)\n @greeting = \"Successfully retrieved data for your account - #{account.inspect}\"\n\n mail to: user.email\n end",
"def index\n @contacts = current_user.contacts.all\n\n\n end",
"def get_contact\r\n @contact = @customer.contact_people.find_by_name params[:id]\r\n end",
"def find_friends\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def technical_contact\n get_user technical_contact_id\n end",
"def index\n\t\t@contacts = current_user.contacts.get_active_contacts\n\tend",
"def call_acepted(contact)\n @contact = contact\n @property = Property.find(contact.property_id)\n @runner = Runner.find(@property.runner_id)\n mail(to: @contact.email, subject: \"El runner acepto la video llamada \")\n end",
"def contacts #allows the contacts page to display all the members and their contact info\n @users = User.all\n @users.each do |user|\n puts user.username\n end\n end",
"def add_contacts\n \tap \"adding contacts\"\n # asking whether we are already authorized\n AddressBook.request_authorization unless AddressBook.authorized?\n\n \n if AddressBook.authorized?\n 25.times do\n person = AddressBook::Person.create(\n :first_name => Forgery::Name.first_name, \n :last_name => Forgery::Name.last_name, \n :email => [{ :value => Forgery(:internet).email_address , :label => 'Home'}], :phones => [{ :value => rand(10 ** 10).to_s, :label => 'Mobile'}])\n end\n else\n #ap \"This app is not authorized to access the address book.\"\n end\n #enVd\n end",
"def new_contact_reply(contact_us_id)\n @contact_us = ContactUs.find contact_us_id\n mail({\n to: @contact_us.email,\n subject: \"Thank you for contacting us\"\n })\n end",
"def contact_form(contact)\n @contact = contact\n\n mail to: contact.email, subject: \"Thanks for getting in touch\"\n end",
"def display_all_contacts\n\t\t@rolodex.contacts.each do |user|\n\t\t\tputs \"First Name:#{user.first_name}\" \n\t\t\tputs \"Last Name: #{user.last_name}\"\n\t\t\tputs \"Email Address:#{user.email}\" \n\t\t\tputs \"Note: #{user.note}\"\n\t\tend\n\tend",
"def contact\n \n ContactMailer.contact_email(params).deliver\n\n begin\n flash[:notice] = \"Successfully...\"\n rescue\n flash[:notice] = \"failed ...\"\n end\n end",
"def contact_to!(actor)\n contact_to(actor) || sent_contacts.create!(receiver: actor)\n end"
] |
[
"0.6687541",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6655019",
"0.6622191",
"0.6622191",
"0.6593828",
"0.6524484",
"0.6339413",
"0.6286772",
"0.62792695",
"0.6253815",
"0.618505",
"0.6160406",
"0.61597323",
"0.6115063",
"0.60841453",
"0.60513014",
"0.60363626",
"0.60317403",
"0.6008215",
"0.60079694",
"0.5997043",
"0.5997043",
"0.5995897",
"0.5951459",
"0.5898325",
"0.58853114",
"0.58749455",
"0.5870169",
"0.5860107",
"0.5859156",
"0.5857208",
"0.58563465",
"0.58538187",
"0.580326",
"0.5797212",
"0.5771061",
"0.5768003",
"0.57619333",
"0.5757288",
"0.5753529",
"0.57531756",
"0.5752606",
"0.57465994",
"0.57358074",
"0.5724678",
"0.57201207",
"0.570766",
"0.57059973",
"0.57059973",
"0.5705621",
"0.5701497",
"0.57002693",
"0.56999147",
"0.5696335",
"0.569493",
"0.5692709",
"0.56847674",
"0.568146",
"0.56781375",
"0.5677427",
"0.56762296",
"0.56688464",
"0.5668681",
"0.5660787",
"0.5657405",
"0.5653908",
"0.56498456",
"0.5648778",
"0.56479913",
"0.56470865",
"0.56462836",
"0.56449366",
"0.5635453",
"0.56319684",
"0.5627903",
"0.56272227",
"0.5623131",
"0.56197464",
"0.56189644",
"0.5615752",
"0.5613824",
"0.5613117",
"0.5611508",
"0.56087637",
"0.5607175",
"0.5591378",
"0.55708325"
] |
0.6122399
|
26
|
Contact profile Only "Email" of customer account(AX.Customer) is changeable.
|
def profile
if request.post?
@customer.update_attributes :email => params[:customer][:email], :phone => params[:customer][:phone]
@store_user.my_account_log(@customer,"Update Profile Email: #{@customer.email} Phone: #{@customer.phone}")
@customer.update_ax
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def personal_profile\n RubyRedtail::Query.run(\"contacts/#{@id}/personalprofile\", @api_hash, \"GET\")\n end",
"def email; default_profile.try :email; end",
"def update_profile_email\n user_profile.update_attribute(:email, email) if saved_change_to_email?\n end",
"def customer_profile(user)\n resp = Caboose::StdClass.new('success' => true) \n options = { :profile => { :merchant_customer_id => user.id, :email => user.email }}\n \n if user.authnet_customer_profile_id.nil? || user.authnet_customer_profile_id.strip.length == 0 # No customer profile, so create it \n response = self.gateway.create_customer_profile(options)\n if response.success?\n user.authnet_customer_profile_id = response.params['customer_profile_id']\n user.save\n elsif response.message.starts_with?(\"A duplicate record with ID \")\n user.authnet_customer_profile_id = response.message.gsub(\"A duplicate record with ID \", '').gsub(\" already exists.\", '')\n user.save\n else\n resp.success = false\n resp.error = \"A fatal error occured, the web administrator has been notified. Please try again later.\" \n end \t\n else # Update the profile\n options[:profile][:customer_profile_id] = user.authnet_customer_profile_id \n response = self.gateway.update_customer_profile(options) \n if !response.success?\n resp.success = false\n resp.error = \"A fatal error occured, the web administrator has been notified. Please try again later.\" \n end\n end\n return resp \n end",
"def contact_email\n contact['email_address']\n end",
"def email\n @json['profile']['email'] rescue nil\n end",
"def contact_email\n self.contact[:contact_email]\n end",
"def contact_email=(value)\n @contact_email = value\n end",
"def update_payment_contact_info(contact_info, email)\n cc_address_tb.type_text(contact_info.address) unless contact_info.address.nil?\n # Since country and state are close related, you have to change them together\n unless contact_info.country.nil?\n cc_country_select.select(contact_info.country)\n alert_accept if alert_present?\n wait_until_bus_section_load\n case contact_info.country\n when 'United States'\n cc_state_us_select.select(contact_info.state_abbrev)\n when 'Canada'\n cc_state_ca_select.select(contact_info.state_abbrev)\n else\n cc_state_tb.type_text(contact_info.state)\n end\n end\n cc_city_tb.type_text(contact_info.city) unless contact_info.city.nil?\n cc_zip_tb.type_text(contact_info.zip) unless contact_info.zip.nil?\n cc_phone_tb.type_text(contact_info.phone) unless contact_info.phone.nil?\n cc_email_tb.type_text(email) unless email.nil?\n end",
"def contact_email\n return @contact_email\n end",
"def profile_update(profile,user)\n @profile=profile\n @user=user\n mail to: @user.email, subject: \"Profile updated (Socail Trip App)\", from:'test@example.com'\n end",
"def contact\r\n @profile ||= ContactProfile.new(:account_id => session[:account_id])\r\n @email = session[:email]\r\n \r\n if request.post?\r\n # ! unlimited required !\r\n \r\n @profile.msn = params[:msn] && params[:msn].strip\r\n @profile.gtalk = params[:gtalk] && params[:gtalk].strip\r\n @profile.qq = params[:qq] && params[:qq].strip\r\n @profile.skype = params[:skype] && params[:skype].strip\r\n @profile.mobile = params[:mobile] && params[:mobile].strip\r\n @profile.phone = params[:phone] && params[:phone].strip\r\n @profile.address = params[:address] && params[:address].strip\r\n @profile.website = params[:website] && params[:website].strip\r\n \r\n if @profile.save\r\n flash.now[:message] = \"已成功保存\"\r\n else\r\n flash.now[:error_msg] = \"操作失败, 再试一次吧\"\r\n end\r\n \r\n end\r\n end",
"def update_customer_profile\n json_response({ message: 'NOT IMPLEMENTED' })\n end",
"def verify_customer_profile(user)\n \n if user.authnet_customer_profile_id\n resp = self.gateway.get_customer_profile({ :customer_profile_id => user.authnet_customer_profile_id })\n if resp.success? # The profile id is valid\n return true\n else\n user.authnet_customer_profile_id = nil\n user.save\n end\n end\n \n # No customer profile, so create it \n resp = self.gateway.create_customer_profile({ :profile => { :merchant_customer_id => user.id, :email => user.email }})\n Caboose.log(resp.inspect)\n if resp.success?\n user.authnet_customer_profile_id = resp.params['customer_profile_id']\n user.save\n elsif resp.message.starts_with?(\"A duplicate record with ID \")\n user.authnet_customer_profile_id = resp.message.gsub(\"A duplicate record with ID \", '').gsub(\" already exists.\", '')\n user.save\n else\n Caboose.log(\"Error creating authnet customer profile for user #{user.id}\")\n return false \n end\n return true \n end",
"def get_customer_profile\n json_response({ message: 'NOT IMPLEMENTED' })\n end",
"def apply_facebook(omniauth)\n if (info = omniauth['info'] rescue false)\n self.email = (info['email'] rescue '')\n end\n end",
"def billing_contact\n get_user billing_contact_id\n end",
"def display_one_contact\n contact = retrieve_contact_by_email\n end",
"def set_profile_type\n if determine_email\n self.profile_type = \"Contributor\"\n else\n self.profile_type = \"Viewer\"\n end\n end",
"def profile_claim(profile_claim)\n @profile_claim = profile_claim\n mail :to => profile_claim.email, :subject => \"Profile Claim\"\n end",
"def email\n if read_attribute(:active) == 1\n if Rails.env.development?\n self.first_name + \" \" + self.last_name + \" <dtg_ror_devel@lists.teradyne.com>\"\n else\n read_attribute(:email)\n end\n else\n \"\"\n end\n end",
"def contact\n @contact ||= get_contact(@data_object.user_contact)\n end",
"def device_account_email=(value)\n @device_account_email = value\n end",
"def investor_email_address\n return self.user_company_info.blank? ? self.email : self.user_company_info.business_email\n end",
"def add_user_personal_info(email, first_name, last_name, phone=nil)\n user_email.set email\n user_first_name.set first_name\n user_last_name.set last_name\n user_phone.set phone if phone\n end",
"def get_display_name\n return self.has_profile? ?\n self.profile.first_name + \" \" + self.profile.last_name :\n self.email\n end",
"def to_s\n if profile and profile.to_s.present?\n profile.to_s\n else\n email\n end\n end",
"def profile\n @profile ||= GATEWAY.get_profile_details(self.profile_id) unless profile_id.nil?\n end",
"def profile_complete?\n\t\tself.contact_phone && self.bio && self.first_name\n\tend",
"def payee\n profile\n end",
"def set_contact_email email\n contact_email_tb.type_text email\n end",
"def email\n # If product_specific_contacts is off, always return the facility's email\n return facility.email unless SettingsHelper.feature_on? :product_specific_contacts\n contact_email.presence || facility.try(:email)\n end",
"def verify_payment_profile(user) \n resp = self.gateway.get_customer_profile({ :customer_profile_id => user.authnet_customer_profile_id }) \n if resp.success?\n arr = resp.params['profile']['payment_profiles'] \n arr = [arr] if arr && arr.is_a?(Hash)\n if arr.nil? || arr.count == 0\n self.create_empty_payment_profile(user)\n user.valid_authnet_payment_profile_id = false \n else \n h = arr[0]\n user.authnet_payment_profile_id = h['customer_payment_profile_id'] \n user.valid_authnet_payment_profile_id = h['bill_to'] && h['bill_to']['address'] && h['bill_to']['address'].strip.length > 0 \n user.save\n end\n end \n end",
"def show_user_profile\n\t\t# find the home address\n\t\t@home_addresses = @profile_setting.addresses.where(address_type: \"home\")\n\tend",
"def cc_email_address\n @cc_email_address\n end",
"def technical_contact\n get_user technical_contact_id\n end",
"def cc_email_address\n @cc_email_address\n end",
"def new\n @profile = Profile.new\n unless current_user.profile\n @profile.user = current_user\n @profile.display_email = current_user.email\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @profile }\n end\n end",
"def show\n contact_shard = Facebase::Contact.shard_for(params[:id])\n @contact = contact_shard.where(\"profile_id = ? \", params[:id]).includes(:profile, :events, :emails).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end",
"def new_profile?\n @profile = Profile.new(params[:profile])\n @profile.user = current_user\n @profile.email = current_user.email\n end",
"def create\n @profile = Profile.new(params[:profile])\n # @user = @profile.email params[:email] \n respond_to do |format|\n if @profile.save\n flash[:notice] = 'Profile was successfully created.'\n format.html { redirect_to(@profile) }\n format.xml { render :xml => @profile, :status => :created, :location => @profile }\n else\n @profile.errors << @profile.user.errors\n format.html { render :action => \"new\" }\n format.xml { render :xml => @profile.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def personal_information(xml)\n xml.__send__(:\"clientbio:DateOfBirth\", applicant.date_of_birth.to_fs(:ccms_date))\n xml.__send__(:\"clientbio:Gender\", \"UNSPECIFIED\")\n xml.__send__(:\"clientbio:MaritalStatus\", \"U\")\n xml.__send__(:\"clientbio:VulnerableClient\", false)\n xml.__send__(:\"clientbio:HighProfileClient\", false)\n xml.__send__(:\"clientbio:VexatiousLitigant\", false)\n xml.__send__(:\"clientbio:CountryOfOrigin\", \"GBR\")\n xml.__send__(:\"clientbio:MentalCapacityInd\", false)\n end",
"def email_address\n raw_info['email_addresses'] && raw_info['email_addresses'].first\n end",
"def email_address\n @data['emailAddress']\n end",
"def getProfile\n account = current_user.account\n if account.nil?\n render status: 400, json: {error: \"Invalid User\"}\n else\n if current_user.registered && (account.referral_code.nil? || account.referral_code.blank?)\n account.generate_referral_code\n end\n render status: 200, json: {username: current_user.username,\n email: current_user.email,\n firstName: current_user.first_name,\n lastName: current_user.last_name,\n company: current_user.company,\n balance: account.balance,\n registered: current_user.registered,\n referralCode: account.referral_code}\n end\n end",
"def email\n get_attribute('Email')\n end",
"def email\n if @data.attribute_names.include?(:cmupreferredmail)\n @email ||= @data[:cmupreferredmail].last\n else\n @email ||= @data[:mail].last\n end\n end",
"def set_contactperson_email\n @contactperson_email = ContactpersonEmail.find(params[:id])\n end",
"def set_profiledetail\n @profiledetail = current_user.profiledetail\n end",
"def index\n @user_contact_information = current_user.user_contact_information\n end",
"def account\n @ipn['business'] || @ipn['receiver_email']\n end",
"def contact_email\n\t\treturn get_configuration['sa_contact_email']\n\tend",
"def customer_mailchimp_profile_updated\n {\n :list_id => data['list_id'],\n :fired_at => params['fired_at'],\n :mailchimp_id => data['id'],\n :email => data['email'],\n :email_type => data['email_type'],\n :merges => data['merges'],\n :ip_opt => params['ip_opt'],\n :human => \"#{data['email']} updated Mailchimp profile information.\"\n }\n end",
"def payment_customer_email\n\t\t\t\t\treturn self.customer_email\n\t\t\t\tend",
"def identity\n \"#{email} #{profile.name} \"\n end",
"def has_basic_profile_info?\n return false if name.blank? || email.blank?\n return true\n end",
"def customer_metadata\n customer.metadata.to_h.merge!(email: customer.email)\n end",
"def customer_metadata\n customer.metadata.to_h.merge!(email: customer.email)\n end",
"def profile_params\n params.require(:profile).permit(:first_name, :last_name, :phone, :emergency_contact_name, :emergency_contact_no)\n end",
"def contact_phone\n self.contact[:contact_phone]\n end",
"def account_info_edit\n result = ChargeBee::Customer.retrieve(@customer_id)\n @customer = result.customer\n end",
"def index\n @profile = current_user.payment_profile || Payments::Profile.new(email: current_user.login)\n end",
"def update_contact_info txn\n AddressManager::set_user_address txn.user, txn\n end",
"def set_user_contact_information\n @user_contact_information = UserContactInformation.find(params[:id])\n end",
"def yes_email_customer_from_authorizes_side\n add_field 'x_email_customer', 'TRUE'\n end",
"def contact_email\n TESTING_EMAIL || @comment[:email]\n end",
"def profile\n @profile = current_user\n end",
"def customer_email\n params['email']\n end",
"def contact\n response[\"contact\"]\n end",
"def apply_facebook(omniauth)\n if (extra = omniauth['extra']['user_hash'] rescue false)\n self.email = (extra['email'] rescue '')\n end\nend",
"def xml_query_profile(xml) \n if current_user \n profile_name = (xml.root.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n properties = @profile.properties.map{|p| p.property_type.title }.join(',') \n return render(:text => \"<Response>#{properties}</Response>\") \n end \n render(:text => \"<Response>Internal Error</Response>\") \n end",
"def user_profile_for(structure)\n user_profile = self.user_profiles.where(structure_id: structure.id).first\n if user_profile.nil?\n user_profile = structure.user_profiles.create(email: self.email)\n end\n user_profile\n end",
"def create\n # TO DO: make this for just generic creation.\n @profile = Profile.find_by_email(params[:profile][:email])\n @profile.user_id = current_user.id\n\n if @profile.nil?\n @profile = Profile.new(params[:profile])\n add_to_list_niche(params[:profile][:fname], params[:profile][:email], params[:profile][:niche], list_id=ENV[\"MAILCHIMP_LISTID\"])\n @profile.save\n else\n @profile.update_attributes(params[:profile])\n end\n\n redirect_to profiles_path, notice: 'Profile was successfully created.' \n # format.json { render json: @profile, status: :created, location: @profile }\n end",
"def user_profile_data\n\t\t@user = devise_current_user\n\t\t# find the work address\n\t\t@work_addresses = @profile_setting.addresses.where(address_type: \"work\").count\n\t\t# find the home address\n\t\t@home_addresses = @profile_setting.addresses.where(address_type: \"home\").count\n\tend",
"def update(billing_key, credit_card = nil, address = nil, user = nil)\n a = ActiveMerchantCall.new(:login => username, :password => password, :user => user, :billing_key => billing_key)\n a.interact('update_customer_profile', :profile => {\n\t\t\t\t\t\t:customer_profile_id => user.customer_profile_id,\n\t\t\t\t\t\t:merchant_customer_id => \"#{Time.now.to_i}-#{(rand()*100000).to_i}\",\n\t\t\t\t\t :payment_profile => {\n\t\t\t\t\t \t:customer_payment_profile_id => billing_key,\n\t\t\t\t\t \t:payment => {\n\t\t\t\t\t \t\t:credit_card => credit_card\n\t\t\t\t\t \t}\n\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t\treturn a.response\n end",
"def association_contact_information\n contact = \"<a href='mailto: #{current_association.contact_email}'>#{current_association.contact_name.blank? ? current_association.name : current_association.contact_name}</a>\"\n \n contact += \" at #{current_association.formatted_contact_phone}\" unless current_association.contact_phone.blank?\n contact += \" ext. #{current_association.contact_phone_extension}\" unless current_association.contact_phone_extension.blank?\n \n return contact\n end",
"def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Entities::Profile::Contacts)\n end",
"def email_address\n get_attribute(Yoti::Attribute::EMAIL_ADDRESS)\n end",
"def contact\n ::HubEdos::Common::Reference::Descriptor.new(@data['contact']) if @data['contact']\n end",
"def details\n contact_details = {\"Full Name\" => full_name, \"Email\" => email, \"Note\" => note}\n end",
"def general_account_information(person, options = {})\n @person = person\n\n mail(:to => [@person.personal_email],\n :subject => options[:subject] || \"Account information (\" + @person.email + \")\",\n :date => Time.now)\n\n end",
"def device_account_email\n return @device_account_email\n end",
"def update_profile\n @profile = @account.employee\n \n if params[:profile].present?\n @profile.assign_attributes(profile_params)\n @profile.save\n redirect_to gns_core.my_profile_backend_accounts_path, flash: {success: 'Profile has been updated successfully.'}\n else\n redirect_to gns_core.my_profile_backend_accounts_path, flash: {error: 'Profile update failed. Please try again!'}\n end\n end",
"def personal_account?\n account_type == 'personal'\n end",
"def by_email email\n query = { \"and\" => [{ \"email\" => { \"is\"=> email } },{ \"record type\"=> { \"is\"=> \"person\" }} ] }\n resp = @nimble.get 'contacts', { :query => query.to_json }\n self.contact = resp['resources'].first\n return nil unless self.contact\n self\n end",
"def get_customer_profile\n authenticate_request!\n json_response(current_customer)\n end",
"def contact_name\n attributes[:contact] && attributes[:contact][:name]\n end",
"def create\n @contact = Contact.new\n old_user=User.where(\"email=?\",params[:contact][:contact_email]).last\n @contact.user_id=session[:user].user_id\n @contact.contact_email=params[:contact][:contact_email]\n @contact.contact_name=params[:contact][:contact_name]\n @contact.avatar=params[:contact][:avatar]\n @contact.app_user_id= old_user.user_id if !old_user.nil?\n @contact.contact_from= \"myapp\" \n @contact.contact_type= old_user ? \"member\" : \"non_member\"\n respond_to do |format|\n if @contact.save\n format.html { redirect_to @contact, notice: 'Contact was successfully created.' }\n format.json { render json: @contact, status: :created, location: @contact }\n else\n format.html { render action: \"new\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def preferred_contact_detail\n return nil if preferred_contact_method.blank?\n if preferred_contact_method == (\"Home Phone\")\n number_to_phone(phone_home)\n elsif preferred_contact_method == (\"Mobile Phone\")\n number_to_phone(phone_mobile)\n elsif preferred_contact_method.include?(\"Email\")\n email\n end\n end",
"def profile\n @profile ||= @request.do_request { FacebookUserProfile.populate(user) }\n end",
"def mail_account\n if @yaml[\"mail\"][\"account\"] != \"example@example.com\"\n @yaml[\"mail\"][\"account\"]\n end\n end",
"def account\n authorize current_employer\n current_employer.build_employer_profile if !current_employer.employer_profile\n end",
"def email(full = false)\n full ? \"#{self.profile.name} <#{self.login}>\" : self.login\n end",
"def set_profile\n\t\t@profile = current_user.profile\n\tend",
"def customer_email\n params['email']\n end",
"def customer_email\n params['email']\n end",
"def email=(s)\n pull unless @details\n @details.email_address = s\n end",
"def formatted_email(contact)\n \"#{contact.username} <#{contact.email}>\"\n end",
"def not_yet_approved profiles\n @profiles = profiles\n\n mail to: Rails.application.secrets.admins_emails\n end",
"def load_profile(token)\n profile = GoogleService.user_info(token)\n email_field = profile[\"emails\"].select do |email| \n email[\"type\"] == \"account\"\n end\n\n email = email_field[0][\"value\"] if email_field && email_field.size > 0\n\n {:displayName => profile[\"displayName\"],\n :image => profile[\"image\"][\"url\"],\n :url => profile[\"url\"],\n :email => email} \n end"
] |
[
"0.6796298",
"0.6526886",
"0.6511111",
"0.63874984",
"0.6371345",
"0.6347491",
"0.62825084",
"0.6266809",
"0.604923",
"0.6016393",
"0.6011583",
"0.6005552",
"0.6003028",
"0.5976328",
"0.5940195",
"0.5912079",
"0.59075475",
"0.58509773",
"0.58488977",
"0.5844784",
"0.5844245",
"0.58407634",
"0.5835451",
"0.58262616",
"0.5817812",
"0.58097506",
"0.5809367",
"0.57386047",
"0.57369506",
"0.5734199",
"0.5715291",
"0.5712128",
"0.5709485",
"0.57072294",
"0.568426",
"0.5684217",
"0.56832343",
"0.5682767",
"0.56739277",
"0.5653469",
"0.565263",
"0.56525964",
"0.56458044",
"0.56434196",
"0.5640428",
"0.56228596",
"0.56190896",
"0.56055",
"0.5601864",
"0.5601705",
"0.55916965",
"0.5577625",
"0.5575089",
"0.5572914",
"0.5563581",
"0.5561498",
"0.5551449",
"0.5551449",
"0.5547139",
"0.55456764",
"0.55448914",
"0.5542911",
"0.5539083",
"0.5532008",
"0.5530694",
"0.55206335",
"0.55146265",
"0.5504985",
"0.5503743",
"0.5501309",
"0.55006695",
"0.5500479",
"0.5498922",
"0.549258",
"0.5492173",
"0.5490671",
"0.54904616",
"0.54896915",
"0.54876316",
"0.54861087",
"0.54685736",
"0.54666847",
"0.54641646",
"0.54610425",
"0.54578096",
"0.54541564",
"0.5452829",
"0.5452146",
"0.5448131",
"0.54480696",
"0.5439396",
"0.543117",
"0.5430355",
"0.5426503",
"0.54205996",
"0.54205996",
"0.5417879",
"0.5413899",
"0.54109776",
"0.54083204"
] |
0.71256965
|
0
|
Order History TODO: Find out the completed orders of current customer account.
|
def order_history
@orders = @customer.close_orders
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recent_orders()\n\t\twith_auth nil do |options|\n\t\t\tself.class.get(\"/api/v1/orders\", options)\n \tend\n\tend",
"def order_history(limit = 10)\n plain_orders = Fyb.private.getorderhistory(limit: limit).perform.parse\n error = plain_orders['error']\n\n fail Exception, error unless error == 0\n\n plain_orders['orders'].map do |data|\n Order.new data['qty'], data['price'], data['type'] == 'B' ? :buy : :sell, data['ticket']\n end\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def tracking_orders\n return [] if !is_employee?\n employee.orders\n end",
"def index# not :post order. this is a :get index of previous orders.\n @orders = current_refinery_user.orders.order('created_at DESC')\n end",
"def monitor_orders()\r\n\t\topen = $future_rest.open_orders symbol: 'BTCUSDT'\r\n\t\t# all orders\r\n\t\tall = $future_rest.all_orders symbol: 'BTCUSDT'\r\n\tend",
"def orderhistory(market = nil)\n if market.nil?\n res = sget(\"/getorderhistory\", {})\n else\n res = sget(\"/getorderhistory\", {market: market})\n end\n resp = ::BittrexRb::Response::Account.new(res)\n end",
"def order_history(market = nil, count = 10)\n params = market ? \"market=#{market}\" : \"\"\n orders = request(\"#{@base_url}/account/getorderhistory\", params)\n\n if orders.size > count then\n return orders[0,count]\n end\n\n return orders\n end",
"def orders_completed\n # TODO:\n # How about service ?\n result = Array.new\n self.jobs.unscoped.each do |j|\n j.orders.each do |o|\n if !o.workspace.blank?\n result << o if o.workspace.completed?\n end\n end\n end\n result\n end",
"def account_history\n get('account/history')\n end",
"def index\n require_user()\n add_breadcrumb \"Orders\", orders_path\n \n if current_user\n @order = Order.find_by_customer_id_and_active(current_user.id,true) \n @past_orders = Order.admin_grid(params,current_user.id,true, false).order(sort_column + \" \" + sort_direction).\n paginate(:page => pagination_page, :per_page => pagination_rows)\n end \n end",
"def recent_orders(user, from)\n\t\tif from.nil?\n\t\t\tstart = 0\n\t\telse\n\t\t\tstart = from\n\t\tend\n\t\t\t\n\t\tif user.nil?\n\t\t\torders = Order.where(created_at: (Time.current.midnight - start.day)..Time.current)\n\t\telse\n\t\t\torders = user.orders.where(created_at: (Time.current.midnight - start.day)..Time.current)\n\t\tend\n\t\treturn orders\n\tend",
"def orders_history(options = {}, &blk)\n if block_given?\n websocket.subscribe :orderhistory, params: options.merge(auth: true), &blk\n else\n http.get :orderhistory, auth: true, params: options\n end\n end",
"def orders\n super.complete.order('completed_at DESC, id DESC')\n end",
"def set_order_history\n @order_history = OrderHistory.find(params[:id])\n end",
"def hestory\n @orders = current_user.orders.all.order(created_at: :desc)\n end",
"def orders_completed\n result = Array.new\n self.job_applications.each do |j|\n j.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end",
"def index\n @order_history_joints = OrderHistoryJoint.all\n end",
"def list_orders\n Order.list(@current_user)\n end",
"def orderCompleted\n order = Order.last\n user = User.find(Contract.find(order.contract_id).buyer_id)\n MagicMailer.orderCompleted(order, user)\n end",
"def purchase_history \n # TODO: I should be looking at @purchases once I've converted Customer to a Class\n return @purchases.join('\\n')\n\n\n\tend",
"def orders\n authenticated_post(\"auth/r/orders\").body\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 get_orders\n orders\n end",
"def billing_history_hashes\n expand(billing_information_icon)\n show_billing_history_link.click\n wait_until { !billing_history_table.hashes.first.values.first.nil? }\n billing_history_table.hashes\n end",
"def index\n @customer = current_customer\n @orders = current_customer.orders.all.order(created_at: :desc)\n end",
"def history\n # Should be paginatable.\n # Oh, it's belongs as a separate resource, paginateable.\n self.edits.where(state: 'applied').order(:date)\n end",
"def complete_orders\n @orders = search_reasult(params).where(\"fulflmnt_state = 'complete'\").order('order_date desc')\n @orders = Kaminari.paginate_array(@orders).page(params[:page]).per(params[:per_page] || Spree::Config[:orders_per_page])\n end",
"def history\n command = AccountHistory.call(@current_user)\n if command.success?\n @history = command.result\n render 'history.json.jbuilder', status: :ok\n else\n render json: {error: command.errors}, status: :bad_request\n end\n end",
"def current_order\n current_customer.incomplete_order\n end",
"def index\n @orders = current_customer.try(:orders).order(date: :desc)\n end",
"def current_orders\n @current_orders ||= OrderDecorator.decorate_collection(\n object.\n orders.\n includes(:order_items).\n from_current_month.\n limit(CURRENT_ORDERS_LIMIT).\n order(:created_at))\n end",
"def current_order\n \torders = self.orders\n \t@current_order = nil\n \tfor order in orders\n \t\t@current_order = order if order.current?\n \tend\n \t\n \tif @current_order == nil\n \t\t@current_order = self.orders.create\n \t\t@current_order.current = true\n \t\t@current_order.save\n \tend\n \t@current_order\n end",
"def history\n\t\tcuisine = params[:template]\n\t\t@user = User.find_by(customerid: \"ADMIN\")\n\t\t@orders = @user.orders.where(name: \"Template for #{cuisine}\")\n\t\t@cuisine_history = cuisine\n\tend",
"def index\n @club = current_member.club\n @order_history_approved = Order.where(requester_id: current_member.id,\n returned: false)\n .where.not(approved_at: nil)\n @order_history_requested = Order.where(requester_id: current_member.id,\n approved_at: nil)\n @order_history_returned = Order.where(requester_id: current_member.id,\n returned: true)\n .where.not(approved_at: nil)\n end",
"def customer\n @orders = Spree::Order.where(user_id: current_spree_user.id, state: 'complete').where.not(shipment_state: 'shipped', state: 'returned').order(created_at: :desc)\n end",
"def history\n # retrieves a paginated list of the current user's purchases\n @purchases = current_user.purchases.page params[:page]\n end",
"def index\n @order_lines = current_user.orders.includes(:order_lines).where(closed: false).first.try(:order_lines) || []\n end",
"def index\n @orders = current_user.type == 'Referral' ? current_user.orders : Order\n @orders = @orders.success_order.page(params[:page]).per(100).order('orders.created_at DESC')\n end",
"def orders\n resp = API.connection.get 'api/orders', {\n user_email: @email,\n user_token: @token\n }\n\n case resp.status\n when 200\n resp.body.map { |order_hash| Order.new(order_hash) }\n when 401\n raise Teachable::AuthError, resp.body['error']\n else\n raise Teachable::Error, 'Unknown response.'\n end\n end",
"def show_history(account_id,accounts)\n account = accounts[account_id]\n\n length1=account[:transaction].length\n copy_to_sort=account[:transaction]\n\n copy_to_sort.sort_by! {|obj| obj[:time]}.reverse!\n show_message \"\\n\"\n show_message \"##############################################################################################################################################\\n\"\n show_message \"Date and Time\\t\\t\\t\\t\\t action\\t\\t\\t\\t amount\\t\\t\\t\\tcurrent_balance\"\n show_message \"#############################################################################################################################################\\n\"\n show_message \"\\n\"\n copy_to_sort.each { |element|\n element.each{ |key,value| \n if key == :date_time\n value = value.strftime( \"%d %b %Y %H:%M %p\") \n end \n print \"#{value}\\t\\t\\t\\t\"\n }\n print \"\\n\"\n\n }\n show_message \"\\n\"\n show_message \"**********************************************************************************************************************************************\\n\"\nend",
"def orders\n authenticated_post(\"orders\").body\n end",
"def index\n @orders = Order.all.order(:customer_id, :day_of_week)\n @customer_orders = @orders.select{|order| order.cancelled_on == nil }.group_by{|order| order.customer_id }\n end",
"def history\n credit_lines = credits.map do |transfer|\n { date: transfer.created_at, counterparty: transfer.sender&.email, amount: transfer.amount, note: transfer.note }\n end\n debit_lines = debits.map do |transfer|\n { date: transfer.created_at, counterparty: transfer.receiver&.email, amount: -transfer.amount, note: transfer.note }\n end\n credit_lines.concat(debit_lines).sort_by { |line| line[:date] }.reverse\n end",
"def index\n @orders = Order.all.where(status: 'completed')\n end",
"def index\n @orders = current_user.orders.all.order(created_at: :desc)\n end",
"def get_withdrawal_history\n # body = {\n # cmd: \"get_withdrawal_history\"\n # }\n\n end",
"def index\n @orders = current_member.orders.order(\"created_at desc\")\n end",
"def index\n @orders = current_user.orders.order(\"created_at DESC\")\n end",
"def index\n @order_product_histories = OrderProductHistory.all\n end",
"def service_orders_completed\n result = Array.new\n self.services.each do |s|\n s.orders.each do |order|\n if !order.blank? and !order.workspace.blank?\n result << order if order.workspace.completed?\n end\n end\n end\n result\n end",
"def index\n @orders = Order.all.chronological.paginate(:page => params[:page]).per_page(10)\n #for shippers\n @paid_orders = Order.paid.chronological.to_a\n @unshipped_orders = Order.not_shipped.chronological.to_a\n @paid_and_unshipped_orders = Order.paid.not_shipped.chronological.to_a\n end",
"def history\n self.class.history.chronological.of(self)\n end",
"def index\n @dispatched_orders = @team\n .order_lines\n .index_join\n .where_scheduled\n .where_not_completed\n .accessible_by(current_ability)\n\n @completed_orders = @team\n .order_lines\n .index_join\n .where_completed\n .accessible_by(current_ability)\n\n store_location\n end",
"def my_account\n @orders = current_customer.orders.includes(:product).in_order || []\n end",
"def me_order_pending\n object_from_response(self, Artsy::Client::Domain::Order, :get, \"/api/v1/me/order/pending\", {})\n end",
"def bought_orders\n @orders = current_user.bought_orders\n\n end",
"def bought_orders\n @orders = current_user.bought_orders\n\n end",
"def set_admin_order_history\n @admin_order_history = OrderHistory.find(params[:id])\n end",
"def view_waitlist_orders\n str = \"\"\n array = @queue.to_array\n array.each do |order|\n str += order.get_id.to_s + \",\"\n end\n str.chop\n end",
"def orders(id, orderid = nil)\n get(\"/accounts/#{id}/orders#{orderid ? \"/#{orderid}\" : ''}\")['orders']\n end",
"def history\n @step = Step.find(params[:id])\n @activities = @step.step_activities.order(\"created_at desc\").all\n end",
"def orders\r\n\t\t@current_area = 'orders_report'\r\n\t\t@current_menu = 'reports'\r\n\r\n\t\tif request.post? || (request.get? && params[:page])\r\n\t\t\t@report_title = 'Orders'\r\n\t\t\tfilename = 'reports/orders'\r\n\t\t\t@criteria = [\"status='completed'\"]\r\n\r\n\t\t\t@page = (params[:page] || 1).to_i\r\n\t\t\t@items_per_page = 20\r\n\t\t\t@offset = (@page - 1) * @items_per_page\r\n\r\n\t\t\tif params[:start_date]\r\n\t\t\t\t@start_date = ffs_parse_date(params[:start_date])\r\n\r\n\t\t\t\t@criteria << \"(created_at >= '\" + @start_date.strftime('%Y-%m-%d') + \"')\"\r\n\t\t\t\tfilename += '-' + @start_date.strftime('%Y-%m-%d')\r\n\t\t\t\t@report_title += ': ' + @start_date.strftime('%d/%m/%Y')\r\n\t\t\tend\r\n\r\n\t\t\tif params[:end_date]\r\n\t\t\t\t# We want to show records that fall before the day after the end date\r\n\t\t\t\t@end_date = ffs_parse_date(params[:end_date])\r\n\t\t\t\tquery_end_date = @end_date + 1\r\n\r\n\t\t\t\t@criteria << \"(created_at <= '\" + query_end_date.strftime('%Y-%m-%d') + \"')\"\r\n\t\t\t\tfilename += '-to-' + @end_date.strftime('%Y-%m-%d')\r\n\t\t\t\t@report_title += ' to ' + @end_date.strftime('%d/%m/%Y')\r\n\t\t\telse\r\n\t\t\t\t@report_title += ' to present'\r\n\t\t\tend\r\n\r\n\t\t\t@order_count = Order.count(@criteria.join(' AND '))\r\n\t\t\t@pages = Paginator.new(self, @order_count, @items_per_page, @page)\r\n\t\t\t@orders = Order.find(\r\n\t\t\t\t:all,\r\n\t\t\t\t:conditions => @criteria.join(' AND '),\r\n\t\t\t\t:order => 'created_at DESC',\r\n\t\t\t\t:offset => params[:download] ? 0 : @offset,\r\n\t\t\t\t:limit => params[:download] ? nil : @items_per_page\r\n\t\t\t)\r\n\r\n\t\t\t# make Excel file if download is selected - otherwise render in page\r\n\t\t\tif params[:download]\r\n\t\t\t\t@rows = @orders.collect { |x| [ x.id, [x.created_at, :date], x.user.to_s, x.delivery_address ? x.delivery_address.country : x.billing_address.country, x.items.count, [x.total, :price] ] }\r\n\r\n\t\t\t\t@report_title += ' ' + Date.today.strftime('%d/%m/%Y')\r\n\t\t\t\tfilename += '.xls'\r\n\r\n\t\t\t\treport = Report.new filename\r\n\t\t\t\treport.write 0, 0, @report_title, :title\r\n\t\t\t\treport.write 1, 0, [ 'ID', 'Date', 'User', 'Country', 'Items', 'Total' ], :heading\r\n\t\t\t\treport.write_rows @rows\r\n\t\t\t\treport.close\r\n\r\n\t\t\t\t@headers['Expires'] = '0'\r\n\t\t\t\t@headers['Cache-Control'] = 'must-revalidate,post-check=0,pre-check=0'\r\n\t\t\t\t@headers['Pragma'] = 'public'\r\n\r\n\t\t\t\tsend_file filename, :type => 'application/vnd.ms-excel', :stream => false\r\n\t\t\t\tFile.delete filename\r\n\t\t\tend\r\n\t\telse\r\n\t\t\t@start_date = @end_date = Date.today\r\n\t\tend\r\n\tend",
"def index\n @orders = current_user.orders\n end",
"def index\n @orders = current_user.orders\n end",
"def order_list\n if org_type==\"поставщик\"\n return orders\n else\n return outgoing_orders\n end\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def index\n @orders = Order.user_orders current_user\n end",
"def index\n #here we find all orders in the orders table and add to the @orders variable.\n @orders = Order.all\n end",
"def my_order\n @orders = Order.where(user: current_user)\n end",
"def order(id, orderid = '')\n get(\"/accounts/#{id}/orders\")['orders']\n end",
"def order_completed(user_id, email:, first_name:, last_name:, order_id:, products:, revenue:, subtotal_price:, total_price:, total_shipping:, total_tax:, discount_code: nil)\n track(user_id, OrderCompleted.new(\n email: email,\n first_name: first_name,\n last_name: last_name,\n order_id: order_id,\n products: products,\n revenue: revenue,\n subtotal_price: subtotal_price,\n total_price: total_price,\n total_shipping: total_shipping,\n total_tax: total_tax,\n discount_code: discount_code \n ))\n end",
"def index\n # Admin users see all orders; non-Admins only see their own orders\n if current_user.admin\n @orders = Order.order(\"updated_at DESC\")\n else\n @orders = current_user.orders.order(\"updated_at DESC\")\n end\n end",
"def orders\n return [] if !is_client?\n client.orders\n end",
"def index\n @orders = orders_for_user.order(created_at: :desc)\n end",
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def get_orders\n return ShopifyAPI::Order.all\n end",
"def orders_including_customer\n Spree::Order\n .joins(:order_cycle)\n .includes(:customer)\n .for_order_cycle(order_cycle)\n .completed\n .order('customers.name ASC')\n end",
"def completed_flights\n self.flights.completed.in_order_of_creation\n end",
"def history\r\n []\r\n end",
"def completed_orders\n orders = current_user.restaurant.orders.where(\"status = ? OR status = ? \", 7, 8)\n render json: orders, status: :ok\n end",
"def history\n return @history\n end",
"def history\n return @history\n end",
"def index\n last_id = Order.where(:trigger=> false).order('created_at ASC').last.id\n @orders_before = Order.where('trigger = ? AND id != ?', false, last_id).order('created_at DESC')\n @lastorder = Order.where(:trigger=> false).last\n end",
"def index\n @orders = Order.where(user_id: current_user.id)\n end",
"def index\n @work_orders = WorkOrder.pending\n @completed_work_orders = WorkOrder.completed\n @work_order_requests = WorkOrderRequest.pending\n\n end",
"def history\n RailsCommits::Request.new('repos/rails/rails/commits', @token, @count, @author).run\n end",
"def history\n @payments = Payment.all.where(host: current_user).order(\"created_at DESC\")\n#just added, you need to show history and add a new colmn, wheter they were a host or player and show ALL history\n @payments = Payment.all.where(player: current_user).order(\"created_at DESC\")\n\n \n end",
"def orders(params = {})\n get('/market/orders', params)\n .map { |data| build_persisted_order data }\n end",
"def index\n @transferred_event_orders = TransferredEventOrder.all\n end",
"def getOrderDetail(orderId)\n try_get(\"https://checkout.google.com/sell/multiOrder?order=#{orderId}&ordersTable=1\")\n return @agent.page.body\n end",
"def completed(order)\n @order = order\n\n mail :to => order.billing_address.email\n end",
"def my_orders\n @orders = current_user.orders.all\n end",
"def get_fax_history(date_from = nil,\r\n date_to = nil,\r\n q = nil,\r\n order = nil)\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/fax/history'\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'date_from' => date_from,\r\n 'date_to' => date_to,\r\n 'q' => q,\r\n 'order' => order\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def index\n # uses the customer_orders scope to retrieve all the orders that the current customer has made\n @orders = Order.customer_orders(current_customer)\n # uses the customer_average_order_cost scope to calculate the average cost of all the orders that the\n # current customer has made\n @average_cost_of_orders = Order.customer_average_order_cost(current_customer)\n end",
"def index\n @orders = @orders.all\n end",
"def list_orders(code)\n PsegRecurring::Order.new(@credentials).fetch_orders(code)\n end",
"def list\n local_orders = Order.find( :all, :order => 'order_state_id' )\n ref_order = Order.find( params[:id] )\n @orders = Array.new\n @sum = 0\n\n for o in local_orders\n if o.order_state.name == \"needs\" && ref_order.order_state.name == \"needs\"\n str = o.prize.supplier.name\n ref_str = ref_order.prize.supplier.name\n else\n str = o.prize.supplier.name + o.updated_at.strftime( \"%d.%m.%Y\" )\n ref_str = ref_order.prize.supplier.name + ref_order.updated_at.strftime( \"%d.%m.%Y\" )\n end\n\n if str == ref_str\n @orders << o\n @sum += o.prize.value * o.count\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @orders }\n end\n end",
"def orderActive\n order = Order.last\n user = User.find(Contract.find(order.contract_id).buyer_id)\n MagicMailer.orderActive(order, user)\n end",
"def customer_order\n @customer_order\n end"
] |
[
"0.67846155",
"0.66428006",
"0.6506397",
"0.6493447",
"0.64623666",
"0.63281834",
"0.63238096",
"0.62117016",
"0.61890954",
"0.6144186",
"0.61402255",
"0.61331505",
"0.60950536",
"0.6086065",
"0.60834295",
"0.60790026",
"0.60756993",
"0.60676146",
"0.6056458",
"0.6043835",
"0.6038359",
"0.6033067",
"0.60044706",
"0.59601164",
"0.59592",
"0.5940033",
"0.59338284",
"0.59073365",
"0.5874663",
"0.58635074",
"0.5842572",
"0.5834172",
"0.5825631",
"0.5814693",
"0.58104634",
"0.58080316",
"0.5801599",
"0.5783411",
"0.5781531",
"0.5779981",
"0.5760335",
"0.57520247",
"0.5746624",
"0.57423466",
"0.5741406",
"0.57330406",
"0.5731795",
"0.5723295",
"0.57173526",
"0.5716123",
"0.569668",
"0.56926954",
"0.56925523",
"0.5686296",
"0.5681796",
"0.5675515",
"0.5650099",
"0.5650099",
"0.5645514",
"0.5619304",
"0.5613417",
"0.56084335",
"0.56002164",
"0.5595128",
"0.5595128",
"0.5588033",
"0.5585923",
"0.55842423",
"0.5577128",
"0.55753005",
"0.55723447",
"0.5570818",
"0.55704474",
"0.556691",
"0.555037",
"0.5547719",
"0.55394113",
"0.5526673",
"0.5525544",
"0.55236334",
"0.55101866",
"0.550724",
"0.550724",
"0.5502377",
"0.5491557",
"0.5489336",
"0.54887253",
"0.5485048",
"0.54791695",
"0.54724723",
"0.5470364",
"0.5463254",
"0.54618776",
"0.5460575",
"0.5453303",
"0.5452585",
"0.54484314",
"0.54433626",
"0.54429114",
"0.5439024"
] |
0.78379375
|
0
|
Open Orders TODO: Find out the processing orders of current customer account.
|
def open_orders
# store_user = StoreUser.find_by_erp_account_number "CU 0101388"
# store_user.order_users.find(:first).orders.find(:first)
# ERP::ThreadPool.new(@options[:threads], time_blocks).start do |pair|
# sleep(1 * rand)
# result = search_by_modified_date( pair.first, pair.last )
# nodes.concat result unless result.empty?
# end
store_user = session[:web_user]
web_orders = Order.find_by_store_user_id(store_user.id)
sales_ids = @customer.sales_orders.collect{|sales_order| sales_order.sales_id}
web_orders.delete_if { |web_order| sales_ids.include?(web_order.erp_order_number) }
# raise web_orders.to_yaml
@orders = @customer.open_orders
web_orders.each do |web_order|
virtual_order = ERP::SalesOrder.new(
:sales_status => "Invoice",
:document_status => "Invoice",
:shipping_charges => web_order.shipping_cost,
:sales_tax => web_order.tax,
:synchronized => true,
:purch_order_form_num => web_order.order_number,
:delivery_mode_id => 0,
:completed => true,
:erp_modstamp => web_order.created_on
)
web_order.order_line_items.each do |line|
virtual_order.sales_lines.build(
:sales_order => virtual_order,
:item_id => line.product.erp_product_item,
:sales_qty => line.quantity,
:status => "Downloading",
:remain_sales_physical => 0,
:sales_price => line.product.price,
:line_amount => line.quantity * line.product.price
)
end
web_ship_to = web_order.order_user.order_addresses.find_by_is_shipping(true)
virtual_order.ship_to_address = ERP::DeliveryAddress.new(
:name => web_ship_to.company,
:street => web_ship_to.address,
:address => "#{web_ship_to.address}\n#{web_ship_to.city}, #{web_ship_to.state} #{web_ship_to.zip}\n#{web_ship_to.country.fedex_code}",
:city => web_ship_to.city,
:state => web_ship_to.state,
:zip_code => web_ship_to.zip,
:country_region_id => web_ship_to.country.fedex_code
)
web_bill_to = web_order.order_user.order_addresses.find_by_is_shipping(false)
virtual_order.bill_to_address = ERP::InvoiceAddress.new(
:name => web_bill_to.company,
:street => web_bill_to.address,
:address => "#{web_bill_to.address}\n#{web_bill_to.city}, #{web_bill_to.state} #{web_bill_to.zip}\n#{web_bill_to.country.fedex_code}",
:city => web_bill_to.city,
:state => web_bill_to.state,
:zip_code => web_bill_to.zip,
:country_region_id => web_bill_to.country.fedex_code
)
@orders.unshift(virtual_order)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def open_orders\n orders.open\n end",
"def open_orders(options)\n request :account, :get, 'openOrders', options\n end",
"def open_orders\n OpenOrderParser.parse_collection(post(\"open_orders\"))\n end",
"def open_orders\n OpenOrderParser.parse_collection(post(\"money/orders\"))\n end",
"def monitor_orders()\r\n\t\topen = $future_rest.open_orders symbol: 'BTCUSDT'\r\n\t\t# all orders\r\n\t\tall = $future_rest.all_orders symbol: 'BTCUSDT'\r\n\tend",
"def orders_open\n orders = Bitstamp.orders.all\n orders.sort_by{ |order| order.price }.reverse\n end",
"def order_history\r\n @orders = @customer.close_orders\r\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def list_orders\n Order.list(@current_user)\n end",
"def index\n @order_lines = current_user.orders.includes(:order_lines).where(closed: false).first.try(:order_lines) || []\n end",
"def get_or_create_open_order\n self.open_order || self.orders.create(:status => Order::OPEN, :subtotal => 0)\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def get_orders\n orders\n end",
"def recent_orders()\n\t\twith_auth nil do |options|\n\t\t\tself.class.get(\"/api/v1/orders\", options)\n \tend\n\tend",
"def list_orders(code)\n PsegRecurring::Order.new(@credentials).fetch_orders(code)\n end",
"def customer\n @orders = Spree::Order.where(user_id: current_spree_user.id, state: 'complete').where.not(shipment_state: 'shipped', state: 'returned').order(created_at: :desc)\n end",
"def invoiced_orders\n return [] if !is_client?\n client.orders\n end",
"def current_order\n current_customer.incomplete_order\n end",
"def orders\n authenticated_post(\"orders\").body\n end",
"def index\n @orders = Order.user_orders current_user\n end",
"def index\n require_user()\n add_breadcrumb \"Orders\", orders_path\n \n if current_user\n @order = Order.find_by_customer_id_and_active(current_user.id,true) \n @past_orders = Order.admin_grid(params,current_user.id,true, false).order(sort_column + \" \" + sort_direction).\n paginate(:page => pagination_page, :per_page => pagination_rows)\n end \n end",
"def current_order\n \torders = self.orders\n \t@current_order = nil\n \tfor order in orders\n \t\t@current_order = order if order.current?\n \tend\n \t\n \tif @current_order == nil\n \t\t@current_order = self.orders.create\n \t\t@current_order.current = true\n \t\t@current_order.save\n \tend\n \t@current_order\n end",
"def index\n @orders = current_user.orders\n end",
"def index\n @orders = current_user.orders\n end",
"def request_orders\n @player.request_orders\n end",
"def index\n @info_dispatch_orders = InfoDispatchOrder.all\n end",
"def orders\n @title = \"Your Orders\"\n @orders = @customer.orders.paginate(\n :page => params[:page],\n :per_page => 10\n )\n end",
"def orders\r\n @orders ||= OrdersController.new(configuration: @configuration)\r\n end",
"def current_orders\n @current_orders ||= OrderDecorator.decorate_collection(\n object.\n orders.\n includes(:order_items).\n from_current_month.\n limit(CURRENT_ORDERS_LIMIT).\n order(:created_at))\n end",
"def get_orders\n return ShopifyAPI::Order.all\n end",
"def my_orders\n @orders = current_user.orders.all\n end",
"def orders\n return [] if !is_client?\n client.orders\n end",
"def index\n @part_orders = PartOrder.open\n @closed_part_orders = PartOrder.closed\n @all_part_orders = PartOrder.all\n end",
"def bought_orders\n @orders = current_user.bought_orders\n\n end",
"def bought_orders\n @orders = current_user.bought_orders\n\n end",
"def my_account\n @orders = current_customer.orders.includes(:product).in_order || []\n end",
"def _wapi_order(order_type_sym, order_hash)\n response = c.soap(order_type_sym, { \n order_type_sym => { \n :_attributes => { :xmlns => 'http://wildwestdomains.com/webservices/' }\n }.update(order_hash).update(creds).update(c.class.uuid_hash) }\n )\n \n result = c.class.decode_soap(response.body)\n if result['result']['code'] == '1000'\n self.orders ||= []\n self.orders << { :user_id => result['user'], :dbpuser_id => result['dbpuser'], :orderid => result['resdata']['orderid'] }\n return self.orders.last\n else\n raise(GoDaddyResellerError.new(result['result']['msg']))\n end\n end",
"def has_confirmed_order?\n confirmed_order = false\n open_orders.each do |o|\n if o.confirmed\n confirmed_order = true\n break\n end\n end\n confirmed_order\n end",
"def commit_orders\r\n orders = @customer.open_orders.find_all_by_synchronized( false )\r\n sales_id = \"\"\r\n orders.each do |o| sales_id += \"'#{o.sales_id}', \" end \r\n @store_user.my_account_log(@customer,\"Commit Sales Order Updates: #{sales_id}\")\r\n\r\n if orders.empty? || ERP::SalesOrder.commit_orders( orders )\r\n flash.now[:message] = \"All changes have been commited.\"\r\n else\r\n flash.now[:message] = \"Operation Failed.\"\r\n end\r\n end",
"def current_order\n @current_order ||= load_order_from_session unless @current_order == false\n end",
"def order_list\n if org_type==\"поставщик\"\n return orders\n else\n return outgoing_orders\n end\n end",
"def order\n @order ||= Elong::API::GHotel::Order.new(@client)\n end",
"def my_order\n @orders = Order.where(user: current_user)\n end",
"def index\n @orders = current_user.type == 'Referral' ? current_user.orders : Order\n @orders = @orders.success_order.page(params[:page]).per(100).order('orders.created_at DESC')\n end",
"def index# not :post order. this is a :get index of previous orders.\n @orders = current_refinery_user.orders.order('created_at DESC')\n end",
"def customer_order\n @customer_order\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 orders\n resp = API.connection.get 'api/orders', {\n user_email: @email,\n user_token: @token\n }\n\n case resp.status\n when 200\n resp.body.map { |order_hash| Order.new(order_hash) }\n when 401\n raise Teachable::AuthError, resp.body['error']\n else\n raise Teachable::Error, 'Unknown response.'\n end\n end",
"def order\n Spree::Order.find(@attributes[:order_id].to_i)\n end",
"def orderActive\n order = Order.last\n user = User.find(Contract.find(order.contract_id).buyer_id)\n MagicMailer.orderActive(order, user)\n end",
"def listOrders()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n ret = []\n Order.find_each do |order|\n ret << {id: order.id, product_id: order.product_id, product_name: Product.find(order.product_id).name, user_id: order.user_id, quantity: order.quantity, price_per_unit: order.price_per_unit, int_status: order.order_status}\n end\n render json: {data: ret.to_json, reason: '', status: true}\n end",
"def index\n @orders = Order.where(user_id: current_user.id) if logged_in?\n if logged_in_and_admin?\n @orders = Order.all.sort_by { |a| a.ordered ? 0 : 1 }\n end\n end",
"def partial_orders\n @orders = search_reasult(params).includes(:line_items).where(\"fulflmnt_tracking_no IS NULL AND is_cancel=false\").order('order_date desc')\n @orders = Kaminari.paginate_array(@orders).page(params[:page]).per(params[:per_page] || Spree::Config[:orders_per_page])\n end",
"def get_order_list(criteria = {})\n order_criteria = {}\n order_criteria[\"ins1:OrderCreationFilterBeginTimeGMT\"] = criteria[:created_from]\n order_criteria[\"ins1:OrderCreationFilterEndTimeGMT\"] = criteria[:created_to]\n order_criteria[\"ins1:StatusUpdateFilterBeginTimeGMT\"] = criteria[:updated_from]\n order_criteria[\"ins1:StatusUpdateFilterEndTimeGMT\"] = criteria[:updated_to]\n order_criteria[\"ins1:JoinDateFiltersWithOr\"] = criteria[:join_dates]\n\n if order_ids = criteria[:order_ids]\n order_criteria[\"ins1:OrderIDList\"] = {\"ins1:int\" => order_ids}\n end\n\n if client_order_ids = criteria[:client_order_ids]\n order_criteria[\"ins1:ClientOrderIdentifierList\"] = {\"ins1:string\" => client_order_ids}\n end\n\n order_criteria[\"ins1:DetailLevel\"] = criteria[:detail_level] if criteria[:detail_level]\n order_criteria[\"ins1:ExportState\"] = criteria[:export_state] if criteria[:export_state]\n order_criteria[\"ins1:OrderStateFilter\"] = criteria[:state] if criteria[:state]\n order_criteria[\"ins1:PaymentStatusFilter\"] = criteria[:payment_status] if criteria[:payment_status]\n order_criteria[\"ins1:CheckoutStatusFilter\"] = criteria[:checkout_status] if criteria[:checkout_status]\n order_criteria[\"ins1:ShippingStatusFilter\"] = criteria[:shipping_status] if criteria[:shipping_status]\n order_criteria[\"ins1:RefundStatusFilter\"] = criteria[:refund_status] if criteria[:refund_status]\n order_criteria[\"ins1:DistributionCenterCode\"] = criteria[:distribution_center] if criteria[:distribution_center]\n order_criteria[\"ins1:PageNumberFilter\"] = criteria[:page_number]\n order_criteria[\"ins1:PageSize\"] = criteria[:page_size]\n\n soap_response = client.request :get_order_list do\n soap.header = soap_header\n soap.body = {\n \"ins0:accountID\" => creds(:account_id),\n \"ins0:orderCriteria\" => order_criteria\n }\n end\n\n @last_request = client.http\n @last_response = soap_response\n end",
"def orders(options = {})\n perform_get_with_key_and_objects('/orders', options, :items, Epages::Order)\n end",
"def index\n if @current_customer.admin?\n # Show all orders to the admin\n @orders = Order.all.paginate(page: params[:page], per_page: 15)\n\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Order viewed by admin \\n\")\n else\n # show user's order only\n @orders = Order.where(customer: @current_customer.id).paginate(page: params[:page], per_page: 15)\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Order viewed by user \\n\")\n end\n end",
"def checkout \n \t@order_items = current_order.order_items\n end",
"def add_to_current_order\n\n # get the first open order that the user has\n if current_user.orders.where(status:'Open').first\n current_order = current_user.orders.where(status:'Open').first\n OrderProduct.create({product_id: params[:product],order_id: current_order.id, quantity: params[:order][:orderproduct][:quantity], price: params[:order][:orderproduct][:price],additional_info: params[:order][:orderproduct][:additional_info] })\n\n # If not open and create a new order for the current user\n else\n current_order = current_user.orders.create(order_params)\n current_order.update(status: 'Open')\n OrderProduct.create({product_id: params[:product],order_id: current_order.id, quantity: params[:order][:orderproduct][:quantity], price: params[:order][:orderproduct][:price],additional_info: params[:order][:orderproduct][:additional_info]})\n end\n redirect_to order_path(current_order)\n end",
"def orders(params = {})\n get('/market/orders', params)\n .map { |data| build_persisted_order data }\n end",
"def get_customer_order\n begin\n db = SQLite3::Database.open(ENV[\"BANGAZON\"])\n array_of_orders = db.execute(\"SELECT customers.id 'Customer Number', customers.last_name 'Last Name', customers.first_name 'First Name', orders.id 'Order Number', products.product_title 'Product', products.product_price 'Price'\n FROM orders, customers, order_products, products\n\n WHERE orders.customer_id = ?\n AND orders.id = ?\n AND order_products.product_id = products.id\", [@customer_id, @id])\n db.close\n end\n array_of_orders\n end",
"def listor\n puts \"\\n -- List of orders --\"\n @restaurant.retrieve_orders\n end",
"def getOrderDetail(orderId)\n try_get(\"https://checkout.google.com/sell/multiOrder?order=#{orderId}&ordersTable=1\")\n return @agent.page.body\n end",
"def commit_order\r\n order = @customer.open_orders.find params[:id]\r\n \r\n unless !order.commit\r\n headers['Content-Type'] = 'text/plain'\r\n render :text => \"Failed to connect with AX server.\"\r\n end\r\n end",
"def index\n @orders = current_user.orders\n @involvedOrders = OrderUser.where('user_id = (?)',current_user.try(:id))\n end",
"def display_order_list(orders)\n list = orders.map do |o| \n res = { 'order_url' => url(:display_from_id, o.order_id) }\n o.add_to_hash(res)\n res\n end\n \n standard_page(\"Matching Orders\", {'list' => list}, ORDER_LIST)\n end",
"def index\n @orders = current_user.orders\n .where(status: [Order.statuses[:initiated], Order.statuses[:deleted]])\n .includes(:items, :supplier)\n .order(id: :desc)\n .page(params[:page])\n .per(params[:per])\n end",
"def current_order\n @current_order ||= Order.find_by(id: user_id)\n end",
"def tracking_orders\n return [] if !is_employee?\n employee.orders\n end",
"def index\n @orders = Order.all.order(:customer_id, :day_of_week)\n @customer_orders = @orders.select{|order| order.cancelled_on == nil }.group_by{|order| order.customer_id }\n end",
"def index\n @ecom_orders = EcomOrder.all\n end",
"def orders\n Order.find_all_by_origin_code(\"smnl#{id}\")\n end",
"def index\n if params[:company_id]\n @company = Company.find(params[:company_id])\n @orders = @company.orders\n @account_managers = @current_agency.account_managers if @current_agency.present?\n @order = @company.orders.new if @company.present?\n \n else\n # @orders = @current_company.orders.active.order(created_at: :desc) if @current_company.present?\n @orders = @current_agency.orders.active.order(created_at: :desc) if @current_agency.present?\n end\n \n \n authorize @orders\n\n end",
"def activate_orders(token, coupon,card_id)\n order_with_coupon = self.orders.where(\"state = ? and coupon_id is not ?\", \"paused\", nil).first\n order_with_coupon.assign_attributes(coupon_id: coupon[\"id\"]) if coupon.present? && order_with_coupon.present?\n order_with_coupon.assign_attributes(coupon_id: nil) if order_with_coupon.present? && coupon.blank?\n\n\n if order_with_coupon.present?\n order_with_coupon.save(validate: false)\n order_with_coupon.update_total_and_item_total\n end\n\n paused_orders = self.orders.where(state: 'paused')\n\n paused_orders.each_with_index do |order, index|\n order.assign_attributes(state: \"confirm\",\n delivery_date: FIRST_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 0\n order.assign_attributes(state: \"confirm\",\n delivery_date: SECOND_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 1\n order.assign_attributes(state: \"confirm\",\n delivery_date: THIRD_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 2\n order.assign_attributes(creditcard_id: card_id)\n order.save(validate: false)\n end\n end",
"def order(id, orderid = '')\n get(\"/accounts/#{id}/orders\")['orders']\n end",
"def index\n @orders = Order.where(user_id: current_user.id)\n end",
"def index\n @confirmed_orders = ConfirmedOrder.all\n end",
"def index\n @orders = Order.search(attach_owner_user_id)\n end",
"def orders(id, orderid = nil)\n get(\"/accounts/#{id}/orders#{orderid ? \"/#{orderid}\" : ''}\")['orders']\n end",
"def simple_current_order\n @order ||= Spree::Order.find_by(id: session[:order_id], currency: current_currency)\n end",
"def go_to_orderpage()\n locat = Locator.where(brand: 'all', offer: 'orderplacementlocators')\n if(@browser.first('.special-offers-popup') || @browser.first('.popover') || @browser.first('.tv0ffer-popup') || @browser.first('#notify'))\n homepage_popovers\n sleep(2)\n end\n Rails.logger.info \"clicking order now\"\n\n locat.where(step: \"order_now\").each do |locator|\n begin\n @browser.first(:css, locator.css).click()\n rescue => e\n\n end\n end\n\n sleep(3)\n if(@browser.first('.special-offers-popup') || @browser.first('.popover') || @browser.first('.tv0ffer-popup') || @browser.first('#notify'))\n homepage_popovers\n sleep(2)\n end\n\n locat.where(step: \"order_now\").each do |locator|\n begin\n @browser.first(:css, locator.css).click()\n rescue => e\n\n end\n end\n\n sleep(3)\n\n locat.where(step: \"order_now\").each do |locator|\n begin\n @browser.first(:css, locator.css).click()\n rescue => e\n\n end\n end\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def show_orders\n @promotion = Promotion.find(params[:id])\n @title = \"Orders for #{@promotion.code}\"\n @orders = Order.paginate(\n :order => 'created_on DESC',\n :conditions => [\"#{Order.connection.quote_column_name(\"promotion_id\")} = ?\", @promotion.id],\n :page => params[:page],\n :per_page => 30\n )\n end",
"def index\n @work_orders = current_user.work_orders\n end",
"def fulfill_order\n return Order.format_order(process_customer_order)\n end",
"def complete_orders\n @orders = search_reasult(params).where(\"fulflmnt_state = 'complete'\").order('order_date desc')\n @orders = Kaminari.paginate_array(@orders).page(params[:page]).per(params[:per_page] || Spree::Config[:orders_per_page])\n end",
"def order\n @order ||= Order.find_by(id: session[:order_id]) if session[:order_id]\n end",
"def index\n @purchase_orders = PurchaseOrder.all.order(client_id: :asc, active: :desc, title: :asc)\n end",
"def index\n # Admin users see all orders; non-Admins only see their own orders\n if current_user.admin\n @orders = Order.order(\"updated_at DESC\")\n else\n @orders = current_user.orders.order(\"updated_at DESC\")\n end\n end",
"def index\n # uses the customer_orders scope to retrieve all the orders that the current customer has made\n @orders = Order.customer_orders(current_customer)\n # uses the customer_average_order_cost scope to calculate the average cost of all the orders that the\n # current customer has made\n @average_cost_of_orders = Order.customer_average_order_cost(current_customer)\n end",
"def index\n session[:showing_user] = nil # make sure this session variable is cleared out\n if admin_user?\n @orders = Order.all\n else\n @orders = current_user.orders.to_a\n end\n end",
"def show_orders\n @promotion = Promotion.find(params[:id])\n @title = t(:orders_for) + \" \" + @promotion.code\n @orders = Order.paginate(\n :order => 'created_on DESC',\n :conditions => [\"promotion_id = ?\", @promotion.id],\n :page => params[:page],\n :per_page => 30\n )\n end",
"def list\n local_orders = Order.find( :all, :order => 'order_state_id' )\n ref_order = Order.find( params[:id] )\n @orders = Array.new\n @sum = 0\n\n for o in local_orders\n if o.order_state.name == \"needs\" && ref_order.order_state.name == \"needs\"\n str = o.prize.supplier.name\n ref_str = ref_order.prize.supplier.name\n else\n str = o.prize.supplier.name + o.updated_at.strftime( \"%d.%m.%Y\" )\n ref_str = ref_order.prize.supplier.name + ref_order.updated_at.strftime( \"%d.%m.%Y\" )\n end\n\n if str == ref_str\n @orders << o\n @sum += o.prize.value * o.count\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @orders }\n end\n end",
"def index\n @orders = current_customer.try(:orders).order(date: :desc)\n end",
"def buyer_orders \n if current_user && current_user.seller\n @items_info = find_buyers_orders.sort_by { |k| item_is_shipped(k[3],k[0].id) ? 1 : 0 }\n else\n redirect_to signin_path\n end\n end",
"def orders_including_customer\n Spree::Order\n .joins(:order_cycle)\n .includes(:customer)\n .for_order_cycle(order_cycle)\n .completed\n .order('customers.name ASC')\n end",
"def eligibleOrders(orders, available_cookies)\n eligibleorders = Array.new\n # iterate through each order, and if it is not fulfilled, then iterate over each product it has, then see if it is\n # an eligible order based on it it has less cookies than what is currently the available cookies\n orders.each do |order|\n if !order.isFulfilled\n order.getProducts.each do |product|\n if product.getTitle == 'Cookie' and product.getAmount <= available_cookies\n eligibleorders.push(order)\n end\n end\n end\n end\n return eligibleorders\nend",
"def current_order\n if session[:order_id]\n Order.find(session[:order_id])\n else\n Order.new\n end\n end",
"def current_order\n if session[:order_id]\n Order.find(session[:order_id])\n else\n Order.new\n end\n end",
"def index\n scope = Order.paginate(page: params[:orders_page], per_page: params[:per_page])\n if params[:search].present?\n scope = scope.search(params[:search])\n end\n if params[:ordering] && ordering = ORDERS[params[:ordering].to_i]\n scope = scope.order(ordering)\n end\n @orders = scope.with_current_status()\n @orders_qty = @orders.to_a.count\n end",
"def check_current_order\t\n\t\t# TODO: Introduce a proper way to check the order payment status\n\t\t# Currently the order get removed from the session the moment the\n\t\t# spree receives payment and no way of tracking. Might have to introduce\n\t\t# other means of checking for payment receival for orders. A possible\n\t\t# method would be to have session id sent along with IPN secret and\n\t\t# mark a flag on payment notifications after displaying payment received\n\t\t# message\n\t\t# if current_order \\\n\t\t# && current_order.completed? \n\t\t# # && ((current_order.payment_state == \"paid\") or (current_order.payment_state == \"credit_owed\"))\n\t\t# \tflash[:notice] = t(:pp_ws_payment_received)\n\t\t# \t@order = current_order\n\t\t# \tsession[:order_id] = nil\n\n\t\t# \tif current_user\n\t\t# \t\tredirect_to spree.order_path(@order)\n\t\t# \telse\n\t\t# \t\tredirect_to root_path\n\t\t# \tend\n\t\t\t\n\t\t# end\n\tend"
] |
[
"0.80987334",
"0.77585447",
"0.7751193",
"0.7675796",
"0.73043394",
"0.67345554",
"0.65871435",
"0.64006597",
"0.6287636",
"0.6246477",
"0.6228287",
"0.62208235",
"0.61404765",
"0.6113854",
"0.6083525",
"0.6080662",
"0.60653496",
"0.6055265",
"0.60369486",
"0.59895504",
"0.59850186",
"0.5980638",
"0.59710515",
"0.59710515",
"0.59704804",
"0.5952824",
"0.5938228",
"0.5896644",
"0.5887642",
"0.5882711",
"0.5866795",
"0.58602273",
"0.5857489",
"0.5850416",
"0.5850416",
"0.5834016",
"0.5832385",
"0.58173144",
"0.580318",
"0.57944906",
"0.57935506",
"0.5788726",
"0.57811683",
"0.57696813",
"0.5749389",
"0.5727755",
"0.57199085",
"0.5714213",
"0.57063246",
"0.56962967",
"0.56934685",
"0.56869483",
"0.5681532",
"0.5664465",
"0.56494594",
"0.56477326",
"0.5647201",
"0.5646915",
"0.56353486",
"0.563333",
"0.5630275",
"0.56229764",
"0.56208193",
"0.5614415",
"0.5613238",
"0.56127125",
"0.56076586",
"0.56009555",
"0.56001776",
"0.5596544",
"0.5592939",
"0.5590729",
"0.558358",
"0.5575582",
"0.55724853",
"0.55671906",
"0.5562118",
"0.55572987",
"0.5555373",
"0.5547218",
"0.55449283",
"0.5542476",
"0.5534481",
"0.55339265",
"0.55307335",
"0.5529773",
"0.5529444",
"0.5516596",
"0.55119395",
"0.5504122",
"0.54963624",
"0.5492255",
"0.549033",
"0.5490237",
"0.5487522",
"0.5484846",
"0.54832524",
"0.54832524",
"0.54706454",
"0.54694426"
] |
0.65643936
|
7
|
Delete sales line of an open order via given id
|
def delete_sales_line
sales_line = ERP::SalesLine.find( params[:id], :include => "sales_order" )
@store_user.my_account_log(sales_line,"Delete Sales Line: #{sales_line.invent_trans_id} (#{sales_line.item_id})")
if @customer.open_orders.collect{|order| order.id}.include?( sales_line.sales_order.id ) && sales_line.modifiable?
sales_line.destroy
render :text => "Deleted..."
else
render :text => "Failed to delete sales line (ID=#{params[:id]})", :status => 500
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_sales_invoice!(id)\n delete(\"sales_invoices/#{id}\")\n end",
"def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end",
"def delete_sales_entry_from_sales_order\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @sales_entry = @sales_order.active_sales_entries.where(:id => params[:object_to_destroy_id]).first\n \n @sales_order.delete_sales_entry( @sales_entry ) \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 @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_items.clear\n respond_to do |format| \n format.html { redirect_to(edit_object_url) } \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_item = @current_cart.line_items.where(:id => params[:id]).first\n unless @line_item.nil?\n @line_item.destroy\n end\n end",
"def destroy\n @invoice_adjustment_line = InvoiceAdjustmentLine.find(params[:id])\n @invoice_adjustment_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(invoice_adjustment_lines_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n DB.exec(\"DELETE FROM line WHERE id = #{self.id};\")\n end",
"def delete()\n sql = \"DELETE FROM stock_items WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\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 delete_line_item(table)\r\n if table_exists?(table)\r\n print_table(table)\r\n puts \"please choose the id number of the line you'd like to delete.\"\r\n id = get_valid_id(table)\r\n delete = (\"DELETE FROM #{table} WHERE id = #{id}\")\r\n @db.execute(delete)\r\n end\r\n end",
"def destroy\n if params[:line_item_id]\n @cart.line_items.find(params[:line_item_id]).destroy\n else\n @cart.destroy\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 @sale_order = current_company.sale_orders.find(params[:id])\n @sale_order.destroy\n\n respond_to do |format|\n format.html { redirect_to sale_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 remove_lineitem\n line_item = @sale.line_items.find_by_id(params[:line_item])\n respond_to do |format|\n if line_item.present?\n line_item.item.stock_amount = line_item.item.stock_amount + line_item.quantity\n line_item.item.save\n line_item.destroy\n end\n update_totals\n\n format.js { ajax_refresh }\n end\n end",
"def destroy\n @line_item = current_member.seller.line_items.find(params[:id])\n @line_item.destroy\n \n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.xml { render :nothing => true }\n end\n end",
"def destroy\n @delivery = Delivery.find(params[:id])\n order = Order.find(@delivery.order_id)\n order.order_items.each do |order_item|\n ordered_item = OrderedItem.find_by sale_item_id: order_item.sale_item_id\n a = SaleItem.find(order_item.sale_item_id)\n a.amount += order_item.quantity\n a.save\n User.find(SaleItem.find(order_item.sale_item_id).user_id).ordered_items.find(ordered_item.id).destroy\n ordered_item.destroy\n end\n @delivery.destroy\n respond_to do |format|\n format.html { redirect_to profile_url, notice: 'Order was successfully canceled.' }\n format.json { head :no_content }\n end\n end",
"def delete_order(id)\n Order.destroy(@current_user, id)\n end",
"def record_sales\n @deleted_lines.each {|l| l.delete}\n @deleted_lines.clear\n calc_values\n save\n @lines.each do |li|\n li.li_order_id = @data_object.order_id\n li.save\n end\n end",
"def destroy\n @sale_order = SaleOrder.find(params[:id])\n @sale_order.destroy\n\n respond_to do |format|\n format.html { redirect_to(sale_orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sales_order = SalesOrder.find(params[:id])\n @sales_order.destroy\n\n respond_to do |format|\n format.html { redirect_to sales_orders_url }\n format.json { head :no_content }\n end\n end",
"def sales_orders_id_delete_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrdersApi.sales_orders_id_delete ...\"\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 OrdersApi.sales_orders_id_delete\"\n end\n # resource path\n local_var_path = \"/sales/orders/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrdersApi#sales_orders_id_delete\\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 destroy\n @line_item.destroy\n destroy_line_item_response\n end",
"def remove_item(id:)\n order.items.destroy(id)\n end",
"def destroy\n @order = current_order\n @confirmed_order = ConfirmedOrder.new\n @confirmed_order.user_id = current_user.id\n @confirmed_order.payment_method = \"Cash\"\n @confirmed_order.payment_status = \"Not paid yet.\"\n @confirmed_order.save\n @orderlines = Orderline.where(\"order_id like ?\", current_order.id) \n @orderlines.each do |orderline|\n orderline.order_id = @confirmed_order.id\n orderline.save\n end\n\n session[:order_id] = nil\n respond_to do |format|\n if @confirmed_order.save\n format.html { redirect_to foods_path, notice: 'Your order was successfully placed.' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @confirmed_order.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def move_sales_line( sales_line_id, target_order_id )\r\n sales_line = self.sales_lines.find sales_line_id\r\n target_order = self.customer.sales_orders.find target_order_id\r\n\r\n moving_qty = sales_line.remain_sales_physical\r\n if moving_qty.zero?\r\n self.errors.add :sales_lines, \"This sales line has been fully completed.\"\r\n return false\r\n end\r\n\r\n self.class.transaction( sales_line ) do\r\n # Move out sales line from original order\r\n sales_line.sales_qty -= moving_qty\r\n sales_line.remain_sales_physical -= moving_qty\r\n sales_line.save!\r\n self.mark_as_modified\r\n\r\n # Append sales_line to target order\r\n existing_line = target_order.sales_lines.find_by_item_id sales_line.item_id\r\n if existing_line.nil?\r\n target_order.sales_lines.create! :sales_qty => moving_qty, :item_id => sales_line.item_id\r\n else\r\n existing_line.sales_qty += moving_qty\r\n existing_line.remain_sales_physical += moving_qty\r\n existing_line.save!\r\n end\r\n target_order.mark_as_modified\r\n end\r\n end",
"def destroy\n @invoice_line_item = InvoiceLineItem.find(params[:id])\n @invoice_line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to invoice_line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n stock= @sales_order_detail.stock\n stock.update(:quantity=> (stock.quantity+@sales_order_detail.quantity))\n @sales_order_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to new_sales_order_detail_path+'?status=Start&id='+@sales_order_detail.sales_order.id.to_s, notice: 'Sales order detail was successfully deleted.' }\n end\n end",
"def move_sales_line\r\n=begin\r\n sales_line = ERP::SalesLine.find params[:id]\r\n @original_order_id = sales_line.erp_sales_order_id\r\n sales_line.update_attribute :erp_sales_order_id, params[:target]\r\n \r\n mark_as_unsync [@original_order_id, params[:target]]\r\n=end\r\n @sales_line = ERP::SalesLine.find params[:id]\r\n @store_user.my_account_log(@sales_line,\"Move Sales Line #{@sales_line.invent_trans_id} From #{@sales_line.sales_order.sales_id}\")\r\n if @sales_line && @sales_line.sales_order.erp_customer_id == @customer.id\r\n @sales_line.move_to_order @customer.sales_orders.find( params[:target] )\r\n end\r\n end",
"def destroy\n @estimate_line_item = EstimateLineItem.find(params[:id])\n @estimate_line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(estimate_line_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n Order.where(id: params[:id], user: current_user).first.destroy!\n redirect_to action: 'index'\n end",
"def destroy\n @service_line = ServiceLine.find(params[:id])\n @service_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(service_lines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n unless current_member.admin or (!@order.paid and !@order.taken)\n store_location\n flash[:notice] = \"Too late to edit that one, bro.\"\n redirect_to orders_path\n end\n\n # add stock back\n @order.order_details.each{ |od|\n od.stock.quantity += od.quantity\n od.stock.save\n }\n\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_url) }\n format.xml { head :ok }\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 @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 destroy\n @order = Order.by_vendor.find(params[:id].to_s)\n @order.kill\n respond_to do |format|\n format.html { redirect_to(orders_url) }\n format.xml { head :ok }\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 = 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\r\n @lineitem = Lineitem.find(params[:id])\r\n @lineitem.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(lineitems_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def stop_order(id)\n # response = post(\n # \"peatio/market/orders/#{id}/cancel\"\n # )\n #\n\n order = @current_user.orders.find id\n Ordering.new(order).cancel\n @open_orders.remove_order(id)\n\n # response\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n product = Product.find_by_id(@line_item.product.id)\n product.update_attributes(:remaining_quantity => (product.remaining_quantity + @line_item.quantity))\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_path) }\n format.json { head :ok }\n end\n end",
"def destroy\n @sale_invoice = SaleInvoice.find(params[:id])\n @sale_invoice.destroy\n\n respond_to do |format|\n format.html { redirect_to monthly_movement_sale_invoices_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @line_item = Spree::LineItem.find_by_id(params[:id])\n @order = Spree::Order.find_by_number(params[:order_id])\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\" , \"zalora\"\n order_total = @order.total\n end\n end\n if @line_item.present?\n increased_qty = @line_item.quantity\n @variant = @line_item.variant\n @product = @variant.product if @variant.present?\n @line_item.destroy\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>@stock_product.count_on_hand + increased_qty.to_i)\n @variant.update_attributes(:fba_quantity=>@variant.fba_quantity + increased_qty.to_i) if !@variant.quantity_inflations.present?\n msg = 'Line Items Controller destroy'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n respond_to do |format|\n format.html { redirect_to modify_order_admin_order_path(@order), notice: 'Product is successfully deleted' }\n end\n end",
"def destroy\n @OrderOfService = OrderOfService.find_by_id(params[:id])\n @OrderOfService.cancel\n @OrderOfService.update(:status => 0, :date_of_elimination => Time.now)\n @OrderOfService.update(:user_id_historic => current_user.id)\n stateOrderDetail = StatePerOrderOfService.new\n stateOrderDetail.state = @OrderOfService.human_state_name\n stateOrderDetail.order_of_service_id = params[:id]\n stateOrderDetail.user_id = current_user.id\n stateOrderDetail.save\n #redirect_to :action => :index, company_id: params[:company_id]\n render :json => @OrderOfService\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 delete_order_item_group(id)\n @client.raw('delete', \"/ecommerce/order-items-groups/#{id}\")\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n head :no_content\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 @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 @ordered_product = OrderedProduct.find(params[:id])\n product = @ordered_product.product\n order_id = @ordered_product.order_id\n\n @ordered_product.destroy\n\n respond_to do |format|\n if order_id.blank?\n format.html { redirect_to build_admin_orders_path }\n else\n change_order_total\n format.html { redirect_to admin_order_edit_detail_path(order_id) }\n end\n end\n end",
"def delete_line(line)\n raise \"Can't find line item to delete\" unless @lines.delete(line)\n @deleted_lines << line\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n redirect_to :action => :index\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 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 @order_item = OrderItem.find(params[:id])\n @order_item.destroy\n\n head :no_content\n end",
"def destroy\n\n if params[:product_id] then\n# TODO need to use @cart.id to ensure only this users line_item is accessed.\n current_item = LineItem.find_by_product_id(params[:product_id] )\n else\n current_item = LineItem.find(params[:id])\n end\n\n if current_item\n current_item.quantity -= 1\n puts current_item.quantity\n if current_item.quantity <= 0\n current_item.destroy\n else\n current_item.save\n end\n else\n current_item.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase_order.record_activity(:delete, current_user, \"Deleted PO\")\n @purchase_order.destroy\n respond_to do |format|\n\n format.html { redirect_to purchase_orders_url, notice: \"Purchase Order #{@purchase_order.po_id} has been deleted.\" }\n format.json { head :no_content }\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 @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_orders_url, notice: 'Ordem de serviço excluída com sucesso.' }\n end\n end",
"def destroy\n @shipping_line = ShippingLine.find(params[:id])\n @shipping_line.destroy\n\n respond_to do |format|\n format.html { redirect_to shipping_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oligo_order = OligoOrder.find(params[:id])\n @oligo_order.destroy\n\n respond_to do |format|\n format.html { redirect_to(oligo_orders_url) }\n format.xml { head :ok }\n end\n end",
"def ship(id, ship_number)\n @conn.exec(\"DELETE FROM products WHERE id = '#{id}';\")\n puts \"SUBSTRACTION\"\nend",
"def remove!(donation_or_purchase)\n log = {}\n donation_or_purchase.line_items.each do |line_item|\n inventory_item = InventoryItem.find_by(storage_location: id, item_id: line_item.item_id)\n if (inventory_item.quantity - line_item.quantity) <= 0\n inventory_item.destroy\n else\n inventory_item.update(quantity: inventory_item.quantity - line_item.quantity)\n end\n log[line_item.item_id] = \"-#{line_item.quantity}\"\n end\n log\n end",
"def decrement_line_item_quantity(line_item_id)\n current_item = line_items.find(line_item_id)\n if current_item.quantity > 1\n current_item.quantity -= 1\n else\n current_item.destroy\n end\n current_item\n end",
"def destroy\n @invent_journal_line = InventJournalLine.find(params[:id])\n @invent_journal_line.destroy\n\n respond_to do |format|\n format.html { redirect_to invent_journal_lines_url }\n format.json { head :no_content }\n end\n end",
"def delete_lines_main_order\n # Eliminamos las lineas de la orden principal\n @main_order.line_items.each do |line_item|\n line_item.delete\n end\n # Eliminamos la orden principal\n @main_order.delete\n end",
"def destroy\n @product_line = ProductLine.find(params[:id])\n @product_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(product_lines_url) }\n format.xml { head :ok }\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 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 @deliveryOrder = DeliveryOrder.find_by_id(params[:id])\n if !DeliveryOrder.inspect_have_data(params[:id])\n if @deliveryOrder.cancel\n stateOrderDetail = StatePerOrderDetail.new\n stateOrderDetail.state = @deliveryOrder.human_state_name\n stateOrderDetail.delivery_order_id = params[:id]\n stateOrderDetail.user_id = current_user.id\n stateOrderDetail.save\n end\n else\n flash[:error] = \"La Orden de Servicio N° \" + @deliveryOrder.id.to_s.rjust(5, '0') + \" no puede ser eliminada. Los datos de esta orden están siendo utilizados.\"\n end\n #redirect_to :action => :index, company_id: params[:company_id]\n render :json => @deliveryOrder\n end",
"def destroy\n @linea = Linea.find(params[:id])\n @linea.destroy\n\n respond_to do |format|\n format.html { redirect_to(lineas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n head :no_content\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 delete_order_item_group(id)\r\n @client.raw('delete', \"/ecommerce/order-items-groups/#{id}\", nil, nil, @contact_v1_url)\r\n end",
"def destroy!(id = nil)\n Order.delete(id ? id : self.id)\n end",
"def destroy\n @order = Order.find(params[:id])\n \n begin\n @order.destroy\n message = \"Order was successfully deleted.\"\n rescue ActiveRecord::DeleteRestrictionError => e\n #@order.errors.add(:base, e)\n message = \"Order is still in use. Unable to delete order. \"\n end\n\n respond_to do |format|\n format.html { redirect_to orders_url, notice: message }\n format.json { head :no_content }\n end\n end",
"def remove_item\n\t\tset_sale\n\t\tpopulate_products\n\n\t\tline_item = Item.where(sale_id: params[:sale_id], product_id: params[:product_id]).first\n\t\tline_item.quantity -= 1\n\n\t\tif line_item.quantity == 0\n\t\t\tline_item.destroy\n\t\telse\n\t\t\tline_item.save\n\t\t\tupdate_line_item_totals(line_item)\n\t\tend\n\n\t\t# Llama método que devuelve cantidad al stock\n\t\treturn_item_to_stock(params[:product_id])\n\n\t\tupdate_totals\n\n\t\trespond_to do |format|\n\t\t\tformat.js { ajax_refresh }\n\t\tend\n\tend",
"def destroy\n get_data\n @sale_detail = @sale.details.find(params[:id])\n @sale_detail.destroy\n get_data\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 delete_item_price(id)\n @client.raw('delete', \"/ecommerce/item-prices/#{id}\")\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 @sorder = Sorder.find(params[:id])\n @sorder.destroy\n\n respond_to do |format|\n format.html { redirect_to sorders_url }\n format.json { head :no_content }\n end\n end",
"def remove\n @order.ig_remove_order\n redirect_to admin_orders_path\n end",
"def destroy\n @purchase_order.destroy\n end",
"def destroy_from_open_pay\n OpenPay::Customer.new.destroy(open_pay_id) if open_pay_id.present?\n end",
"def removeline(step, order)\n\t\t#active_steps.find_by(line_id: line.id).destroy\n\t\tactive_steps.find_by(id: step.id).destroy\n\t\t\n\t\t#active_relationships.find_by(followed_id: other_user.id).destroy\n\t\t#steps.find_by(installation_id: self, line_id: line.id).destroy\n\tend",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_orders_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @order = Order.find(params[:id])\n @order.destroy\n redirect_to user_order_path\n end",
"def destroy\n @order = Order.find(params[:order_id])\n @order_item = @order.order_items.find(params[:id])\n @order_item.destroy\n\n respond_to do |format|\n format.html { redirect_to order_order_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @invoice = Invoice.find(params[:id])\n\n @customer = Customer.find_by_id(params[:customer_id])\n #@invoice.customer_id = @customer.id\n\n\n\n @invoice.destroy\n\n# respond_to do |format|\n# format.html { redirect_to (customer_path(@invoice.customer_id), :notice => 'Invoice was successfully deleted.') }\n# format.xml { head :ok }\n# end\n end",
"def destroy\n\t\t@line_item.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to line_items_url, notice: \"Req ID: #{@line_item.id} removed.\" }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"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"
] |
[
"0.7191335",
"0.7036305",
"0.70347667",
"0.70268524",
"0.7011492",
"0.6572518",
"0.6530496",
"0.6511341",
"0.6409515",
"0.6324507",
"0.632261",
"0.625593",
"0.62545407",
"0.6243178",
"0.6235454",
"0.62074715",
"0.6194714",
"0.61884665",
"0.6162448",
"0.615727",
"0.6145458",
"0.6119424",
"0.61174583",
"0.6098444",
"0.60960454",
"0.60950893",
"0.6072052",
"0.60388523",
"0.6030497",
"0.6027666",
"0.60190517",
"0.6013525",
"0.60125077",
"0.60053366",
"0.59993523",
"0.59944004",
"0.5963491",
"0.59473646",
"0.5936201",
"0.5935201",
"0.59342647",
"0.59278816",
"0.59058315",
"0.58975905",
"0.58724594",
"0.5863961",
"0.58570856",
"0.5841997",
"0.5832992",
"0.58317703",
"0.58316606",
"0.58306754",
"0.5829085",
"0.58204234",
"0.58204234",
"0.58204234",
"0.58204234",
"0.5802047",
"0.5792618",
"0.5792031",
"0.57883704",
"0.57879424",
"0.5784275",
"0.5782478",
"0.57815963",
"0.5776744",
"0.5775465",
"0.57745665",
"0.5770612",
"0.5768395",
"0.5762794",
"0.57621074",
"0.57617044",
"0.57608116",
"0.57474035",
"0.57473683",
"0.5742664",
"0.5738815",
"0.57383144",
"0.5737554",
"0.5729902",
"0.57182956",
"0.57119703",
"0.57030165",
"0.569757",
"0.56907856",
"0.56808645",
"0.56807077",
"0.5679777",
"0.56788313",
"0.5676799",
"0.5676375",
"0.56748265",
"0.5670043",
"0.566324",
"0.56603503",
"0.56588256",
"0.564927",
"0.56444275",
"0.5642501"
] |
0.8255487
|
0
|
Update product quantity of sales line with given id
|
def update_sales_line_qty
sales_line = ERP::SalesLine.find params[:id]
result = sales_line.update_sales_qty( params[:value].to_i )
@store_user.my_account_log(sales_line,"Update Sales Line Qty: #{sales_line.invent_trans_id} (#{sales_line.item_id}), returns #{result}")
render :text => result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_product_qty\n @order = Spree::Order.find_by_id(params[:order_id])\n @line_item = Spree::LineItem.find_by_id(params[:line_item_id])\n request_to_update_qty = params[:quantity].to_i\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\", 'zalora'\n order_total = @order.total\n end\n end\n if @line_item.present?\n prev_qty = @line_item.quantity.to_i\n final_qty = prev_qty - request_to_update_qty\n @variant = @line_item.variant\n @product = @variant.product if @variant.present?\n # code to update line item\n @line_item.update_column(:quantity, request_to_update_qty)\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>(@stock_product.count_on_hand + final_qty.to_i) >= 0 ? (@stock_product.count_on_hand + final_qty.to_i) : 0)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity + final_qty.to_i) >= 0 ? (@variant.fba_quantity + final_qty.to_i) : 0) if !@variant.quantity_inflations.present?\n msg = 'Admin/Orders Controller update_product_qty '\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n line_items = @order.line_items\n respond_to do |format|\n format.html { render :partial=>\"modify_shipping\", :locals => { :line_items => line_items }}\n end\n end",
"def update\n logger.debug \"***Updating Line Item #{params[:id]} quantity to #{params[:cart_line_item][:quantity]}\"\n @cart_line_item = CartLineItem.find(params[:id])\n @cart_line_item.quantity = params[:cart_line_item][:quantity]\n if @cart_line_item.save\n flash[:success] = \"Cart Item successfully updated\"\n else\n flash[:error] = \"Cart Item update unsuccessful\"\n end\n redirect_to cart_path(session[:cart_id])\n end",
"def update_product_on_order\n prod_id = params[:id].to_i\n qty_to_order = params[:qty].to_i\n\n add_or_update_product_qty(prod_id, qty_to_order)\n\n flash[:notice] = 'Updated qty in cart'\n redirect_back(fallback_location: cart_path)\n end",
"def add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end",
"def add_product (product_id)\n current_item = line_items.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n # The default quantity is 1. \n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end",
"def update!(**args)\n @line_item_id = args[:line_item_id] if args.key?(:line_item_id)\n @product_id = args[:product_id] if args.key?(:product_id)\n @quantity = args[:quantity] if args.key?(:quantity)\n end",
"def update_quantity token, cart_id, product_code, qty = 1\n\tend",
"def add_product(product_id)\n current_item = line_item.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\t\n current_item\nend",
"def update_line_item_totals(line_item)\n line_item.total_price = line_item.price * line_item.quantity\n line_item.save\n end",
"def add_item(product_id)\n item = line_items.where(product_id: product_id).first\n if item.present?\n item.quantity += 1\n item\n else\n line_items.new(product_id: product_id)\n end\n end",
"def add_product(product_id)\n \t#current_item = line_items.where(product_id: product_id).first\n\n \t# if current_item\n \t# if (current_item.quantity == nil) \n # current_item.quantity = 0\n # end\n # current_item.quantity = 1\n \t# else\n \t# current_item = line_items.build(:product_id => product_id)\n # current_item.quantity += 1\n # end\n #current_item\n line_items.create(:product_id => product_id, :quantity => 1)\n end",
"def add_product(product_id)\n\t\tcurrent_item = line_items.find_by(product_id: product_id)\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(product_id: product_id)\n\t\tend\n\t\tcurrent_item\n\tend",
"def update_quantity\n @id=params[:id]\n @quantity=params[:quantity]\n CartItem.where(:cart_id =>@@cartId ,:product_id => @id).limit(1).update_all(:quantity => @quantity) \n redirect_to \"/carts\"\n end",
"def add_product(product_id)\n current_item = line_items.where(:product_id => product_id).first\n if current_item\n current_item.quantity += 1\n # Otherwise create a new line_item\n else\n current_item = LineItem.new(:product_id => product_id)\n line_items << current_item # add the current_item to the end of the line_items\n end\n current_item\n end",
"def add_product(product_id)\n\t\tcurrent_item = line_items.find_by_product_id(product_id)\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(:product_id => product_id)\n\t\tend\n\t\tcurrent_item\n\tend",
"def update_product\n if inbound_order? || quantity_adjustment?\n product.update(stock: product.stock + quantity)\n else outbound_order?\n product.update(stock: product.stock - quantity)\n end\n end",
"def update_sales_entry\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @sales_entry = @sales_order.active_sales_entries.where(:id => params[:id]).first\n \n @quantity = params[:sales_entry][:quantity].to_i\n @selling_price_per_piece = BigDecimal( params[:sales_entry][:selling_price_per_piece] )\n \n @new_object = @sales_entry.update_item( @quantity, @selling_price_per_piece)\n @has_no_errors = @new_object.errors.messages.length == 0 \n \n @item = @sales_entry.item\n end",
"def set_quantity product_id, quantity, options = {}\n options.reverse_merge!(override: false)\n quantity = quantity.to_i\n\n return unless quantity > 0\n\n # If product was in cart\n if (product = self.product(product_id))\n if options[:override]\n product.quantity = quantity\n else\n product.quantity += quantity\n end\n else\n @products << Glysellin::Cart::Product.new(\n id: product_id,\n quantity: quantity\n )\n end\n\n # Refresh discount code adjustment\n self.discount_code = discount_code\n end",
"def update\n @lineitem = Lineitem.find(params[:id])\n @item = Item.find(@lineitem.item_id)\n @lineitem_quantity_temp = @lineitem.quantity\n respond_to do |format|\n if @lineitem.update_attributes(params[:lineitem])\n if @item.amount > 0\n format.html { redirect_to 'http://localhost:3000/carts/show'}\n format.json { head :no_content }\n else\n @lineitem.quantity = @lineitem_quantity_temp\n @lineitem.save\n format.html {redirect_to 'http://localhost:3000/itemnotfound.html/' }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lineitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end",
"def update_line_item_totals(line_item)\n\t\tline_item.total_price = line_item.price * line_item.quantity\n\t\tline_item.save\n\tend",
"def update_cart_line_item(a_line_item, quantity, options={})\n return remove(a_line_item, options) if quantity <= 0\n item = find(:first, a_line_item)\n item.quantity = quantity if item\n item\n end",
"def update(stuff, quantity, options={})\n if stuff.is_a?(MerchantSidekick::ShoppingCart::LineItem)\n self.update_cart_line_item(stuff, quantity, options)\n else\n self.update_product(stuff, quantity, options)\n end\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\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 add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n \tif current_item\n \t\tcurrent_item.quantity += 1\n \telse\n \t\tcurrent_item = line_items.build(product_id: product_id)\n current_item.product_price = Product.find(product_id).price\n \tend\n \tcurrent_item\n end",
"def update_product(a_product, quantity, options={})\n return remove(a_product, options) if quantity <= 0\n item = find(:first, a_product)\n item.quantity = quantity if item\n item\n end",
"def update\n @product = TempProduct.find(params[:id])\n @product.qty = params[:qty]\n # save product\n if @product.save\n # success\n render :json => { :success => true }\n else\n # failed\n render :json => { :success => false }\n end\n end",
"def add_product(product_id)\n \n #Check if the current item is in our current line items\n current_item = line_items.find_by_product_id(product_id)\n if current_item\n #If it is already in our line items, increment the quantity\n current_item.quantity += 1\n else\n #Otherwise, build the relationship\n current_item = line_items.build(product_id: product_id)\n end\n \n #return the current item\n current_item\n end",
"def update_quantity_to_cart\n \t\n\n \tproduct_id_ = params[:product_id].to_i\n\n \tsession[\"cart\"].each do |h|\n \t\tif h['id'] == product_id_\n \t\t\th['quantity'] = params[:quantity_update].to_i\n \t\t\th['total'] = h['price'] * h['quantity']\n \t\t\t\n \t\tend\n \tend\n\n \tredirect_to :back\n end",
"def update\n requested_qty = params[:quantity].to_i\n\n # Check that user hasn't entered invalid qty\n unless requested_qty > 0\n flash[:item_error] = 'Please enter a valid quantity.'\n redirect_to cart_path\n return\n end\n\n # Get the line_item to update\n current_item = LineItem.find params[:id]\n\n # Ensure users don't update line items that don't belong to their cart\n unless @cart.line_items.include?(current_item)\n redirect_to cart_path\n return\n end\n\n # Invoke method in line_item.rb that checks the\n # requested qty against current stock levels\n update_qty = current_item.get_update_qty requested_qty\n\n # If the user's requested quantity can not be fulfilled, set a flash error\n unless update_qty == requested_qty\n flash[:item_error] = \"Sorry, not enough stock. Your shopping basket has been adjusted accordingly.\"\n end\n\n # Save the line_item update\n current_item.update quantity: update_qty\n\n # Redirect to My Basket page\n redirect_to cart_path\n end",
"def add_product(product_id) #why methid in model? not in controller?\n\t\tcurrent_item = line_items.find_by(product_id: product_id) #find_by returns one object, where return array\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(product_id: product_id) #you could build it from \"cart\" side as well\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#rails establishes connections for you\n\t\tend\n\n\t\tcurrent_item\n\tend",
"def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend",
"def deduct_quantity\n line_items.each do |i|\n i.product.current_stock -= i.quantity\n i.product.save\n end\n end",
"def add_product(product_id) #a method that accumulates the quantity of a product that has been added more than twice, using its id\n\t\tcurrent_item = line_items.where(:product_id => product_id).first\n\n\t\tif current_item\n\n\t\t\tcurrent_item.quantity += 1 rescue current_item.quantity\n\t\telse\n\t\t\tcurrent_item = LineItem.new(:product_id=>product_id) #adding a new product to the order line, since its unique to this cart\n\t\t\tline_items << current_item\n\t\tend\n\n\t\tcurrent_item\n\tend",
"def update_quantity\n product = Product.find_by_title(params[:product_title])\n order_item = OrderItem.find_by(product: product)\n if params[:quantity_of_products].present? && product.present?\n if product.quantity_products + order_item.quantity >= params[:quantity_of_products].to_i\n order_item.update_quantity_product(params[:quantity_of_products], true)\n order_item.order.update_total_price_cents(nil)\n redirect_to cart_path, notice: \"Количество товара #{params[:product_title]} было обновлено до #{params[:quantity_of_products]}\"\n else\n redirect_to cart_path, notice: \"Простите, вы не можите купить этот товар количеством в #{params[:quantity_of_products].to_i} так как их всего #{product.quantity_products}\"\n end\n end\n end",
"def update()\n query = \"UPDATE sale_items SET (sli_qty, sli_unit_price, sli_alb_id) = ($1, $2, $3) WHERE sli_id = $4\"\n DbHelper.run_sql(query, [@sli_qty, @sli_unit_price, @sli_alb_id, @sli_id])\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 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_purchase_receival_stock_entry(purchase_receival_entry)\n self.quantity = stock_migration.quantity \n self.save \n \n stock_mutation = StockMutation.where(\n :stock_entry_id => self.id , \n :source_document_entry_id => stock_migration.id,\n :source_document_entry => stock_migration.class.to_s \n ).first \n stock_mutation.quantity = self.quantity \n stock_mutation.save \n end",
"def add_product(product)\n current_item = line_items.where(:product_id => product.id).first\n if current_item\n current_item.quantity += 1\n else\n current_item = LineItem.new(:product_id => product_id)\n line_items << current_item\n end\n current_item\n end",
"def create \n @product = Product.find_by_title(params[:product]) \n @line_item = LineItem.new(params[:line_item])\n @line_item.product_id = @product.id\n @line_items= LineItem.where(:demand_id => @line_item.demand_id, :product_id => @line_item.product_id)\n \n @quantity = @line_item.quantity\n \n if @line_items != nil\n @line_items.each do |item|\n @quantity += item.quantity\n LineItem.find(item.id).destroy\n end\n @line_item.update_attributes(:quantity => @quantity)\n end\n \n respond_to do |format|\n if @line_item.save\n format.js\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 set_quantity\n @quantity = Quantity.find(params[:id])\n end",
"def order(id, quantity_number)\n @conn.exec(\"UPDATE products SET #{product} = '#{query_term}' WHERE id = '#{id}';\")\n #{quantity} =\n #{n}=\n puts \"ADDITION\"\nend",
"def update_product_amounts\n commits = Commit.where(:product_id => self.product_id)\n price_with_fee = commits.collect(&:sale_amount_with_fees).reduce(:+)\n price = commits.collect(&:sale_amount).reduce(:+)\n if price_with_fee.nil?\n product.current_sales_with_fees = 0\n product.current_sales = 0\n else\n product.current_sales_with_fees = price_with_fee\n product.current_sales = price\n end\n product.save(validate: false)\n end",
"def add_product(product)\n\t\tcurrent_item = line_items.find_by(product_id: product.id)\n\t\tif current_item\n\t\t\tcurrent_item.quantity += 1\n\t\telse\n\t\t\tcurrent_item = line_items.build(product_id: product.id)\n\t\tend\n\t\tcurrent_item\n\tend",
"def destroy\n @line_item = LineItem.find(params[:id])\n product = Product.find_by_id(@line_item.product.id)\n product.update_attributes(:remaining_quantity => (product.remaining_quantity + @line_item.quantity))\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(orders_path) }\n format.json { head :ok }\n end\n end",
"def add_product(product)\n # @type [LineItem, NilClass]\n item = line_items.find_by(product: product)\n if item.present?\n item.quantity += 1\n else\n item = line_items.build(product: product)\n end\n\n item\n end",
"def get_line_item_quantity(id)\n\t\tself.order_line_items.each do |item|\n\t\t\treturn item.quantity if item.product_id == id\n\t\tend\n\t\treturn 0\n\tend",
"def destroy\n @cart = current_cart\n product = Product.find(params[:product_id])\n #@line_item = LineItem.find(params[:id])\n @line_item = @cart.remove_product(product.id)\n product.update_attributes(:quantity => product.quantity + 1)\n\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end",
"def add_product(product)\n current_item = line_items.find_by(product_id: product.id) # find the current item in the line items. find_by() returns an existing LineItem or nil.\n if current_item # if the current item is present...\n current_item.quantity += 1 # ...increment by one.\n else\n current_item = line_items.build(product_id: product.id) # If the item isn't present then build the line_item.\n current_item.price = product.price # Take the current_item and capture the price attribute.\n end\n current_item # Return the current item.\n end",
"def add_item\n\t\tset_sale\n\t\tpopulate_products\n\n\t\tline_item = Item.where(sale_id: params[:sale_id], product_id: params[:product_id]).first\n\t\tline_item.quantity += 1\n\t\tline_item.save\n\n\t\t# Llama método que reduce cantidad de stock\n\t\tremove_item_from_stock(params[:product_id])\n\t\tupdate_line_item_totals(line_item)\n\n\t\tupdate_totals\n\n\t\trespond_to do |format|\n\t\t\tformat.js { ajax_refresh }\n\t\tend\n\tend",
"def update_quantity(quantity)\n if quantity != self.quantity\n old_cost = self.extra_cost || 0\n transaction do\n self.quantity = quantity\n self.extra_cost = self.extra_unit_cost * quantity\n self.save\n shopping_cart.extras_cost += (self.extra_cost - old_cost)\n shopping_cart.calculate_cost(false, false)\n shopping_cart.save\n end\n end\n end",
"def change_inventory\n order_item_obj = OrderItem.last\n product_id = order_item_obj.product_id\n inventory_of_ordered_product = InventoryStock.where(product_id:product_id)\n quantity_in_inventory = inventory_of_ordered_product[0].quantity\n quantity_in_ordered_item = order_item_obj.quantity\n updated_quantity_in_inventory = quantity_in_inventory.to_i-quantity_in_ordered_item.to_i\n InventoryStock.where(product_id:product_id).update(quantity: updated_quantity_in_inventory)\n end",
"def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend",
"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 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_line_item_product\n @line_item_product = LineItemProduct.find(params[:id])\n end",
"def increment_quantity\n self.quantity_needed += self.quantity\n save\n end",
"def update\n reference_set\n\n @product.subsection_ids = params[:product][:subsection_ids]\n puts @quantity = params[:quantity]\n \n no_price_fix\n @checkBoxs = @product.subsection_ids\n @intsallchecks = params[:install_ids]\n #exvatcalc = @price.to_i * 0.14\n #@exvat_pirce = @price.to_i - exvatcalc.to_f\n @count = 0\n\n clone_product_to_lineitem\n render :js => \" $('#testnow').modal('hide')\"\n\n\n end",
"def sale_quantity=(value)\n unless value.is_a?(Numeric) && value > 0\n raise ArgumentError.new(\"A product's sale quantity must be numeric and greater than 0 if it is on sale.\") if self.on_sale?\n value = 1\n end\n @sale_quantity = value\n end",
"def update\n if params[:commit] == 'Add'\n current_quantity = params[:product_quantity].to_i + 1\n stock_status = @line_item.product.has_enough_products(current_quantity)\n update_quantity(stock_status, \"add\")\n end\n\n if params[:commit] == 'Reduce'\n if params[:product_quantity].to_i > 1 #at least 1\n current_quantity = params[:product_quantity].to_i - 1\n stock_status = @line_item.product.has_enough_products(current_quantity)\n update_quantity(stock_status, \"reduce\")\n else #1\n @notice = \"Only one in your cart. You can only remove it.\"\n @add_class = \"alert-danger\"\n end\n end\n\n respond_to do |format|\n format.js\n end\n\n # respond_to do |format|\n # if @line_item.update(line_item_params)\n # format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n # format.json { render :show, status: :ok, location: @line_item }\n # else\n # format.html { render :edit }\n # format.json { render json: @line_item.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update_quantity(quantity)\n\n if quantity != self.quantity\n\n old_quantity = self.quantity || 0\n old_item_cost = self.item_cost || 0\n old_item_deposit = self.product_deposit_cost || 0\n old_category_supplement_1_cost = self.category_supplement_1_cost || 0\n old_category_supplement_2_cost = self.category_supplement_2_cost || 0\n old_category_supplement_3_cost = self.category_supplement_3_cost || 0\n\n transaction do\n\n # Update the item\n self.quantity = quantity\n self.item_cost = (self.item_unit_cost || 0) * quantity\n self.product_deposit_cost = (self.product_deposit_unit_cost || 0) * quantity\n self.category_supplement_1_cost = (self.category_supplement_1_unit_cost || 0) * quantity\n self.category_supplement_2_cost = (self.category_supplement_2_unit_cost || 0) * quantity\n self.category_supplement_3_cost = (self.category_supplement_3_unit_cost || 0) * quantity\n self.save\n\n # Update the shopping cart cost\n self.shopping_cart_item_cost_variation(old_item_cost, \n old_item_deposit, \n old_category_supplement_1_cost,\n old_category_supplement_2_cost,\n old_category_supplement_3_cost)\n self.shopping_cart.calculate_cost(false, true)\n\n begin\n self.shopping_cart.save\n rescue DataMapper::SaveFailureError => error\n p \"Error saving shopping cart: #{self.shopping_cart.errors.full_messages.inspect}\"\n raise error\n end\n\n # Add or shopping cart item resources\n if quantity < old_quantity\n (quantity..(old_quantity-1)).each do |resource_number|\n self.item_resources[quantity].destroy unless self.item_resources[quantity].nil?\n self.item_resources.reload\n end\n elsif quantity > old_quantity\n product = ::Yito::Model::Booking::BookingCategory.get(item_id)\n (old_quantity..(quantity-1)).each do |resource_number|\n shopping_cart_item_resource = ShoppingCartItemResourceRenting.new\n shopping_cart_item_resource.item = self\n shopping_cart_item_resource.pax = product.capacity unless product.nil?\n shopping_cart_item_resource.save\n end\n end\n\n end\n end\n end",
"def update\n @products = params[:inputprod]\n @quantity = params[:inputcantidad]\n \n respond_to do |format|\n if @service_order.update(service_order_params)\n ServiceOrderDetail.delete_all(:service_order_id => params[:id])\n cont =0\n @products.each do |p|\n detalle = ServiceOrderDetail.new(product_id: p, quantity: @quantity[cont], service_order_id:@service_order.id)\n detalle.save\n cont +=1\n end\n \n format.html { redirect_to @service_order, notice: 'Service order was successfully updated.' }\n format.json { render :show, status: :ok, location: @service_order }\n else\n format.html { render :edit }\n format.json { render json: @service_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_cart\n product = Product.find_by_cs_sku(params[:sku])\n item = ReservedItem.where('user_id = ? and product_id = ? and session_id = ?', current_user.id,\n product.id,\n session.id).first\n qty = BigDecimal.new(get_qty)\n\n if available?(product, item, qty)\n product.update_attribute(:qty, (product.qty + item.qty) - qty)\n item.update_attribute(:qty, qty)\n respond_with_format { @cart.update_item(params[:sku], get_qty) }\n else\n flash[:error] = 'Not enough item in inventory'\n respond_with_format\n end\n end",
"def reduce_quantity\n @batch = Batch.find_by(batchID: params[:batchID])\n #update the quantity \n #@batch[:quantity] -= 1\n \n @batch.quantity = @batch.quantity - 1\n end",
"def add_item(item_id)\n line_item = self.line_items.find_by(item_id: item_id)\n if line_item\n line_item.quantity += 1\n else\n line_item=self.line_items.build(item_id: item_id)\n end\n line_item\n end",
"def decrement_line_item_quantity(line_item_id)\n current_item = line_items.find(line_item_id)\n if current_item.quantity > 1\n current_item.quantity -= 1\n else\n current_item.destroy\n end\n current_item\n end",
"def set_quantity\n @subscription.quantity += 1 if @subscription.persisted?\n end",
"def add_product_to_order\n prod_id = params[:id].to_i\n qty_to_order = params[:qty].to_i\n\n add_or_update_product_qty(prod_id, qty_to_order)\n\n flash[:notice] = 'Product added to cart'\n redirect_back(fallback_location: root_path)\n end",
"def set_quantity_and_price(purchase, n, price, entry = find_or_create_item(purchase))\n entry.components.clear\n update_entry(entry) do |i|\n i.components.build(:price => price, :quantity => n, :total => price * n)\n end\n end",
"def add_product(product)\n item = @items.find {|i| i.product_id == product.id}\n if item\n item.quantity += 1\n else\n item = LineItem.for_product(product)\n @items << item\n end\n @total_price += product.price\n end",
"def update\n @cart = current_cart\n #We use params to get the product ID from the request\n #This is stored locally as no need to let view see it\n product = Product.find(params[:product_id])\n \n #Adds an item to the cart using the \"add_product\" \n #function in the \"cart.rb\" file.\n @line_item = @cart.delete_product(product.id)\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to(store_url) }\n format.js { @current_item = @line_item }\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_quantity(opts = {})\n data, _status_code, _headers = update_quantity_with_http_info(opts)\n data\n end",
"def increment_quantity\n self.quantity += 1\n save\n end",
"def si_update_product_select_from_order_item\n i = params[:i]\n product_id = 0\n if i != '0'\n @item = PurchaseOrderItem.find(i)\n product_id = @item.blank? ? 0 : @item.product_id\n end\n # Setup JSON\n @json_data = { \"product\" => product_id }\n render json: @json_data\n end",
"def add_item(item_id)\n if line_item = line_items.find_by(item_id: item_id)\n line_item.quantity += 1\n else\n line_item = line_items.build(item_id: item_id)\n end\n line_item\n end",
"def update\n @cart = current_cart\n @item = @cart.cart_items.find_by(product_id: params[:id])\n if @item.product.quantity >= item_params[:quantity].to_i\n @item.update(item_params)\n flash[:notice] = \"Updated!\"\n else\n flash[:warning] = \"Could not update.\"\n end\n\n redirect_to carts_path\n end",
"def add_product(product)\n\t\titem_to_add = line_items.find_by(product_id: product.id)\n\t\tif item_to_add\n\t\t\titem_to_add.quantity += 1\n\t\telse\n\t\t\t# in this case we create the line_item, the quantity default is 1\n\t\t\titem_to_add = line_items.build(product_id: product.id)\n\t\t\titem_to_add.order = nil\n\t\tend\n\t\titem_to_add\n\tend",
"def create\n @ticket = Ticket.find(params[:ticket_id])\n if @line_item =@ticket.products.exists?(lineitem_params[:product_id])\n @line_item_first=@ticket.LineItems.where(product_id: lineitem_params[:product_id]).first \n @line_item_first.update(quantity: lineitem_params[:quantity].to_d+@line_item_first.quantity, totalsale: (lineitem_params[:totalsale].to_d+@line_item_first.totalsale < 0 ? lineitem_params[:totalsale]=@line_item_first.totalsale : lineitem_params[:totalsale].to_d+@line_item_first.totalsale ))\n @line_item_first.destroy if @line_item_first.quantity<=0\n respond_to do |format|\n format.json {head :no_content}\n end\n else\n @line_item = @ticket.LineItems.create(lineitem_params) \n end \n \n respond_to do |format|\n if @ticket.update_columns(total: @ticket.total+lineitem_params[:totalsale] < 0 ? 0 : @ticket.total+lineitem_params[:totalsale])\n format.json { head :no_content }\n else\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n chosen_product = Product.find(params[:line_item][:product_id])\n if @current_cart.products.include?(chosen_product)\n @line_item = @current_cart.line_items.find_by(product_id: chosen_product)\n @line_item.quantity += 1\n else\n @line_item = LineItem.create!(line_item_params)\n end\n\n @line_item.save\n respond_to do |format|\n format.html { redirect_to cart_path(@current_cart), notice: 'Item successfully added to cart!' }\n format.json { head :no_content }\n end\n end",
"def set_quantity(purchase, n, entry = find_or_create_item(purchase))\n\n if n == 0\n delete(entry)\n else\n entry.components.clear\n\n max_qty = maximum_quantity_allowed(purchase)\n\n if max_qty > n\n assign_components(entry, purchase, n)\n else\n assign_components(entry, purchase, max_qty)\n if !stock_available?(purchase, n)\n entry.errors.add(:quantity, \"There #{max_qty > 1 ? 'are' : 'is'} only #{max_qty} of this item available.\")\n elsif purchase_limited?(purchase)\n entry.errors.add(:quantity, \"This item is limited to #{purchase.purchase_limit} per customer.\")\n end\n end\n\n entry.quantity = entry.components.map(&:quantity).sum\n\n if entry.quantity == 0\n delete(entry)\n else\n entry.total = entry.components.reduce(SpookAndPuff::Money.new('0')) {|m, c| m + c.total }\n entry.pre_discount_total = entry.total\n end\n end\n\n entry\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_products(options)\n quantity = options[:quantity]\n is_bundle = options[:is_bundle]\n if (is_bundle)\n bundle = Bundle.find(options[:id])\n OrderItem.create!(order_id: self.id, bundle_id: bundle.id, quantity: quantity) #products of an bundle OrderItem are found through the association to the bundle\n else\n product = Product.find(options[:id])\n add_product(product, quantity)\n end\n end",
"def destroy\n\n if params[:product_id] then\n# TODO need to use @cart.id to ensure only this users line_item is accessed.\n current_item = LineItem.find_by_product_id(params[:product_id] )\n else\n current_item = LineItem.find(params[:id])\n end\n\n if current_item\n current_item.quantity -= 1\n puts current_item.quantity\n if current_item.quantity <= 0\n current_item.destroy\n else\n current_item.save\n end\n else\n current_item.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to store_url }\n format.json { head :no_content }\n end\n end",
"def set_product_quantities(quantities)\n quantities.each_pair do |product_id, quantity|\n quantity = quantity.to_i\n if quantity < 1\n BasketItem.where(basket_id: id, product_id: product_id).destroy_all\n else\n item = BasketItem.find_by(basket_id: id, product_id: product_id)\n if item\n item.quantity = quantity\n item.save\n else\n BasketItem.create(basket_id: id, product_id: product_id, quantity: quantity)\n end\n end\n end\n end",
"def update\n self.class.update_product_by_id(self.id, self)\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 @invoice = Invoice.find(params[:id])\n\n success = false\n begin\n ActiveRecord::Base.transaction do\n @invoice.destroy!\n @invoice = Invoice.new(invoice_params)\n sales = params[:invoice][:sales_attributes]\n success = false\n @invoice.pick_sales sales\n success = @invoice.save!\n end\n rescue ActiveRecord::RecordInvalid => ex\n puts ex\n rescue Existence::NotEnoughExistence => ex\n @invoice.errors.add :sales, \"Not Enough Existence\"\n end\n\n if success\n head :no_content\n else\n render json: {errors: @invoice.errors}, status: :unprocessable_entity\n end\n end",
"def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend",
"def change_delivery_drink_quantity\n # get data to add/update\n @data = params[:id]\n @data_split = @data.split(\"-\")\n @add_or_subtract = @data_split[0]\n @user_delivery_id = @data_split[1]\n \n # get User Delivery info\n @account = Account.find_by_id(current_user.account_id)\n @user_subscription = UserSubscriptionn.where(account_id: current_user.account_id, currently_active: true).first\n @user_delivery_info = UserDelivery.find_by_id(@user_delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n @inventory = Inventory.find_by_id(@user_delivery_info.inventory_id)\n \n # adjust drink quantity, price and inventory\n @original_quantity = @user_delivery_info.quantity\n @drink_price = @user_delivery_info.inventory. + @user_subscription.pricing_model\n @current_inventory_reserved = @inventory.reserved\n if @add_or_subtract == \"add\"\n # set new quantity\n @new_quantity = @original_quantity + 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal + @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved + 1\n @inventory.update(reserved: @new_inventory_reserved)\n\n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n \n else\n # set new quantity\n @new_quantity = @original_quantity - 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal - @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved - 1\n @inventory.update(reserved: @new_inventory_reserved)\n \n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n end\n \n # update delivery info and note a confirmation email should be sent\n @delivery.update(subtotal: @new_subtotal, sales_tax: @new_sales_tax, total_drink_price: @new_total_price, delivery_change_confirmation: false)\n \n # add change to the customer_delivery_changes table\n @customer_delivery_change = CustomerDeliveryChange.where(user_delivery_id: @user_delivery_id).first\n if !@customer_delivery_change.blank?\n @customer_delivery_change.update(new_quantity: @new_quantity, change_noted: false)\n else\n @new_customer_delivery_change = CustomerDeliveryChange.new(user_id: current_user.id, \n delivery_id: @user_delivery_info.delivery_id,\n user_delivery_id: @user_delivery_id,\n beer_id: @user_delivery_info.beer_id,\n original_quantity: @original_quantity,\n new_quantity: @new_quantity,\n change_noted: false)\n @new_customer_delivery_change.save!\n end\n \n # set new delivery details and delivery info\n @next_delivery = UserDelivery.where(delivery_id: @user_delivery_info.delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n \n # count number of drinks in delivery\n @drink_count = @next_delivery.sum(:quantity)\n # count number of drinks that are new to user\n @next_delivery_cooler = 0\n @next_delivery_cellar = 0\n @next_delivery_small = 0\n @next_delivery_large = 0\n # cycle through next delivery drinks to get delivery counts\n @next_delivery.each do |drink|\n @quantity = drink.quantity\n if drink.cellar == true\n @next_delivery_cellar += (1 * @quantity)\n else\n @next_delivery_cooler += (1 * @quantity)\n end\n if drink.large_format == true\n @next_delivery_large += (1 * @quantity)\n else\n @next_delivery_small += (1 * @quantity)\n end\n end \n \n respond_to do |format|\n format.js\n end # end of redirect to jquery\n end",
"def update\n order_items_params = {\n product_id: @order_item.product_id,\n order_id: @order_item.order_id,\n quantity: params[:quantity]\n} \n\nif @order_item.update(order_items_params)\n redirect_to order_path(@order_item.order_id)\n return\nend\nend",
"def return_item_to_stock(product_id)\n\t\tproduct = Product.find(product_id)\n\t\tproduct.stock += 1\n\t\tproduct.save\n\tend",
"def create_line_item\n\t\tset_sale\n\t\tpopulate_products\n\n\t\texisting_line_item = Item.where('product_id = ? AND sale_id = ?', params[:product_id], @sale.id).first\n\n\t\tif existing_line_item.blank?\n\t\t\tline_item = Item.new(product_id: params[:product_id], sale_id: params[:sale_id], quantity: params[:quantity])\n\t\t\tline_item.price = line_item.product.price\n\t\t\tline_item.save\n\n\t\t\tremove_item_from_stock(params[:product_id])\n\t\t\tupdate_line_item_totals(line_item)\n\t\telse\n\t\t\texisting_line_item.quantity += 1\n\t\t\texisting_line_item.save\n\n\t\t\tremove_item_from_stock(params[:product_id])\n\t\t\tupdate_line_item_totals(existing_line_item)\n\t\tend\n\n\t\tupdate_totals\n\n\t\trespond_to do |format|\n\t\t\tformat.js { ajax_refresh }\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @order_product.update(order_product_params)\n format.html { redirect_to order_path(@order_product.order), notice: 'Quantity updated.' }\n format.json { render :show, status: :ok, location: @order_product }\n else\n format.html { render :edit }\n format.json { render json: @order_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n @line_item.price = @line_item.catalog_item.unit_price\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n flash[:notice] = 'LineItem was successfully updated.'\n format.html { redirect_to(@line_item) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @line_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_quantity\n\t\t@user_basket = UserBasket.find(params[:id])\n\t\t@shop_product = ShopProduct.find_by(id: @user_basket.shop_product_id)\n\t @user_basket.quantity = params[:user_basket][:quantity].to_f\n\n\t # for checking quantity exists in shop_inventory\n\t if @shop_product.shop_inventory.quantity - @user_basket.quantity < 0\n\t\t\tflash[:danger] = 'Insufficient Quantity'\n\t\t\tredirect_to edit_user_basket_path and return\n\t\tend\n\n\t\tif (@shop_product.unit_type == 'packet' or @shop_product.unit_type == 'pcs') and \n\t\t\t@user_basket.quantity % 1 != 0\n\t\t\tflash[:danger] = 'Please enter whole numbers for packed products'\n\t\t\tredirect_to edit_user_basket_path and return\n\t\tend\n\n\t\tif @user_basket.update_attributes(user_baskets_params)\n\t\t\tflash[:success] = 'Quantity Updated'\n\t\t\tredirect_to edit_user_basket_path\n\t\telse\n\t\t flash[:danger] = 'Not Updated'\n\t\t\tredirect_to edit_user_basket_path\n\t\tend\t\n\tend",
"def decrease\n @line_item = @current_cart.line_items.where(:id => params[:line_item_id]).first\n if @line_item.count > 0\n @line_item.update_attribute :count, @line_item.count - 1\n else\n @line_item.destroy # destroy database record if quantity was decreased to 0\n end\n end",
"def move_sales_line( sales_line_id, target_order_id )\r\n sales_line = self.sales_lines.find sales_line_id\r\n target_order = self.customer.sales_orders.find target_order_id\r\n\r\n moving_qty = sales_line.remain_sales_physical\r\n if moving_qty.zero?\r\n self.errors.add :sales_lines, \"This sales line has been fully completed.\"\r\n return false\r\n end\r\n\r\n self.class.transaction( sales_line ) do\r\n # Move out sales line from original order\r\n sales_line.sales_qty -= moving_qty\r\n sales_line.remain_sales_physical -= moving_qty\r\n sales_line.save!\r\n self.mark_as_modified\r\n\r\n # Append sales_line to target order\r\n existing_line = target_order.sales_lines.find_by_item_id sales_line.item_id\r\n if existing_line.nil?\r\n target_order.sales_lines.create! :sales_qty => moving_qty, :item_id => sales_line.item_id\r\n else\r\n existing_line.sales_qty += moving_qty\r\n existing_line.remain_sales_physical += moving_qty\r\n existing_line.save!\r\n end\r\n target_order.mark_as_modified\r\n end\r\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"
] |
[
"0.7286502",
"0.72142226",
"0.7144943",
"0.7038057",
"0.6993245",
"0.697177",
"0.6956866",
"0.69196177",
"0.68746245",
"0.68467855",
"0.6830455",
"0.68247193",
"0.68189305",
"0.6801956",
"0.6786757",
"0.6782704",
"0.6778026",
"0.67523664",
"0.6694163",
"0.6694044",
"0.6693155",
"0.66867024",
"0.6686494",
"0.6663755",
"0.6661742",
"0.6646909",
"0.6637496",
"0.66166645",
"0.6604991",
"0.6601312",
"0.6571964",
"0.656545",
"0.6564474",
"0.65641695",
"0.65627307",
"0.6540151",
"0.6537755",
"0.65278405",
"0.6512979",
"0.650848",
"0.65015197",
"0.6501408",
"0.64824575",
"0.64488244",
"0.643366",
"0.6425581",
"0.6422373",
"0.6406203",
"0.64041394",
"0.63867813",
"0.6374144",
"0.63716686",
"0.63629997",
"0.6349478",
"0.63471043",
"0.6341266",
"0.6339821",
"0.63303566",
"0.6314438",
"0.6309981",
"0.6306513",
"0.629925",
"0.6296728",
"0.6294598",
"0.6277058",
"0.6262931",
"0.62624705",
"0.62496984",
"0.6249009",
"0.6245404",
"0.624078",
"0.62389666",
"0.62264884",
"0.618944",
"0.61860996",
"0.6185587",
"0.6182335",
"0.61815625",
"0.61814076",
"0.61709297",
"0.6167935",
"0.61648333",
"0.6147786",
"0.6142808",
"0.61330926",
"0.613151",
"0.6129064",
"0.6108299",
"0.61079603",
"0.60963696",
"0.6095221",
"0.6090268",
"0.6089966",
"0.6088276",
"0.6085273",
"0.6077056",
"0.60762626",
"0.607571",
"0.6066274",
"0.6065968"
] |
0.77470005
|
0
|
Move sales line with given id to another open order
|
def move_sales_line
=begin
sales_line = ERP::SalesLine.find params[:id]
@original_order_id = sales_line.erp_sales_order_id
sales_line.update_attribute :erp_sales_order_id, params[:target]
mark_as_unsync [@original_order_id, params[:target]]
=end
@sales_line = ERP::SalesLine.find params[:id]
@store_user.my_account_log(@sales_line,"Move Sales Line #{@sales_line.invent_trans_id} From #{@sales_line.sales_order.sales_id}")
if @sales_line && @sales_line.sales_order.erp_customer_id == @customer.id
@sales_line.move_to_order @customer.sales_orders.find( params[:target] )
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def move_sales_line( sales_line_id, target_order_id )\r\n sales_line = self.sales_lines.find sales_line_id\r\n target_order = self.customer.sales_orders.find target_order_id\r\n\r\n moving_qty = sales_line.remain_sales_physical\r\n if moving_qty.zero?\r\n self.errors.add :sales_lines, \"This sales line has been fully completed.\"\r\n return false\r\n end\r\n\r\n self.class.transaction( sales_line ) do\r\n # Move out sales line from original order\r\n sales_line.sales_qty -= moving_qty\r\n sales_line.remain_sales_physical -= moving_qty\r\n sales_line.save!\r\n self.mark_as_modified\r\n\r\n # Append sales_line to target order\r\n existing_line = target_order.sales_lines.find_by_item_id sales_line.item_id\r\n if existing_line.nil?\r\n target_order.sales_lines.create! :sales_qty => moving_qty, :item_id => sales_line.item_id\r\n else\r\n existing_line.sales_qty += moving_qty\r\n existing_line.remain_sales_physical += moving_qty\r\n existing_line.save!\r\n end\r\n target_order.mark_as_modified\r\n end\r\n end",
"def place_order\n @order = Order.new(order_params)\n @basket.line_items.map do |line_item|\n @order.line_items << line_item\n item.basket_id = nil\n\n dish = Dish.find(line_item.dish_id)\n dish.inventory -= line_item.quantity\n dish.save\n end\n @order.save\n @basket.destroy\n render Dish.all, status: :ok\n end",
"def merge!(order)\n if self.line_items.count > 0\n order.destroy\n else\n self.billing_address = self.billing_address || order.billing_address\n self.shipping_address = self.shipping_address || order.shipping_address\n order.line_items.each do |line_item|\n next unless line_item.currency == currency\n line_item.order_id = self.id\n line_item.save\n end\n\n end\n end",
"def delete_sales_line\r\n sales_line = ERP::SalesLine.find( params[:id], :include => \"sales_order\" )\r\n @store_user.my_account_log(sales_line,\"Delete Sales Line: #{sales_line.invent_trans_id} (#{sales_line.item_id})\")\r\n if @customer.open_orders.collect{|order| order.id}.include?( sales_line.sales_order.id ) && sales_line.modifiable?\r\n sales_line.destroy\r\n render :text => \"Deleted...\"\r\n else\r\n render :text => \"Failed to delete sales line (ID=#{params[:id]})\", :status => 500\r\n end\r\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 set_line_item\n @line_item = order.line_items.find(params[:id])\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def record_sales\n @deleted_lines.each {|l| l.delete}\n @deleted_lines.clear\n calc_values\n save\n @lines.each do |li|\n li.li_order_id = @data_object.order_id\n li.save\n end\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def update_order(result)\n create_asendia_shipment_record(result['Status'], result['Error'])\n @transaction_id = result['ParcelId']\n @tracking_number = nil\n shipment = @order.shipment\n shipment.tracking = @tracking_number\n shipment.save\n shipment.ship!\n @order.line_items.each do |line_item|\n @success_orders << [\"#{@order.number}, #{line_item.sku}, #{@tracking_number}, #{@transaction_id}, #{line_item.quantity}, #{@order.completed_at}, #{(@order.ship_address.country.try(:name) || '').delete(',')}\"]\n end\n end",
"def issue_unissue_po_line_items_when_so_and_cart_diffs(issue_cart)\n logger.debug \"==@@@@==SalesOrder: issue unissue(), issuce_cart.id==== #{issue_cart.id}\"\n # so line_items not in cart(will be removed), issueback po\n self.line_items.each do |so_line|\n if not issue_cart.line_items.where(line_number: so_line.line_number).exists?\n logger.debug \"==@@@@==line_items to be removed from so==== #{so_line.id}\"\n self.issue_back_refer_line_item(so_line, so_line.quantity)\n end\n end\n\n # cart line_items not in so(will be added), issue po\n issue_cart.line_items.each do |line_item|\n # cart line_items not in so: to be added to so\n if not self.line_items.where(line_number: line_item.line_number).exists?\n logger.debug \"==@@@@==new line, to be added to so==== #{line_item.id}\" \n self.issue_refer_line_item(line_item, line_item.quantity) \n else # exist, but quantity different\n line = self.line_items.where(line_number: line_item.line_number).take\n logger.debug \"==@@@@==exsit line, update po==== #{line_item.id}\"\n if line.quantity < line_item.quantity\n self.issue_refer_line_item(line_item, line_item.quantity - line.quantity)\n elsif line.quantity > line_item.quantity\n self.issue_back_refer_line_item(line_item, line.quantity - line_item.quantity) \n end\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 set_order_line_item\n @order_line_item = OrderLineItem.find(params[:id])\n end",
"def update\n @sales_order = SalesOrder.find(params[:id])\n\n # update delivery_status(includes reschedule devlivery_plan) \n if not params[:delivery_status]\n # if current_issue_cart.line_items.exists? \n @sales_order.issue_unissue_po_line_items_when_so_and_cart_diffs(current_issue_cart) \n\n @sales_order.line_items.clear\n @sales_order.add_line_items_from_issue_cart(current_issue_cart)\n @sales_order.save\n # Cart.destroy(session[:issue_cart_id])\n # session[:issue_cart_id] = nil \n # end \n end \n\n respond_to do |format|\n if @sales_order.update_attributes(params[:sales_order])\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully updated.' }\n format.json { head :no_content } \n else\n @orders = Order.where(customer_id: @sales_order.customer.id)\n @cart = current_issue_cart\n\n session[:cart_order_type] = \"SalesOrder\"\n session[:cart_order_id] = @sales_order.id\n\n format.html { render action: \"edit\", notice: 'Sales order can not update.' }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def shipped\n order = Order.second\n items = LineItem.where(order_id: order.id)\n items.each do |item|\n order.line_items << item\n end\n OrderNotifier.shipped(order)\n end",
"def move_item(id, to)\n record \"/todos/move_item/#{id}\", :to => to\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 set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def populate\n @order = current_order(session)\n variant_id = params[:variant_id]\n \n new_line_item = Breeze::Commerce::LineItem.new(:variant_id => variant_id, :quantity => params[:quantity] || 1)\n existing_line_item = @order.line_items.unarchived.where(:variant_id => variant_id).first \n if existing_line_item\n existing_line_item.quantity += new_line_item.quantity\n existing_line_item.save\n else\n @order.line_items << new_line_item\n end\n\n @order.save\n end",
"def convert_to_orders\n purchased_at = Time.zone.now\n line_items.includes(:item).each do |li|\n # TODO: Do this in memory\n order = Order.where(buyer_id: user_id, seller_id: li.item.user_id, purchased_at: purchased_at) \\\n .first_or_initialize(buyer_id: user_id, seller_id: li.item.user_id)\n order.line_items << li\n li.item.update_attribute(:sold, true)\n order.purchased_at = purchased_at unless order.persisted?\n orders << order unless orders.include? order\n order.save\n end\n # TODO this is not a great place for this... this entire method is\n # getting out of hand. Need a separate domain concept.\n orders.each do |order|\n OrderMailer.delay.sale_made_email(order.id)\n ReminderDeliveryWorker.perform_in(7.days, order.id) # Schedule review reminder\n end\n update_attribute(:purchased_at, purchased_at)\n save\n end",
"def create\n @sales_order = SalesOrder.new(params[:sales_order])\n @sales_order.add_line_items_from_issue_cart(current_issue_cart)\n\n # @sales_order.customer_id = session[:customer_id]\n respond_to do |format|\n if @sales_order.save\n\n @sales_order.issue_refer_line_items\n\n Cart.destroy(session[:issue_cart_id])\n session[:issue_cart_id] = nil\n\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully created.' }\n format.json { render json: @sales_order, status: :created, location: @sales_order }\n else\n @orders = Order.where(customer_id: @sales_order.customer.id)\n @cart = current_issue_cart\n\n session[:cart_order_type] = \"SalesOrder\"\n session[:cart_order_id] = @sales_order.id\n\n format.html { render action: \"new\" }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_order_item\n \n end",
"def handle_merge(current_line_item, other_order_line_item)\n if current_line_item\n current_line_item.quantity += other_order_line_item.quantity\n handle_error(current_line_item) unless current_line_item.save\n else\n order.line_items << other_order_line_item\n handle_error(other_order_line_item) unless other_order_line_item.save\n end\n end",
"def shift_up_orders()\n Feature.update_all('\"order\" = \"order\" - 1', '\"order\" > '+order.to_s)\n end",
"def merge!(other_order, user = nil)\n if other_order.currency == order.currency\n other_order.line_items.each do |other_order_line_item|\n current_line_item = find_matching_line_item(other_order_line_item)\n handle_merge(current_line_item, other_order_line_item)\n end\n end\n\n set_user(user)\n persist_merge\n\n # So that the destroy doesn't take out line items which may have been re-assigned\n other_order.line_items.reload\n other_order.destroy\n end",
"def moveStockDispatch(id,to,oc,price)\n body = {\n 'productoId': id,\n 'almacenId': to,\n 'oc': oc,\n 'precio': price\n }\n resp = Fetcher.Bodegas(\"POST\"+id.to_s+to.to_s,\"moveStockBodega\",body)\n end",
"def move_to(dest_position)\n return if self.orderable_position == dest_position\n\n pos = orderable_attribute\n con = orderable_condition\n\n self.class.transaction do\n if orderable_position < dest_position\n adj = \"#{pos} = #{pos} - 1\"\n con = con + [ \"#{pos} > #{orderable_position}\", \"#{pos} <= #{dest_position}\" ]\n else\n adj = \"#{pos} = #{pos} + 1\"\n con = con + [ \"#{pos} < #{orderable_position}\", \"#{pos} >= #{dest_position}\" ]\n end\n self.class.update( adj, :condition => con.join(' AND ') )\n self.orderable_position = dest_position\n update_attribute(orderable_attribute)\n end\n\n self\n end",
"def update_shipments_with_qb_ids(shipment_id, object)\n file_name = \"#{path.base_name}/#{path.pending}/shipments_#{shipment_id}_.json\"\n\n begin\n contents = amazon_s3.convert_download('json', amazon_s3.bucket.object(file_name).get.body.read)\n amazon_s3.bucket.object(file_name).delete\n rescue Aws::S3::Errors::NoSuchKey => _e\n puts \"File not found[update_shipments_with_qb_ids]: #{file_name}\"\n end\n\n contents.first['items'] = object[:extra_data]['line_items']\n .map do |item|\n item['sales_order_txn_line_id'] = item['txn_line_id']\n item['sales_order_txn_id'] = item['txn_id']\n item.delete('txn_line_id')\n item.delete('txn_id')\n item\n end\n\n contents.first['adjustments'] = object[:extra_data]['adjustments']\n .map do |item|\n item['sales_order_txn_line_id'] = item['txn_line_id']\n item['sales_order_txn_id'] = item['txn_id']\n item.delete('txn_line_id')\n item.delete('txn_id')\n item\n end\n\n amazon_s3.export file_name: file_name, objects: contents\n\n begin\n order_file_name = \"#{path.base_name}/#{path.ready}/orders_#{object[:object_ref]}_.json\"\n amazon_s3.bucket.object(order_file_name).delete\n rescue Aws::S3::Errors::NoSuchKey => _e\n puts \"File not found[delete orders]: #{file_name}\"\n end\n end",
"def set_sale_line\n @sale_line = SaleLine.find(params[:id])\n end",
"def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end",
"def set_order\n @order = Order.find(params[:id])\n #Также нужны переменные\n @client=Client.find(@order.client_id)\n @delivery=Delivery.find(@order.delivery_id)\n @employee=Employee.find(@order.employee_id)\n @ordered=Ordered.where(\"order_id=?\",@order.id)\n end",
"def add_to_line_item(line_item, variant, quantity, currency=nil, shipment=nil, price=nil)\n if line_item\n line_item.target_shipment = shipment\n line_item.quantity += quantity.to_i\n line_item.currency = currency unless currency.nil?\n line_item.save\n else\n line_item = order.line_items.new(quantity: quantity, variant: variant)\n # line_item = Spree::LineItem.new(quantity: quantity)\n line_item.target_shipment = shipment\n line_item.variant = variant\n if currency\n line_item.currency = currency unless currency.nil?\n line_item.price = price || variant.price_in(currency).amount\n else\n line_item.price = price || variant.price\n end\n # order.line_items << line_item\n # line_item\n end\n \n line_item.save\n order.reload\n line_item\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 ship_order\n self.update_attributes(status: 2)\n end",
"def edit_sales_order\n begin\n @sale = Sale.find(params[:id])\n rescue\n end\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 move(accountid, moveto, amount, confirms = 6)\n raise # TODO\n end",
"def rollback_item\n ingreso_producto = self.ingreso_producto\n ingreso_producto.cantidad = ingreso_producto.cantidad + self.cantidad\n ingreso_producto.producto.stock = ingreso_producto.producto.stock + self.cantidad #suma al stock si se anula\n Lineakardex.create(:kardex => ingreso_producto.producto.kardex, :tipo => \"Entrada\", :fecha => Time.now, :cantidad => self.cantidad, :v_unitario => self.ingreso_producto.producto.precio_venta, :modulo => \"Hospitalizacion\", :observaciones => \"Pedido Anulado\" )\n ingreso_producto.save\n ingreso_producto.producto.save\n end",
"def set_order\n @item = Order.find(params[:id])\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 addline(line, order)\n\t\t#steps.create(installation_id: self, line_id: line.id, order: order)\n\t\tactive_steps.create(line_id: line.id, order: order)\n\tend",
"def set_sales_order_detail\n @sales_order_detail = SalesOrderDetail.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n @delivery = Delivery.find(@order.delivery_id)\n end",
"def link_line_item(line_item)\n self.spree_line_item_id = line_item.id\n self.save!\n end",
"def mover_stock (producto, almacen)\n\t\tr = HTTParty.post(Integra2::STOCK_API_URL+'moveStock',\n\t\t{ \n\t\t:body => {\"productoId\" => producto, \"almacenId\" => almacen},\n\t\t:headers => {'Authorization' => generate_auth_hash('POST'+producto+almacen)}\n\t\t})\n\t\t#retorna Producto\n\tend",
"def send_order order_id\n order_to_send = @current_orders.find {|order| order.id.to_i == order_id.to_i}\n @order_history.push(@current_orders.delete(order_to_send))\n if order_to_send != nil\n send \"Your order is 1 hour away from arriving\"\n puts \"For kitchen: #{order_to_send.adress}\"\n puts \"For driver: #{order_to_send.array}\"\n end\n end",
"def move\n cart = get_cart\n cart.toggle_saved_for_later(params[:id])\n rescue Exception => e\n flash[:message] = 'Error: Could not move item between cart and saved items'\n ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver\n ensure\n redirect_to(:action => '')\n end",
"def removeline(step, order)\n\t\t#active_steps.find_by(line_id: line.id).destroy\n\t\tactive_steps.find_by(id: step.id).destroy\n\t\t\n\t\t#active_relationships.find_by(followed_id: other_user.id).destroy\n\t\t#steps.find_by(installation_id: self, line_id: line.id).destroy\n\tend",
"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 duplicate(qty_ordered, qty_received = nil, qty_issued = nil)\n new_item = OrderedLineItem.create!(self.attributes.merge({\n :quantity_ordered => qty_ordered, \n :quantity_received => qty_received, \n :issued_quantity => qty_issued,\n :date_received => nil\n }))\n new_item.line_item_no = self.line_item_no\n new_item.save!\n end",
"def set_event_order_line_item\n @event_order_line_item = EventOrderLineItem.preloaded_data.find(params[:id])\n end",
"def set_order\n @order = @circle.orders.find(params[:id])\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 set_order\n @order = Order.includes(:orderitems).find_by_id(params[:id])\n @order.subscribe(Orderlog.new)\n end",
"def set_order\n @order = Order.find(params[:id])\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 set_order\n @order = ShopOrder.find(params[:id])\n end",
"def process\n Trade::Shipment.where(taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id)\n .update_all(taxon_concept_id: @taxon_relationship.taxon_concept_id)\n end",
"def edit\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @sales_entry = @sales_order.active_sales_entries.where(:id => params[:id]).first\n @item = @sales_entry.item \n end",
"def order(params, id)\n db = database()\n cart = cart(id)\n i = 0\n time = Time.now.to_s[0..18]\n db.execute(\"INSERT INTO invoices (Sum, UserId, Timestamp) VALUES (?, ?, ?)\", params[\"sum\"].to_i, id, time)\n invoiceid = db.execute(\"SELECT Id FROM invoices WHERE Timestamp = ?\", time)\n cart.each do |item|\n print item\n db.execute(\"INSERT INTO pizza_invoice_relation (InvoiceId, PizzaId) VALUES (?, ?)\", invoiceid, item[2])\n end\n delete_cart(id)\n end",
"def assign_beer_to_line\n if (beer_id)\n beer = Beer.find(beer_id)\n previous_stock = beer.stock\n beer.stock = previous_stock -1\n beer.save\n end\n end",
"def add_line_item_to_order( variant )\n duplicate_line_item = line_item_exists?( variant )\n duplicate_line_item.quantity += 1 and return duplicate_line_item if duplicate_line_item\n\n line_items.build :name => variant.good.name, \n :price => variant.price, \n :options => variant.option_values_to_s,\n :sku => variant.sku\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order\n # finds the current order using the params\n @order = Order.find(params[:id])\n end",
"def delete_sales_entry_from_sales_order\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @sales_entry = @sales_order.active_sales_entries.where(:id => params[:object_to_destroy_id]).first\n \n @sales_order.delete_sales_entry( @sales_entry ) \n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def update_position(account_name, pos_id, order_qty, escrow)\n action \"set escrow for position(#{pos_id}) to #{escrow}\"\n p = get(pos_id)\n p.escrow += escrow\n p.order_qty += order_qty\n end",
"def set_order\n @cart = current_cart\n @order = Order.find(params[:id])\n @orders = Order.where(\"cart_id=? AND id<>?\", @cart.id, params[:id])\n end",
"def set_line_destination\n @line_destination = LineDestination.find(params[:id])\n end",
"def move_to_property(property_id, logged_user_id)\r\n property = Property.find(property_id)\r\n if (property.belongs_to_user(logged_user_id) && \r\n (self.property_id != property_id) && !property.is_closed )\r\n self.new_accommodation(property_id)\r\n self.update_autopays\r\n else\r\n return false\r\n end\r\n end",
"def set_order\n @order = Order.find(params[:id])\n OrderStateMgr.instance(self).set_curr_state(@order)\n end",
"def convert_to_order\n @order = self.wholesale_profile.orders.create(status: :draft)\n self.cart_items.each do |ci|\n pv = ProductVariant.find(ci.product_variant_id)\n @order.order_items.create(product_variant_id: pv.id, quantity: ci.quantity, line_item_total: (ci.quantity * pv.price_in_cents))\n end\n @invoice = @order.create_invoice\n if @order.update(status: :processing)\n self.cart_items.destroy_all\n end\n return @order\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def update_order\n if order.present?\n order.price = order.order_items.pluck(:total_price).sum rescue 0\n order.shipping_price = 0\n order.total_price = order.price + order.shipping_price\n order.save\n end\n end",
"def add_or_create_line_item(item_id)\n if line_item = self.line_items.find_by(item_id: item_id)\n line_item.increment\n line_item\n else\n LineItem.new(cart_id: self.id, item_id: item_id)\n end\n end",
"def set_order\n @order = @restaurant.orders.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end"
] |
[
"0.7951165",
"0.6301795",
"0.62164396",
"0.62020606",
"0.6030135",
"0.6030135",
"0.60238665",
"0.60203403",
"0.5993305",
"0.5978917",
"0.5947596",
"0.5893678",
"0.5888943",
"0.5830033",
"0.5809828",
"0.57957757",
"0.5781215",
"0.5753478",
"0.5739659",
"0.5739659",
"0.5689915",
"0.5676306",
"0.5671368",
"0.56665343",
"0.5655741",
"0.5647035",
"0.56303376",
"0.56126267",
"0.56040496",
"0.56008875",
"0.55573803",
"0.5538972",
"0.5515631",
"0.54850763",
"0.546946",
"0.5468968",
"0.546195",
"0.5455859",
"0.54499835",
"0.5444464",
"0.543489",
"0.54227614",
"0.54199505",
"0.53829086",
"0.537959",
"0.5374128",
"0.53625727",
"0.5362523",
"0.5356102",
"0.53527915",
"0.53334063",
"0.5331221",
"0.5328255",
"0.5309587",
"0.530476",
"0.5303468",
"0.52832735",
"0.52752125",
"0.52713805",
"0.5267225",
"0.5258811",
"0.52585834",
"0.5251183",
"0.5251045",
"0.5245685",
"0.5245685",
"0.5240648",
"0.5237778",
"0.5217731",
"0.5217584",
"0.52136916",
"0.5210891",
"0.52093214",
"0.5208252",
"0.52066714",
"0.5204584",
"0.5197007",
"0.5191836",
"0.51845473",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925",
"0.5177925"
] |
0.75429773
|
1
|
Commit changes of sales order with given id to AX server.
|
def commit_order
order = @customer.open_orders.find params[:id]
unless !order.commit
headers['Content-Type'] = 'text/plain'
render :text => "Failed to connect with AX server."
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def commit_orders\r\n orders = @customer.open_orders.find_all_by_synchronized( false )\r\n sales_id = \"\"\r\n orders.each do |o| sales_id += \"'#{o.sales_id}', \" end \r\n @store_user.my_account_log(@customer,\"Commit Sales Order Updates: #{sales_id}\")\r\n\r\n if orders.empty? || ERP::SalesOrder.commit_orders( orders )\r\n flash.now[:message] = \"All changes have been commited.\"\r\n else\r\n flash.now[:message] = \"Operation Failed.\"\r\n end\r\n end",
"def commit\r\n self.class.commit_orders [self]\r\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def updateTransaction(state, id)\n parameters={state: state}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4050/transactions/\" + id.to_s , options) # put pending state\n return results\n end",
"def update_sales_invoice(id, options)\n put(\"sales_invoices/#{id}\", sales_invoice: options)\n end",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all' })\n all_orders = orders[:items]\n all_orders.each do |order|\n unless order[:status].present?\n order_id = order[:increment_id]\n id = order[:entity_id]\n status = order[:state]\n params = {\n entity_id: id,\n increment_id: order_id,\n status: status,\n }\n if status\n Magento2::Api.put(\"/rest/en/V1/orders/create\", {entity: params})\n end\n end\n end\n end",
"def commit(id)\n Commit.new(connection, { :id => id, :repo => self })\n end",
"def commit(id = nil)\n get_object :commit, id\n end",
"def commit(id = nil)\n get_object :commit, id\n end",
"def move_sales_line\r\n=begin\r\n sales_line = ERP::SalesLine.find params[:id]\r\n @original_order_id = sales_line.erp_sales_order_id\r\n sales_line.update_attribute :erp_sales_order_id, params[:target]\r\n \r\n mark_as_unsync [@original_order_id, params[:target]]\r\n=end\r\n @sales_line = ERP::SalesLine.find params[:id]\r\n @store_user.my_account_log(@sales_line,\"Move Sales Line #{@sales_line.invent_trans_id} From #{@sales_line.sales_order.sales_id}\")\r\n if @sales_line && @sales_line.sales_order.erp_customer_id == @customer.id\r\n @sales_line.move_to_order @customer.sales_orders.find( params[:target] )\r\n end\r\n end",
"def commit (id)\n params = {\n :id => id\n }\n requires params\n DataSift.request(:POST, 'list/replace/commit', @config, params)\n end",
"def commit(id)\n @commit = @repo.commit(id)\n raise(Ginatra::InvalidCommit.new(id)) if @commit.nil?\n add_refs(@commit,{})\n @commit\n end",
"def move_sales_line( sales_line_id, target_order_id )\r\n sales_line = self.sales_lines.find sales_line_id\r\n target_order = self.customer.sales_orders.find target_order_id\r\n\r\n moving_qty = sales_line.remain_sales_physical\r\n if moving_qty.zero?\r\n self.errors.add :sales_lines, \"This sales line has been fully completed.\"\r\n return false\r\n end\r\n\r\n self.class.transaction( sales_line ) do\r\n # Move out sales line from original order\r\n sales_line.sales_qty -= moving_qty\r\n sales_line.remain_sales_physical -= moving_qty\r\n sales_line.save!\r\n self.mark_as_modified\r\n\r\n # Append sales_line to target order\r\n existing_line = target_order.sales_lines.find_by_item_id sales_line.item_id\r\n if existing_line.nil?\r\n target_order.sales_lines.create! :sales_qty => moving_qty, :item_id => sales_line.item_id\r\n else\r\n existing_line.sales_qty += moving_qty\r\n existing_line.remain_sales_physical += moving_qty\r\n existing_line.save!\r\n end\r\n target_order.mark_as_modified\r\n end\r\n end",
"def update_shipments_with_qb_ids(shipment_id, object)\n file_name = \"#{path.base_name}/#{path.pending}/shipments_#{shipment_id}_.json\"\n\n begin\n contents = amazon_s3.convert_download('json', amazon_s3.bucket.object(file_name).get.body.read)\n amazon_s3.bucket.object(file_name).delete\n rescue Aws::S3::Errors::NoSuchKey => _e\n puts \"File not found[update_shipments_with_qb_ids]: #{file_name}\"\n end\n\n contents.first['items'] = object[:extra_data]['line_items']\n .map do |item|\n item['sales_order_txn_line_id'] = item['txn_line_id']\n item['sales_order_txn_id'] = item['txn_id']\n item.delete('txn_line_id')\n item.delete('txn_id')\n item\n end\n\n contents.first['adjustments'] = object[:extra_data]['adjustments']\n .map do |item|\n item['sales_order_txn_line_id'] = item['txn_line_id']\n item['sales_order_txn_id'] = item['txn_id']\n item.delete('txn_line_id')\n item.delete('txn_id')\n item\n end\n\n amazon_s3.export file_name: file_name, objects: contents\n\n begin\n order_file_name = \"#{path.base_name}/#{path.ready}/orders_#{object[:object_ref]}_.json\"\n amazon_s3.bucket.object(order_file_name).delete\n rescue Aws::S3::Errors::NoSuchKey => _e\n puts \"File not found[delete orders]: #{file_name}\"\n end\n end",
"def update_order(result)\n create_asendia_shipment_record(result['Status'], result['Error'])\n @transaction_id = result['ParcelId']\n @tracking_number = nil\n shipment = @order.shipment\n shipment.tracking = @tracking_number\n shipment.save\n shipment.ship!\n @order.line_items.each do |line_item|\n @success_orders << [\"#{@order.number}, #{line_item.sku}, #{@tracking_number}, #{@transaction_id}, #{line_item.quantity}, #{@order.completed_at}, #{(@order.ship_address.country.try(:name) || '').delete(',')}\"]\n end\n end",
"def mark_as_delivered\n order = Order.find(params[:id])\n order.delivered_at = DateTime.now\n order.save!\n redirect_to orders_path\n end",
"def send_order order_id\n order_to_send = @current_orders.find {|order| order.id.to_i == order_id.to_i}\n @order_history.push(@current_orders.delete(order_to_send))\n if order_to_send != nil\n send \"Your order is 1 hour away from arriving\"\n puts \"For kitchen: #{order_to_send.adress}\"\n puts \"For driver: #{order_to_send.array}\"\n end\n end",
"def save\n @connection.transactions.save\n end",
"def update_order (changes)\n authenticated_post(\"auth/w/order/update\", params: changes).body\n end",
"def record_sales\n @deleted_lines.each {|l| l.delete}\n @deleted_lines.clear\n calc_values\n save\n @lines.each do |li|\n li.li_order_id = @data_object.order_id\n li.save\n end\n end",
"def save(id)\n self.trans_id = id\n self.save!\n end",
"def update\n @sales_order = SalesOrder.find(params[:id])\n\n # update delivery_status(includes reschedule devlivery_plan) \n if not params[:delivery_status]\n # if current_issue_cart.line_items.exists? \n @sales_order.issue_unissue_po_line_items_when_so_and_cart_diffs(current_issue_cart) \n\n @sales_order.line_items.clear\n @sales_order.add_line_items_from_issue_cart(current_issue_cart)\n @sales_order.save\n # Cart.destroy(session[:issue_cart_id])\n # session[:issue_cart_id] = nil \n # end \n end \n\n respond_to do |format|\n if @sales_order.update_attributes(params[:sales_order])\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully updated.' }\n format.json { head :no_content } \n else\n @orders = Order.where(customer_id: @sales_order.customer.id)\n @cart = current_issue_cart\n\n session[:cart_order_type] = \"SalesOrder\"\n session[:cart_order_id] = @sales_order.id\n\n format.html { render action: \"edit\", notice: 'Sales order can not update.' }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def perform(shipment_id)\n shp = Shipment.find(shipment_id)\n file_path = Setting.get(shp.order.domain_id, :ecommerce, \"Edi Path\")\n file_path += \"/incoming/tracking/tracking_#{DateTime.now.strftime(\"%F_%H%M%S\")}.txt\"\n\n s = StringIO.new\n\n shp.items.each do |i|\n s << [shp.order.external_order_id,\n \"Invoice ID\",\n i.order_item.item_number,\n i.quantity,\n \"SHIPPED\",\n shp.recipient_name,\n shp.ship_date,\n shp.carrier.sub(\"FedExSmartPost\", \"FedEx SmartPost\"),\n shp.ship_method,\n shp.tracking_number,\n \"\", \"\", \"\", \"\"\n ].join(\"\\t\")\n s << \"\\n\"\n end\n\n File.write(file_path, s.string)\n end",
"def commit\n sanity_check\n @handle.commit\n end",
"def save\n\t\t@connection.transactions.save\n\tend",
"def commit()\n check_return_code(PureHailDB.ib_trx_commit(@trx_ptr))\n end",
"def set_order\n @order = Order.includes(:orderitems).find_by_id(params[:id])\n @order.subscribe(Orderlog.new)\n end",
"def commit\n validate_params\n\n client = AdminModule::Client.new\n client.env = env\n\n if self.respond_to? action\n self.send(action, client)\n return\n else\n raise \"Unknown action - #{action}\"\n end\n\n rescue Exception => e\n raise e if stop_on_exception == true\n ensure\n client.quit\n end",
"def commit\n validate_params\n\n client = AdminModule::Client.new\n client.env = env\n\n if self.respond_to? action\n self.send(action, client)\n return\n else\n raise \"Unknown action - #{action}\"\n end\n\n rescue Exception => e\n raise e if stop_on_exception == true\n ensure\n client.quit\n end",
"def sell\n self.save\n customer_name = self.find_customer_name\n customer_funds = self.find_customer_funds\n customer_funds -= self.find_price\n if customer_funds < 0 || !self.tickets_available?\n self.delete\n return\n end\n sql = 'UPDATE customers\n SET name = $1, funds = $2\n WHERE id = $3'\n values = [ customer_name, customer_funds, @customer_id ]\n SqlRunner.run( sql, values )\n end",
"def order(params, id)\n db = database()\n cart = cart(id)\n i = 0\n time = Time.now.to_s[0..18]\n db.execute(\"INSERT INTO invoices (Sum, UserId, Timestamp) VALUES (?, ?, ?)\", params[\"sum\"].to_i, id, time)\n invoiceid = db.execute(\"SELECT Id FROM invoices WHERE Timestamp = ?\", time)\n cart.each do |item|\n print item\n db.execute(\"INSERT INTO pizza_invoice_relation (InvoiceId, PizzaId) VALUES (?, ?)\", invoiceid, item[2])\n end\n delete_cart(id)\n end",
"def update\n @order = Order.find(params[:id])\n redirect_to :action => \"index\" and return if current_admin.limited_sales_rep && !current_admin.users.include?(@order.user)\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to(admin_orders_url, :notice => 'Order was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def moveStockDispatch(id,to,oc,price)\n body = {\n 'productoId': id,\n 'almacenId': to,\n 'oc': oc,\n 'precio': price\n }\n resp = Fetcher.Bodegas(\"POST\"+id.to_s+to.to_s,\"moveStockBodega\",body)\n end",
"def update\n @sale_order = current_company.sale_orders.find(params[:id])\n\n respond_to do |format|\n if @sale_order.update_attributes(params[:sale_order])\n format.html { redirect_to sale_orders_path, notice: 'Sale order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_order(order_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/orders/{order_id}',\n 'default')\n .template_param(new_parameter(order_id, key: 'order_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def apply_to_order(user, order, session)\n cc = @data_object\n cc.cc_order_id = order.order_id\n pay = gen_payment\n $store.transaction do \n pay.apply_to_order(user, order, cc.cc_amount, session)\n cc.cc_pay_id = pay.pay_id\n save\n end\n end",
"def commit()\n #This is a stub, used for indexing\n end",
"def update\n @sale_order = SaleOrder.find(params[:id])\n\n respond_to do |format|\n if @sale_order.update_attributes(params[:sale_order])\n flash[:notice] = 'SaleOrder was successfully updated.'\n format.html { redirect_to(@sale_order) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sale_order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(invoice_number, invoice_sequence)\n #xml = order_update_template % { status: status.to_i }\n #put_request(t_url(:order, order_id), xml)\n end",
"def update\n respond_to do |format|\n if @sales_order.update(sales_order_params)\n format.html { \n flash[:notice] = 'La Orden de Venta se actualizó satisfactoriamente.'\n redirect_to sales_orders_path\n }\n format.json { render :show, status: :ok, location: @sales_order }\n else\n format.html { \n flash[:error] = @sales_order.errors\n redirect_to edit_sales_order_path(@sales_order.id)\n }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_delivery_mode\r\n sales_order = @customer.open_orders.find_by_id( params[:id] )\r\n sales_order.delivery_mode_id = params[:delivery_mode_id]\r\n render :text => sales_order.save\r\n end",
"def commit\n # no op\n end",
"def set_order_transaction\n @order_transaction = OrderTransaction.find(params[:id])\n end",
"def commit(soft_commit = false)\n session.commit soft_commit\n end",
"def commit(action, params = {})\n unless VALID_ACTIONS.include? action.to_sym\n raise \"Invalid action\"\n end\n @action = action\n @params = params\n \n conn = Faraday.new(:url => API_URL) do |c|\n c.request :soap\n c.response :soap, \"item\"\n c.adapter :net_http\n end\n \n request = conn.post do |r|\n r.body = format_params_for_fantastico\n r.headers = {'Content-Type' => 'text/xml; charset=utf-8'}\n end\n \n response = request.body\n \n @success = !(response.is_a?(Hash) && response.has_key?(\"faultcode\"))\n \n response\n end",
"def purchase(id)\n response = Shippo::API.post(\"#{url}/#{CGI.escape(id)}/purchase\")\n self.from(response)\n end",
"def delete_sales_line\r\n sales_line = ERP::SalesLine.find( params[:id], :include => \"sales_order\" )\r\n @store_user.my_account_log(sales_line,\"Delete Sales Line: #{sales_line.invent_trans_id} (#{sales_line.item_id})\")\r\n if @customer.open_orders.collect{|order| order.id}.include?( sales_line.sales_order.id ) && sales_line.modifiable?\r\n sales_line.destroy\r\n render :text => \"Deleted...\"\r\n else\r\n render :text => \"Failed to delete sales line (ID=#{params[:id]})\", :status => 500\r\n end\r\n end",
"def commit(request, options)\n requires!(options, :soap_action)\n \n\t response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, build_request(request, options),\n\t {\"SOAPAction\" => options[:soap_action],\n\t \"Content-Type\" => \"text/xml; charset=utf-8\" }))\n \n # puts response.inspect if test?\n \n\t success = response[:transaction_result][:status_code] == \"0\"\n\t message = response[:transaction_result][:message]\n authorization = success ? [ options[:order_id], response[:transaction_output_data][:cross_reference], response[:transaction_output_data][:auth_code] ].compact.join(\";\") : nil\n \n IridiumResponse.new(success, message, response, \n :test => test?, \n :authorization => authorization,\n :avs_result => { :code => response[:avsCode] },\n :cvv_result => response[:cvCode],\n :three_d_secure => response[:transaction_result][:status_code] == \"3\",\n :pa_req => (response[:transaction_output_data][:three_d_secure_output_data][:pa_req] rescue \"\"),\n :md => (response[:transaction_output_data][:cross_reference] rescue \"\"),\n :acs_url => (response[:transaction_output_data][:three_d_secure_output_data][:acsurl] rescue \"\")\n )\n end",
"def send_commit\n post_to_solr({},true)\n end",
"def set_ordertransaction\n @ordertransaction = Ordertransaction.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n OrderStateMgr.instance(self).set_curr_state(@order)\n end",
"def _commit_externals \n __pack[:stubs].each_with_index do |obj_hash, index|\n obj = obj_hash[:id]\n if obj.commit\n obj_hash[:id] = obj.id\n else\n if obj.id\n self._warnings << \"Unable to save latest version of #{obj.inspect}, stubbed at index #{index}\"\n obj_hash[:id] = obj.id if obj.id \n else \n self._warnings << \"Unable to save #{obj.inspect}, stubbed at index #{index}\" \n end \n end \n end \n end",
"def set_order\n @order = ShopOrder.find(params[:id])\n end",
"def commit\n IBM_DB.commit(@conn)\n end",
"def set_order\n @order = Order.find(params[:id])\n #Также нужны переменные\n @client=Client.find(@order.client_id)\n @delivery=Delivery.find(@order.delivery_id)\n @employee=Employee.find(@order.employee_id)\n @ordered=Ordered.where(\"order_id=?\",@order.id)\n end",
"def set_sent_order\n @sent_order = SentOrder.find(params[:id])\n end",
"def commit\n solr_service_connection.commit\n end",
"def commit!\n _commit( false )\n end",
"def pay\n raise \"Only ajax request.\" if !request.xhr?\n begin\n @order = Order.find(params[:id])\n @order.status = 'Paid'\n if @order.save\n head :ok\n else\n head :unprocessable_entity\n end\n rescue\n head :unprocessable_entity\n end\n end",
"def update_sales_order\n begin\n @customer_info = Sale.find(params[:id])\n @customer_info.update_attributes(params[:sale])\n @customer_info.payments.each do|sale_payment|\n sale_payment.update_attributes(:paid_amount=>params[:payments][:cash_amount], :next_pay_date=>params[:payments][:next_pay_date], :pay_date=> @customer_info.date) if sale_payment.pay_mode == \"cash\"\n cheque_payment = Payment.cheque_update(@customer_info,params[:payments]) if sale_payment.pay_mode == \"cheque\"\n sale_payment.update_attributes(:paid_amount=>params[:payments][:transfer_amount], :next_pay_date=>params[:payments][:next_pay_date], :pay_date=> @customer_info.date, :transfer_to_account_no=> params[:payments][:transfer_to_acount_no]) if sale_payment.pay_mode == \"transfer\"\n sale_payment.update_attributes(:paid_amount=>params[:payments][:card_paid_amount],:next_pay_date=>params[:payments][:next_pay_date], :pay_date=> @customer_info.date) if sale_payment.pay_mode == \"card\"\n end\n names = params[:product][:name]\n product_descs = params[:product][:description]\n serial_numbers = params[:product][:serial_number]\n service_types = params[:product][:service_type]\n quantities = params[:product][:quantity]\n rates = params[:product][:rate]\n index =0\n \n @customer_info.sale_products.each do |sale_product|\n product = Product.find(names[index])\n if (sale_product.product_reference_type == \"ProductSerialNumber\" && !serial_numbers[index].blank?)\n serial_number = ProductSerialNumber.find(sale_product.serial_number_reference_id)\n serial_number.update_attributes(:is_sold => false)\n end\n\n if !serial_numbers[index].blank?\n serial_no2 = ProductSerialNumber.find(serial_numbers[index])\n if( !serial_no2.nil?)\n serial_no2.update_attributes( :is_sold => true)\n sale_product.update_attributes(:product_reference_type =>\"ProductSerialNumber\")\n end\n else\n sale_product.update_attributes( :product_reference_type =>\"Product\")\n end\n sale_product.update_attributes(:product_reference_id => product_descs[index], :quantity => quantities[index], :rate => rates[index],:service_type_id => service_types[index],:serial_number_reference_id => serial_numbers[index] )\n index=index+1\n end\n redirect_to sales_sales_register_path\n rescue\n redirect_to home_path\n end\nend",
"def commit\n query 'commit'\n self\n end",
"def update\n respond_to do |format|\n if @sales_order.update(sales_order_params)\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully updated.' }\n format.json { render :show, status: :ok, location: @sales_order }\n else\n format.html { render :edit }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(id, params)\n wrapped_params = { address: params }\n\n @client.make_request(:put, \"end_shippers/#{id}\", MODEL_CLASS, wrapped_params)\n end",
"def tx_commit(&block)\n @connection.send_frame(Protocol::Tx::Commit.encode(@id))\n\n self.redefine_callback :tx_commit, &block\n self\n end",
"def commit(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\", [[\"commit\", \"true\"]])\n req = HTTP::Post.new(uri)\n response = @client.send_http(req, true, ['200'])\n end",
"def set_sales_order_detail\n @sales_order_detail = SalesOrderDetail.find(params[:id])\n end",
"def commit\n db_interface.commit\n end",
"def solr_commit\n Solarize::Post.execute(Solr::Request::Commit.new)\n end",
"def commit_transaction(tx)\n tx.execute\n end",
"def shipped(order)\n @order = order\n\n puts \">> shipped order email sent\"\n\n mail to: @admin_email, subject: 'Pragmatic Store Order Shipped'\n end",
"def commit!\n rsp = post(\"<commit/>\")\n success?(rsp.body) or log_error(rsp.body)\n end",
"def create\n @stock=Stock.find(params[:stock][:id])\n params[:sales_order_detail][:stock_id]=@stock.id\n @sales_order_detail = SalesOrderDetail.new(sales_order_detail_params)\n @stock.update(:quantity=>(@stock.quantity-(params[:sales_order_detail][:quantity]).to_i))\n\n if params[:commit]=='Save'\n if @sales_order_detail.save\n @sales_order=@sales_order_detail.sales_order\n @sales_order.update(:status=>'Finished', :total_amount=>@sales_order.sales_order_details.sum(:amount))\n respond_to do |format|\n if @sales_order\n format.html { redirect_to @sales_order, notice: 'Sales order Created' }\n else\n format.html { redirect_to new_sales_order_detail_path+'?status=Start&id='+@sales_order.id.to_s, :alert=> 'Sorry, Please Try Again...' }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to new_sales_order_detail_path+'?status=Start&id='+params[:sales_order_detail][:sales_order_id], :alert=> 'Sorry, Please Try Again...' }\n end\n end\n else\n respond_to do |format|\n if @sales_order_detail.save\n format.html { redirect_to new_sales_order_detail_path+'?status=Start&id='+params[:sales_order_detail][:sales_order_id], notice: 'Sales order detail was successfully created.' }\n else\n format.html { redirect_to new_sales_order_detail_path+'?status=Start&id='+params[:sales_order_detail][:sales_order_id], :alert=> 'Sorry, Please Try Again...' }\n end\n end\n end\n end",
"def putTransaction( entity_id, user_id, basket_total, basket, currency, notes)\n params = Hash.new\n params['entity_id'] = entity_id\n params['user_id'] = user_id\n params['basket_total'] = basket_total\n params['basket'] = basket\n params['currency'] = currency\n params['notes'] = notes\n return doCurl(\"put\",\"/transaction\",params)\n end",
"def commit\n @repo.commit\n end",
"def cancel_transaction\n @dps_pxpay_id = params[:id]\n zencartdps_pxpay_record = ActiveRecord::Base.connection.update(\n \"UPDATE zencartdps_pxpay SET success = 0, response_text = '' WHERE dps_pxpay_id = #{@dps_pxpay_id}\"\n )\n if zencartdps_pxpay_record > 0\n flash[:notice] = 'The transaction was cancelled'\n else\n flash[:error] = 'An error happened. The transaction was not cancelled'\n end\n\n redirect_to :action => :new_order, :id => @dps_pxpay_id\n end",
"def archive(id:)\n client.execute(method: :put, path: \"/live_events/#{id}/archive\")\n end",
"def update\n @invoice = Invoice.find(params[:id])\n\n success = false\n begin\n ActiveRecord::Base.transaction do\n @invoice.destroy!\n @invoice = Invoice.new(invoice_params)\n sales = params[:invoice][:sales_attributes]\n success = false\n @invoice.pick_sales sales\n success = @invoice.save!\n end\n rescue ActiveRecord::RecordInvalid => ex\n puts ex\n rescue Existence::NotEnoughExistence => ex\n @invoice.errors.add :sales, \"Not Enough Existence\"\n end\n\n if success\n head :no_content\n else\n render json: {errors: @invoice.errors}, status: :unprocessable_entity\n end\n end",
"def update_sales_line_qty\r\n sales_line = ERP::SalesLine.find params[:id]\r\n result = sales_line.update_sales_qty( params[:value].to_i )\r\n @store_user.my_account_log(sales_line,\"Update Sales Line Qty: #{sales_line.invent_trans_id} (#{sales_line.item_id}), returns #{result}\")\r\n render :text => result\r\n end",
"def update_sales_entry\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @sales_entry = @sales_order.active_sales_entries.where(:id => params[:id]).first\n \n @quantity = params[:sales_entry][:quantity].to_i\n @selling_price_per_piece = BigDecimal( params[:sales_entry][:selling_price_per_piece] )\n \n @new_object = @sales_entry.update_item( @quantity, @selling_price_per_piece)\n @has_no_errors = @new_object.errors.messages.length == 0 \n \n @item = @sales_entry.item\n end",
"def commit_transaction(conn)\n log_info(TRANSACTION_COMMIT)\n conn.commit\n end",
"def update(sObject, updated_values)\n #updated_account = Hash[\"name\" => \"Test Account -- Updated\", \"id\" => \"a00A0001009zA2m\"] # Nearly identical to an insert, but we need to pass the salesforce id.\n\n #puts updated_values\n #puts sObject\n #records_to_update.push(updated_account)\n Salesforce.updateRecord(@salesforceBulk, sObject, updated_values)\n end",
"def process\n Trade::Shipment.update_all(\n { taxon_concept_id: @taxon_relationship.taxon_concept_id },\n {\n taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id\n }\n )\n end",
"def update\n @mws_order = MwsOrder.find(params[:id])\n \n\t\tmessage = ''\n\t\tresponse = @mws_order.reprocess_order\n\t\tif response.is_a?(Numeric)\n\t\t\tr = MwsResponse.find(response)\n\t\t\tmessage += \"response_id #{r.id} #{r.error_code}: #{r.error_message}\"\n\t\tend\n\n respond_to do |format|\n \tformat.html { redirect_to @mws_order, notice: \"Amazon order reprocessed. #{message}\" }\n format.json { render json: @mws_order }\n end\n end",
"def set_state_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:state_id, @customer.state_id)\n end",
"def delete_sales_entry_from_sales_order\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @sales_entry = @sales_order.active_sales_entries.where(:id => params[:object_to_destroy_id]).first\n \n @sales_order.delete_sales_entry( @sales_entry ) \n end",
"def write\n @id = store.put(self)\n end",
"def sales_order(record, _params)\n <<-XML\n\n <CustomerRef>\n <FullName>#{record['email']}</FullName>\n </CustomerRef>\n <TxnDate>#{Time.parse(record['placed_on']).to_date}</TxnDate>\n <RefNumber>#{record['id']}</RefNumber>\n <BillAddress>\n <Addr1>#{record['billing_address']['address1']}</Addr1>\n <Addr2>#{record['billing_address']['address2']}</Addr2>\n <City>#{record['billing_address']['city']}</City>\n <State>#{record['billing_address']['state']}</State>\n <PostalCode>#{record['billing_address']['zipcode']}</PostalCode>\n <Country>#{record['billing_address']['country']}</Country>\n </BillAddress>\n <ShipAddress>\n <Addr1>#{record['shipping_address']['address1']}</Addr1>\n <Addr2>#{record['shipping_address']['address2']}</Addr2>\n <City>#{record['shipping_address']['city']}</City>\n <State>#{record['shipping_address']['state']}</State>\n <PostalCode>#{record['shipping_address']['zipcode']}</PostalCode>\n <Country>#{record['shipping_address']['country']}</Country>\n </ShipAddress>\n #{cancel_order?(record)}\n XML\n end",
"def commit\n update\n end",
"def write_order(order, request_body = nil)\n path = \"/checkout/orders\"\n path += \"/#{order.id}\" if order.id\n\n request_body ||= order.to_json\n response = https_connection.post do |req|\n req.url path\n\n req.headers['Authorization'] = \"Klarna #{sign_payload(request_body)}\"\n req.headers['Accept'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json',\n req.headers['Content-Type'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json'\n req.headers['Accept-Encoding'] = ''\n\n req.body = request_body\n end\n handle_status_code(response.status, response.body)\n response\n end",
"def update\n @order = Order.find(params[:id])\n @order.update_attributes(params[:order])\n redirect_to orders_path\n end",
"def commit\n begin\n update_response = @streaming_update_server.commit\n rescue org.apache.solr.common.SolrException => e\n @logger.error(\"SolrException while committing updates\")\n @logger.error(\"#{e.message}\")\n @logger.error(\"#{e.backtrace}\")\n end\n end",
"def mark_shipped\n @orderproduct = OrderProduct.find(params[:current_order_product].to_i)\n @orderproduct.shipped = true\n @orderproduct.save\n\n redirect_to selling_history_path\n end",
"def update(id, params)\n if valid_data?(params)\n update_execution('accounts', params, id)\n else\n print(\"ERROR: couldn't insert account data\")\n end\n end",
"def place_order\n @order = Order.new(order_params)\n @basket.line_items.map do |line_item|\n @order.line_items << line_item\n item.basket_id = nil\n\n dish = Dish.find(line_item.dish_id)\n dish.inventory -= line_item.quantity\n dish.save\n end\n @order.save\n @basket.destroy\n render Dish.all, status: :ok\n end",
"def update_purchase_order(purchase_order, options={})\n raise(ArgumentError, \"purchase order has the wrong type\") unless purchase_order.is_a?(Invoicexpress::Models::PurchaseOrder)\n\n if !purchase_order.id\n raise ArgumentError, \"Purchase Order ID is required\"\n end\n params = { :klass => Invoicexpress::Models::PurchaseOrder, :body => purchase_order.to_core_purchase_order }\n put(\"purchase_orders/#{purchase_order.id}.xml\", params.merge(options))\n end",
"def commit\n writer.commit\n end",
"def save_order\n @order = Order.new(params[:order]) \n @order.line_items << @cart.items \n if @order.save \n @cart.empty!\n redirect_to_index('Thank you for your order.')\n else\n render(:action => 'checkout') \n end\n end",
"def commit mutations, transaction: nil\n mode = transaction.nil? ? :NON_TRANSACTIONAL : :TRANSACTIONAL\n service.commit project_id: project, database_id: database, mode: mode,\n mutations: mutations, transaction: transaction\n end",
"def update\n @sorder = Sorder.find(params[:id])\n\n respond_to do |format|\n if @sorder.update_attributes(params[:sorder])\n format.html { redirect_to @sorder, notice: '成功更新场地申请表.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sorder.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.706133",
"0.61689913",
"0.58067054",
"0.58067054",
"0.5658508",
"0.55772775",
"0.5566188",
"0.5561589",
"0.5535155",
"0.5535155",
"0.5525487",
"0.55223143",
"0.54974896",
"0.54317796",
"0.53934306",
"0.5352393",
"0.5285899",
"0.52817357",
"0.52787346",
"0.52727956",
"0.5267516",
"0.5265559",
"0.52450824",
"0.52297163",
"0.52269596",
"0.52016246",
"0.51851386",
"0.5184199",
"0.51796025",
"0.51796025",
"0.5161667",
"0.51428175",
"0.51200813",
"0.51146996",
"0.50968695",
"0.50890964",
"0.50855386",
"0.5081533",
"0.5058752",
"0.5055097",
"0.50479025",
"0.5038786",
"0.5021682",
"0.5011697",
"0.50105816",
"0.49971288",
"0.49954146",
"0.49880952",
"0.49859616",
"0.49846536",
"0.4977768",
"0.49735546",
"0.49674636",
"0.49652275",
"0.49631175",
"0.49602157",
"0.49581656",
"0.495106",
"0.4942508",
"0.49373746",
"0.49366388",
"0.49363473",
"0.4933929",
"0.49274805",
"0.49236512",
"0.49210468",
"0.4917722",
"0.49166486",
"0.49119687",
"0.49035415",
"0.48997024",
"0.48897573",
"0.48826167",
"0.4870561",
"0.48703942",
"0.48680633",
"0.48646188",
"0.4862966",
"0.48548803",
"0.48465076",
"0.48435345",
"0.4833816",
"0.48194116",
"0.48129135",
"0.48116255",
"0.48110986",
"0.48086393",
"0.48068348",
"0.48063397",
"0.48041958",
"0.48022428",
"0.4802133",
"0.48002708",
"0.47997084",
"0.47968495",
"0.47934955",
"0.4787509",
"0.47872344",
"0.47847497",
"0.47835535"
] |
0.7198284
|
0
|
Commit all changed orders under customer's account
|
def commit_orders
orders = @customer.open_orders.find_all_by_synchronized( false )
sales_id = ""
orders.each do |o| sales_id += "'#{o.sales_id}', " end
@store_user.my_account_log(@customer,"Commit Sales Order Updates: #{sales_id}")
if orders.empty? || ERP::SalesOrder.commit_orders( orders )
flash.now[:message] = "All changes have been commited."
else
flash.now[:message] = "Operation Failed."
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def commit\r\n self.class.commit_orders [self]\r\n end",
"def submit_order!\n @customer_order.transaction do\n cache_addresses!\n mark_deliveries_as_pending!\n cache_billing_address! unless @customer_order.anon_billing_address?\n update_subtotal_items!\n assign_submitted_at!\n submitted!\n end\n end",
"def commit_order\r\n order = @customer.open_orders.find params[:id]\r\n \r\n unless !order.commit\r\n headers['Content-Type'] = 'text/plain'\r\n render :text => \"Failed to connect with AX server.\"\r\n end\r\n end",
"def update_order (changes)\n authenticated_post(\"auth/w/order/update\", params: changes).body\n end",
"def apply_to_order(user, order, session)\n cc = @data_object\n cc.cc_order_id = order.order_id\n pay = gen_payment\n $store.transaction do \n pay.apply_to_order(user, order, cc.cc_amount, session)\n cc.cc_pay_id = pay.pay_id\n save\n end\n end",
"def update_order_detail_accounts\n order_details.each do |od|\n od.account = account\n od.save!\n end\n end",
"def finalize(customer_for)\n begin\n ActiveRecord::Base.transaction do\n self.imported_orders.each do |order|\n order.processed_by = self.processed_by\n io = order.from_import\n sold_on = io.transaction_date\n # if a non-nil customer ID is specified, assign to that customer; else create new\n cid = customer_for[order.id.to_s].to_i\n if (cid != 0)\n order.finalize_with_existing_customer_id!(cid, self.processed_by, sold_on)\n self.existing_customers += 1\n else # create new customer\n customer = Customer.new(:first_name => io.first, :last_name => io.last,\n :email => io.email, :ticket_sales_import => self)\n order.finalize_with_new_customer!(customer, self.processed_by, sold_on)\n self.new_customers += 1\n end\n self.tickets_sold += order.ticket_count\n end\n self.completed = true\n self.save!\n true\n end # transaction block\n rescue Order::OrderFinalizeError => e\n raise e\n rescue ActiveRecord::RecordInvalid => e\n raise e\n rescue StandardError => e\n raise e\n end\n end",
"def submit_orders_to_suppliers(customer, orders)\n raise ArgumentError unless customer.is_a? Customer and orders.is_a? Array\n\n # Submit each wine order to the revelant supplier\n orders.each do |order|\n RestClient.post \"#{order[:wine].supplier.url}orders\", {\n name: customer.name,\n address: customer.address,\n email: customer.email,\n upc: order[:wine].upc,\n quantity: order[:quantity]\n }.to_json, content_type: :json do |response|\n case response.code\n when 200, 201\n session[:basket].clear\n else\n #TODO: log an error\n puts 'error oh nooooo'\n end\n end\n end\n end",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all' })\n all_orders = orders[:items]\n all_orders.each do |order|\n unless order[:status].present?\n order_id = order[:increment_id]\n id = order[:entity_id]\n status = order[:state]\n params = {\n entity_id: id,\n increment_id: order_id,\n status: status,\n }\n if status\n Magento2::Api.put(\"/rest/en/V1/orders/create\", {entity: params})\n end\n end\n end\n end",
"def synchronize_customers\n fetch_shopify_customers.each do |shp_cus|\n create_customer(shp_cus)\n end\n end",
"def customer\n @orders = Spree::Order.where(user_id: current_spree_user.id, state: 'complete').where.not(shipment_state: 'shipped', state: 'returned').order(created_at: :desc)\n end",
"def update\n @customer = current_user.customers.find(params[:id])\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n @customer.orders.create(:user_id => @customer.user.id, \n :total => params[:total], :name => @customer.name, :phone => @customer.phone,\n :address => @customer.address, :instruction => params[:instruction]) if params[:order] == 'true'\n format.html { redirect_to(@customer, :notice => 'Customer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @customer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def activate_orders(token, coupon,card_id)\n order_with_coupon = self.orders.where(\"state = ? and coupon_id is not ?\", \"paused\", nil).first\n order_with_coupon.assign_attributes(coupon_id: coupon[\"id\"]) if coupon.present? && order_with_coupon.present?\n order_with_coupon.assign_attributes(coupon_id: nil) if order_with_coupon.present? && coupon.blank?\n\n\n if order_with_coupon.present?\n order_with_coupon.save(validate: false)\n order_with_coupon.update_total_and_item_total\n end\n\n paused_orders = self.orders.where(state: 'paused')\n\n paused_orders.each_with_index do |order, index|\n order.assign_attributes(state: \"confirm\",\n delivery_date: FIRST_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 0\n order.assign_attributes(state: \"confirm\",\n delivery_date: SECOND_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 1\n order.assign_attributes(state: \"confirm\",\n delivery_date: THIRD_DELIVERY_DAYS.days.from_now, subscription_token: token, is_blocked: false) if index == 2\n order.assign_attributes(creditcard_id: card_id)\n order.save(validate: false)\n end\n end",
"def submit_order\n @order = current_order(session)\n\n # Set customer, if any\n if customer_signed_in?\n @order.customer = current_store_customer\n else\n if params[:create_new_account]\n @order.customer = create_customer(@order, params[:new_account_password], store)\n end\n end\n\n @order.update_attributes params[:order] # SHouldn't need this as well as save below\n @order.billing_status_id = Breeze::Commerce::OrderStatus.where(:type => :billing, :name => \"Payment in process\").first.id\n\n\n if @order.save \n # Process payment with PxPay\n @payment = create_payment(@order, store)\n if @payment.save and redirectable?\n redirect_to @payment.redirect_url and return\n else\n Rails.logger.debug @payment.errors.to_s\n @payment.errors.each { |attrib, err| Rails.logger.debug attrib.to_s + ': ' + err.to_s }\n flash[:error] = \"Sorry, we can't reach the payment gateway right now.\" # This error message might not be accurate!\n redirect_to breeze.checkout_path and return\n end\n else\n @customer = current_store_customer || Breeze::Commerce::Customer.new\n render :action => \"checkout\"\n end\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def order_history\r\n @orders = @customer.close_orders\r\n end",
"def payment\n @orders = current_user.orders.all\n @orders.map do |order|\n order.update_attribute(:paid, true)\n order.save \n end\n redirect_to products_path\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end",
"def update!\n update_totals\n update_payment_state\n # update_adjustments\n # update totals a second time in case updated adjustments have an effect on the total\n update_totals\n \n update_attributes_without_callbacks({\n :state => \"complete\"\n }) \n \n logger.info 'UPDATED ORDER'\n # update_hooks.each { |hook| self.send hook }\n end",
"def cancel!\n logger.debug 'Cancel all orders'\n canceled_orders = client.cancel_orders\n logger.debug \"Orders canceled #{canceled_orders.count}\"\n end",
"def update\n authenticate_customer!\n # We put this in the session in case the user adds an authentication.\n tpauth = Authentication.find session[:customer_oauth_id]\n if tpauth\n @customer = current_customer\n @customer.update_attributes(params[:customer])\n @customer.authentications << tpauth\n @customer.save\n redirect_to edit_customer_registration_path(@customer), :notice => \"Account Updated!\"\n else\n redirect_to customer_sign_in_path, \"You need to authenticate first.\"\n end\n end",
"def apply_changes\n\t\t@admin_manager.CommitChanges\n\tend",
"def of_update_charge_account_from_order\n order = params[:order]\n projects = projects_dropdown\n charge_account_id = 0\n store_id = 0\n if order != '0'\n @order = WorkOrder.find(order)\n @project = @order.project\n @charge_account = @order.charge_account\n charge_account_id = @charge_account.id rescue 0\n @store = @order.store\n store_id = @store.id rescue 0\n if @charge_account.blank?\n @charge_account = @project.blank? ? projects_charge_accounts(projects) : charge_accounts_dropdown_edit(@project)\n end\n if @store.blank?\n @store = project_stores(@project)\n end\n else\n @charge_account = projects_charge_accounts(projects)\n @store = stores_dropdown\n end\n @json_data = { \"charge_account\" => @charge_account, \"store\" => @store,\n \"charge_account_id\" => charge_account_id, \"store_id\" => store_id }\n render json: @json_data\n end",
"def commit_and_filter(order)\n response = commit(order)\n\n remove_cc_from_response_hash(response) if @options[:clean_cc_from_response]\n\n response\n end",
"def si_update_charge_account_from_order\n order = params[:order]\n projects = projects_dropdown\n charge_account_id = 0\n store_id = 0\n if order != '0'\n @order = WorkOrder.find(order)\n @project = @order.project\n @charge_account = @order.charge_account\n charge_account_id = @charge_account.id rescue 0\n @store = @order.store\n store_id = @store.id rescue 0\n if @charge_account.blank?\n @charge_account = @project.blank? ? projects_charge_accounts(projects) : charge_accounts_dropdown_edit(@project)\n end\n if @store.blank?\n @store = project_stores(@project)\n end\n else\n @charge_account = projects_charge_accounts(projects)\n @store = stores_dropdown\n end\n @json_data = { \"charge_account\" => @charge_account, \"store\" => @store,\n \"charge_account_id\" => charge_account_id, \"store_id\" => store_id }\n render json: @json_data\n end",
"def transfer_funds()\n vendor = Portfolio.find(self.seller_id)\n customer = Portfolio.find(self.buyer_id)\n amount = self.transaction_cost\n customer.balance -= amount\n vendor.balance += amount\n \n Transactor.transaction do \n raise \"Transaction of funds failed!\" unless customer.save && vendor.save\n end\n end",
"def update\n @ordered.each do |ord|\n #уничтожаем все объекты из таблице многие ко многим, чтобы обновление было корректно\n if @order.id==ord.order_id\n Ordered.find(ord.id).destroy\n end\n end\n respond_to do |format|\n if @order.update(order_params_update)\n format.html { redirect_to @order, notice: 'Информация о заказе была успешно обновлена.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def allow_customer_specific_changes\n cust_no_arr = session[:account_switcher_array].map { |session_data| session_data.scan(/\\d+/).first }\n cust_name_arr = session[:account_switcher_array].map { |session_data| session_data.split(session_data.scan(/\\d+/).first).last.gsub(/[[:space:]]/, ' ').strip }\n customer_records = Hash[cust_no_arr.zip(cust_name_arr)]\n bin_center_list = get_default_bin_center(\"default_kit_bin_center\")\n part_bin_center_list = get_default_bin_center(\"default_part_bin_center\")\n crib_part_bin_center_list = get_default_bin_center(\"default_crib_part_bin_center\")\n kitting_type_list = get_default_bin_center(\"kitting_type\")\n customer_records.each do |cust_no,cust_name|\n customer = Kitting::CustomerConfigurations.find_or_create_by_cust_no(cust_no: cust_no)\n customer.update_attributes(:cust_name =>cust_name,:updated_by => current_customer.id,:non_contract_part => check_config(\"non_contract_check\",cust_no),:multiple_part => check_config(\"multiple_part\",cust_no),:prevent_kit_copy => check_config(\"prevent_kit_copy\",cust_no), :default_kit_bin_center => set_default_bin_center(bin_center_list,cust_no), :default_part_bin_center => set_default_bin_center(part_bin_center_list,cust_no), :default_crib_part_bin_center => set_default_bin_center(crib_part_bin_center_list,cust_no), :kitting_type => set_default_bin_center(kitting_type_list,cust_no), :invoicing_required => check_config(\"invoicing_required\",cust_no))\n @error = \"ERROR WHILE SAVING RECORD\" unless customer.save\n end\n if @error.present?\n flash[:error] = \"ERROR WHILE UPDATING RECORDS.\"\n else\n flash[:notice] = \"Successfully Updated the Changes\"\n end\n redirect_to :back\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 update_customer(customer)\n respond_with customer.to_vaulted_billing\n end",
"def update_customer(customer)\n respond_with customer.to_vaulted_billing\n end",
"def void_pending_authorizations\n self.transactions.authorized.pending.each do |t|\n t.account.void(t.authorization)\n end\n end",
"def checkout\n @order = current_order\n @order.order_status_id = 2\n if @order.update_attributes(order_params)\n\n if @order.agreement\n @payment = PaymentChoice.find(@order.payment_choice_id)\n\n if @payment.name == \"Braintree\"\n @order.order_status_id = 6\n @order.save\n create_braintree_payment @order.total, @order, params[\"payment_method_nonce\"]\n\n elsif @payment.name == \"Stripe\"\n @order.order_status_id = 6\n @order.save\n create_stripe_payment params[:stripeEmail], params[:stripeToken], @order.total, @order\n\n else\n @order.decrease_inventory\n @order.placed_on = DateTime.now\n @order.save\n session.delete :order_id\n OrderMailer.confirmation_mail(@order).deliver_later\n @token = DownloadToken.create(:expires_at => Time.now + 24.hours)\n flash[:success] = \"Order placed successfully\"\n if current_user\n redirect_to confirm_order_path(@order, :token => @token.token)\n else\n redirect_to thanks_path :token => @token.token\n end\n end\n\n else\n flash[:danger] = \"Sorry, your order could not be completed\"\n redirect_to cart_path\n end\n\n else\n flash[:danger] = \"Sorry, your order could not be completed\"\n redirect_to cart_path\n end\n end",
"def logging_in\n orders = guest_user.orders.all\n orders.each do |order|\n order.user_id = current_user.id\n order.save!\n puts order.inspect\n end\n end",
"def sync( tag = nil )\r\n if tag == :all\r\n nodes = get_all_records\r\n else\r\n end_time = Time.now\r\n start_time = end_time - 20.day\r\n nodes = self.search_by_modified_date( start_time, end_time )\r\n end\r\n \r\n # TODO:\r\n # 1. Require a processing thread from ThreadPool\r\n # 2. Synchronize customer with given Account Num.\r\n # 3. Exception handler for each process. Serialize record if failed for severial times (Save to DB?)\r\n \r\n ERP::ThreadPool.new(@options[:threads], nodes).start do |customer_node|\r\n account_num = customer_node.search( 'AccountNum' ).inner_html\r\n output_log \"Synchronizing customer \\\"#{account_num}\\\" ...\"\r\n begin\r\n ERP::Customer.transaction do\r\n #sales_order = sales_orders.find_by_sales_id( sales_id ) || sales_orders.build( :sales_id => sales_id )\r\n #if sales_order.new_record? || ax_modstamp(node) > sales_order.erp_modstamp\r\n #BUG: \r\n customer = ERP::Customer.find_by_account_num( account_num ) || ERP::Customer.new( :account_num => account_num )\r\n if customer.new_record? || ax_modstamp(customer_node) > customer.erp_modstamp\r\n output_log \"#{account_num} Prepare to Sync Customer Account\"\r\n customer.synchronize # recursively syncs sales orders and sales lines\r\n end\r\n end\r\n rescue => e\r\n\t\t\t raise e\r\n output_log \"#{account_num} synchronized failed!!!\"\r\n unsynchronized_customer( account_num )\r\n end\r\n end\r\n end",
"def update_customer_details\n\n # Make the order in final state to add specific validations\n @order.is_final\n \n if @order.update_attributes(params[:order])\n redirect_to confirm_order_path(@order)\n else\n render :edit_customer_details\n end\n end",
"def customer_status_updated(invoice) \n @invoice = invoice\n mail(:to => invoice.customer.email, :subject => 'Order status update')\n end",
"def complete_transactions!\n pending_transactions.each do |transaction|\n ActiveRecord::Base.transaction do\n transaction.entries.create!(amount: transaction.amount, entry_type: 'D', transaction: transaction, account: Account.mimo_assets)\n transaction.entries.create!(amount: transaction.amount, entry_type: 'C', transaction: transaction, account: wallet)\n transaction.destination_user = self\n transaction.complete! unless transaction.completed?\n end\n transaction.source_user.send_pending_sent_transfer_completed(transaction)\n self.send_pending_received_transfer_completed(transaction)\n end\n end",
"def confirm_all_pending_purchases\r\n self.pending_purchases.each{|purchase| purchase.confirm}\r\n end",
"def sync_all_orders_qoo10(orders)\n @message = []\n @cart_numbers = []\n begin\n orders.each do |ord|\n if !ord.products.present?\n @order = nil\n @shpping_address = nil\n @billing_address = nil\n @is_customer_pickup = nil\n order = ord.market_place_details\n @order = Spree::Order.find_by_market_place_order_no(order[\"orderNo\"]) if order.present?\n if @order.present? && order.present?\n gift = order[\"Gift\"].present? ? false : true\n shipping_country = Spree::Country.find_by_iso(order[\"shippingCountry\"])\n billing_country = Spree::Country.find_by_iso(order[\"senderNation\"])\n name = order[\"receiver\"].present? ? order[\"receiver\"] : (order[\"buyer\"].present? ? order[\"buyer\"] : \"NA\")\n telno = order[\"receiverTel\"].present? ? order[\"receiverTel\"] : (order[\"buyerTel\"].present? ? order[\"buyerTel\"] : \"NA\")\n mobileno = order[\"receiverMobile\"].present? ? order[\"receiverMobile\"] : (order[\"buyerMobile\"].present? ? order[\"buyerMobile\"] : \"NA\")\n if order[\"OrderType\"] == \"Pickup\"\n @is_customer_pickup = true\n # our singapore warehouse address\n address1 = \"151 Pasir Panjang Road\"\n address2 = \"#02-02 Pasir Panjang Distripark\"\n zipcode = \"118480\"\n phone = \"+65 6271 0524\"\n @order.shipping_address.update_attributes(:firstname=> name, :lastname=> name, :address1=> address1, :address2=> address2,\n :city=> shipping_country.name, :zipcode=> zipcode, :phone=> phone, :alternative_phone=> \"\", :country_id=> shipping_country.id,\n :state_name=> shipping_country.name)\n if order[:Addr1].present?\n @order.billing_address.update_attributes(:firstname=> name, :lastname=> name, :address1=> order[\"Addr1\"], :address2=> order[\"Addr2\"],\n :city=> shipping_country.name, :zipcode=> order[\"zipCode\"], :phone=> telno, :alternative_phone=> mobileno, :country_id=> shipping_country.id,\n :state_name=> shipping_country.name)\n end\n else\n @is_customer_pickup = false\n @order.shipping_address.update_attributes(:firstname=> name, :lastname=> name,\n :address1=> order[\"Addr1\"], :address2=> order[\"Addr2\"],\n :city=> shipping_country.name, :zipcode=> order[\"zipCode\"],\n :phone=> telno, :alternative_phone=> mobileno,\n :country_id=> shipping_country.id, :state_name=> shipping_country.name)\n end\n if !order[\"senderName\"].present? && !order[\"senderAddr\"].present? && !order[\"senderNation\"].present? && !order[\"senderZipCode\"].present? && !order[\"senderTel\"].present? && !billing_country.nil?\n @order.billing_address.update_attributes(:first_name=> order[\"senderName\"], :lastname=>\"\",\n :address1=> order[\"senderAddr\"], :address2=>\"\",\n :city=> billing_country.name, :zipcode=> order[\"senderZipCode\"],\n :phone=> order[\"senderTel\"], :alternative_phone=>\"\",\n :country_id=> billing_country.id, :state_name=> billing_country.name)\n end\n billing_address = (!@order.billing_address.nil? && !@order.billing_address.blank?) ? @order.billing_address.id : nil\n @mp_product = nil\n @line_item = nil\n @stock = nil\n @mp_product = Spree::SellersMarketPlacesProduct.find_by_market_place_product_code(order[\"itemCode\"])\n @order.update_attributes(:number=> order[\"orderNo\"], :order_date=> order[\"PaymentDate\"], :item_total=> order[\"orderPrice\"],\n :total=> order[\"total\"], :payment_total=> order[\"total\"],\n :email=> order[\"buyerEmail\"], :currency=> order[\"Currency\"],\n :send_as_gift=> gift, :market_place_id=> @mp_product.present? ? @mp_product.market_place_id : nil,\n :market_place_order_no=> order[\"orderNo\"],\n :bill_address_id=> billing_address, :ship_address_id=> @order.shipping_address.id)\n #@order.adjustments.first.update_attributes(:amount=> -order[\"discount\"].to_f, :label=> \"discount\") if @order && @order.adjustments.present? && order[\"discount\"].to_f != 0.0\n if @mp_product.present? && @order.present?\n if order[\"option\"] == \"\"\n # options not present i.e. for product\n @variant = Spree::Variant.find_by_sku(@mp_product.product.sku)\n if !@mp_product.nil? && !@mp_product.blank? && !@variant.nil? && !@variant.blank?\n @line_item = Spree::LineItem.create!(:variant_id=> @variant.id, :order_id=> @order.id, :quantity=> order[\"orderQty\"].to_i, :price=> order[\"orderPrice\"], :currency=> order[\"Currency\"], :is_pick_at_store => @is_customer_pickup)\n @stock = @mp_product.product.stock_products.first\n end\n else\n # options are present i.e. for variant\n #option_arr = order[\"option\"].split(\"(\")[0].split(\":\")\n option_arr = order[:option].split(\":\")\n if option_arr[1].split(\"(+\").count > 1\n option_arr[1] = option_arr[1].split(\"(+\")[0]\n elsif option_arr[1].split(\"(-\").count > 1\n option_arr[1] = option_arr[1].split(\"(-\")[0]\n end\n @variant = nil\n @mp_product.product.variants.each do |v|\n @variant = v if !v.option_values.blank? && (v.option_values.map(&:presentation).include?option_arr[1].strip)\n end if !@mp_product.nil? && @mp_product.product && @mp_product.product.option_types && !@mp_product.product.option_types.blank? && (@mp_product.product.option_types.map(&:presentation).include?option_arr[0])\n if !@mp_product.nil? && !@mp_product.blank? && !@variant.nil? && !@variant.blank?\n @line_item = Spree::LineItem.create!(:variant_id=> @variant.id, :order_id=> @order.id, :quantity=> order[\"orderQty\"].to_i, :price=> order[\"orderPrice\"], :currency=> order[\"Currency\"], :is_pick_at_store => @is_customer_pickup)\n @stock = @mp_product.product.stock_products.where(\"variant_id=?\", @variant.id).first\n end\n end\n # to reduce the stock after placing the order\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[\"orderQty\"].to_i) >= 0 ? (@stock.count_on_hand - order[\"orderQty\"].to_i) : 0 ) if @stock\n # code to reduce the kit quantity after order placed for kit as product\n @product = @mp_product.product\n if @product.kit.present? && @product.present?\n @product.kit.update_attributes(:quantity => @product.kit.quantity - order[\"orderQty\"].to_i)\n end\n # reload the order object\n @order.reload\n # add cart number into array\n @cart_numbers << order[\"packNo\"]\n end\n end\n @message << (@order && @order.present? ? (@order.market_place_order_no.to_s+\": \"+ \"Success\") : nil)\n end # end of if product does not exist\n end # end of orders loop\n rescue Exception => e\n @message << e.message\n end\n # take only unique cart number from array\n @cart_numbers = @cart_numbers.uniq\n # pass the array to method which can clubbed the orders according to cart number and then push to FBA\n @message << \"FBA: \"+ Spree::Order.push_to_fba(@cart_numbers)\n return @message.join(\"; \")\n end",
"def orders\n authenticated_post(\"orders\").body\n end",
"def amend_customer\n # we should have a current customer.\n cust = current_customer\n if (cust)\n auth = request.env[\"omniauth.auth\"]\n # We should only have one of these.\n oauths = Authentication.where(:provider => auth[\"provider\"],\n :uid => auth[\"uid\"],\n :customer_id.ne => nil,\n :master => nil).order(\"created_at desc\").all\n oauth = nil\n oauths.each do |oa|\n if oa.customer == cust\n if oauth.nil?\n oauth = oa\n else\n # Be proactive resilience here and get rid of this one. We should not have multiples\n logger.error(\"sessions#ammend_customer: getting rid of multiple customer authentications.\")\n oa.destroy()\n end\n else\n redirect_to edit_customer_registration_path(cust), :alert => \"This authentication belongs to different customer.\"\n return\n end\n end\n if oauth\n # Already added\n redirect_to edit_customer_registration_path(cust), :notice => \"This authentication already exists\"\n else\n oauth = Authentication.create_with_omniauth(auth)\n cust.authentications << oauth\n cust.save\n # We do not change the current_customer_authentication.\n redirect_to edit_customer_registration_path(cust), :notice => \"Authentication Added.\"\n end\n else\n redirect_to customer_sign_in_path, :notice => \"Need to sign in first.\"\n end\n end",
"def update!(orders)\n raise 'Must be a Set' unless orders.is_a? Set\n\n logger.info \"Update with #{orders.to_a.join(',')}\"\n Order::SIDES.map do |side|\n update_by_side!(side, orders.filter { |o| o.side.to_s == side.to_s })\n end.flatten.compact\n end",
"def sell\n self.save\n customer_name = self.find_customer_name\n customer_funds = self.find_customer_funds\n customer_funds -= self.find_price\n if customer_funds < 0 || !self.tickets_available?\n self.delete\n return\n end\n sql = 'UPDATE customers\n SET name = $1, funds = $2\n WHERE id = $3'\n values = [ customer_name, customer_funds, @customer_id ]\n SqlRunner.run( sql, values )\n end",
"def set_customer_order\n @customer_order = CustomerOrder.find(params[:id])\n end",
"def set_order\n \tcustomer = Customer.find(params[:customer_id])\n \t@order = customer.orders.find(params[:id])\n\n \t#*TEST- Currently using Fictious customer 5 as a test\n \t# @order = Order.find(params[:id])\n\n\n # @order = Order.find(params[:id])\n # respond_with (@orders)\n\n\n end",
"def perform_changes\n Token.where(stake_currency_id: @pax_stake_currency_id).find_in_batches(batch_size: 100) do |token_batches|\n @client_ids_array = []\n token_batches.each do |token|\n unless token['client_id'].present?\n fail 'invalid client id'\n end\n current_client_id = token['client_id']\n @client_ids_array.push(current_client_id)\n debug_data = {\"disassociation_reason\": \"Removing all economies whose stake currency is PAX\"}\n Token.where(client_id: current_client_id).update_all(client_id_was: current_client_id, client_id: nil, debug: debug_data.to_json)\n Workflow.where(client_id: current_client_id, kind: GlobalConstant::Workflow.token_deploy).update_all(unique_hash: nil)\n end\n\n change_client_related_flags\n KitSaasSharedCacheManagement::TokenDetails.new(@client_ids_array).clear\n CacheManagement::WorkflowByClient.new(@client_ids_array).clear\n end\n end",
"def my_account\n @orders = current_customer.orders.includes(:product).in_order || []\n end",
"def redsys_confirm\n logger.info \"==== REDSYS#CONFIRM ==== order##{params[:order_id]} params# #{params.inspect}\"\n @order ||= Spree::Order.find_by_number!(params[:order_id])\n if check_signature\n unless @order.payments.any?(&:completed?)\n payment_upgrade\n @order.updater.update_payment_total\n end\n @order.next\n if @order.completed?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(@order)\n else\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to checkout_state_path(@order.state) and return\n end\n else\n flash[:alert] = Spree.t(:spree_gateway_error_flash_for_checkout)\n redirect_to checkout_state_path(@order.state)\n end\n end",
"def void_pending_expired_authorizations\n self.transactions.authorized.pending.expired.each do |t|\n t.account.void(t.authorization)\n end\n end",
"def call_buy_orders(item)\n buy_orders_copy = Array.new\n @buy_orders.each{ |buy_order| buy_orders_copy << buy_order } #NOTE by urs: need to copy array, because a buy_order deletes itself directly from @buy_orders when done!\n buy_orders_copy.each{ |buy_order|\n buy_order.item_changed(item)\n }\n end",
"def create\n # creates a new order which belongs to the current customer and contains fields which have values equal to\n # parameters accessed from the order_params hash\n @order = current_customer.orders.new(order_params)\n # sets the total_cost of the order to 0\n @order.total_cost = 0\n # calculates the total_cost of the order by calculating the sum of the cost of the line_items which the\n # basket that the current customer owns contains\n current_customer.basket.line_items.each do |item|\n # the total_cost of the order must be increased by the price of the game which the line_item belongs to\n @order.total_cost += item.game.price\n # the order_id of the line_item is equal to the id of the order which is currently being created\n item.order_id = Order.last.id + 1\n # the basket_id of the line_item is set to nil because the line_item is removed from the basket which\n # belongs to the current customer and is added to the order\n item.basket_id = nil\n # the total cost of the basket which the current customer owns is decreased by the price of the game which\n # the line_item belongs to\n current_customer.basket.total_cost -= item.game.price\n # if a game has been released, the delivery_date of the line_item is the next day\n # if a game has not been released, the delivery_date of the line_item is the release_date of the game\n # which the line_item belongs to\n if item.game.release_date <= Date.today\n # the delivery_date of the line_item is the next day\n item.delivery_date = Date.today + 1\n else\n # the delivery_date of the line_item is the release_date of the game which the line_item belongs to\n item.delivery_date = item.game.release_date\n end\n end\n\n respond_to do |format|\n # attempts to save the order\n if @order.save\n # if the order has successfully been saved, each line_item in the basket which the current customer\n # owns is saved because the value of the fields which the line_items contain is updated\n LineItem.transaction do\n current_customer.basket.line_items.each(&:save!)\n end\n # if the order has successfully been saved, the basket which the current customer owns is saved\n # because the total_cost of the basket is updated\n current_customer.basket.save\n # if the order has successfully been saved, the current customer should be redirected to the page which\n # shows the order that the current_customer has made.\n # shows a notice to the customer that the order has successfully been created\n format.html { redirect_to @order, notice: t('.notice') }\n format.json { render :show, status: :created, location: @order }\n else\n # if the order has not successfully been saved, the current customer should not be redirected to another\n # page and should be shown the errors which prevented the order from being saved\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def checkout \n \t@order_items = current_order.order_items\n end",
"def customer_destroy_with_orders_error\n invoke_callbacks(:destroy, :fails)\n render status: :forbidden, plain: Spree.t(:error_customer_destroy_with_orders)\n end",
"def checkout\n #@carts.each do |c|\n @order = Order.new\n @order.item_ordered = params[:itemid]\n @order.user_id = params[:user_id] \n @order.orderdate = Datetime.now\n @order.save\n #end\n end",
"def update_order!\n order.update(\n coupon_discount: coupon_discount,\n coupon_applied_at: Time.now,\n coupon_id: coupon.id\n )\n end",
"def update_customer_in_gateway\n resp = gateway_client.update_customer(update_params)\n return resp unless resp.success?\n\n puts(resp.inspect)\n\n success\n end",
"def update\n if @order.completed?\n process_and_add_store_credit(@order)\n end\n\n return orig_update\n end",
"def associate_past_orders\n orders = Spree::Order.where(\"email = ?\", @user.email)\n unless orders == nil\n orders.each { |order|\n order.associate_user!(@user)\n }\n end\n end",
"def monitor_orders()\r\n\t\topen = $future_rest.open_orders symbol: 'BTCUSDT'\r\n\t\t# all orders\r\n\t\tall = $future_rest.all_orders symbol: 'BTCUSDT'\r\n\tend",
"def update_sales_order\n begin\n @customer_info = Sale.find(params[:id])\n @customer_info.update_attributes(params[:sale])\n @customer_info.payments.each do|sale_payment|\n sale_payment.update_attributes(:paid_amount=>params[:payments][:cash_amount], :next_pay_date=>params[:payments][:next_pay_date], :pay_date=> @customer_info.date) if sale_payment.pay_mode == \"cash\"\n cheque_payment = Payment.cheque_update(@customer_info,params[:payments]) if sale_payment.pay_mode == \"cheque\"\n sale_payment.update_attributes(:paid_amount=>params[:payments][:transfer_amount], :next_pay_date=>params[:payments][:next_pay_date], :pay_date=> @customer_info.date, :transfer_to_account_no=> params[:payments][:transfer_to_acount_no]) if sale_payment.pay_mode == \"transfer\"\n sale_payment.update_attributes(:paid_amount=>params[:payments][:card_paid_amount],:next_pay_date=>params[:payments][:next_pay_date], :pay_date=> @customer_info.date) if sale_payment.pay_mode == \"card\"\n end\n names = params[:product][:name]\n product_descs = params[:product][:description]\n serial_numbers = params[:product][:serial_number]\n service_types = params[:product][:service_type]\n quantities = params[:product][:quantity]\n rates = params[:product][:rate]\n index =0\n \n @customer_info.sale_products.each do |sale_product|\n product = Product.find(names[index])\n if (sale_product.product_reference_type == \"ProductSerialNumber\" && !serial_numbers[index].blank?)\n serial_number = ProductSerialNumber.find(sale_product.serial_number_reference_id)\n serial_number.update_attributes(:is_sold => false)\n end\n\n if !serial_numbers[index].blank?\n serial_no2 = ProductSerialNumber.find(serial_numbers[index])\n if( !serial_no2.nil?)\n serial_no2.update_attributes( :is_sold => true)\n sale_product.update_attributes(:product_reference_type =>\"ProductSerialNumber\")\n end\n else\n sale_product.update_attributes( :product_reference_type =>\"Product\")\n end\n sale_product.update_attributes(:product_reference_id => product_descs[index], :quantity => quantities[index], :rate => rates[index],:service_type_id => service_types[index],:serial_number_reference_id => serial_numbers[index] )\n index=index+1\n end\n redirect_to sales_sales_register_path\n rescue\n redirect_to home_path\n end\nend",
"def mark_as_unsync(order_ids)\r\n order_ids = [order_ids] unless order_ids.is_a?(Array)\r\n @customer.sales_orders.update_all \"synchronized = false\", [\"id in (?)\", order_ids]\r\n end",
"def send_orders_email\n UserMailer.orders(self).deliver_now\n end",
"def update\n @order = Order.find(params[:id])\n up_ordr = @order.update_attributes(params[:order])\n @order_user = @order.order_user\n up_user = @order_user.update_attributes(params[:order_user])\n @order_account = @order_user.order_account\n up_acct = @order_account.update_attributes(params[:order_account])\n @billing_address = @order.billing_address\n up_bill = @billing_address.update_attributes(params[:billing_address])\n @shipping_address = @order.shipping_address\n up_ship = @shipping_address.update_attributes(params[:shipping_address])\n\n if params[:order_transaction]\n OrderTransaction.update(params[:order_transaction].keys, params[:order_transaction].values) \n end\n\n @store_user = @order.order_user.store_user\n @order.order_user.store_user.update_attributes(params[:store_user]) if @store_user\n\n\n @products = Product.find(:all)\n if (up_ordr && up_user && up_acct && up_bill && up_ship) then\n flash[:notice] = 'Order was successfully updated.'\n redirect_to :action => 'show', :id => @order.id\n else\n flash[:notice] = 'There were problems modifying the order.'\n render :action => 'show'\n end\n end",
"def send_customer(customer)\n request(customer, \"customer\", :post, {method: \"add\"})\n end",
"def index\n @customer = current_customer\n @orders = current_customer.orders.all.order(created_at: :desc)\n end",
"def update\n if @order.update_attributes(object_params)\n\n # fire_event('moseller.checkout.update')\n \n if @order.respond_to?(:coupon_code) && @order.coupon_code.present?\n # fire_event('moseller.checkout.coupon_code_added', :coupon_code => @order.coupon_code)\n end \n \n if @order.state == \"delivery\"\n logger.info params\n @order.customer_name = params[:customer_name]\n @order.email = params[:email]\n @order.mobile_number = params[:mobile_number]\n \n if @order.check_sms\n flash[:success] = I18n.t(:order_sms_to_long)\n respond_with(@order, :location => checkout_state_path('delivery'))\n else\n @order.save\n end\n \n end\n\n if @order.state == \"payment\"\n logger.info \"PAYMENT\"\n if @order.payment_not_required?\n @order.next\n end\n end\n \n if @order.next\n state_callback(:after)\n else\n flash[:error] = I18n.t(:payment_processing_failed)\n respond_with(@order, :location => checkout_state_path(@order.state))\n return\n end\n \n if @order.state == \"complete\" || @order.completed?\n flash[:success] = I18n.t(:order_processed_successfully)\n # gflash :success => I18n.t(:order_processed_successfully)\n flash[:commerce_tracking] = \"Your order number is \" + @order.number().to_s()\n respond_with(@order, :location => completion_route)\n else\n respond_with(@order, :location => checkout_state_path(@order.state))\n end\n else\n respond_with(@order) { |format| format.html { render :edit } }\n end\n end",
"def write_order(order, request_body = nil)\n path = \"/checkout/orders\"\n path += \"/#{order.id}\" if order.id\n\n request_body ||= order.to_json\n response = https_connection.post do |req|\n req.url path\n\n req.headers['Authorization'] = \"Klarna #{sign_payload(request_body)}\"\n req.headers['Accept'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json',\n req.headers['Content-Type'] = 'application/vnd.klarna.checkout.aggregated-order-v2+json'\n req.headers['Accept-Encoding'] = ''\n\n req.body = request_body\n end\n handle_status_code(response.status, response.body)\n response\n end",
"def customer_order\n @customer_order\n end",
"def add_to_customers\n \t\t@@customers.each do |customer|\n \t\traise DuplicateCustomerError, \"#{@name} already exists.\" if customer.name == @name\n \tend\n \t\t@@customers << self\n \tend",
"def update\n op = object_params\n if op && op[:payments_attributes]\n @order.payments.where('spree_payments.state = \"checkout\"').destroy_all\n end\n # binding.pry\n if @order.update_attributes(op)\n\n fire_event('spree.checkout.update')\n\n if @order.next\n state_callback(:after)\n else\n flash[:error] = t(:payment_processing_failed)\n respond_with(@order, :location => hto_checkout_state_path(@order.state))\n return\n end\n\n if @order.state == 'complete' || @order.completed?\n flash.notice = t(:order_processed_successfully)\n flash[:commerce_tracking] = 'nothing special'\n respond_with(@order, :location => completion_route)\n else\n respond_with(@order, :location => hto_checkout_state_path(@order.state))\n end\n else\n respond_with(@order) { |format| format.html { render :edit } }\n end\n end",
"def confirm_order\n end",
"def after_complete\n #remove the order from the session\n session[:order_id] = nil\n\n #add the order access token to the session so user can see thank you window\n #and order status, all through the orders controller.\n session[:access_token] ||= @order.token\n\n # trigger the photo copy and preparation, this is done here because normal state machine transitions\n # happen in a transaction and could allow resque work to begin too soon. See comment in order_decorator.rb\n @order.prepare!\n\n if current_user\n # If a user is looged in, save addresses and creditcard as default\n # Backup order addresses with addresses that cannot be modified by user.\n # creditcards are non editable just erasable.\n #(no need to do this for guests)\n original_ship = @order.ship_address\n original_bill = @order.bill_address\n\n new_ship = Address.create( original_ship.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n @order.ship_address_id = new_ship.id\n if original_ship.id == original_bill.id\n @order.bill_address_id = new_ship.id\n else\n if original_ship.same_as?( original_bill )\n @order.bill_address.id = new_ship.id\n else\n @order.bill_address = Address.create( original_bill.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n end\n end\n @order.save\n\n # new creditcards should be saved in the user's wallet\n if @order.payment.source.user.nil?\n @order.payment.source.update_attributes!(\n :user_id => current_user.id\n )\n end\n\n #make addresses, creditcard user's default\n @order.user.update_attributes!(\n :bill_address_id => original_bill.id,\n :ship_address_id => original_ship.id,\n :creditcard_id => @order.payment.source.id\n )\n end\n end",
"def update_order(result)\n create_asendia_shipment_record(result['Status'], result['Error'])\n @transaction_id = result['ParcelId']\n @tracking_number = nil\n shipment = @order.shipment\n shipment.tracking = @tracking_number\n shipment.save\n shipment.ship!\n @order.line_items.each do |line_item|\n @success_orders << [\"#{@order.number}, #{line_item.sku}, #{@tracking_number}, #{@transaction_id}, #{line_item.quantity}, #{@order.completed_at}, #{(@order.ship_address.country.try(:name) || '').delete(',')}\"]\n end\n end",
"def update\n # puts \"params: #{params.to_hash}\"\n return_order_items = JSON.parse(params[:order][:items]) \n\n # puts \"Params: #{return_order_items}\"\n\n @order = Order.find(params[:id])\n\n\n ActiveRecord::Base.transaction do\n return_order_items.each do |item|\n if params[:order].has_key?(:supplier) \n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.decrement!(:remaining_quantity, item[\"quantity\"].to_i)\n else\n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.increment!(:remaining_quantity, item[\"quantity\"].to_i)\n end\n end\n\n @order.return = true\n if @order.save\n @current_user = current_user\n redirect_to :root, notice: 'Return Order was successfully created.'\n else\n render :new\n end\n end\n\n end",
"def save\n @connection.transactions.save\n end",
"def index\r\n @sales_orders = @customer.sales_orders\r\n end",
"def update\n if params[:ask][:status] == 2 && @ask.status != 2\n @ask.orders.each do |order|\n create_transaction(fermastore, order.producer, (order.total*0.9).to_i, @ask, order, 2)\n end\n create_transaction(fermastore, money_user, (@ask.amount*0.1).to_i, @ask, nil, 2)\n create_transaction(fermastore, tk_user, 500, @ask, nil, 2)\n if @ask.update(ask_params)\n build do \n message 'Статус заказа изменен'\n view 'consumer/asks/show'\n end\n else\n render json: @ask.errors, status: :unprocessable_entity\n end\n end\n end",
"def commit_transaction(session)\n session.commit_transaction\n Threaded.clear_modified_documents(session).each do |doc|\n doc.run_after_callbacks(:commit)\n end\n end",
"def all_orders_sync\n @all_partial_orders = Spree::Order.includes(:line_items).where(\"spree_line_items.id is null\")\n if !@all_partial_orders.present? || @all_partial_orders.count == 0\n flash[:error] = \"No orders found to sync\"\n redirect_to partial_orders_admin_orders_path\n return\n else\n res = view_context.sync_all_orders_qoo10(@all_partial_orders)\n redirect_to partial_orders_admin_orders_path, :notice => \"All orders synced successfully!\"\n end\n end",
"def edit \n @order = current_order || Order.incomplete.\n includes(line_items: [variant: [:images, :option_values, :product]]).\n find_or_initialize_by(guest_token: cookies.signed[:guest_token])\n @order.save! unless @order.id\n puts \"\\n\\n\\n edit guest_token=[#{cookies.signed[:guest_token]}] order=[#{@order.to_json}] \\n\\n\\n\"\n associate_user \n\n @order.assign_default_addresses!\n puts \"\\n\\n\\n\\n edit assign_default_addresses good bill_address=[#{@order.bill_address}]\\n\\n\\n\\n\";\n @order.bill_address = User.find(1).bill_address.try(:clone) unless @order.bill_address\n puts \"\\n\\n\\n\\n edit bill_address good\\n\\n\\n\\n\";\n \n \n # if @order.next\n # puts \"\\n\\n\\n\\n edit order next good\\n\\n\\n\\n\";\n\n # else\n # puts \"\\n\\n\\n\\n edit order next bad\\n\\n\\n\\n\";\n # end\n \n # @order.create_proposed_shipments \n # @order.refresh_shipment_rates\n # @order.set_shipments_cost\n # @order.apply_free_shipping_promotions\n\n if (@order[:state] == 'cart')\n if @order.next\n puts \"\\n\\n\\n\\n edit order next cart good\\n\\n\\n\\n\";\n else\n puts \"\\n\\n\\n\\n edit order next cart bad\\n\\n\\n\\n\";\n end\n else\n puts \"\\n\\n\\n\\n edit order state not eq cart\\n\\n\\n\\n\";\n end \n @order.ship_address = User.find(1).ship_address.try(:clone) unless @order.ship_address\n # @updating_params = {order: { bill_address_attributes: [{city: \"Kriviy Rih\", country_id: 229, state_id: 2975, zipcode: \"50015\"} ] } }\n \n # \n @order.shipments = Spree::Stock::Coordinator.new(@order).shipments unless @order.shipments&.count > 0\n @order.refresh_shipment_rates\n @order.set_shipments_cost\n @order.apply_free_shipping_promotions\n @order.available_payment_methods\n # @updating_params ||= {}\n # @updating_params[:order] ||= {bill_address_attributes:[{city: \"Kriviy Rih\", country_id: 229, state_id: 2975, zipcode: \"50015\"}]}\n # @updating_params[:order][:bill_address_attributes] ||= [{}]\n # @updating_params[:order][:bill_address_attributes].first[:city] = \"Kriviy Rih\"\n # @updating_params[:order][:bill_address_attributes].first[:country_id] = \"229\"\n # @updating_params[:order][:bill_address_attributes].first[:state_id] = \"2975\"\n # @updating_params[:order][:bill_address_attributes].first[:zipcode] = \"50015\"\n # if @order.update_from_params(@updating_params, permitted_checkout_attributes, request.headers.env)\n\n # end\n # @order.bill_address = user.bill_address.try(:clone)\n # @order.create_proposed_shipments \n # @order.refresh_shipment_rates\n # @order.set_shipments_cost\n # @order.apply_free_shipping_promotions\n puts \"\\n\\n\\n edit shipments=[\"+@order.shipments.to_json+\"]\\n\\n\\n\\n\"\n puts \"\\n\\n\\n edit shipment_total=[\"+@order.shipment_total.to_json+\"]\\n\\n\\n\\n\"\n # puts \"\\n\\n\\n edit client_store_ref_path=[#{client_store_ref_path}] \\n\\n\\n\"\n # puts \"\\n\\n\\n edit packages=[\"+Spree::Stock::Coordinator.packages.to_json+\"]\\n\\n\\n\\n\"\n # flash[:error] = \"order1112=[\"+@order.to_json+\"]\\n\\n available_payment_methods=[\"+@order.available_payment_methods.to_json+\"]\"\n end",
"def update(params = {})\n req = WebPay::CustomerRequestUpdate.create(params)\n raw_response = @client._request(:post, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end",
"def persist_totals(options = { update_balance: true })\n order.move_balance_and_credit if (order.total_was != order.total) && \\\n order.approved? && options[:update_balance]\n order.update_columns(\n payment_state: order.payment_state,\n shipment_state: order.shipment_state,\n item_total: order.item_total,\n item_count: order.item_count,\n adjustment_total: order.adjustment_total,\n included_tax_total: order.included_tax_total,\n additional_tax_total: order.additional_tax_total,\n payment_total: order.payment_total,\n shipment_total: order.shipment_total,\n promo_total: order.promo_total,\n total: order.total,\n updated_at: Time.current\n )\n end",
"def complete_order customer\n puts \"========= Completing Order\"\n # Go to Cart Page\n @b.goto 'https://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n # Check if all items can be purchased\n sleep 5\n if @b.button(class: \"buy-now-disabled-info\").exists?\n raise \"Um dos produtos do carrinho não está mais disponível\"\n end\n @b.button(class: \"buy-now\").wait_until_present(timeout: 30)\n if !@b.button(class: \"buy-now\").exists?\n raise \"Produto sem estoque na Aliexpress\"\n else\n @b.button(class: \"buy-now\").click\n end\n\n # Check if current session if up\n self.check_if_session_is_up\n\n fullname = to_english(customer[\"first_name\"]+\" \"+customer[\"last_name\"])\n\n # Fill customer's address\n puts \"========= Adding customer informations\"\n @log.add_message('Adicionando informações do cliente')\n @b.text_field(name: \"contactPerson\").wait_until_present(timeout: 3)\n @log.add_message(fullname)\n @b.text_field(name: \"contactPerson\").set fullname\n @b.select_list(name: \"country\").select \"Brazil\"\n if customer['number'].nil?\n adds = customer[\"address_1\"]\n else\n adds = customer[\"address_1\"]+\" \"+customer['number']\n end\n @log.add_message(to_english(adds))\n @b.text_field(name: \"address\").set to_english(adds)\n @log.add_message(to_english(customer[\"address_2\"]))\n @b.text_field(name: \"address2\").set to_english(customer[\"address_2\"])\n # Wait for States to turn on select\n sleep 1\n state = self.state.assoc(customer[\"state\"])\n @b.div(class: \"sa-province-wrapper\").select_list.select state[1]\n @b.text_field(name: \"city\").set to_english(customer[\"city\"])\n postcode = customer['postcode'].gsub(/\\D/, '')\n @b.text_field(name: \"zip\").set postcode\n @b.text_field(name: \"phoneCountry\").set '55'\n @b.text_field(name: \"mobileNo\").set '941873849'\n @b.text_field(name: \"cpf\").set '35825265856'\n @b.a(class: \"sa-confirm\").click\n\n check_costumer_data @b, fullname\n\n # Placing order on desktop website\n @b.button(id: \"place-order-btn\").click\n\n puts \"========= Finishing Order\"\n @log.add_message('Finalizando Pedido')\n sleep 3\n if @b.span(class: \"order-no\").exists?\n # Return the number of the Order if there is no captcha\n @finished = true\n @b.span(class: \"order-no\").text\n else\n puts \"========= Captcha detected, going to mobile...\"\n @log.add_message('Captcha detectado, indo para carrinho mobile')\n @b.goto 'm.aliexpress.com/shopcart/detail.htm'\n @b.div(class: \"buyall\").wait_until_present(timeout: 30)\n @b.div(class: \"buyall\").click\n # Create the final order on mobile website to avoid captcha\n @b.button(id: \"create-order\").wait_until_present(timeout: 30)\n @b.button(id: \"create-order\").click\n @finished = true\n @b.div(class: \"desc_txt\").wait_until_present(timeout: 30)\n @b.div(class: \"desc_txt\").text\n end\n end",
"def set_state_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:state_id, @customer.state_id)\n end",
"def proceed_to_checkout\n \n order = Order.new\n order.cart_id = @cart.id\n order.responseCode = 100\n order.responseDescription = \"Tests added to your account.\"\n order.save!\n \n cart = Cart.find(order.cart_id)\n \n # Add each cartitem to user's account.\n cart.cart_items.each do | cart_item |\n if cart_item.quiz_id != nil\n # Add Quiz\n quiz_user = QuizUser.new\n quiz_user.quiz_id = cart_item.quiz_id\n quiz_user.user_id = current_user.id\n quiz_user.save!\n end\n end\n \n redirect_to homes_index_path, notice: \"Test added to your account.\"\n end",
"def merge!(order)\n if self.line_items.count > 0\n order.destroy\n else\n self.billing_address = self.billing_address || order.billing_address\n self.shipping_address = self.shipping_address || order.shipping_address\n order.line_items.each do |line_item|\n next unless line_item.currency == currency\n line_item.order_id = self.id\n line_item.save\n end\n\n end\n end",
"def update(customer_token, payment_method, options = {})\n params = {}\n add_metadata(params, options)\n add_invoice(params, 0, options)\n add_customer_data(params, options, payment_method)\n add_credit_card(params, payment_method, options)\n add_customer_token(params, customer_token)\n params['Method'] = 'UpdateTokenCustomer'\n commit(url_for('Transaction'), params)\n end",
"def update(cust_token, data = {})\n pdata = build_payment_info(data)\n data = FiveDL.build_params(data.merge!(transtype: 'updatecustomer', token: cust_token).merge!(pdata))\n FiveDL::Response.new( FiveDL::Gateway.post('/Payments/Services_api.aspx', data) )\n end",
"def order_upgrade\n @order.next\n @order.complete!\n # Since we dont rely on state machine callback, we just explicitly call this method for spree_store_credits\n if @order.respond_to?(:consume_users_credit, true)\n @order.send(:consume_users_credit)\n end\n @order.finalize!\n end",
"def test_orders_auth \n c = customers(:bob)\n assert_equal(orders(:bob_order), c.find_order(1))\n assert_nil(c.find_order(2))\n assert_nil(c.find_order(100000))\n end",
"def push_transactions\n AirdropMint.push_transactions_for_pending_rewards(user)\n end",
"def checkout\n self.balance = 0\n self.orders.each do |order|\n self.balance += order.food.price\n end\n self.balance\n end",
"def convert_to_orders\n purchased_at = Time.zone.now\n line_items.includes(:item).each do |li|\n # TODO: Do this in memory\n order = Order.where(buyer_id: user_id, seller_id: li.item.user_id, purchased_at: purchased_at) \\\n .first_or_initialize(buyer_id: user_id, seller_id: li.item.user_id)\n order.line_items << li\n li.item.update_attribute(:sold, true)\n order.purchased_at = purchased_at unless order.persisted?\n orders << order unless orders.include? order\n order.save\n end\n # TODO this is not a great place for this... this entire method is\n # getting out of hand. Need a separate domain concept.\n orders.each do |order|\n OrderMailer.delay.sale_made_email(order.id)\n ReminderDeliveryWorker.perform_in(7.days, order.id) # Schedule review reminder\n end\n update_attribute(:purchased_at, purchased_at)\n save\n end",
"def confirm_sales_order\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n # add some defensive programming.. current user has role admin, and current_user is indeed belongs to the company \n @sales_order.confirm( current_user ) \n end",
"def finalize!\n # lock all adjustments (coupon promotions, etc.)\n all_adjustments.each{|a| a.close}\n\n # update payment and shipment(s) states, and save\n #updater.update_payment_state\n shipments.each do |shipment|\n shipment.update!(self)\n shipment.finalize!\n end\n\n updater.update_shipment_state\n save!\n updater.run_hooks\n\n touch :completed_at\n if self.created_by_customer?\n unless self.vendor.try(:auto_approve_orders)\n if !confirmation_delivered?\n self.deliver_vendor_confirmation\n elsif confirmation_delivered? && self.approver_id\n self.deliver_vendor_confirmation(true)\n end\n # changing this so that customer will receive an order confirmation email when order is updated\n # only send if order was created by customer (otherwise will be sent after transition to approve)\n deliver_order_confirmation_email\n end\n end\n\n consider_risk\n end",
"def bought_orders\n @orders = current_user.bought_orders\n\n end",
"def bought_orders\n @orders = current_user.bought_orders\n\n end",
"def confirm\n order = current_order || raise(ActiveRecord::RecordNotFound)\n order.payments.create!(\n {\n source: Spree::PaypalExpressCheckout.create(\n {\n token: params[:token],\n payer_id: params[:PayerID],\n payment_id: params[:paymentId]\n }\n ),\n amount: sprintf(\"%0.02f\", order.total),\n payment_method: payment_method\n }\n )\n order.next\n if order.complete?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(order)\n else\n redirect_to checkout_state_path(order.state)\n end\n end"
] |
[
"0.6986604",
"0.6477692",
"0.6333579",
"0.6221034",
"0.6045331",
"0.603372",
"0.59519094",
"0.5916829",
"0.5779564",
"0.5764588",
"0.57638794",
"0.5753903",
"0.5660284",
"0.56332177",
"0.56252193",
"0.5624888",
"0.561535",
"0.558923",
"0.558393",
"0.5488663",
"0.54863745",
"0.54636526",
"0.5441855",
"0.544073",
"0.5437313",
"0.54227906",
"0.5416063",
"0.537569",
"0.5375482",
"0.5366206",
"0.5351028",
"0.5351028",
"0.533373",
"0.5322574",
"0.5301255",
"0.52984864",
"0.5293921",
"0.5292965",
"0.5286512",
"0.5261524",
"0.5256732",
"0.5250099",
"0.5248156",
"0.5245313",
"0.5229695",
"0.52185094",
"0.52180296",
"0.52088434",
"0.5202912",
"0.519689",
"0.519602",
"0.5195702",
"0.5191416",
"0.5185724",
"0.5183473",
"0.51690143",
"0.51573396",
"0.51383305",
"0.5137713",
"0.51365334",
"0.5126995",
"0.51233166",
"0.5123222",
"0.5118296",
"0.51169735",
"0.5113442",
"0.51121384",
"0.5096876",
"0.5088278",
"0.5079145",
"0.507903",
"0.50621784",
"0.5043742",
"0.5042383",
"0.50407696",
"0.50368595",
"0.50335705",
"0.5032174",
"0.5030236",
"0.5029755",
"0.5029462",
"0.5027998",
"0.50240684",
"0.50230545",
"0.50229245",
"0.50209606",
"0.50084233",
"0.5007442",
"0.50059366",
"0.49982658",
"0.499794",
"0.49959198",
"0.49953538",
"0.49953386",
"0.49927157",
"0.4991782",
"0.49893203",
"0.4988517",
"0.4988517",
"0.49874723"
] |
0.8004923
|
0
|
Return address's JSON for filling address form in "MyAccount / OpenOrders" (while editing a billing / shipping address)
|
def get_address_json
address = @customer.addresses.find( params[:id] )
render :text => address.attributes.to_json
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_address(options)\n address = options[:billing_address]\n\n post = {}\n post['Address 1'] = address[:address1] unless empty?(address[:address1])\n post['Address 2'] = address[:address2] unless empty?(address[:address2])\n post['City'] = address[:city] unless empty?(address[:city])\n post['State or Province'] = address[:state] unless empty?(\n address[:state]\n )\n post['ZIP or Postal Code'] = address[:zip] unless empty?(address[:zip])\n post['Country'] = address[:country] unless empty?(address[:country])\n\n post\n end",
"def fake_address\n {\n first_name: 'Jack',\n last_name: 'Macdowall',\n company_name: 'Macdowalls',\n line_1: '1225 Invention Avenue',\n line_2: 'Birmingham',\n postcode: 'B21 9AF',\n county: 'West Midlands',\n country: 'UK'\n }\n end",
"def customer_address\n { :address1 => params['address1'], :address2 => params['address2'],\n :city => params['city'], :state => params['state'],\n :country => params['country'], :zipcode => params['zipcode'] }\n end",
"def customer_address\n { :address1 => params['address1'], :address2 => params['address2'],\n :city => params['city'], :state => params['state'],\n :country => params['country'], :zipcode => params['zipcode'] }\n end",
"def customer_address\n { :address1 => params['addressStreet1'], :address2 => params['addressStreet2'],\n :city => params['addressCity'], :state => params['addressState'],\n :country => params['addressCountry'], :zip => params['addressZip'] }\n end",
"def get_address\n @address\n end",
"def delivery_address\n\t\tadd=Partay.get('http://shoponline.tescolotus.com/api/v1/Customer/', :headers => {'Content-Type' => 'application/json', 'language' => 'en-gb', 'region' => 'TH', 'userId' => access_token })\n\t\tresponse_address=JSON(add)\n\t\tself.address_info(JSON(response_address)[\"address\"][\"name\"])\n\tend",
"def billing_address\n Address.new(\n email_address: email_address,\n company: billing_company,\n full_name: billing_full_name,\n address_line_1: billing_address_line_1,\n address_line_2: billing_address_line_2,\n address_line_3: billing_address_line_3,\n town_city: billing_town_city,\n county: billing_county,\n postcode: billing_postcode,\n country_id: billing_country_id,\n phone_number: billing_phone_number\n )\n end",
"def get_address\n booking = Booking.where(user_id: current_user.id).last\n pick_up_addr = PickupAddress.where(:booking_id => booking.id).last\n drop_off_addr = DropoffAddress.where(:booking_id => booking.id).last\n hash = {:pick_up_addr => pick_up_addr.address, :drop_off_addr => drop_off_addr.address}\n respond_to do |format|\n format.json { render :json => hash.to_json, :status => 200 }\n end\n end",
"def address\n @client.request('getaccountaddress', name)\n end",
"def order_billing_address_lines\n order.bill_address.try(:full_address_array)\n end",
"def billing_address(params={})\n add_field(mappings[:billing_address][:zip], params[:zip])\n add_field(mappings[:billing_address][:country], lookup_country_code(params[:country]))\n \n address = [params[:address1], params[:address2], params[:city], params[:state]].compact\n add_field('address', address.join(' '))\n end",
"def full_address\n merchant.street + \", \" + merchant.city + \", \" + merchant.state + \" \" + merchant.zip\n end",
"def address_prop\n # See https://schema.org/PostalAddress for details and examples\n # {\n # \"streetAddress\": \"1600 Pennsylvania Avenue\",\n # \"addressLocality\": \"Washington\",\n # \"addressRegion\": \"District of Columbia\",\n # \"postalCode\": \"20500\",\n # \"addressCountry\": \"US\"\n # }\n end",
"def billing_address\n all = {}\n for key_out in [:fax, :city, :company, :last_name, :country, :zip, :first_name, :address, :email, :state]\n all[key_out] = unescape params['x_' + key_out.to_s]\n end\n all\n end",
"def update_customer_address\n json_response({ message: 'NOT IMPLEMENTED' })\n end",
"def address\n # match Geocoder::Result::Google#formatted_address\n \"#{street}, #{city}, #{state} #{zip}, #{country}\"\n end",
"def build_address(address)\n {\n id: address&.id,\n address_line1: address&.address_line1,\n address_line2: address&.address_line2,\n city: address&.city,\n state: address&.state,\n country: address&.country,\n }\n end",
"def billing_address\n all = {}\n [:fax, :city, :company, :last_name, :country, :zip, :first_name, :address, :email, :state].each do |key_out|\n all[key_out] = unescape params['x_' + key_out.to_s]\n end\n all\n end",
"def purchase_options\n {\n :billing_address => {\n :address1 => @address,\n :city => @city,\n :state => @state,\n :country => \"US\",\n :zip => @zip\n }\n }\n end",
"def post_address\n postcode = params['value'].delete('- ')\n address = CoreService.get_address(postcode)\n\n respond_to do |format|\n format.json { render json: { success: true, address: address } }\n end\n end",
"def order_ship_address_lines\n order.ship_address.try(:full_address_array)\n end",
"def add_address(post, options)\n if address = options[:billing_address] || options[:address]\n post[:ci_billaddr1] = address[:address1]\n post[:ci_billaddr2] = address[:address2] if address[:address2]\n post[:ci_billcity] = address[:city]\n post[:ci_billstate] = address[:state]\n post[:ci_billzip] = address[:zip]\n post[:ci_billcountry] = address[:country]\n end\n\n if address = options[:shipping_address]\n post[:ci_shipaddr1] = address[:address1]\n post[:ci_shipaddr2] = address[:address2] if address[:address2]\n post[:ci_shipcity] = address[:city]\n post[:ci_shipstate] = address[:state]\n post[:ci_shipzip] = address[:zip]\n post[:ci_shipcountry] = address[:country]\n end\n end",
"def address\n fields = %w[address_line_1 address_line_2 address_line_3 city state zip country]\n Hash[fields.collect { |field| [field.to_sym, send(field)] }]\n end",
"def full_address\n \"#{address}, #{city}, #{state}, #{zip}\"\n end",
"def full_order_to_address\n ship_address.address1 + ' ' + ship_address.address2\n end",
"def address\n\t\taddress_str = \"\"\n\t\taddress_str += \"#{address_street}\\n\" unless address_street.blank?\n\t\taddress_str += \"#{address_city}, \" unless address_city.blank?\n\t\taddress_str += \"#{address_state} \" unless address_state.blank?\n\t\taddress_str += \"#{address_zip}\" unless address_zip.blank?\n\t\taddress_str\n\tend",
"def address\n get_value :address\n end",
"def update_order_addresses\n order = current_order\n if order.bill_address.blank? || order.shipping_address.blank?\n order.bill_address ||= build_bill_address(payment_details_response)\n order.shipping_address ||= build_shipping_address(payment_details_response)\n\n complete_order_step(order, 'address')\n end\n end",
"def address_model\n a = CIVICRM::Address.new(\n contact_id: self.contact_id,\n location_type_id: self.location_type_id,\n is_primary: self.primary,\n is_billing: false,\n street_address: self.address1,\n street_number: self.street_number,\n supplemental_address_1: self.address2,\n supplemental_address_2: self.address3\n\n )\n # Add county, state, country, and zipcode stuff now\n self.set_location(a)\n end",
"def address_fields\n \"\".tap do |result|\n fields_for(:address) do |f|\n result << f.text_field(:street_address_line_one)\n result << f.text_field(:street_address_line_two)\n result << f.text_field(:city)\n result << f.select(:state, IsoState.select_options,\n :include_blank => true)\n result << f.text_field(:postal_code)\n result << f.select(:iso_country_id, IsoCountry.select_options,\n :include_blank => true)\n end\n end\n end",
"def build_address(address)\n {\n receiver: address.full_name,\n email: order.email,\n phoneNumber: address.phone,\n route: address.address1,\n street_number: address.address1.scan(/\\d+/).first,\n internalNumber: address.address2.scan(/\\d+/).first,\n neighborhood: address.address2,\n locality: address.address3,\n postal_code: address.zipcode,\n subLocality: address.city,\n state: address.state.name,\n country: address.country.name,\n }\n end",
"def full_address\n \"#{address1} #{address2} #{city},#{state} #{postal_code} #{country}\"\n end",
"def address\n post('/api/1/generic/bitcoin/address')['addr']\n end",
"def address\n \"#{self.building} #{return_data_format(self.street)} #{self.zipcode}\"\n end",
"def show\n @billing_address = BillingAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @billing_address }\n end\n end",
"def address_model\n a = CIVICRM::Address.new(\n contact_id: self.contact_id,\n location_type_id: self.location_type_id,\n is_primary: self.primary,\n is_billing: false,\n street_address: self.address1,\n street_number: self.street_number,\n supplemental_address_1: self.address2,\n supplemental_address_2: self.address3,\n city: self.city\n\n )\n # Add county, state, country, and zipcode stuff now\n self.set_location(a)\n end",
"def address\n address = \"#{self.street_address}, #{self.city}, #{self.country}\"\n \n end",
"def create_full_address\n \"#{address_line1}, #{city}, #{state} #{zip}\"\n end",
"def payment_customer_address\n\t\t\t\t\tif self.billing_address.is_a?(String)\n\t\t\t\t\t\tparsed_address = self.class.parse_address(self.billing_address)\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tstreet: parsed_address[3],\n\t\t\t\t\t\t\tnumber: parsed_address[4],\n\t\t\t\t\t\t\tcity: parsed_address[2],\n\t\t\t\t\t\t\tzipcode: parsed_address[1]\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\treturn self.billing_address # We expect hash containing :street, :number, :city and :zipcode keys\n\t\t\t\t\tend\n\t\t\t\tend",
"def address\n @address\n end",
"def address\n\t\t\taddress = [self.address_1, self.try(:address_2), \"#{self.city} #{self.try(:state)}\", \"#{self.try(:zip)}\"].compact\n\t\t\taddress.delete(\"\")\n\t\t\taddress.join(\"<br/>\")\n\t\tend",
"def address_params\n end",
"def address\n load_step # Need to load the account to make the decision\n if AccountType.other_organisation?(@account.account_type)\n # Uses overrides as the address is at address.company not at company\n wizard_address_step(STEPS, address_attribute: :org_address,\n next_step: :address_next_step)\n elsif AccountType.registered_organisation?(@account.account_type)\n wizard_address_step(STEPS, address_not_required: :reg_company_contact_address_yes_no,\n next_step: :address_next_step)\n else # must be individual\n wizard_address_step(STEPS, next_step: :address_next_step)\n end\n end",
"def shipping_address_edit\n @shipping_address = retrieve_shipping_address(@subscription_id)\n @country_codes = get_country_codes\n end",
"def get_address(street_number:, street:, city:, state:, zip:)\n response = RestClient.get \"https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address=#{street_number}+#{street}%2C+#{city}%2C+#{state}+#{zip}&benchmark=9&format=json\"\n json = JSON.parse(response.body)\n end",
"def setup_address_hash(options)\n default_address = {\n address1: 'Unspecified',\n city: 'Unspecified',\n state: 'NC',\n zip: '00000',\n country: 'US'\n }\n\n submitted_address = options[:billing_address] || options[:address] || default_address\n options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }\n options[:shipping_address] = options[:shipping_address] || {}\n end",
"def address\n {\n street: @data[:ulica].to_s,\n number: @data.values_at(:nr_domu, :nr_lokalu).compact.join('/'),\n code: @data[:pna].to_s,\n town: @data[:miejscowosc].to_s\n }\n end",
"def edit_frontend_address(user, address, expect_success, values, default_bill=nil, default_ship=nil)\n address = address.id if address.is_a?(Spree::Address)\n\n visit spree.account_path\n if address\n click_link \"edit_address_#{address}\"\n expect(current_path).to eq(spree.edit_address_path(address))\n else\n within('#addresses > tbody > tr:first-child') do\n click_link Spree.t(:edit)\n end\n end\n\n fill_in_address(values)\n check_frontend_defaults(default_bill, default_ship)\n\n click_button Spree.t(:update)\n\n if expect_success\n expect(page).to have_content(Spree.t(:successfully_updated, :resource => Spree.t(:address1)))\n expect(current_path).to eq(spree.account_path)\n expect_frontend_addresses(user)\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, :resource => Spree.t(:address1)))\n end\n end",
"def full_address\n \"#{address}, #{suburb}, #{state}, #{postcode}\"\n end",
"def address\n \"%s %s %s %s\"%([self.prefecture_code,self.address_city,self.address_street,self.address_building])\n end",
"def address\n @address = Address.new()\n @address.addressable_type = params.keys.first.capitalize\n @address.addressable_id = params[params.keys.first]\n end",
"def get_address\n address = {}\n begin\n address[:line_one] = @rand.rand(1000).to_s + \" \" + DataUtility.select_random_from_options(@rand, BaseEntity.demographics['street'])\n address[:city] = BaseEntity.demographics['city']\n address[:state] = BaseEntity.demographics['state']\n address[:postal_code] = BaseEntity.demographics['postalCode']\n rescue NameError\n # occurs when @@d in BaseEntity hasn't been initialized (will happen during testing)\n return nil\n end\n address\n end",
"def full_street_address\n postcode_only_address\n end",
"def ship_to_address\n all = {}\n for key_out in [:city, :last_name, :first_name, :country, :zip, :address]\n all[key_out] = unescape params['x_ship_to_' + key_out.to_s]\n end\n \n all\n end",
"def show\n @customers_address = CustomersAddress.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @customers_address }\n end\n end",
"def save_address\n end",
"def gmaps4rails_address\n \"#{address1}, #{address2}, #{city}, #{state}, #{zipcode}\"\n end",
"def full_address\n \"#{region}, #{district}, #{street_type} #{street_name}, д. #{house_number} кв. #{apartment}\"\n end",
"def default_billing_address(options={})\n unless self.billing_address\n self.build_billing_address(options.merge({\n :company_name => self.company_name, :academic_title_id => self.academic_title_id, :gender => self.gender,\n :first_name => self.first_name, :last_name => self.last_name,\n :street => self.business_address.street, :street_number => self.business_address.street_number,\n :note => self.business_address.note, :postal_code => self.business_address.postal_code,\n :city => self.business_address.city, :country_code => self.business_address.country_code,\n :email => self.email}))\n else\n self.billing_address\n end\n end",
"def addresses\n format_entities('gd$structuredPostalAddress', :format_address)\n end",
"def full_address\n\t\t\"#{street}, #{postal_code}, #{city}, #{country}\"\n\tend",
"def generate_address\n name = self.name\n unless self.address\n key = ENV['GMAPS_KEY']\n search = name.gsub(\" \",\"+\")\n map_results = JSON.parse(open(\n \"https://maps.googleapis.com/maps/api/place/textsearch/json?location=41.310362,-72.928914&radius=500&key=#{key}&query=#{search}&sensor=true\").read)\n loc = map_results['results'].first\n if loc\n address = loc[\"formatted_address\"]\n lat = loc[\"geometry\"][\"location\"][\"lat\"]\n lng = loc[\"geometry\"][\"location\"][\"lng\"]\n else\n address = \"38 Hillhouse Avenue, New Haven, CT 06511\"\n lat = \"41.310362\"\n lng = \"-72.928914\"\n end\n self.attributes = {:address => address, :latitude => lat, :longitude => lng}\n end\n end",
"def build_addresses(options={})\n raise \"override in purchase_order or sales_order\"\n end",
"def create\n @address = current_customer.addresses.build(\n province: Province.find(params[:province_id].to_i),\n country_code: params[:country_code],\n is_primary_address: address_params[:is_primary_address].to_i == 1,\n address_line_one: address_params[:address_line_one],\n address_line_two: address_params[:address_line_two],\n address_additional: address_params[:address_additional],\n city: address_params[:city],\n postal_code: address_params[:postal_code]\n )\n\n respond_to do |format|\n if @address.save\n format.html { redirect_to @address, notice: \"Address was successfully created.\" }\n format.json { render :show, status: :created, location: @address }\n else\n format.html { render :new }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def address_attributes\n {'business_address' => self.business_address.try(:id) }\n end",
"def new\n @billing_address = BillingAddress.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @billing_address }\n end\n end",
"def resource_url\n \"orders/#{self.order_id}/shippingaddresses\"\n end",
"def customer_billing_address(address)\n address_str=\"\"\n unless address.blank?\n address_str+=\"<p></p><p>#{address.address_line1}</p>\" unless address.address_line1.blank?\n address_str+=\"<p>City-#{address.city}</p>\" unless address.city.blank?\n address_str+=\"<p>State-#{address.state}</p>\" unless address.state.blank?\n address_str+=\"<p>Country-#{address.country}</p>\" unless address.country.blank?\n address_str+=\"<p>Postal code-#{address.postal_code}</p>\" unless address.postal_code.blank?\n end\n address_str.html_safe\n end",
"def getaccountaddress(account)\n request :getaccountaddress, account\n end",
"def shipping_address\n [name_tb.value,address1_tb.value,address2_tb.value,city_tb.value,state_tb.value,country_select.first_selected_option.text,zip_tb.value,phone_tb.value,power_adapter_select.first_selected_option.text]\n end",
"def full_address\n return \"#{address}, #{city}, #{state}, #{zip}\"\nend",
"def full_address\n \"#{address1}, #{address2}, #{city}, #{state}, #{zipcode}\"\nend",
"def resource_url\n \"orders/#{self.order_id}/shipping_addresses\"\n end",
"def build_addresses(options={})\n raise \"override in purchase_order or sales_order\"\n end",
"def getaccountaddress(account)\n @api.request 'getaccountaddress', account\n end",
"def purchase_options\n {\n :ip => ip_address,\n :billing_address => {\n :name => name,\n :address1 => address,\n :city => city,\n :state => state,\n :country => country,\n :zip => zip\n }\n }\n end",
"def formatted_address\n \"#{self.street_address}, #{self.city}, #{self.state} #{self.zip_code}\"\n end",
"def populate_billing_address!(options)\n options['contract.default'].billing_address ||= Address.new\n end",
"def address_string\n \"#{address}, #{city}, #{state} #{zip}\"\n end",
"def update\n if @address.update(address_params)\n render json: @address\n else\n render json: @address.errors, status: :unprocessable_entity\n end\n end",
"def account_address(address_details)\n self.address = Address.new(\n address_line1: address_details[:address_line1], address_line2: address_details[:address_line2],\n address_line3: address_details[:address_line3], address_line4: address_details[:address_line4],\n town: address_details[:address_town_or_city], county: address_details[:address_county_or_region],\n postcode: address_details[:address_postcode_or_zip], country: address_details[:address_country_code]\n )\n end",
"def build_params_for_address()\n\n end",
"def full_address\n return \"#{@address}, #{@apart} #{@city} #{@state}, 60611\"\n end",
"def getnewaddress\n @api.request 'getnewaddress'\n end",
"def address\n @address\n end",
"def billing_address\n @billing_addresses = BillingAddress.all.order('id DESC')\n render :template => \"backend/BillingAddress/billing_address\"\n end",
"def create\n @address = @company.addresses.build(address_params) \n\n respond_to do |format|\n if @address.save\n # If this is first address, set as bill and ship address\n @company.billaddress ||= @address.id\n @company.shipaddress ||= @address.id\n @company.save!\n\n format.html { redirect_to edit_company_path(@company), notice: 'Address was successfully created.' }\n format.json { render :show, status: :created, location: @address }\n else\n format.html { render :new }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def as_json(options = {})\n { :id => id,\n :name => name,\n :address => 'address',\n :latitude => address.latitude.to_s,\n :longitude => address.longitude.to_s }\n end",
"def address(format = :full)\n if state_code.to_s != \"\"\n s = \", #{state_code}\"\n elsif state.to_s != \"\"\n s = \", #{state}\"\n else\n s = \"\"\n end\n \"#{city}#{s} #{postal_code}, #{country}\".sub(/^[ ,]*/, '')\n end",
"def getnewaddress(account = nil)\n @api.request 'getnewaddress', account\n end",
"def show\n render json: @contact.address\n end",
"def full_address\n return\"#{self.client},#{self.rep_address_one} #{self.rep_address_two},#{self.city},#{self.state},#{self.zipcode}\"\n end",
"def full_address(include_country = false, include_secondary = false)\n address = \"#{street_address(include_secondary)} #{postal_code} #{city}\"\n address = \"#{address} POLOGNE\" if include_country\n address\n end",
"def purchase_options\n {\n :ip => ip_address,\n :billing_address => {\n :name => \"#{billing_address.first_name} #{billing_address.last_name}\",\n :address1 => billing_address.address,\n :city => billing_address.city,\n :state => billing_address.state,\n :country => \"US\",\n :zip => billing_address.zip\n },\n :tax => tax_in_cents,\n :order_id => self.id\n }\n end",
"def full_address\n addr = []\n addr << country.try(:name) if show_country\n addr << (state.try(:name).presence || state_name) if show_state\n addr << address1\n addr.compact.join(', ')\n end",
"def show\n user = User.find(params[:id])\n render json: user.address\n end",
"def address\n '310 S Harrington'\n end",
"def gmaps4rails_address\n \t\"#{address}, #{city}, #{state}\"\n end",
"def gmaps4rails_address\n\t\t\"#{self.street}, #{self.city}, #{self.country}\" \n\tend"
] |
[
"0.7202232",
"0.71755147",
"0.7173584",
"0.7112513",
"0.7093242",
"0.6926755",
"0.6901112",
"0.68754226",
"0.6872379",
"0.68548584",
"0.68484205",
"0.6846325",
"0.67974365",
"0.67877334",
"0.6725801",
"0.6724113",
"0.66894776",
"0.6676635",
"0.6675103",
"0.6662099",
"0.6615622",
"0.65703607",
"0.65684515",
"0.65663606",
"0.65622723",
"0.65275574",
"0.65214694",
"0.65189123",
"0.6516283",
"0.65100926",
"0.64850515",
"0.6465523",
"0.64639354",
"0.6463598",
"0.6460636",
"0.6457005",
"0.64517164",
"0.6443321",
"0.64428604",
"0.64369506",
"0.6436273",
"0.6421669",
"0.64146274",
"0.6408882",
"0.6406967",
"0.64052963",
"0.6405282",
"0.6396349",
"0.6392194",
"0.63843143",
"0.6383369",
"0.63789535",
"0.6375507",
"0.637359",
"0.63689566",
"0.63668394",
"0.63604796",
"0.63545626",
"0.6354157",
"0.6348294",
"0.63347167",
"0.633196",
"0.6331754",
"0.63299525",
"0.6328351",
"0.6321228",
"0.63125086",
"0.63058555",
"0.6289725",
"0.6289424",
"0.6280885",
"0.6279807",
"0.6274404",
"0.62720335",
"0.6269022",
"0.6259353",
"0.62533057",
"0.6253071",
"0.62520087",
"0.6243702",
"0.62405235",
"0.62372965",
"0.6235674",
"0.6235378",
"0.62349087",
"0.62298137",
"0.62291545",
"0.62288785",
"0.622607",
"0.6224821",
"0.6218098",
"0.6214674",
"0.6214031",
"0.6206931",
"0.62024903",
"0.61985236",
"0.6196387",
"0.6195123",
"0.6194033",
"0.61933994"
] |
0.75897086
|
0
|
Update delivery mode id of sales order with given id
|
def update_delivery_mode
sales_order = @customer.open_orders.find_by_id( params[:id] )
sales_order.delivery_mode_id = params[:delivery_mode_id]
render :text => sales_order.save
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_delivery_order\n @delivery_order = DeliveryOrder.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n @delivery = Delivery.find(@order.delivery_id)\n end",
"def update\n @sales_order = SalesOrder.find(params[:id])\n\n # update delivery_status(includes reschedule devlivery_plan) \n if not params[:delivery_status]\n # if current_issue_cart.line_items.exists? \n @sales_order.issue_unissue_po_line_items_when_so_and_cart_diffs(current_issue_cart) \n\n @sales_order.line_items.clear\n @sales_order.add_line_items_from_issue_cart(current_issue_cart)\n @sales_order.save\n # Cart.destroy(session[:issue_cart_id])\n # session[:issue_cart_id] = nil \n # end \n end \n\n respond_to do |format|\n if @sales_order.update_attributes(params[:sales_order])\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully updated.' }\n format.json { head :no_content } \n else\n @orders = Order.where(customer_id: @sales_order.customer.id)\n @cart = current_issue_cart\n\n session[:cart_order_type] = \"SalesOrder\"\n session[:cart_order_id] = @sales_order.id\n\n format.html { render action: \"edit\", notice: 'Sales order can not update.' }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_delivery_option\n @delivery_option = DeliveryOption.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def set_delivery\n @delivery = Delivery.find(params[:id])\n end",
"def update_order_status\n order.delivery_status = status\n order.save\n end",
"def set_delivery\n @delivery = Delivery.find_by_id(params[:id])\n end",
"def update\n @order = Order.find(params[:id])\n @delivery = @order.delivery\n @member = @order.member\n\n respond_to do |format|\n if @order.update_attributes(params[:order])\n Notifier.order_confirmation(@order, true).deliver\n flash[:notice] = 'Order was successfully updated.'\n format.html { redirect_to order_path(:id => @order, :farm_id => @farm.id) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def deliver\n order = current_user.restaurant.orders.find(params[:id])\n order.update(status: 7)\n render json: {is_success: true}, status: :ok\n end",
"def update\n @delivery_order = DeliveryOrder.find(params[:id])\n\n respond_to do |format|\n if @delivery_order.update_attributes(params[:delivery_order])\n format.html { redirect_to @delivery_order, notice: 'Delivery order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @delivery_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_delivery\n if params[:id]\n @delivery = Delivery.find(params[:id])\n else\n @delivery = Delivery.find(params[:delivery_id])\n end\n end",
"def update\n @order = Order.find(params[:id])\n unless @order.delivery_company_id.blank?\n @order.delivery_company_name=DeliveryCompany.find(@order.delivery_company_id).name\n else\n @order.delivery_company_name=\"\"\n end\n order_status_id=params[:order_status_id].to_i\n if @order.current_order_status.id!=order_status_id\n dict={}\n dict[1]=\"未确认\"\n dict[2]=\"确认\"\n dict[4]=\"正在配货\"\n dict[8]=\"配货完成\"\n dict[16]=\"已发货\"\n dict[64]=\"取消\"\n dict[128]=\"过期\"\n#如果订单标记为退货,则积分不返还,这样就省事一些,退货得退钱到现金账户,没有考虑细节,比如部分退换货\n @order.order_statuses << OrderStatus.create(:name=>dict[order_status_id],:value=>order_status_id,:tuangou=>false,:from=>\"后台订单管理\",:url=>request.fullpath)\n if order_status_id==16 and @order.tuangou==true\n email=@order.user.email\n email=\"frederick.mao@gmail.com\"\n title=@order.tuan.sub_title#以后改成edm_title\n mail=TuanMail.order_send(@order,email,title)\n mail.deliver \n logger.debug(\"TTTTTTTTTTTTREEEEEEEEEEEEEEEEEEEEE\")\n elsif order_status_id==16 and @order.tuangou==false\n CoreMail.order_send(@order).deliver\n logger.debug(\"发送已发货邮件\")\n end\n end\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to([:admin,@order], :notice => 'Order was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_farm_order\n @order = Order.find(params[:id])\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def set_deliveryinfo\n @deliveryinfo = Deliveryinfo.find(params[:id])\n end",
"def set_delivery_item\n @delivery_item = Shop::DeliveryItem.find(params[:id])\n end",
"def set_food_delivery_type\n @food_delivery_type = FoodDeliveryType.find(params[:id])\n end",
"def ship_order\n self.update_attributes(status: 2)\n end",
"def update\n @order = Order.find(params[:id])\n redirect_to :action => \"index\" and return if current_admin.limited_sales_rep && !current_admin.users.include?(@order.user)\n respond_to do |format|\n if @order.update_attributes(params[:order])\n format.html { redirect_to(admin_orders_url, :notice => 'Order was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @order.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_delivery_item\n @delivery_item = DeliveryItem.find(params[:id])\n end",
"def update\n @order_detail = OrderDetail.find(params[:id])\n @order = Order.find(@order_detail.order_id)\n if params[:order_detail][:production_status] == \"in_production\"\n @order.order_status = \"in_production\"\n @order.save\n end\n if @order_detail.update(order_detail_params)\n count_production_completed = 0\n @order.order_details.each do |order_detail|\n if order_detail.production_status == \"production_completed\"\n count_production_completed += 1\n end\n end\n if @order.order_details.count == count_production_completed\n @order.order_status = \"preparing_for_shipping\"\n @order.save\n end\n redirect_to admin_order_path(@order)\n else\n redirect_to admin_order_path(@order)\n end\n end",
"def update_delivery\n @cart = Cart.find(params[:cart][:id])\n @cart.update(delivery_id: params[:cart][:delivery_id])\n discount_code_applied\n respond_to do |format|\n format.html { redirect_to @cart, notice: 'La livraison a été mise à jour' }\n format.js {}\n format.json { render :show, status: :ok, location: @cart }\n end\n end",
"def delivery_address_update\n # stores the current delivery address\n delivery_address = @current_user.addresses.find_by(delivery_address: true)\n delivery_address.delivery_address = nil\n delivery_address.save!\n # changes the current delivery address to the given address id as a parameter\n address = @current_user.addresses.find(params[:id])\n address.delivery_address = true\n address.save!\n redirect_to cart_items_path\n end",
"def set_delivery_area\n @delivery_area = DeliveryArea.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @delivery_order.update(delivery_order_params)\n format.html { redirect_to @delivery_order, notice: 'Delivery order was successfully updated.' }\n format.json { render :show, status: :ok, location: @delivery_order }\n else\n format.html { render :edit }\n format.json { render json: @delivery_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sale_order = current_company.sale_orders.find(params[:id])\n\n respond_to do |format|\n if @sale_order.update_attributes(params[:sale_order])\n format.html { redirect_to sale_orders_path, notice: 'Sale order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sale_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order\n @order = ShopOrder.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n #Также нужны переменные\n @client=Client.find(@order.client_id)\n @delivery=Delivery.find(@order.delivery_id)\n @employee=Employee.find(@order.employee_id)\n @ordered=Ordered.where(\"order_id=?\",@order.id)\n end",
"def set_item_delivery\n @item_delivery = ItemDelivery.find(params[:id])\n end",
"def set_confirmed_order\n @confirmed_order = ConfirmedOrder.find(params[:id])\n end",
"def update\n @order = Order.find(params[:id])\n # shop = ShopifyAPI::Shop.current\n\n # f = ShopifyAPI::Fulfillment.new({order_id: @order.shopify_order_id,\n # location_id: @order.location_id,\n # line_items: @order.shopify_product_id,\n # tracking_number: @order.tracking_numbers})\n # f.prefix_options = { :order_id => @order.shopify_order_id }\n # f.save!\n # respond_to do |format|\n if @order.update(order_params)\n # ShopifyAPI::Fulfillment.new({order_number: @order.shopify_order_id,\n # location_id: @order.location_id,\n # line_items: @order.shopify_product_id,\n # tracking_numbers: @order.tracking_numbers})\n f = ShopifyAPI::Fulfillment.new(\n :location_id => \"#{@order.location_id}\",\n :line_item => \"#{@order.shopify_product_id}\",\n :tracking_number => \"#{@order.tracking_numbers}\",\n :tracking_company => \"USPS\",)\n f.prefix_options = { :order_id => \"#{@order.shopify_order_id}\" }\n f.save!\n # format.html { redirect_to '/', notice: 'Order was successfully updated.' }\n # format.json { render :show, status: :ok, location: @order }\n else\n # format.html { render :edit }\n # format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n # end\n end",
"def mark_as_delivered\n order = Order.find(params[:id])\n order.delivered_at = DateTime.now\n order.save!\n redirect_to orders_path\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def update\n @user = current_user\n @order = Order.find(params[:id])\n @price_plan = Country.get_price_plan_by_country_and_id(current_user.account.country_short, @order.price_plan_id)\n\n if @order.save\n if @order.purchase\n\n @order.update_attributes(kind: 'paypal', state: 'success', completed_at: Time.now.utc)\n @price_plan.mark_promotion_code_for_usage(@order)\n subscription = @user.account.add_subscription(@price_plan, @order)\n subscription.activate\n @user.account.finish_registration()\n\n redirect_to( action: 'success', id: @order )\n else\n redirect_to( action: 'failure', id: @order )\n end\n else\n render action: 'edit'\n end\n end",
"def update_order(result)\n create_asendia_shipment_record(result['Status'], result['Error'])\n @transaction_id = result['ParcelId']\n @tracking_number = nil\n shipment = @order.shipment\n shipment.tracking = @tracking_number\n shipment.save\n shipment.ship!\n @order.line_items.each do |line_item|\n @success_orders << [\"#{@order.number}, #{line_item.sku}, #{@tracking_number}, #{@transaction_id}, #{line_item.quantity}, #{@order.completed_at}, #{(@order.ship_address.country.try(:name) || '').delete(',')}\"]\n end\n end",
"def set_order\n @order = @restaurant.orders.find(params[:id])\n end",
"def create_order_id\n self.order_id = \"GO%.5d\" % self.id\n self.save\n end",
"def update\n @order = Order.find_by(id: session[:order_id])\n @order.assign_attributes(order_update_params[:order])\n @order.last_four_cc = params[:order][:last_four_cc][-4..-1]\n\n if @order.save\n @user = User.find_by(id: session[:user_id])\n redirect_to :shipping\n else\n @user = User.find_by(id: session[:user_id])\n render :edit\n end\n end",
"def set_sales_order_product\n @sales_order_product = SalesOrderProduct.find(params[:id])\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Product::Order.find(params[:id])\n end",
"def set_order\n @order = Product::Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_fabrication_order\n @fabrication_order = FabricationOrder.find(params[:id])\n end",
"def change_delivery_drink_quantity\n # get data to add/update\n @data = params[:id]\n @data_split = @data.split(\"-\")\n @add_or_subtract = @data_split[0]\n @user_delivery_id = @data_split[1]\n \n # get User Delivery info\n @account = Account.find_by_id(current_user.account_id)\n @user_subscription = UserSubscriptionn.where(account_id: current_user.account_id, currently_active: true).first\n @user_delivery_info = UserDelivery.find_by_id(@user_delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n @inventory = Inventory.find_by_id(@user_delivery_info.inventory_id)\n \n # adjust drink quantity, price and inventory\n @original_quantity = @user_delivery_info.quantity\n @drink_price = @user_delivery_info.inventory. + @user_subscription.pricing_model\n @current_inventory_reserved = @inventory.reserved\n if @add_or_subtract == \"add\"\n # set new quantity\n @new_quantity = @original_quantity + 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal + @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved + 1\n @inventory.update(reserved: @new_inventory_reserved)\n\n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n \n else\n # set new quantity\n @new_quantity = @original_quantity - 1\n \n #set new price totals\n @original_subtotal = @delivery.subtotal\n @new_subtotal = @original_subtotal - @drink_price\n @new_sales_tax = @new_subtotal * @account.delivery_zone.excise_tax\n @new_total_price = @new_subtotal + @new_sales_tax\n \n # update reserved inventory \n @new_inventory_reserved = @current_inventory_reserved - 1\n @inventory.update(reserved: @new_inventory_reserved)\n \n # update user delivery info\n @user_delivery_info.update(quantity: @new_quantity)\n end\n \n # update delivery info and note a confirmation email should be sent\n @delivery.update(subtotal: @new_subtotal, sales_tax: @new_sales_tax, total_drink_price: @new_total_price, delivery_change_confirmation: false)\n \n # add change to the customer_delivery_changes table\n @customer_delivery_change = CustomerDeliveryChange.where(user_delivery_id: @user_delivery_id).first\n if !@customer_delivery_change.blank?\n @customer_delivery_change.update(new_quantity: @new_quantity, change_noted: false)\n else\n @new_customer_delivery_change = CustomerDeliveryChange.new(user_id: current_user.id, \n delivery_id: @user_delivery_info.delivery_id,\n user_delivery_id: @user_delivery_id,\n beer_id: @user_delivery_info.beer_id,\n original_quantity: @original_quantity,\n new_quantity: @new_quantity,\n change_noted: false)\n @new_customer_delivery_change.save!\n end\n \n # set new delivery details and delivery info\n @next_delivery = UserDelivery.where(delivery_id: @user_delivery_info.delivery_id)\n @delivery = Delivery.find_by_id(@user_delivery_info.delivery_id)\n \n # count number of drinks in delivery\n @drink_count = @next_delivery.sum(:quantity)\n # count number of drinks that are new to user\n @next_delivery_cooler = 0\n @next_delivery_cellar = 0\n @next_delivery_small = 0\n @next_delivery_large = 0\n # cycle through next delivery drinks to get delivery counts\n @next_delivery.each do |drink|\n @quantity = drink.quantity\n if drink.cellar == true\n @next_delivery_cellar += (1 * @quantity)\n else\n @next_delivery_cooler += (1 * @quantity)\n end\n if drink.large_format == true\n @next_delivery_large += (1 * @quantity)\n else\n @next_delivery_small += (1 * @quantity)\n end\n end \n \n respond_to do |format|\n format.js\n end # end of redirect to jquery\n end",
"def update\n @order.update_attribute(:state, 'cart')\n if params[:shipments_attributes].present?\n if cookies[:board_id].present?\n @order.room_cookie = cookies[:board_id]\n end\n if cookies[:portfolio_id].present?\n @order.portfolio_cookie = cookies[:portfolio_id]\n end\n #params[:shipments_attributes].each do |key, value|\n #\n # shipment = @order.shipments.where(id: value[:id]).first\n # if shipment.present?\n # rate = shipment.shipping_rates.where(id: value[:selected_shipping_rate_id]).first\n #\n # if rate.present?\n # shipment.update_attributes({selected_shipping_rate_id: rate.id, cost: rate.cost})\n # end\n # end\n # shipment.adjustments.create(amount: shipment.cost, source_type: 'Spree::Order', order_id: @order.id, label: 'Shipment')\n #\n # #if @order.adjustments.where(label: 'Shipment').blank?\n # #@order.adjustments.shipping.create(amount: @order.shipments.sum(:cost), source_type: 'Spree::Shipment' ,label: 'Shipment')\n # #end\n #end\n if @order.update_from_params(params, permitted_checkout_attributes)\n persist_user_address\n unless @order.next\n\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to one_page_checkout_path and return\n end\n\n if @order.completed?\n @order.payments.destroy_all if request.put?\n @order.update_totals\n # @order.update(shipment_total: @order.shipments.sum(&:cost))\n shipment_total = @order.shipments.sum(&:cost)\n @order.update(total: @order.item_total + @order.additional_tax_total + shipment_total + @order.promo_total + @order.adjustment_total,shipment_total: shipment_total)#+ @order.adjustment_total\n unless @order.confirmation_delivered?\n @order.deliver_order_confirmation_email\n @order.update_columns(send_order_confirmation_email: true, order_confirmation_sent: true)\n end\n # Rails.logger.info session[:order_id]\n # session[:order_id] = nil\n if @order.subscribe == true\n @subscriber = Spree::Subscriber.find_by_email(@order.email)\n if @subscriber.present?\n @subscriber.update_attribute(\"last_subscribed_at\", Time.now)\n else\n sub = Spree::Subscriber.create(:email => @order.email, :last_subscribed_at => Time.now)\n Rails.logger.info \"ADDED TO MAILCHIMP LIST\" if sub.add_subscriber_to_mailchimp('subscribers')\n end\n end\n\n if @order.user_id.nil? and @order.email.present?\n user = Spree::User.find_by_email(@order.email)\n @order.update_columns(user_id: user.id) if user\n end\n\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:commerce_tracking] = \"nothing special\"\n cookies[:user_movement_id] = nil\n redirect_to order_confirmation_path\n else\n redirect_to checkout_state_path(@order.state)\n end\n else\n\n render :edit\n end\n else\n @order.errors.add(:shipments, \"Can't be blank\")\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to cart_path\n end\n\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end"
] |
[
"0.70056903",
"0.664061",
"0.6504144",
"0.64623064",
"0.63080394",
"0.63080394",
"0.63080394",
"0.63080394",
"0.63080394",
"0.63080394",
"0.63080394",
"0.6276239",
"0.62408423",
"0.6236928",
"0.6202967",
"0.6189267",
"0.61659944",
"0.61258143",
"0.6118086",
"0.6083522",
"0.6083522",
"0.60792583",
"0.6012927",
"0.60018194",
"0.5986505",
"0.5917078",
"0.59169734",
"0.5908616",
"0.59001666",
"0.5884983",
"0.5877706",
"0.5860909",
"0.5853874",
"0.5830384",
"0.5828674",
"0.58240664",
"0.5814746",
"0.5803101",
"0.5777338",
"0.5776781",
"0.5775519",
"0.5772373",
"0.5738507",
"0.5733438",
"0.5723061",
"0.5719351",
"0.5711825",
"0.5711825",
"0.5706506",
"0.5697194",
"0.5697194",
"0.56911385",
"0.56885135",
"0.5670597",
"0.5659171",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295",
"0.5654295"
] |
0.8249441
|
0
|
Initialize ERPCustomer and ERPContactPerson via logined user's email.
|
def init_user
#logger.info session.inspect
@store_user = session[:web_user]
@store_user.request_path = request.path + "?" + request.query_string
@customer = ERP::Customer.find_by_account_num @store_user.erp_account_number
if @customer.nil?
render :partial => "unaccessible", :layout => false
return false
end
@user = @customer.contact_people.find_by_email @store_user.email_address
if @user.nil?
@user = ERP::ContactPerson.new
@user.attributes = {
:erp_customer_id => @customer.id,
:first_name => @store_user[:name],
:last_name => @store_user[:name],
:name => @store_user[:name],
:email => @store_user[:email_address]
}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def after_initialize\n if self.new_record?\n self.author_email_address = 'test@test.com'\n end\n end",
"def initialize_email\n require File.expand_path('../../appenders/email', __FILE__)\n end",
"def after_initialize\n if new_record?\n self.email ||= \"jakub.hozak@gmail.com\"\n end\n end",
"def before_rpx_auto_create(rpx_user)\n # Get email (if the provider supports it). This is already done?\n unless rpx_user[\"email\"].blank?\n self.email = rpx_user[\"email\"]\n end\n # This might cause conflicts, should we use the email as name instead?\n unless rpx_user[\"username\"].blank?\n self.name = rpx_user[\"username\"]\n end\n end",
"def initialize(fields)\n set_attributes fields['email']\n end",
"def initialize(uri, factory, email_selector = nil, ldap_lookup = nil, json: nil, ld: nil)\n super(uri, factory)\n if json\n self.first_name = json['firstName']\n self.role = json['role']\n self.surname = json['surname']\n # Set the email, primary_email and username properties from the email address list\n set_email(json['email'], email_selector, ldap_lookup)\n else\n self.first_name = nil\n self.role = []\n self.surname = nil\n self.email = []\n self.primary_email = nil\n self.username = nil\n end\n end",
"def user_setup\n\t\tif self.id.blank?\n\t\t\tself.id = self.email\n\t\t\n\t\tend\n\tend",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.emailIdentity\"\n end",
"def set_contactperson_email\n @contactperson_email = ContactpersonEmail.find(params[:id])\n end",
"def initialize(*args, email_selector: nil, filename: nil, ldap_lookup: nil, **kwargs, &block)\n super(*args, **kwargs, &block)\n self.email_selector = email_selector\n self.ldap_lookup = ldap_lookup\n self.load(filename) if filename\n end",
"def initialize(params)\n require_keys([:email], params)\n merge!(params)\n end",
"def init_by_email(email)\n if email.present?\n where(email: email).first_or_initialize\n else\n new\n end\n end",
"def initialize(params)\n super\n\n @email = @params[:email]\n @name = @params[:name]\n end",
"def meteor_create_initial_email\n add_to_set(emails: build_meteor_mail_hash(email, confirmed?))\n end",
"def initialize(email_to_save)\n @email = email_to_save\nend",
"def init_by_user(user)\n return self unless user\n self.user = user\n self.name = user.name\n self.email = user.email\n self\n end",
"def set_defaults\n\t\tself.email = self.users.first.email if ['student','school_admin','admin'].include? self.role\n\t\tself.uuid = SecureRandom::uuid()\n\t\tself.active = true\n\tend",
"def initialize\n @email = EMAIL\n @name = NAME\n end",
"def initialize(email_addresses) # Second, we initialize our string of emails.\n @email_addresses = email_addresses\n end",
"def initialize(email)\n @email = email\n end",
"def prepare_contacts\n return unless defined? @user\n @user.user_default_emails.sort_by{|a| a.role_id.to_i}\n end",
"def set_user_email\n @user_email = UserEmail.find(params[:id])\n end",
"def initialize(email)\n @email = email\n end",
"def employee\n @last_ext += 1\n p = Person.new\n p.office_phonenumber = Phonenumber.new(@phonenumber.prefix, phonenumber.number, @last_ext.to_s)\n p.office_email = Email.new(p)\n p.office_email.user_from_names(p, \".\")\n p.office_email.host = @domain\n p\n end",
"def set_email(email = nil, email_selector = nil, ldap_lookup = nil)\n self.email = email || []\n if email_selector\n # Get the primary email address from the address list\n self.primary_email = email_selector.email(self.email)\n # Get the username from the primary email address\n if ldap_lookup and self.primary_email\n self.username = ldap_lookup.find(self.primary_email)\n else\n self.username = nil\n end\n else\n self.primary_email = nil\n self.username = nil\n end\n end",
"def initialize(name, phone_number, email)\n\t\t@name = name\n @phone_number = phone_number\n @email = email\n end",
"def initialize\n @name = \"\"\n @recipients = \"\"\n @subject = \"\"\n @email_message = \"\"\n end",
"def set_person_email_address\n @person_email_address = PersonEmailAddress.find(params[:id])\n end",
"def set_user\n @form_user = User.new(:email => self.user_email, :first_name => self.user_first_name,\n :last_name => self.user_last_name)\n @user = User.where(:email => self.user_email).first\n @new_user = false\n if @user.nil?\n @new_user = true\n @user = @form_user\n end\n end",
"def initialize(\n email_address = nil, \n friendly_name = nil\n )\n @email_address = email_address\n @friendly_name = friendly_name\n end",
"def setup \n \t@user = User.create(email: 'example@mail.com', password: '123456789', \n \t\tpassword_confirmation: '123456789')\n \t@request.env[\"devise.mapping\"] = Devise.mappings[:user]\n \t@user1 = users(:one)\n \t@user1.account = accounts(:one)\n end",
"def init_user_orcid\n return unless author_orcid\n return unless (user = resource&.user)\n return if user&.orcid\n\n user.orcid = author_orcid\n user.save\n end",
"def setup_email(user)\n recipients user.email\n from self.contact_email\n sent_on Time.now\n end",
"def initialize(user, attributes = {})\n self.from = user.email\n self.subject = \"#{user.name} resume\"\n self.text_body = TEXT_TEMPLATE\n self.html_body = HTML_TEMPLATE\n self.emails = ''\n attributes.each do |name, value|\n send(\"#{name}=\", value)\n end\n end",
"def initialize email, api_key\n @email = email\n @api_key = api_key\n end",
"def initialize(first_name, last_name, username, email)\n @first_name = first_name\n @last_name = last_name\n @email = email\n @username = username\n end",
"def initialize_advertiser_user\n self.user_type = TYPE_ADVERTISER\n self.update_user_code\n self.status = STATUS_ACTIVE\n end",
"def initialize(user)\n raise(Utility::Errors::NotFound, \"UserProfile Requires a instance from the Users model.\") unless user\n\n @user_object = user\n @last_access = Time.zone.now\n\n [:@id, :@person_authentication_key, :@assigned_roles,\n :@name, :@user_options, :@assigned_groups, :@username,\n :@email, :@roles].each do |k|\n instance_variable_set(k, nil)\n instance_variable_set(k, user.send(k.to_s[1..-1].to_sym) )\n end\n\n @user_options ||= []\n setup_combined_user_roles()\n end",
"def initialize_account\n if employer_profile_account.blank?\n self.build_employer_profile_account\n employer_profile_account.next_premium_due_on = (published_plan_year.start_on.last_month) + (Settings.aca.shop_market.binder_payment_due_on).days\n employer_profile_account.next_premium_amount = 100\n # census_employees.covered\n save\n end\n end",
"def initialize(admin, candidates)\n @admin = admin\n @candidates = candidates\n @email_index = -1\n end",
"def set_employee_email\n @employee_email = EmployeeEmail.find(params[:id])\n end",
"def set_email\n @email = params[:id] ? Email.find(params[:id]) : Email.new(email_params)\n end",
"def initialize(email_to_save)\n @email = email_to_save\n @@user_count = @@user_count + 1\n end",
"def apply_omniauth(omniauth)\r\n self.email = omniauth['user_info']['email'] if email.blank?\r\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\r\n end",
"def setup_email_account\n email_accounts.create!(email: email, primary: true, confirmed: !confirmed_at.blank?)\n end",
"def initialize(configuration)\n super\n require_configuration([:email, :password, :source])\n setup!\n end",
"def initialize(user, data)\n\t\t\tsuper(user)\n\t\t\tinit(data)\n\t\tend",
"def setup_email(user)\n @recipients = \"#{user.email}\"\n @from = AppConfig.app_email\n @subject = \"[#{AppConfig.app_name}] \"\n @sent_on = Time.now\n @body[:user] = user\n end",
"def initialize(name, email)\n self.name = name\n self.email = email\n end",
"def initialize(params)\n @first_name = params[:user][:first_name]\n @last_name = params[:user][:last_name]\n @company_name = params[:user][:company][:company_name]\n @email = params[:user][:email]\n @password = params[:user][:password]\n end",
"def civicrm_emails\n emails = ALF::Email.where('person', self.person_id)\n prev_id = CIVICRM::VineContactPrevId.where(alf_id: self.person_id).take.contact_id;\n contact = CIVICRM::Contact.find(prev_id)\n\n emails.each do |e|\n e_type = ALF::EmailType.findId(e.email_type)\n\n if e_type.present? && (e_type.email_type == 'Personal')\n loc_type = CIVICRM::LocationType.where(name: 'Primary').take\n primary = true\n else\n loc_type = CIVICRM::LocationType.where(name: 'Secondary').take\n primary = false\n end\n\n email = CIVICRM::Email.new(\n contact_id: contact.id,\n email: e.email_address,\n location_type_id: loc_type.id,\n is_primary: primary\n )\n\n if !email.valid? || !email.save\n raise \"Invalid Email Model\\nCIVICRM::Email: #{email.inspect}\\nALF::Email: #{e.inspect}\\nPerson: #{self.person_id}\\n\"\n end\n end\n end",
"def initialize mailer=\"mutt\"\n @mailer = mailer\n end",
"def initialize()\n @email = nil\n @first_name = nil\n @last_name = nil\n @middle_name = nil\n @nickname = nil\n @name_prefix = nil\n @name_suffix = nil\n @name_phonetic = nil\n @phone = nil\n @record_id = nil\n end",
"def initialize(email = '')\n self.address = email\n end",
"def initialize(*args) # * is a splat operator\n #instance variable for email set to argument 0\n @email = args[0]\n @name = args[1]\n @permissions = User.permissions_from_template\n end",
"def user\n @user ||= User.find_or_initialize_by email: @auth.info.email do |user|\n user.name = @auth.info.name\n user.nickname = @auth.info.name.downcase.split(/\\W/).join('.')\n user.password = Devise.friendly_token[0, 20]\n user.role = :reporter\n end\n end",
"def set_customer_mailer\n @customer_mailer = CustomerMailer.find(params[:id])\n end",
"def initialize(name, email)\n @name = name\n @email = email\n end",
"def email\n @email ||= Email::Gateway.new(client)\n end",
"def user_with_email(email)\n client = self\n MagicBell::User.new(client, \"email\" => email)\n end",
"def initialize(email_to_save)\n @email = email_to_save\n @@user_count += 1\n end",
"def initialize(name,email,phone,second_phone)\n @name = name\n @email = email\n @phone = phone\n @second_phone = second_phone\n end",
"def set_email\n @user_email = UserEmail.find(params[:id])\n end",
"def initialize(emails) # accepts strings of unformatted emails (sting of multiple emails )\n @emails = emails # set the instance varibale email to the value for emails passed in arguement\n end",
"def initialize(name, email, phone) #this is used to initialize varriables\n @name = name\n @email = email\n @phone = phone\n end",
"def initialize(name, email, phone) #this is used to initialize varriables\n @name = name\n @email = email\n @phone = phone\n end",
"def create_user_from_email\n from = email.header['from'].to_s\n addr, name = from, nil\n if m = from.match(/^\"?(.+?)\"?\\s+<(.+@.+)>$/)\n addr, name = m[2], m[1]\n end\n if addr.present?\n user = self.class.new_user_from_attributes(addr, name)\n if handler_options[:no_notification]\n user.mail_notification = 'none'\n end\n if user.save\n user\n else\n logger.error \"MailHandler: failed to create User: #{user.errors.full_messages}\" if logger\n nil\n end\n else\n logger.error \"MailHandler: failed to create User: no FROM address found\" if logger\n nil\n end\n end",
"def after_initialize\n self.user_id = self.invoice.user_id unless self.invoice.blank?\n end",
"def initialize_custom_fields\n fields = service.get_custom_fields(contact_point_list)\n existing_fields = fields.map(&:FieldName)\n\n [\n { name: \"organization_id\", type: 'Number' },\n { name: \"organization_name\", type: 'Text' },\n { name: \"cop_status\", type: 'Text' },\n { name: \"cop_due_on\", type: 'Text' },\n ].each do |hash|\n create_custom_field(hash.fetch(:name), hash.fetch(:type))\n end\n end",
"def initialize(attributes = {}) #initialize method executes when do User.new\n\t\t@name = attributes[:name]\n\t\t@email = attributes[:email]\n\tend",
"def constructed_user\n OpenStruct.new(email: current_user.email)\n end",
"def initialize(params)\n @params = params\n @service = ENV['EMAIL_SERVICE'].constantize.new(@params)\n @errors = []\n end",
"def initialize\n @sex = ['f','m'].sample\n\n if @sex == 'm'\n @firstname = FIRSTNAMES_MALE.sample\n else\n @firstname = FIRSTNAMES_FEMALE.sample\n end\n\n @lastname = LASTNAMES.sample\n\n @address = Address.new\n\n @phonenumber = Phonenumber.new(@address.phone_prefix) if rand(1..100) > 10\n @mobile = Phonenumber.mobile if rand(1..100) > 20\n\n @email = Email.new(self) if rand(1..100) > 35\n end",
"def apply_omniauth(omniauth)\n self.email = omniauth['user_info']['email'] if email.blank?\n apply_trusted_services(omniauth) if self.new_record?\n authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])\n end",
"def initialize_emails\n @emails = MailingList.first.emails\n end",
"def user\n @user ||= User.new @mail\n end",
"def initialize(name, email, address1, address2, city, state,\n country, pincode, contact_number, id=nil)\n @name = name\n @email = email\n @address1 = address1\n @address2 = address2\n @city = city\n @state = state\n @country = country\n @pincode = pincode\n @contact_number = contact_number\n @id = id\n end",
"def assign_company_and_set_passenger\n self.type= 'Passenger'\n if self.email\n domain = self.email.split('@')[1]\n company = Company.find_or_initialize_by(domain: domain)\n if company.new_record?\n logger.debug 'creating company with '+domain\n company.name= domain\n company.address= 'unknown'\n end\n self.company = company\n self.default_office = company.offices.first if self.default_office.nil?\n else\n false\n end\n end",
"def email=(value)\n self.from_email = value\n end",
"def user_init; end",
"def initialize(user_context, record)\n @acting_user, @system_settings = extract user_context\n @record = record\n end",
"def email=(value)\n candidate_sheet.candidate_email = value\n end",
"def setup_email(user)\n @recipients = user.email\n @body[:user] = user\n @from = FROM_EMAIL\n @subject = case ENV['RAILS_ENV'] \n when 'development': \"[YourApp Development] \"\n when 'staging': \"[YourApp Staging] \"\n else \"[YourApp] \"\n end\n @sent_on = Time.now\n headers \"Reply-to\" => FROM_EMAIL\n end",
"def initialize(uri, factory, json: nil, ld: nil)\n super(uri, factory)\n json ||= {}\n self.email = json['email']\n self.first_name = json['firstName']\n self.role = json['role']\n self.surname = json['surname']\n end",
"def initialize\n self.mailer = SendGrid::Mail.new\n smtpapi.add_category Emque::Consuming.application.config.app_name\n smtpapi.add_category Inflecto.underscore(self.class.name)\n self\n end",
"def create_user(obj, type)\n @logger.info(\"Creating user for #{type} #{obj.name}\")\n user = SugarCRM::User.new\n user.user_name = (type == 'agent') ? obj.emerchantpay_agent_id : obj.emerchantpay_iso_id\n user.user_name ||= \"EMP\"\n user.last_name = obj.name\n user.type_c = type\n #user.email1 = obj.email_address || \"mail@example.com\"\n user.email1 = 'stefan@emerchantpay.com'\n user.status = 'Inactive'\n user.system_generated_password = false\n user.save!\n obj.assigned_user_id = user.id\n obj.save!\n \n populate_user_pool(user, type)\n end",
"def set_email_account\n @email_account = current_user.email_accounts.find(params[:id])\n end",
"def create_employee_user\n email = self.work_email\n user = User.new(email: self.work_email, password: 'appsimpact@#123', role: 'employee')\n user.save\n self.user_id = user.id\n end",
"def initializeApprovalAndLDAP(emailConf, prod)\n @ldap = ldap_storage\n ApprovalEngine.init(@ldap, nil, !prod)\nend",
"def initialize_ab_person\n @ab_person = ABPerson.alloc.initWithAddressBook(address_book)\n load_ab_person\n @ab_person\n end",
"def initialize email,token\n super(email, token)\n end",
"def initialize(first_name, last_name, contact)\n\t\tsuper(first_name, last_name)\n\t\t@contact = contact\n\tend",
"def set_pcustomer\n @pcustomer = Pcustomer.find(params[:id])\n end",
"def initialize(email, password)\n self.email = email\n self.password = password\n end",
"def initialize(id, email, address)\n @id = id\n @email = email\n @address = address\n end",
"def initialize(first_name, last_name, email, notes)\n@first_name = first_name\n@last_name = last_name\n@email = email\n@notes = notes\n\tend",
"def initialize(email_to_save)\n @email = email_to_save\n puts \"On envoir un email de bienvenue !\"\n @@user_count = @@user_count + 1\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def build_from_email(email)\n new do |auth|\n auth.provider = 'email'\n auth.email = email\n auth.uid = email\n end\n end"
] |
[
"0.6232575",
"0.61504364",
"0.61116004",
"0.5989782",
"0.59440607",
"0.58635557",
"0.56136346",
"0.5609897",
"0.55926967",
"0.55457896",
"0.55336964",
"0.55041265",
"0.5500439",
"0.54990166",
"0.549587",
"0.54816705",
"0.5475785",
"0.54365516",
"0.54329795",
"0.54312396",
"0.54175466",
"0.5397872",
"0.53963333",
"0.5374682",
"0.5372542",
"0.53636366",
"0.534166",
"0.5340996",
"0.5335395",
"0.53304255",
"0.53253996",
"0.5305164",
"0.52929896",
"0.52736723",
"0.5266977",
"0.52669185",
"0.5265744",
"0.5255833",
"0.5250681",
"0.5238455",
"0.52325714",
"0.5226549",
"0.52247375",
"0.5218813",
"0.52158093",
"0.5215645",
"0.52063054",
"0.5191601",
"0.5188747",
"0.5185695",
"0.51761",
"0.5174767",
"0.5174262",
"0.5168679",
"0.5162988",
"0.5157635",
"0.51312643",
"0.5123326",
"0.51182336",
"0.51173383",
"0.5113668",
"0.51120085",
"0.5110375",
"0.510086",
"0.50981945",
"0.50981945",
"0.5091015",
"0.5082678",
"0.50753486",
"0.5072715",
"0.50700516",
"0.5067088",
"0.505665",
"0.5056001",
"0.5049476",
"0.504704",
"0.504582",
"0.5041834",
"0.5041065",
"0.5040423",
"0.5033959",
"0.5031149",
"0.5030213",
"0.5029177",
"0.50291276",
"0.5028998",
"0.5024779",
"0.5019476",
"0.5018757",
"0.5012692",
"0.5010829",
"0.5008002",
"0.5001806",
"0.49879843",
"0.49865898",
"0.49809402",
"0.49805534",
"0.49770683",
"0.49770683",
"0.49753544"
] |
0.642711
|
0
|
Get specified contact person using given name.
|
def get_contact
@contact = @customer.contact_people.find_by_name params[:id]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_contact(name)\n contacts = {\n \"Mike Dane\" => \"(02) 9876 0402\",\n \"Tom Sanchez\" => \"(02) 9872 6432\",\n \"Karen Posner\" => \"(02) 9476 5488\",\n \"Ryan Terry\" => \"(08) 7776 5532\",\n \"Chris Freeman\" => \"(05) 9666 8412\"\n }\n\n for contact in contacts\n if contacts.has_key?(name)\n return contacts[name]\n else\n return \"No Record Found\"\n end\n end\nend",
"def get_contact(contact_name, project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ContactName'] = contact_name\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/contacts/[ContactName]'\n\t\targs[:query]['Action'] = 'GetContact'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tself.run(args)\n\tend",
"def contact(contact, options = {})\n get(\"contacts/#{contact}\", options).pop\n end",
"def by_name first_name, last_name\n query = { \"and\" => [{ \"first name\" => { \"is\"=> first_name } }, { \"last name\" => { \"is\"=> last_name } }, { \"record type\"=> { \"is\"=> \"person\" }} ] }\n resp = @nimble.get 'contacts', { :query => query.to_json }\n self.contact = resp['resources'].first\n return nil unless self.contact\n self\n end",
"def get_contact(id)\n contacts = read_contacts\n contacts.select { |contact| contact[:id] == id }.first\nend",
"def get_contact_by_id(contact_id)\n get_contact(contact_id)\n end",
"def get_contact_by_id(contact_id)\n get_contact(contact_id)\n end",
"def find_or_create_xero_contact(name)\n existing = @api.get('Contacts', where: \"Name=\\\"#{name}\\\"\")['Contacts']&.first\n if existing\n logger.debug \"Found existing contact with name: #{name}\"\n logger.debug \"ID: #{existing['ContactID']}\"\n return existing['ContactID']\n end\n\n logger.debug \"Creating new contact with name: #{name}\"\n response = @api.post('Contacts', 'Name' => name)\n id = response['Contacts'].first['ContactID']\n logger.debug \"Contact created with ID: #{id}\"\n id\n end",
"def contact\n find('Contact', contact_id)\n end",
"def get_contact_by_number(contact_number)\n get_contact(nil, contact_number)\n end",
"def get_contact_by_number(contact_number)\n get_contact(nil, contact_number)\n end",
"def get_person(id)\n self.class.get(url(\"people/#{id}\"), headers: @token.headers).parsed_response\n end",
"def contact_name\n contact['name']\n end",
"def contact; Contact.get(self.contact_id); end",
"def contact; Contact.get(self.contact_id); end",
"def contact; Contact.get(self.contact_id); end",
"def contact; Contact.get(self.contact_id); end",
"def contact; Contact.get(self.contact_id); end",
"def person(id)\n get(\"/catalog/people/#{id.to_s}\")\n end",
"def find_by_name(name)\n #iterate over each contact in the contact list and if the name matches the arguemnt to this method we will return that contact\n #start w/empty array of search results which = the contacts in our contact list\n results = []\n #make em all lowercase\n search = name.downcase\n #iterate thru contact if they match append them to the results []\n #add that loop yo\n contacts.each do |contact|\n #then if the first name (downcase that shite) matches our search...\n if contact.full_name.downcase.include?(search)\n #append our results\n results.push(contact)\n end\n end\n #now print out the results NOT resluts bitches\n print_results(\"Name search results (#{search})\", results)\n #now iterate over the result\n# results.each do |contact|\n# puts contact.to_s('full_name')\n# contact.print_phone_numbers\n# contact.print_addresses\n# puts \"\\n\"\n# end\n end",
"def display_one_contact(contact)\n if contact\n puts \"Name: #{contact.name}\"\n puts \"E-mail: #{contact.email}\"\n puts \"Phone Number: #{contact.phone_number}\"\n else\n puts \"Not found!\"\n end\n end",
"def find_first(name)\n object = build(name)\n object.retrieve\n end",
"def show_contact(id)\n get(\"contacts/#{id}\")\n end",
"def get_user(name)\n User.where(name:).first\n end",
"def find_by_name(name)\n # name = gets.chomp\n Contact.all.each do |contact|\n if contact.first_name == name || contact.last_name == name || \"#{contact.first_name} #{contact.last_name}\" == name\n puts \"ID:#{contact.id} Name: #{contact.first_name} #{contact.last_name}, Email: #{contact.email}\".colorize(:light_blue)\n end\n end\n end",
"def retrieve_contact_by_email\n unless @rolodex.is_empty?\n print \"Please, provide the email of the contact in question: \"\n contact = @rolodex.search_contact(gets.chomp)\n if contact\n @rolodex.display_particular(contact)\n else\n puts \"Error: contact not found.\"\n end\n else\n contact = false\n puts \"Error: the Rolodex is empty.\"\n end\n return contact\n end",
"def person( query )\n Person.find( query, self )\n end",
"def get_contact\n if self.contact_id\n return self.contact\n end\n end",
"def get_contact(id)\n\t\t@nutshell.get_contact(id)\n\tend",
"def get_user(name)\n @model.find_by(name: name)\n end",
"def find_contact(id)\n \t@contacts.find {|contact| contact.id == id}\n \tend",
"def contact(id)\n self.contacts.detect { |c| c.id == id }\n end",
"def get_person_by_id(person_id)\n get_object_list \"Person\", get(\"catalog/people/#{person_id}\")\n end",
"def show\n @contact = contacts.find(params[:id])\n end",
"def find_by_name(name)\n find_by('name', name)\n end",
"def search(name)\n\t\tresult = []\n\t\tpeople.each do |person|\n\t\t \tif person.name.include?(name)\n\t\t \tputs \"tel: #{person.phone}\"\n\t\t \tresult << person\n\t\t\tend\n\t\tend\n\t\tresult\n\tend",
"def display_one_contact\n contact = retrieve_contact_by_email\n end",
"def find_by_name(name)\n domain_record = finder(:select => [:id, :name], :conditions => {:name => name})\n return nil if domain_record.nil?\n\n new(domain_record)\n end",
"def find(id)\n result = connection.exec_params(\"SELECT * FROM contacts WHERE id=$1::int LIMIT 1;\", [id])\n contact = result[0] # put a guard here to make sure not nil \n self.new(contact['name'], contact['email'], contact['id'])\n end",
"def fetch id=nil\n id ||= self.id\n resp = @nimble.get \"contact/#{id}\"\n self.contact = resp['resources'].first\n return nil unless self.contact\n self\n end",
"def find(contact_id)\n @contacts.find{|contact| contact.id == contact_id}\n end",
"def find_by_email_or_name(provenance:, is_contact:, json: {})\n return nil unless valid?(is_contact: is_contact, json: json)\n\n # Search the DB for the email\n contributor = find_by_email(json: json) if json[:mbox].present?\n return contributor if contributor.present?\n\n # Search the DB for the name\n find_by_name(provenance: provenance, json: json)\n end",
"def display_particular_contact(id)\n if person = Contact.find_by(id: id)\n {status: true, contact: person.display}\n else\n {status: false, error: \"\\nContact not found.\"}\n end\n end",
"def search_people(name)\n # The TMDB api wrapper returns an instance of a 'results' object\n # This object (OpenStruct?) contains the meta data of the request made to the api\n # in a instance variable called table, which also contains a list of TMDB::Movie\n # Objects that represent the people the api returned as results of the search\n\n # Store the raw results from the api\n results_object = Tmdb::Search.person(name)\n\n # Check if the part of the 'results' object that contains the actual list of people\n # is empty and if it is return nil (Meaning the person was not found) and exit the function\n if results_object.instance_variable_get('@table')[:results][0] == nil\n return nil\n end\n\n # Strip the results object of the attributes and store them in the results hash\n results_hash = results_object.instance_variable_get('@table')\n\n # Assume that the program wants the first actor matching the search from the list of results\n person_object = results_hash[:results][0]\n\n # Returns a hash with the persons name and id (stored under table instance variable)\n {\n name: person_object.instance_variable_get('@table')[:name],\n id: person_object.instance_variable_get('@table')[:id]\n }\n end",
"def find_student(name)\n\t\tstudents.each do |student|\n\t\t\tif student.name == name\n\t\t\t\treturn student\n\t\t\tend\n\t\tend\n\tend",
"def person\n Person.where(:person_id => @person_id).first\n end",
"def get_contact(contacts)\n\tputs \"What is your name?\"\n\tname = gets.chomp\n\tputs \"What is your phone number?\"\n\tphone = gets.chomp.to_i\n\tif not contacts[name]\n\t\tcontacts[name] = phone\n\tend\n\tcontacts\nend",
"def contact_name\n attributes[:contact] && attributes[:contact][:name]\n end",
"def search_name(name)\n PeopleSearch.search_name(name, @api_key, @https)\n end",
"def find_user(name)\n if ( name.downcase != name )\n @logger.info \"Looking for #{name.downcase} instead of #{name}\"\n end\n\n if @cached_users.has_key?(name.downcase)\n return @cached_users[name.downcase]\n end\n\n single_user_query = RallyAPI::RallyQuery.new()\n single_user_query.type = :user\n single_user_query.fetch = @detail_user_fetch\n single_user_query.page_size = 200 #optional - default is 200\n single_user_query.limit = 90000 #optional - default is 99999\n single_user_query.order = \"UserName Asc\"\n single_user_query.query_string = \"(UserName = \\\"\" + name + \"\\\")\"\n\n query_results = @rally.find(single_user_query)\n\n if query_results.total_result_count == 0\n return nil\n else\n # Cache user for use next time\n this_user = query_results.first\n @cached_users[this_user[\"UserName\"].downcase] = this_user\n @logger.info \"Caching User: #{this_user.UserName}\"\n\n return this_user\n end\n end",
"def find_account(name)\n return (accounts.select { |a| a[:name] == name }).first\n end",
"def search_person(name = \"\")\n\t\t@nutshell.search_person(name)\n\tend",
"def fetch_character_by_name(name)\n uri = URI(BASE_URI + \"?name=#{name}\")\n characters = make_request(uri)\n if characters[0]\n Character.new(characters[0])\n else\n \"Couldn't find a character with that name...\"\n end\n end",
"def find(name)\n @users.fetch(name)\n end",
"def show\r\n\t\t@contact = current_user.contacts.find(params[:id])\r\n\tend",
"def find!(ctx, params:, **)\n ctx[:model] = ::Contact.find_by(uuid: params[:id])\n end",
"def find_org_by_name(name, params = {})\n search_orgs(name, params).select { |o| o.name == name }.first\n end",
"def find(id)\n id = id.to_i\n contacts = Contact.all\n contact = nil\n contact = contacts[id-1] unless contacts[id-1].nil?\n end",
"def contact\n @contact ||= get_contact(@data_object.user_contact)\n end",
"def find_person\r\n if (params[:u] == nil || params[:u] == '')\r\n require_login || return\r\n @person = User.current\r\n else\r\n @person = Person.find(params[:u])\r\n end\r\n rescue ActiveRecord::RecordNotFound\r\n render_404\r\n end",
"def find(id)\n Infopark::Crm::Contact.find(id)\n rescue ActiveResource::ResourceNotFound\n raise UserNotFound.new\n end",
"def find_person\n person = nil\n person = Staff.find_by(sam_staff_id: self.sam_demonstrator_id)\n return person != nil ? person : Student.find_by(sam_student_id: self.sam_demonstrator_id)\n end",
"def show\n @contact = current_user.contacts.find(params[:id])\n\n end",
"def show\n @contact = Contact.find(params[:id])\n end",
"def by_name(name)\r\n return User.by_name(name) if User.exists?(name)\r\n Organization.by_name(name) if Organization.exists?(name)\r\n end",
"def get_organization_by_name(name)\n result = nil\n\n # Fetch all organizations\n organizations = get_organizations()\n\n organizations.each do |organization|\n if organization[0].downcase == name.downcase\n result = get_organization(organization[1])\n end\n end\n result\n end",
"def by_name(name)\n return User.by_name(name) if User.exists?(name)\n Organization.by_name(name) if Organization.exists?(name)\n end",
"def contact\n response[\"contact\"]\n end",
"def name\n if person\n person.name\n else\n \"\"\n end\n end",
"def person\n Person.find_by_id( owner, @client )\n end",
"def find_by_name(name, city, state, resource_type)\n begin\n company = Company.new\n r = InfoconnectWrapper.post url,\n {\n :ResourceType => resource_type,\n :CompanyName => name,\n :RequestType => \"Company\",\n :Limit => \"1\",\n :City => city,\n :StateProvince => state\n }, :content_type => :json, :accept => :json\n\n if r[\"MatchCount\"] > 0\n company_to_parse = r[\"Matches\"][\"Companies\"][0]\n company.init(company_to_parse)\n end\n company\n rescue => e\n puts e\n end\n end",
"def getname(address)\n names = getnames(address)\n if names.empty?\n raise ResolvError.new(\"no name for #{address}\")\n else\n names.first\n end\n end",
"def find_by_names_and_company(card)\n conditions = find_by_names_and_company_conditions(card)\n if conditions[:organization]\n return nil unless organization = Organization.find_by_name(conditions.delete(:organization))\n find_base = organization.contacts\n else\n find_base = self\n end\n \n if conditions[:given_name] || conditions[:family_name]\n find_base.find(:first, :conditions => sanitize_sql_for_conditions(conditions))\n else\n organization\n end\n end",
"def get_contact_detail(business, category)\n contact_details.find_by(business: business, category: category)\n end",
"def get_organization_by_name(name)\n result = nil\n\n # Fetch all organizations\n organizations = get_organizations()\n\n organizations.each do |organization|\n if organization[0].downcase == name.downcase\n result = get_organization(organization[1])\n end\n end\n result\n end",
"def find_entry(name)\n Entry.where(name: name, address_book_id: self.id).first\n end",
"def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end",
"def find_dancer(name, phone, email)\n for dancer in Dancer.where(\"replace(lower(name), ' ', '') = ?\", name.downcase.delete(\" \"))\n if phone == dancer.phone || email == dancer.email\n return dancer\n end\n end\n nil\n end",
"def person(id)\n record \"/contacts/person/#{id}\"\n end",
"def person(id)\n record \"/contacts/person/#{id}\"\n end",
"def find_obj_for_name(name)\n idx = @field_names.index(name)\n if idx\n instantiate_obj(idx)\n @field_objs[idx].obj\n else\n nil\n end\n end",
"def find_by_name(name)\n # self.all.find do |customer|\n # customer.name == name\n # end\n Customer.find_by(name: name)\n end",
"def set_person\n @person = Person.includes( :contact_infos ).find( params[:id] )\n end",
"def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end",
"def show\n @contact = Contacte.find(params[:id])\n end",
"def find_by_name(name)\n end",
"def get_contact_by_phone(phone, opts = {})\n data, _status_code, _headers = get_contact_by_phone_with_http_info(phone, opts)\n data\n end",
"def user_by_name(name)\n @users[name]\n end",
"def find_company_by_name companies, name = \"Beta\"\n companies.find {|company| company.name == name}\nend",
"def conn(person, contact)\n find_by_person_id_and_contact_id(person, contact)\n end",
"def get(name)\n lookup(key(name.to_s))\n end",
"def find_person(person)\n cohort = traverse(person)\n raise Family::Tree::PersonNotFoundError if cohort.nil?\n\n cohort&.\n generation&.\n find { |elem| elem&.name == person }\n end",
"def getPerson(name)\n p = ASF::Person.find(name)\n p.attrs['cn'] = nil\n p\nend",
"def find_first(name)\n find_all(name).first\n end",
"def find(id)\n @@conn.exec_params(\"SELECT * FROM contacts WHERE id=$1;\", [id]) do |results|\n return create_from_row(results[0])\n end \n end",
"def show\n contact_shard = Facebase::Contact.shard_for(params[:id])\n @contact = contact_shard.where(\"profile_id = ? \", params[:id]).includes(:profile, :events, :emails).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contact }\n end\n end",
"def find(id)\n found_contact = nil\n CSV.foreach('contacts.csv') do |row|\n if row[0] == id #remember this tomorrow, it may help in search method\n found_contact = Contact.new(row[0], row[1], row[2])\n end\n end\n found_contact\n end",
"def person\n @person ||= Person.find_or_initialize_by email: @auth[:info][:email] do |p|\n if %i(first_name last_name).all? { |f| @auth[:info].key? f }\n # If the oauth provider gave us first and last name, use them\n p.first_name = @auth[:info][:first_name]\n p.last_name = @auth[:info][:last_name]\n else\n p.name = @auth[:info][:name]\n end\n end\n end",
"def contact\n @contact ||= ActsAsIcontact::Contact.find(contactId.to_i) if contactId.to_i > 0\n end",
"def get_contact(contact)\n ensure_cache_up_to_date\n namespace = \"bluster:objects:contact:#{contact}\"\n keys = self.redis.keys(\"#{namespace}:*\")\n data = {}\n keys.each { |key|\n short_key = key.split(\":\")[4] \n data[short_key] = self.redis.get(\"#{namespace}:#{short_key}\")\n }\n data\n end"
] |
[
"0.7287245",
"0.70697236",
"0.6979043",
"0.68891877",
"0.6626884",
"0.66163087",
"0.66163087",
"0.64621943",
"0.64332324",
"0.6355308",
"0.6355308",
"0.6336558",
"0.63358283",
"0.62979287",
"0.62979287",
"0.62979287",
"0.62979287",
"0.62979287",
"0.6218429",
"0.61829454",
"0.616505",
"0.61621636",
"0.61423373",
"0.6125828",
"0.6121095",
"0.61158895",
"0.61076003",
"0.6054062",
"0.605318",
"0.6051598",
"0.60321987",
"0.602589",
"0.60191315",
"0.59542304",
"0.59513927",
"0.5945346",
"0.5930261",
"0.59121263",
"0.5897976",
"0.5870322",
"0.58680594",
"0.5867154",
"0.5862753",
"0.5857086",
"0.5853592",
"0.58293396",
"0.5817363",
"0.58148545",
"0.580621",
"0.5803431",
"0.57764924",
"0.57600343",
"0.5742498",
"0.5734985",
"0.5732433",
"0.5728569",
"0.5723282",
"0.57137704",
"0.5691899",
"0.5682255",
"0.5674721",
"0.5671508",
"0.5663307",
"0.566282",
"0.56623757",
"0.5651597",
"0.565049",
"0.5643738",
"0.5640105",
"0.56397134",
"0.5623853",
"0.5619429",
"0.56188285",
"0.55969834",
"0.55878717",
"0.55840975",
"0.5581247",
"0.5579251",
"0.5563935",
"0.5563935",
"0.5563809",
"0.55636126",
"0.55525345",
"0.55414",
"0.55377084",
"0.5518271",
"0.55114645",
"0.55022967",
"0.5501728",
"0.54976463",
"0.54964966",
"0.5492841",
"0.54892206",
"0.5479395",
"0.5475032",
"0.5474209",
"0.54696995",
"0.54673797",
"0.5463234",
"0.54619575"
] |
0.74601007
|
0
|
Access only for AJAX request.
|
def access_only_for_ajax
unless request.xhr?
render :text => "Here is an Ajax Service, regular request without security token are denied."
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def xhr?; end",
"def xhr_script; end",
"def non_xhr_javascript_response?; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request_data; end",
"def ajaxcheck(request)\n if request.xhr? == true\n return true\n else\n return false\n end\nend",
"def xhr_request_check\n request.xhr?\n end",
"def ajax?\n return @ajax\n end",
"def check_use_ajax\n case self.use_ajax\n when Object, TrueClass\n self.use_ajax= true\n else\n self.use_ajax= false\n end\n end",
"def on_pre_request( request ); end",
"def request; return @request end",
"def request_method; end",
"def xhr!\n request.headers[\"HTTP_X_REQUESTED_WITH\"] = \"XMLHttpRequest\"\n end",
"def xhr?\n @controller.request.xhr?\n end",
"def set_request; end",
"def request\n raise 'need to be implemented'\n end",
"def request\n @_request\n end",
"def xml_http_request?; end",
"def perform(request, response); end",
"def on_pre_request( request )\n end",
"def xml_http_request?\r\n@env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i\r\nend",
"def request_xhr?\n !!request.xhr?\n end",
"def request\n @@request\n end",
"def xhr?\n @env[\"HTTP_X_REQUESTED_WITH\"] == \"XMLHttpRequest\"\n end",
"def request_object\n $REQUEST\n end",
"def xhr?\n @env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i\n end",
"def request\n nil\n end",
"def before_request\n end",
"def process(request); end",
"def raw_response; end",
"def xml_http_request?\n not /XMLHttpRequest/i.match(@headers['HTTP_X_REQUESTED_WITH']).nil?\n end",
"def render_ajax(event)\n render_event(event, :ajax)\n end",
"def http; end",
"def post_data; end",
"def check_format\n not_found unless request.xhr?\n end",
"def call(request); end",
"def no_ajax # :nologin: :norobots:\n end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def processing_xhr_requests?\n not self.mobylette_options[:skip_xhr_requests] && request.xhr?\n end",
"def processing_xhr_requests?\n not self.mobylette_options[:skip_xhr_requests] && request.xhr?\n end",
"def ajax?\n unless request.xhr?\n redirect_to root_url\n return false\n end\n true\n end",
"def on_success(_request, response)\n response\n end",
"def request\n @controller.request\n end",
"def request\n @controller.request\n end",
"def request\n @controller.request\n end",
"def request\n response.request\n end",
"def ajax\n\n uri_string = @params[:uri]\n # uri_string = \"http://www.phase-eight.com#{path_string}\"\n uri = construct_uri_object uri_string\n response = network_response uri\n logger.debug \"XHR response type #{response.content_type}\"\n logger.debug \"XHR response body #{response.body.html_safe}\"\n render text: response.body\n end",
"def get_content\n respond_to do |format|\n format.js\n end\n end",
"def get_content\n respond_to do |format|\n format.js\n end\n end",
"def request\n @@request\n end",
"def render_js_ajax\n render_code(@js, :ajax)\n end",
"def set_ajax\n @ajax = Ajax.find(params[:id])\n end",
"def getResponse(request)\n filter(request) || super\n end",
"def ajax?\n params[:ajax] || request.path.start_with?(\"/ajax/\")\n end",
"def request_result\n \n end",
"def on_global_request(type, &block); end",
"def ajaxify_extra_content\n ''\n end",
"def request\n @request\n end",
"def determined_by_request\n if request.xhr?\n return false\n else\n 'application'\n end\n end",
"def asynchronous?\n @rack_request.xhr?\n end",
"def render_rb_ajax\n render_code(@rb, :ajax)\n end",
"def GET; end",
"def findplace\n respond_to do |format|\n format.js if request.xhr?\n end\n \n end",
"def ajax_illiad_available\n @available_requests = params['requests']&.values.to_a\n render json: { record: render_to_string('_available_requests', layout: false), locals: { available_requests: @available_requests } }\n end",
"def request\n @cgi\n end",
"def get; end",
"def handler; end",
"def handler; end",
"def xml_http_request?\n return false if !@request || !@request['headers'] || !@request['headers']['X-Requested-With']\n test2 = /XMLHttpRequest/i.match(@request['headers']['X-Requested-With'])\n not test2.nil?\n end",
"def request_empty_page\n @posts.empty? && request.env[\"HTTP_X_REQUESTED_WITH\"] != \"XMLHttpRequest\"\n end",
"def after_request\n end",
"def parse(request)\n raise NotImplementedError\n end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def request=(_arg0); end",
"def check_xhr_header\n return if request.xhr?\n\n render json: { error: 'forbidden' }, status: :forbidden\n end",
"def show\n @message.read! unless request.xhr?\n end",
"def memberrequests\n @group = Group.find(session[:group_id])\n @membership = Membership.find_by(user_id: session[:user_id], group_id: session[:group_id])\n @requests = Request.where(requestor_id: @membership).order('requesting_at DESC')\n authorize @requests, :index?\n respond_to do |format|\n format.js\n format.html\n end\n end"
] |
[
"0.7402831",
"0.69913656",
"0.68071014",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.66760033",
"0.6653148",
"0.6467593",
"0.6456133",
"0.6437094",
"0.64356965",
"0.629644",
"0.62926",
"0.6178369",
"0.61605203",
"0.6124167",
"0.60656667",
"0.60527736",
"0.60189915",
"0.5996831",
"0.5973667",
"0.59687304",
"0.5968458",
"0.5929604",
"0.59266883",
"0.5847068",
"0.58428395",
"0.5831229",
"0.58273375",
"0.5806625",
"0.57940567",
"0.578134",
"0.57741714",
"0.576521",
"0.57407504",
"0.5735839",
"0.5735053",
"0.573378",
"0.5690657",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5688146",
"0.5680681",
"0.5680681",
"0.56680846",
"0.56667227",
"0.5664514",
"0.5664514",
"0.5664514",
"0.56579316",
"0.5647951",
"0.5638557",
"0.5638557",
"0.5635914",
"0.56335473",
"0.5627978",
"0.5595664",
"0.55768687",
"0.5576102",
"0.557329",
"0.55610347",
"0.5552356",
"0.55433506",
"0.5543001",
"0.554227",
"0.5540211",
"0.5539162",
"0.5530492",
"0.551889",
"0.5509016",
"0.55029833",
"0.55029833",
"0.54923683",
"0.54840136",
"0.547297",
"0.54693323",
"0.54615223",
"0.54615223",
"0.54615223",
"0.5458361",
"0.5447092",
"0.54439384"
] |
0.6583006
|
15
|
Mark the sales order(s) with given id(s) as unsynchronized. This method MUST be called after updating anything about these orders ( ERPAddresses, SalesLines, etc. ).
|
def mark_as_unsync(order_ids)
order_ids = [order_ids] unless order_ids.is_a?(Array)
@customer.sales_orders.update_all "synchronized = false", ["id in (?)", order_ids]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_ids\n self.task_id = @task_number\n self.order_id = @order_number\n end",
"def move_sales_line\r\n=begin\r\n sales_line = ERP::SalesLine.find params[:id]\r\n @original_order_id = sales_line.erp_sales_order_id\r\n sales_line.update_attribute :erp_sales_order_id, params[:target]\r\n \r\n mark_as_unsync [@original_order_id, params[:target]]\r\n=end\r\n @sales_line = ERP::SalesLine.find params[:id]\r\n @store_user.my_account_log(@sales_line,\"Move Sales Line #{@sales_line.invent_trans_id} From #{@sales_line.sales_order.sales_id}\")\r\n if @sales_line && @sales_line.sales_order.erp_customer_id == @customer.id\r\n @sales_line.move_to_order @customer.sales_orders.find( params[:target] )\r\n end\r\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def set_sales_order\n @sales_order = SalesOrder.find(params[:id])\n end",
"def update!(orders)\n raise 'Must be a Set' unless orders.is_a? Set\n\n logger.info \"Update with #{orders.to_a.join(',')}\"\n Order::SIDES.map do |side|\n update_by_side!(side, orders.filter { |o| o.side.to_s == side.to_s })\n end.flatten.compact\n end",
"def set_notified!(order)\r\n @notified_orders_set.add order[\"order_id\"]\r\nend",
"def merge!(order)\n if self.line_items.count > 0\n order.destroy\n else\n self.billing_address = self.billing_address || order.billing_address\n self.shipping_address = self.shipping_address || order.shipping_address\n order.line_items.each do |line_item|\n next unless line_item.currency == currency\n line_item.order_id = self.id\n line_item.save\n end\n\n end\n end",
"def record_sales\n @deleted_lines.each {|l| l.delete}\n @deleted_lines.clear\n calc_values\n save\n @lines.each do |li|\n li.li_order_id = @data_object.order_id\n li.save\n end\n end",
"def mark_for_destruction_except(records, ids)\n records.select{ |r| !ids.include?(r.id.to_s) }.each { |r| r.mark_for_destruction }\n end",
"def move_sales_line( sales_line_id, target_order_id )\r\n sales_line = self.sales_lines.find sales_line_id\r\n target_order = self.customer.sales_orders.find target_order_id\r\n\r\n moving_qty = sales_line.remain_sales_physical\r\n if moving_qty.zero?\r\n self.errors.add :sales_lines, \"This sales line has been fully completed.\"\r\n return false\r\n end\r\n\r\n self.class.transaction( sales_line ) do\r\n # Move out sales line from original order\r\n sales_line.sales_qty -= moving_qty\r\n sales_line.remain_sales_physical -= moving_qty\r\n sales_line.save!\r\n self.mark_as_modified\r\n\r\n # Append sales_line to target order\r\n existing_line = target_order.sales_lines.find_by_item_id sales_line.item_id\r\n if existing_line.nil?\r\n target_order.sales_lines.create! :sales_qty => moving_qty, :item_id => sales_line.item_id\r\n else\r\n existing_line.sales_qty += moving_qty\r\n existing_line.remain_sales_physical += moving_qty\r\n existing_line.save!\r\n end\r\n target_order.mark_as_modified\r\n end\r\n end",
"def update\n @sales_order = SalesOrder.find(params[:id])\n\n # update delivery_status(includes reschedule devlivery_plan) \n if not params[:delivery_status]\n # if current_issue_cart.line_items.exists? \n @sales_order.issue_unissue_po_line_items_when_so_and_cart_diffs(current_issue_cart) \n\n @sales_order.line_items.clear\n @sales_order.add_line_items_from_issue_cart(current_issue_cart)\n @sales_order.save\n # Cart.destroy(session[:issue_cart_id])\n # session[:issue_cart_id] = nil \n # end \n end \n\n respond_to do |format|\n if @sales_order.update_attributes(params[:sales_order])\n format.html { redirect_to @sales_order, notice: 'Sales order was successfully updated.' }\n format.json { head :no_content } \n else\n @orders = Order.where(customer_id: @sales_order.customer.id)\n @cart = current_issue_cart\n\n session[:cart_order_type] = \"SalesOrder\"\n session[:cart_order_id] = @sales_order.id\n\n format.html { render action: \"edit\", notice: 'Sales order can not update.' }\n format.json { render json: @sales_order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def commit_orders\r\n orders = @customer.open_orders.find_all_by_synchronized( false )\r\n sales_id = \"\"\r\n orders.each do |o| sales_id += \"'#{o.sales_id}', \" end \r\n @store_user.my_account_log(@customer,\"Commit Sales Order Updates: #{sales_id}\")\r\n\r\n if orders.empty? || ERP::SalesOrder.commit_orders( orders )\r\n flash.now[:message] = \"All changes have been commited.\"\r\n else\r\n flash.now[:message] = \"Operation Failed.\"\r\n end\r\n end",
"def unblock_subscription\n self.update_attributes(is_blocked: false, blocked_at: nil)\n order_ids = self.orders.where(is_blocked: true).pluck(:id)\n Spree::Order.unblock_order(order_ids)\n end",
"def set_sent_order\n @sent_order = SentOrder.find(params[:id])\n end",
"def set_shared_order\n @shared_order = SharedOrder.find(params[:id])\n end",
"def sweetist_synchronize_order(order_id, order_class)\n order = self.integration_item.vendor.sales_orders.find(order_id)\n # order.variants.each do |variant|\n # sweetist_synchronize_variant(variant.id, 'Spree::Variant')\n # end\n order_hash = order.to_integration(\n self.integration_item.integrationable_options_for(order)\n ) rescue {}\n order_match = self.integration_item.integration_sync_matches.find_or_create_by(integration_syncable_id: order_id, integration_syncable_type: order_class)\n if order_match.sync_id\n get_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders/#{order_match.sync_id}?token=#{ENV['SWEETIST_API_KEY']}\")\n sweetist_order_hash = JSON.parse(get_request.body)\n if get_request.code.to_i == 200\n payload = sweetist_map_to_sweetist_order(order_hash)\n push_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders/#{order_match.sync_id}?token=#{ENV['SWEETIST_API_KEY']}\", :patch, payload)\n if push_request.code.to_s.starts_with?('20')\n # syncs line_items & shipment; returns {status: integer, log: []}\n self.sweetist_synchronize_order_associated_objects(order_hash, order_match.sync_id, sweetist_order_hash)\n else\n { status: -1, log: \"#{order_hash.fetch(:name_for_integration)} => Error(#{push_request.code}) - #{push_request.message}\"}\n end\n else\n { status: -1, log: \"Could not find match in Sweetist to order with id => #{order.id} in Sweet\" }\n end\n elsif order_hash.fetch(:channel, '').to_s.downcase == 'sweetist'\n # get_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders?q[number_eq]=#{order.try(:number)}&token=#{ENV['SWEETIST_API_KEY']}\")\n # sweetist_order_hash = JSON.parse(get_request.body).fetch('orders',[]).first\n get_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders/#{order.try(:number)}?token=#{ENV['SWEETIST_API_KEY']}\")\n sweetist_order_hash = get_request.code.to_i == 200 ? JSON.parse(get_request.body) : nil\n if sweetist_order_hash\n order_match.update_columns(sync_id: sweetist_order_hash.fetch('id'))\n payload = sweetist_map_to_sweetist_order(order_hash)\n push_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders/#{sweetist_order_hash.fetch('id',nil)}?token=#{ENV['SWEETIST_API_KEY']}\", :patch, payload)\n if push_request.code.to_s.starts_with?('20')\n # syncs line_items & shipment; returns {status: integer, log: []}\n self.sweetist_synchronize_order_associated_objects(order_hash, order_match.sync_id, sweetist_order_hash)\n\n else\n { status: -1, log: \"#{order_hash.fetch(:name_for_integration)} => Error(#{push_request.code}) - #{push_request.message}\"}\n end\n else\n { status: -1, log: \"Could not find match in Sweetist to order with id => #{order_id} or number => #{order.display_number} in Sweet\" }\n end\n else\n { status: -1, log: \"Could not find match in Sweetist to order with number => #{order.display_number} in Sweet\" }\n end\n rescue Exception => e\n { status: -1, log: \"#{e.class.to_s} - #{e.message}\" }\n end",
"def mark_as_shipped\n @context.no_going_back\n\n list = @data.display_list\n update_from_form(list)\n\n list.each do |address_entry|\n address_entry.each_order do |order_info|\n next unless order_info.ship_order\n\n order = Order.with_id(order_info.order_id)\n\n if order\n order.mark_as_shipped\n else\n raise \"Missing order\"\n end\n\n end\n end\n @session.pop\n end",
"def set_order\n @cart = current_cart\n @order = Order.find(params[:id])\n @orders = Order.where(\"cart_id=? AND id<>?\", @cart.id, params[:id])\n end",
"def update_order\n update_positions params[:sorted_ids]\n render nothing: true\n end",
"def reorder(things, ids)\n ordered_things = []\n ids.each do |id|\n record = things.find {|thing| record_id(thing).to_s == id.to_s} \n raise \"Out of sync! The id #{id} is in the Solr index but missing in the database!\" unless record\n ordered_things << record\n end\n ordered_things\n end",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all' })\n all_orders = orders[:items]\n all_orders.each do |order|\n unless order[:status].present?\n order_id = order[:increment_id]\n id = order[:entity_id]\n status = order[:state]\n params = {\n entity_id: id,\n increment_id: order_id,\n status: status,\n }\n if status\n Magento2::Api.put(\"/rest/en/V1/orders/create\", {entity: params})\n end\n end\n end\n end",
"def all_orders_sync\n @all_partial_orders = Spree::Order.includes(:line_items).where(\"spree_line_items.id is null\")\n if !@all_partial_orders.present? || @all_partial_orders.count == 0\n flash[:error] = \"No orders found to sync\"\n redirect_to partial_orders_admin_orders_path\n return\n else\n res = view_context.sync_all_orders_qoo10(@all_partial_orders)\n redirect_to partial_orders_admin_orders_path, :notice => \"All orders synced successfully!\"\n end\n end",
"def set_order_items\n @order_items = @order.order_items\n end",
"def set_ordered\n @ordered = Ordered.find(params[:id])\n end",
"def set_quotations\n qid = PurchaseOrder.select(:quotation_id).map(&:quotation_id)\n @quotations = Quotation.where.not(id: qid)\n end",
"def dummy_order\n order = spree_line_item ? spree_line_item.order.dup : ::Spree::Order.create\n order.ship_address = subscription.shipping_address || subscription.user.ship_address if subscription\n order.bill_address = subscription.billing_address || subscription.user.bill_address if subscription\n\n order.freeze\n end",
"def set_order\n @order = Order.find(params[:id])\n #Также нужны переменные\n @client=Client.find(@order.client_id)\n @delivery=Delivery.find(@order.delivery_id)\n @employee=Employee.find(@order.employee_id)\n @ordered=Ordered.where(\"order_id=?\",@order.id)\n end",
"def sync_all_orders_qoo10(orders)\n @message = []\n @cart_numbers = []\n begin\n orders.each do |ord|\n if !ord.products.present?\n @order = nil\n @shpping_address = nil\n @billing_address = nil\n @is_customer_pickup = nil\n order = ord.market_place_details\n @order = Spree::Order.find_by_market_place_order_no(order[\"orderNo\"]) if order.present?\n if @order.present? && order.present?\n gift = order[\"Gift\"].present? ? false : true\n shipping_country = Spree::Country.find_by_iso(order[\"shippingCountry\"])\n billing_country = Spree::Country.find_by_iso(order[\"senderNation\"])\n name = order[\"receiver\"].present? ? order[\"receiver\"] : (order[\"buyer\"].present? ? order[\"buyer\"] : \"NA\")\n telno = order[\"receiverTel\"].present? ? order[\"receiverTel\"] : (order[\"buyerTel\"].present? ? order[\"buyerTel\"] : \"NA\")\n mobileno = order[\"receiverMobile\"].present? ? order[\"receiverMobile\"] : (order[\"buyerMobile\"].present? ? order[\"buyerMobile\"] : \"NA\")\n if order[\"OrderType\"] == \"Pickup\"\n @is_customer_pickup = true\n # our singapore warehouse address\n address1 = \"151 Pasir Panjang Road\"\n address2 = \"#02-02 Pasir Panjang Distripark\"\n zipcode = \"118480\"\n phone = \"+65 6271 0524\"\n @order.shipping_address.update_attributes(:firstname=> name, :lastname=> name, :address1=> address1, :address2=> address2,\n :city=> shipping_country.name, :zipcode=> zipcode, :phone=> phone, :alternative_phone=> \"\", :country_id=> shipping_country.id,\n :state_name=> shipping_country.name)\n if order[:Addr1].present?\n @order.billing_address.update_attributes(:firstname=> name, :lastname=> name, :address1=> order[\"Addr1\"], :address2=> order[\"Addr2\"],\n :city=> shipping_country.name, :zipcode=> order[\"zipCode\"], :phone=> telno, :alternative_phone=> mobileno, :country_id=> shipping_country.id,\n :state_name=> shipping_country.name)\n end\n else\n @is_customer_pickup = false\n @order.shipping_address.update_attributes(:firstname=> name, :lastname=> name,\n :address1=> order[\"Addr1\"], :address2=> order[\"Addr2\"],\n :city=> shipping_country.name, :zipcode=> order[\"zipCode\"],\n :phone=> telno, :alternative_phone=> mobileno,\n :country_id=> shipping_country.id, :state_name=> shipping_country.name)\n end\n if !order[\"senderName\"].present? && !order[\"senderAddr\"].present? && !order[\"senderNation\"].present? && !order[\"senderZipCode\"].present? && !order[\"senderTel\"].present? && !billing_country.nil?\n @order.billing_address.update_attributes(:first_name=> order[\"senderName\"], :lastname=>\"\",\n :address1=> order[\"senderAddr\"], :address2=>\"\",\n :city=> billing_country.name, :zipcode=> order[\"senderZipCode\"],\n :phone=> order[\"senderTel\"], :alternative_phone=>\"\",\n :country_id=> billing_country.id, :state_name=> billing_country.name)\n end\n billing_address = (!@order.billing_address.nil? && !@order.billing_address.blank?) ? @order.billing_address.id : nil\n @mp_product = nil\n @line_item = nil\n @stock = nil\n @mp_product = Spree::SellersMarketPlacesProduct.find_by_market_place_product_code(order[\"itemCode\"])\n @order.update_attributes(:number=> order[\"orderNo\"], :order_date=> order[\"PaymentDate\"], :item_total=> order[\"orderPrice\"],\n :total=> order[\"total\"], :payment_total=> order[\"total\"],\n :email=> order[\"buyerEmail\"], :currency=> order[\"Currency\"],\n :send_as_gift=> gift, :market_place_id=> @mp_product.present? ? @mp_product.market_place_id : nil,\n :market_place_order_no=> order[\"orderNo\"],\n :bill_address_id=> billing_address, :ship_address_id=> @order.shipping_address.id)\n #@order.adjustments.first.update_attributes(:amount=> -order[\"discount\"].to_f, :label=> \"discount\") if @order && @order.adjustments.present? && order[\"discount\"].to_f != 0.0\n if @mp_product.present? && @order.present?\n if order[\"option\"] == \"\"\n # options not present i.e. for product\n @variant = Spree::Variant.find_by_sku(@mp_product.product.sku)\n if !@mp_product.nil? && !@mp_product.blank? && !@variant.nil? && !@variant.blank?\n @line_item = Spree::LineItem.create!(:variant_id=> @variant.id, :order_id=> @order.id, :quantity=> order[\"orderQty\"].to_i, :price=> order[\"orderPrice\"], :currency=> order[\"Currency\"], :is_pick_at_store => @is_customer_pickup)\n @stock = @mp_product.product.stock_products.first\n end\n else\n # options are present i.e. for variant\n #option_arr = order[\"option\"].split(\"(\")[0].split(\":\")\n option_arr = order[:option].split(\":\")\n if option_arr[1].split(\"(+\").count > 1\n option_arr[1] = option_arr[1].split(\"(+\")[0]\n elsif option_arr[1].split(\"(-\").count > 1\n option_arr[1] = option_arr[1].split(\"(-\")[0]\n end\n @variant = nil\n @mp_product.product.variants.each do |v|\n @variant = v if !v.option_values.blank? && (v.option_values.map(&:presentation).include?option_arr[1].strip)\n end if !@mp_product.nil? && @mp_product.product && @mp_product.product.option_types && !@mp_product.product.option_types.blank? && (@mp_product.product.option_types.map(&:presentation).include?option_arr[0])\n if !@mp_product.nil? && !@mp_product.blank? && !@variant.nil? && !@variant.blank?\n @line_item = Spree::LineItem.create!(:variant_id=> @variant.id, :order_id=> @order.id, :quantity=> order[\"orderQty\"].to_i, :price=> order[\"orderPrice\"], :currency=> order[\"Currency\"], :is_pick_at_store => @is_customer_pickup)\n @stock = @mp_product.product.stock_products.where(\"variant_id=?\", @variant.id).first\n end\n end\n # to reduce the stock after placing the order\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[\"orderQty\"].to_i) >= 0 ? (@stock.count_on_hand - order[\"orderQty\"].to_i) : 0 ) if @stock\n # code to reduce the kit quantity after order placed for kit as product\n @product = @mp_product.product\n if @product.kit.present? && @product.present?\n @product.kit.update_attributes(:quantity => @product.kit.quantity - order[\"orderQty\"].to_i)\n end\n # reload the order object\n @order.reload\n # add cart number into array\n @cart_numbers << order[\"packNo\"]\n end\n end\n @message << (@order && @order.present? ? (@order.market_place_order_no.to_s+\": \"+ \"Success\") : nil)\n end # end of if product does not exist\n end # end of orders loop\n rescue Exception => e\n @message << e.message\n end\n # take only unique cart number from array\n @cart_numbers = @cart_numbers.uniq\n # pass the array to method which can clubbed the orders according to cart number and then push to FBA\n @message << \"FBA: \"+ Spree::Order.push_to_fba(@cart_numbers)\n return @message.join(\"; \")\n end",
"def set_updateallorder\n @updateallorder = Updateallorder.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n OrderStateMgr.instance(self).set_curr_state(@order)\n end",
"def id=(id)\n @modified = false\n super\n end",
"def id=(id)\n @modified = false\n super\n end",
"def update_shipments_with_qb_ids(shipment_id, object)\n file_name = \"#{path.base_name}/#{path.pending}/shipments_#{shipment_id}_.json\"\n\n begin\n contents = amazon_s3.convert_download('json', amazon_s3.bucket.object(file_name).get.body.read)\n amazon_s3.bucket.object(file_name).delete\n rescue Aws::S3::Errors::NoSuchKey => _e\n puts \"File not found[update_shipments_with_qb_ids]: #{file_name}\"\n end\n\n contents.first['items'] = object[:extra_data]['line_items']\n .map do |item|\n item['sales_order_txn_line_id'] = item['txn_line_id']\n item['sales_order_txn_id'] = item['txn_id']\n item.delete('txn_line_id')\n item.delete('txn_id')\n item\n end\n\n contents.first['adjustments'] = object[:extra_data]['adjustments']\n .map do |item|\n item['sales_order_txn_line_id'] = item['txn_line_id']\n item['sales_order_txn_id'] = item['txn_id']\n item.delete('txn_line_id')\n item.delete('txn_id')\n item\n end\n\n amazon_s3.export file_name: file_name, objects: contents\n\n begin\n order_file_name = \"#{path.base_name}/#{path.ready}/orders_#{object[:object_ref]}_.json\"\n amazon_s3.bucket.object(order_file_name).delete\n rescue Aws::S3::Errors::NoSuchKey => _e\n puts \"File not found[delete orders]: #{file_name}\"\n end\n end",
"def update_account_ids!(acct_ids)\n self.account_ids = []\n save!\n\n reload\n\n acct_ids.map do |aid|\n begin\n Account.find(aid)\n rescue Mongoid::Errors::DocumentNotFound => e\n nil\n end\n end.compact.each do |acct|\n self.accounts << acct unless self.accounts.include?(acct)\n end\n\n self.reload if save!\n end",
"def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end",
"def set_journal_for_order_details(journal, order_detail_ids)\n OrderDetail.where_ids_in(order_detail_ids).update_all(journal_id: journal.id)\n end",
"def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end",
"def update_records\n # Get all line items include redone body and it's serial number.\n line_items = AxOrderLineItem.find(:all, :conditions => ['item_id = ? and sales_item_reservation_number <> ?', Product::REDONE_ERP_PRODUCT_ITEM, ''], :include => :ax_order)\n \n # Get all serial numbers from ax order line items.\n serial_numbers = line_items.map(&:serial_number).sort_by { |i| i.to_i }\n \n # Calc all new serial numbers.\n new_serial_numbers = serial_numbers - self.find(:all).map(&:serial_number)\n \n # Add new serial numbers to database.\n new_serial_numbers.each do |serial_number|\n line_item = line_items.find {|i| i.serial_number == serial_number}\n self.create(\n :ax_account_number => line_item.ax_account_number,\n :ax_account_id => line_item.ax_account_id,\n :ax_order_number => line_item.ax_order_number,\n :ax_order_id => line_item.ax_order_id,\n :email_address => line_item.email_address,\n :first_name => line_item.first_name,\n :last_name => line_item.last_name,\n :serial_number => line_item.serial_number,\n :purch_order_form_num => line_item.purch_order_form_num\n )\n end\n \n # Update exist but not sent records data up to date.\n self.find(:all, :conditions => ['sent_mail = ?', false]).each do |item|\n if line_item = line_items.find {|i| i.serial_number == item.serial_number}\n item.update_attributes(\n :ax_account_number => line_item.ax_account_number,\n :ax_account_id => line_item.ax_account_id,\n :ax_order_number => line_item.ax_order_number,\n :ax_order_id => line_item.ax_order_id,\n :email_address => line_item.email_address,\n :first_name => line_item.first_name,\n :last_name => line_item.last_name,\n :serial_number => line_item.serial_number,\n :purch_order_form_num => line_item.purch_order_form_num\n ) unless compare_equal?(item, line_item)\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 send_order order_id\n order_to_send = @current_orders.find {|order| order.id.to_i == order_id.to_i}\n @order_history.push(@current_orders.delete(order_to_send))\n if order_to_send != nil\n send \"Your order is 1 hour away from arriving\"\n puts \"For kitchen: #{order_to_send.adress}\"\n puts \"For driver: #{order_to_send.array}\"\n end\n end",
"def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end",
"def markRemove id, which\n\t0.upto(@toRemove.length - 1) { |i|\n\t\tif i != which\n\t\t\t@toRemove[i] << id\n\t\tend\n\t}\nend",
"def set_order\n @order = Order.includes(:orderitems).find_by_id(params[:id])\n @order.subscribe(Orderlog.new)\n end",
"def mark_outputs_as_unspent(output_ids, on_disconnect)\n self.class.add_to_utxo_set(output_ids, on_disconnect)\n\n # mark these unspent all at once\n Toshi::Models::Output.where(id: output_ids)\n .update(spent: false, branch: Toshi::Models::Block::MAIN_BRANCH)\n end",
"def cancel_orders(order_ids)\n order_ids.each do |id|\n @api.cancel_order(id)\n @log.info \"successfully cancelled order #{id}\"\n end\n end",
"def update\n @ordered.each do |ord|\n #уничтожаем все объекты из таблице многие ко многим, чтобы обновление было корректно\n if @order.id==ord.order_id\n Ordered.find(ord.id).destroy\n end\n end\n respond_to do |format|\n if @order.update(order_params_update)\n format.html { redirect_to @order, notice: 'Информация о заказе была успешно обновлена.' }\n format.json { render :show, status: :ok, location: @order }\n else\n format.html { render :edit }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def move_to_index(id)\n @store.transaction do\n @store[id].categories[\"completed\"] = false\n end\n end",
"def set_sales_order_detail\n @sales_order_detail = SalesOrderDetail.find(params[:id])\n end",
"def block_subscription\n self.update_attributes(is_blocked: true, blocked_at: Time.now)\n order_ids = self.orders.where(\"state = ? and payment_state = ? and shipment_state = ? \", 'paused', 'pending', 'pending').pluck(:id)\n Spree::Order.block_order(order_ids)\n end",
"def process\n Trade::Shipment.update_all(\n { taxon_concept_id: @taxon_relationship.taxon_concept_id },\n {\n taxon_concept_id: @old_taxon_relationship.taxon_concept_id,\n reported_taxon_concept_id: @taxon_relationship.other_taxon_concept_id\n }\n )\n end",
"def synchronize_products\n # NOTE: This won't delete products if we resynchronize and they\n # are no longer in the line items. I don't see why that would\n # ever happen, though.\n shop.products.each do |product|\n product.update(quantity: 0, total_revenue: 0)\n end\n\n shop.line_items.paid.each do |line_item|\n if product = shop.products.find_by(uid: line_item.product_uid)\n product.update!(\n quantity: product.quantity + line_item.quantity,\n total_revenue: product.total_revenue + line_item.revenue\n )\n else\n shop.products.create!(\n uid: line_item.product_uid,\n name: line_item.title,\n quantity: line_item.quantity,\n total_revenue: line_item.revenue\n )\n end\n end\n end",
"def dequeue_stats_orders(iLstStatsOrderIDs)\n @MySQLConnection.query('start transaction')\n iLstStatsOrderIDs.each do |iStatsOrderID|\n @StatementDeleteFromStatsOrders.execute(iStatsOrderID)\n end\n end",
"def set_to_ordered\n self.status = \"ordered\"\n self.save\n end",
"def update_snack_queue\n\n order_ids = params[:undelivered_order_ids]\n cart_ids = params[:cart_ids]\n @subscription_id = params[:subscription_id]\n\n orders = []\n @all_carts_full = Cart.is_carts_full?(cart_ids)\n\n if @all_carts_full\n\n order_ids.each do |key, order_id|\n orders.push(order_id)\n order = Spree::Order.where(id: order_id).first\n cart = Cart.where(id: cart_ids[key.to_i]).first\n order_line_items = cart.get_line_items_for_order\n order.pack_line_items(order_line_items, current_user.id, \"USD\", request.remote_ip)\n order.update_total_and_item_total\n #cart.destroy\n end\n\n order = Spree::Order.where(id: order_ids[\"0\"]).first\n result = queue_update_mail_params(order)\n VeganMailer.snack_queue_update_mail(result).deliver\n\n else\n\n end #end of complete if condition.\n end",
"def delete_sales_line\r\n sales_line = ERP::SalesLine.find( params[:id], :include => \"sales_order\" )\r\n @store_user.my_account_log(sales_line,\"Delete Sales Line: #{sales_line.invent_trans_id} (#{sales_line.item_id})\")\r\n if @customer.open_orders.collect{|order| order.id}.include?( sales_line.sales_order.id ) && sales_line.modifiable?\r\n sales_line.destroy\r\n render :text => \"Deleted...\"\r\n else\r\n render :text => \"Failed to delete sales line (ID=#{params[:id]})\", :status => 500\r\n end\r\n end",
"def set_transaction_order\n\n # if params[:order_id].nil?\n # @transaction_order = TransactionOrder.find(params[:id])\n # end\n @transaction_order = TransactionOrder.find(params[:id])\n\n\n #@transaction_order = TransactionOrder.find(params[:order_id]) if @transaction_order.nil?\n end",
"def ship_order\n self.update_attributes(status: 2)\n end",
"def set_order\n @order = ShopOrder.find(params[:id])\n end",
"def rem_sale_entity(sale_id)\n redis.srem(\"#{Porp.ns}:stockentity:id:#{id}:saleentities\", sale_id) \n end",
"def update_order(result)\n create_asendia_shipment_record(result['Status'], result['Error'])\n @transaction_id = result['ParcelId']\n @tracking_number = nil\n shipment = @order.shipment\n shipment.tracking = @tracking_number\n shipment.save\n shipment.ship!\n @order.line_items.each do |line_item|\n @success_orders << [\"#{@order.number}, #{line_item.sku}, #{@tracking_number}, #{@transaction_id}, #{line_item.quantity}, #{@order.completed_at}, #{(@order.ship_address.country.try(:name) || '').delete(',')}\"]\n end\n end",
"def set_order\n\t\t\t@order = Order.find(params[:id])\n\t\tend",
"def shipped\n order = Order.second\n items = LineItem.where(order_id: order.id)\n items.each do |item|\n order.line_items << item\n end\n OrderNotifier.shipped(order)\n end",
"def set_order\n # finds the current order using the params\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order\r\n @order = Order.find(params[:id])\r\n end",
"def set_order_transaction\n @order_transaction = OrderTransaction.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def reset_atomic_updates!\n Atomic::UPDATES.each do |update|\n send(update).clear\n end\n end",
"def ignore(*ids); end",
"def set_order\n\t\t@order = Order.find(params[:id])\n\tend",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end",
"def set_order\n @order = Order.find(params[:id])\n end"
] |
[
"0.5774726",
"0.56881034",
"0.5487312",
"0.5487312",
"0.547677",
"0.5456823",
"0.5411922",
"0.5388102",
"0.5331965",
"0.52381945",
"0.51438457",
"0.51162374",
"0.5106291",
"0.5096775",
"0.5087578",
"0.5081171",
"0.5075133",
"0.5058175",
"0.5012792",
"0.5012114",
"0.49914965",
"0.4976994",
"0.49576107",
"0.49294868",
"0.49274048",
"0.49113128",
"0.49020427",
"0.48885414",
"0.48872593",
"0.48838237",
"0.48578805",
"0.48578805",
"0.48539606",
"0.4844244",
"0.4826021",
"0.4818666",
"0.48172545",
"0.48107222",
"0.480679",
"0.48011827",
"0.479259",
"0.47908726",
"0.47897923",
"0.4775146",
"0.4771508",
"0.47617087",
"0.4753795",
"0.47146282",
"0.47001597",
"0.4695329",
"0.46950194",
"0.4691459",
"0.46849325",
"0.46814585",
"0.4677133",
"0.46767366",
"0.46672732",
"0.46596023",
"0.46569997",
"0.46477136",
"0.46390826",
"0.4632835",
"0.46178403",
"0.46121716",
"0.46101603",
"0.46101603",
"0.4604976",
"0.46043873",
"0.46019053",
"0.45993543",
"0.45950475",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658",
"0.45931658"
] |
0.74006194
|
0
|
After signed in My Account, start a backend process to synchronize customer's account including orders. Note: Unsaved changes from last login are discarded.
|
def synchronize_customer_account
return false unless session[:web_user] && request.post?
unless (cust_id = session[:web_user].erp_account_number).blank?
customer = ERP::Customer.find_by_account_num(cust_id) ||
ERP::Customer.new(:account_num => cust_id)
customer.synchronize(true)
end
rescue
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run\n handle_service do\n @order.save!\n # create an activity register\n ::Activity.new_activity(@user, :created, @order, nil)\n ::JobActivation.perform_later(@order, @user)\n end\n\n @order\n end",
"def submit_order!\n @customer_order.transaction do\n cache_addresses!\n mark_deliveries_as_pending!\n cache_billing_address! unless @customer_order.anon_billing_address?\n update_subtotal_items!\n assign_submitted_at!\n submitted!\n end\n end",
"def logging_in\n guest_order = guest_user.current_order_in_progress\n current_order = current_user.current_order_in_progress\n current_order.merge guest_order\n end",
"def perform\n\n r = validate_and_sanitize\n return r unless r.success?\n\n fetch_client_token_sale_details\n\n r = validate_client_details\n return r unless r.success?\n\n r = check_if_email_already_registered\n return r unless r.success?\n\n r = generate_login_salt\n return r unless r.success?\n\n create_user\n\n enqueue_job\n\n set_cookie_value\n\n end",
"def submit_order\n @order = current_order(session)\n\n # Set customer, if any\n if customer_signed_in?\n @order.customer = current_store_customer\n else\n if params[:create_new_account]\n @order.customer = create_customer(@order, params[:new_account_password], store)\n end\n end\n\n @order.update_attributes params[:order] # SHouldn't need this as well as save below\n @order.billing_status_id = Breeze::Commerce::OrderStatus.where(:type => :billing, :name => \"Payment in process\").first.id\n\n\n if @order.save \n # Process payment with PxPay\n @payment = create_payment(@order, store)\n if @payment.save and redirectable?\n redirect_to @payment.redirect_url and return\n else\n Rails.logger.debug @payment.errors.to_s\n @payment.errors.each { |attrib, err| Rails.logger.debug attrib.to_s + ': ' + err.to_s }\n flash[:error] = \"Sorry, we can't reach the payment gateway right now.\" # This error message might not be accurate!\n redirect_to breeze.checkout_path and return\n end\n else\n @customer = current_store_customer || Breeze::Commerce::Customer.new\n render :action => \"checkout\"\n end\n end",
"def sync( tag = nil )\r\n if tag == :all\r\n nodes = get_all_records\r\n else\r\n end_time = Time.now\r\n start_time = end_time - 20.day\r\n nodes = self.search_by_modified_date( start_time, end_time )\r\n end\r\n \r\n # TODO:\r\n # 1. Require a processing thread from ThreadPool\r\n # 2. Synchronize customer with given Account Num.\r\n # 3. Exception handler for each process. Serialize record if failed for severial times (Save to DB?)\r\n \r\n ERP::ThreadPool.new(@options[:threads], nodes).start do |customer_node|\r\n account_num = customer_node.search( 'AccountNum' ).inner_html\r\n output_log \"Synchronizing customer \\\"#{account_num}\\\" ...\"\r\n begin\r\n ERP::Customer.transaction do\r\n #sales_order = sales_orders.find_by_sales_id( sales_id ) || sales_orders.build( :sales_id => sales_id )\r\n #if sales_order.new_record? || ax_modstamp(node) > sales_order.erp_modstamp\r\n #BUG: \r\n customer = ERP::Customer.find_by_account_num( account_num ) || ERP::Customer.new( :account_num => account_num )\r\n if customer.new_record? || ax_modstamp(customer_node) > customer.erp_modstamp\r\n output_log \"#{account_num} Prepare to Sync Customer Account\"\r\n customer.synchronize # recursively syncs sales orders and sales lines\r\n end\r\n end\r\n rescue => e\r\n\t\t\t raise e\r\n output_log \"#{account_num} synchronized failed!!!\"\r\n unsynchronized_customer( account_num )\r\n end\r\n end\r\n end",
"def auto_login(account)\n request.env[\"keycard.authentication\"] = notary.waive(account)\n setup_session\n end",
"def authenticate_account!\n store_bookingsync_account_id if BookingSync::Engine.embedded\n sign_out_if_inactive\n enforce_requested_account_authorized!\n request_authorization! if current_account.nil?\n end",
"def after_complete\n #remove the order from the session\n session[:order_id] = nil\n\n #add the order access token to the session so user can see thank you window\n #and order status, all through the orders controller.\n session[:access_token] ||= @order.token\n\n # trigger the photo copy and preparation, this is done here because normal state machine transitions\n # happen in a transaction and could allow resque work to begin too soon. See comment in order_decorator.rb\n @order.prepare!\n\n if current_user\n # If a user is looged in, save addresses and creditcard as default\n # Backup order addresses with addresses that cannot be modified by user.\n # creditcards are non editable just erasable.\n #(no need to do this for guests)\n original_ship = @order.ship_address\n original_bill = @order.bill_address\n\n new_ship = Address.create( original_ship.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n @order.ship_address_id = new_ship.id\n if original_ship.id == original_bill.id\n @order.bill_address_id = new_ship.id\n else\n if original_ship.same_as?( original_bill )\n @order.bill_address.id = new_ship.id\n else\n @order.bill_address = Address.create( original_bill.attributes.except(\"id\", \"user_id\", \"updated_at\", \"created_at\"))\n end\n end\n @order.save\n\n # new creditcards should be saved in the user's wallet\n if @order.payment.source.user.nil?\n @order.payment.source.update_attributes!(\n :user_id => current_user.id\n )\n end\n\n #make addresses, creditcard user's default\n @order.user.update_attributes!(\n :bill_address_id => original_bill.id,\n :ship_address_id => original_ship.id,\n :creditcard_id => @order.payment.source.id\n )\n end\n end",
"def after_save_actions\n Logger.d(\"Inside after_save_actions in User\")\n ContactsSync.new(@context, get(:auth_token)).sync if is_user_contacts_syncable? == true # non-blocking\n end",
"def logging_in\n orders = guest_user.orders.all\n orders.each do |order|\n order.user_id = current_user.id\n order.save!\n puts order.inspect\n end\n end",
"def sign_the_customer_in\n transaction = ::Refinery::Transactions::Transaction.find_by_unique_guid(params['REFERENCE'])\n sign_in(:customer, ::Refinery::Customers::Customer.find(transaction.order.customer_id))\n @current_cart = get_cart # get the cart again now that the customer is signed in.\n\n #@order = Order.find(params[:order_id])\n #if params['CUSTOMER_ID'].present? and @order.customer.id.to_s == params['CUSTOMER_ID'].to_s\n # sign_in(:customer, ::Refinery::Customers::Customer.find(params['CUSTOMER_ID']))\n # @current_cart = get_cart # get the cart again now that the customer is signed in.\n #else\n # flash[:alert] = \"You are not authorised to view that order's details\"\n # redirect_to refinery.root_path\n #end\n end",
"def sync_job(first_time = false, user = 'requester')\n\t\tRails.logger.info('Authorisation sync job started for scope: ' + self.scope)\n\t\tGmailSyncerJob.new.async.perform(self, first_time, user)\n\tend",
"def synchronize_customers\n fetch_shopify_customers.each do |shp_cus|\n create_customer(shp_cus)\n end\n end",
"def logging_in\n guest_order_items = guest_user.order_items.all\n guest_order_items.each do |order_item|\n order_item.user_id = current_user.id\n order_item.save!\n end\n guest_orders = guest_user.orders.all\n guest_orders.each do |order|\n order.user_id = current_user.id\n order.save!\n end\n end",
"def my_account\n @orders = current_customer.orders.includes(:product).in_order || []\n end",
"def amend_customer\n # we should have a current customer.\n cust = current_customer\n if (cust)\n auth = request.env[\"omniauth.auth\"]\n # We should only have one of these.\n oauths = Authentication.where(:provider => auth[\"provider\"],\n :uid => auth[\"uid\"],\n :customer_id.ne => nil,\n :master => nil).order(\"created_at desc\").all\n oauth = nil\n oauths.each do |oa|\n if oa.customer == cust\n if oauth.nil?\n oauth = oa\n else\n # Be proactive resilience here and get rid of this one. We should not have multiples\n logger.error(\"sessions#ammend_customer: getting rid of multiple customer authentications.\")\n oa.destroy()\n end\n else\n redirect_to edit_customer_registration_path(cust), :alert => \"This authentication belongs to different customer.\"\n return\n end\n end\n if oauth\n # Already added\n redirect_to edit_customer_registration_path(cust), :notice => \"This authentication already exists\"\n else\n oauth = Authentication.create_with_omniauth(auth)\n cust.authentications << oauth\n cust.save\n # We do not change the current_customer_authentication.\n redirect_to edit_customer_registration_path(cust), :notice => \"Authentication Added.\"\n end\n else\n redirect_to customer_sign_in_path, :notice => \"Need to sign in first.\"\n end\n end",
"def switch_account\n cust_no = params[:customer_number].scan(/\\d+/).first\n cust_name = params[:customer_number].split(cust_no).last.gsub(/[[:space:]]/, ' ').strip\n session[:customer_number] = cust_no\n session[:customer_Name] = cust_name\n # Populate New Customer into DB\n Kitting::Customer.find_by_user_name_and_user_level_and_cust_no(session[:user_name],session[:user_level],session[:customer_number]) || Kitting::Customer.create(:cust_no => session[:customer_number], :cust_name => session[:customer_Name], :user_name => session[:user_name],:user_level => session[:user_level],:user_type => session[:user_type])\n Kitting::CustomerConfigurations.find_or_create_by_cust_no(cust_no: cust_no,cust_name: cust_name,updated_by: current_customer )\n render :json => {:controller => params[:controller_name]}\n end",
"def auth_pending_driver\n @user.is_driver = true\n @user.pending_driver_verification = false\n NotificationWorker.perform_async(\"became_authorized_driver\", nil, @user.id)\n NotificationWorker.perform_async(\"add_a_car\", nil, @user.id)\n if @user.save\n render nothing: true, status: 204\n else\n render :json => {:error => \"Non è stato possibile effettuare l'operazione.\"}.to_json, :status => 500\n end\n end",
"def sync_datas_process\n SyncDatas.sync(self)\n # user = self\n end",
"def active_customer\n if (current_customer && !current_customer.active?)\n redirect_to(job_requests_url)\n end\n end",
"def after_complete(order, transition)\n Delayed::Job.enqueue DelayedSubscriberUpdate.new(Spree::Config.get(:exact_target_user), Spree::Config.get(:exact_target_password), order.number)\n end",
"def simultaneous_login!\n redirect_to root_path if current_admin && current_account\n end",
"def sync\n logger.info \"Syncing EVERYTHING\"\n # Update info in background\n Thread.new do\n if Qbo.exists?\n Customer.sync\n Invoice.sync\n QboItem.sync\n Employee.sync\n Estimate.sync\n \n # Record the last sync time\n Qbo.update_time_stamp\n end\n ActiveRecord::Base.connection.close\n end\n\n redirect_to :home, :flash => { :notice => \"Successfully synced to Quickbooks\" }\n end",
"def add_customer_account\n self.create_account! unless self.account\n end",
"def login\r\n\t\t@user = @current_user || User.new\r\n\t\t# If logged in, redirect to the pending orders page. This only happens if we didn't jump_to\r\n\t\t# something in require_authorisation: it's pretty confusing if you get the login screen again\r\n\t\t# _after_ you successfully logged in!\r\n\t\tif @user.permissions >= :client\r\n\t\t\tredirect_to(:controller => 'admin/orders', :action=> 'pending') and return false\r\n\t\tend\r\n\tend",
"def autologin_the_user\n #unless logged_in?\n # FrontendUserSession.create(params[:frontend_user_session])\n #end\n end",
"def current\n Job.generate_work_order\n redirect_to '/'\n end",
"def update\n authenticate_customer!\n # We put this in the session in case the user adds an authentication.\n tpauth = Authentication.find session[:customer_oauth_id]\n if tpauth\n @customer = current_customer\n @customer.update_attributes(params[:customer])\n @customer.authentications << tpauth\n @customer.save\n redirect_to edit_customer_registration_path(@customer), :notice => \"Account Updated!\"\n else\n redirect_to customer_sign_in_path, \"You need to authenticate first.\"\n end\n end",
"def submit!\n raise('already submitted') if was_submitted?\n raise('expected a purchased order') unless submit_order&.purchased?\n\n wizard_steps[:checkout] ||= Time.zone.now\n wizard_steps[:submitted] = Time.zone.now\n submitted!\n end",
"def execute\n if activemerchant_credit_card.nil?\n # Client created by admin\n create_subscription\n user.update_attribute :card_access, User.card_access.find_value(:forbidden).value\n subscription.update_attribute :start_at, Date.today if subscription.present?\n UserMailer.welcome(user.id).deliver_later\n else\n # Subscription by Client.\n process_payment_workflow\n return false unless subscription.present? && user.persisted?\n finalize_user_subscription\n end\n end",
"def set_broker_acct\n #@broker_acct = current_account.meta\n end",
"def sync\n # Update info in background\n Thread.new do\n if Qbo.exists?\n Customer.sync\n QboItem.sync\n QboEmployee.sync\n QboEstimate.sync\n QboInvoice.sync\n \n # Record the last sync time\n Qbo.update_time_stamp\n end\n ActiveRecord::Base.connection.close\n end\n\n redirect_to qbo_path(:redmine_qbo), :flash => { :notice => \"Successfully synced to Quickbooks\" }\n end",
"def after_create\n super\n create_account\n end",
"def post_transaction_process\n bet_wallet.persist_wallet!\n end",
"def apply_to_order(user, order, session)\n cc = @data_object\n cc.cc_order_id = order.order_id\n pay = gen_payment\n $store.transaction do \n pay.apply_to_order(user, order, cc.cc_amount, session)\n cc.cc_pay_id = pay.pay_id\n save\n end\n end",
"def zoho_sync\n\n\t\t\tUser.zoho_sync\n\n\t\t\trender text: 'OK'\n\n\t\tend",
"def account_complete # POST '/admin/account_setup'\n @admin = Admin.find(session[:admin_id])\n\n # This section of the site is built for new admin accounts.\n # Update the admin attributes with more detailed information from the\n # account_setup (step 2) form, && update the their first store which was\n # instantiated at the account_create action.\n if @admin.update(admin_params) && @admin.stores.first.update(store_params)\n ## Sign-up is successful and admin dashboard is loaded.\n redirect_to admin_path\n else\n render :account_setup\n end\n end",
"def check_if_processed\n if self.active == true\n # If you just got rid of your old order, grab a new one\n Order.create(user_id: self.user_id)\n end\n end",
"def schedule\n\t\tputs \"the self attributes in the background job are:\"\n\t\tputs self.attributes.to_s\n\t\tif self.uuid.blank?\n\t\t\tself.sign_up\n\t\tend\n\t\tif !self.otp.blank?\n\t\t\tif self.mobile_confirmed == 0\n\t\t\t\tself.confirm_otp\n\t\t\tend\n\t\tend\n\t\tif self.resend_otp == 1\n\t\t\t## should reset resend otp.\n\t\t\tself.do_resend_otp\n\t\tend\n\t\tif self.forgot_password == 1\n\t\t\t## should resent forgot_password.\n\t\t\tself.do_forgot_password\n\t\tend\n\t\t## and sign in, is done in the controller itself ?\n\t\t## or when ?\n\t\t## is that a save call ?\n\tend",
"def perform\n begin\n\n # Values from the form.\n account = request.POST['account']\n pac = request.POST['password']\n branch = request.POST['branch'] # Can be a hidden field if always same branch\n\n # Hashmap/Hash\n auth_details = get_authentication_client().authenticateMember(account, branch, pac)\n\n raise Exception.new(auth_details[\"error\"]) if auth_details[\"error\"]\n\n @user_info = auth_details[\"user_info\"]\n\n @env['omniauth.auth'] = auth_hash\n @env['PATH_INFO'] = \"#{OmniAuth.config.path_prefix}/#{name}/callback\"\n\n call_app!\n rescue Exception => e\n #Rails.logger.info(\"Exception => #{e.inspect}\")\n Rails.logger.info(\"Message: #{e.message}\")\n #Rails.logger.info(\"Backtrace: #{e.backtrace}\")\n fail!(e.message, e)\n end\n end",
"def synchronize\n if session[:xero_auth] && $xero\n Contact.synchronize($xero,current_user)\n else\n redirect_to xero_reconnect_path and return\n end\n redirect_to contacts_url\n end",
"def customer_login(customer_reference)\n MerchantPluginProvider.api_not_implemented(self)\n end",
"def process_order\n @order.process!\n redirect_to root_path\n end",
"def activate\n\n # Add your extension tab to the admin.\n # Requires that you have defined an admin controller:\n # app/controllers/admin/yourextension_controller\n # and that you mapped your admin in config/routes\n\n #Admin::BaseController.class_eval do\n # before_filter :add_yourextension_tab\n #\n # def add_yourextension_tab\n # # add_extension_admin_tab takes an array containing the same arguments expected\n # # by the tab helper method:\n # # [ :extension_name, { :label => \"Your Extension\", :route => \"/some/non/standard/route\" } ]\n # add_extension_admin_tab [ :yourextension ]\n # end\n #end\n\n Order.class_eval do\n after_create :create_quote\n\n has_one :quote\n accepts_nested_attributes_for :quote\n\n has_one :bill_address, :through => :checkout\n\n named_scope :quote_complete, {:include => :quote, :conditions => [\"quotes.completed_at IS NOT NULL\"]}\n\n Order.state_machines[:state] = StateMachine::Machine.new(Order, :initial => 'in_progress') do\n after_transition :to => 'quote', :do => :complete_quote\n event :save_as_quote do\n transition :from => 'in_progress', :to => 'quote'\n end\n event :complete do\n transition :from => 'new', :from => 'quote'\n end\n end\n\n def quote_complete\n quote.completed_at\n end\n\n def complete_quote\n quote.update_attribute(:completed_at, Time.now)\n if email\n OrderMailer.deliver_confirm(self)\n end\n end\n\n def create_quote\n self.quote ||= Quote.create(:order => self)\n end\n end\n\n OrdersController.class_eval do\n def duplicate\n quote_order = @order\n\n @order = Order.create\n session[:order_id] = @order.id\n session[:order_token] = @order.token\n\n quote_order.line_items.each do |line_item|\n @order.add_variant(line_item.variant, line_item.quantity) if line_item.quantity > 0\n end\n\n @order.save \n redirect_to edit_order_path(@order)\n end\n end\n\n Admin::BaseController.class_eval do\n before_filter :add_quotes_tab\n def add_quotes_tab\n @extension_tabs << [ :quotes ]\n end\n end \n # make your helper avaliable in all views\n # Spree::BaseController.class_eval do\n # helper YourHelper\n # end\n end",
"def send_confirmation_email\n\t\tRentersConfirmationJob.perform_later self\n OwnersConfirmationJob.perform_later self\n\tend",
"def process_authorization(options)\n gateway = options[:gateway]\n transaction_type = options[:transaction_type]\n amount = options[:amount]\n confirmation_code = options[:confirmation_code]\n transaction_id = options[:transaction_id]\n begin\n Order.transaction do\n # lock order\n Order.find_by_id(self.id, :lock => true)\n # ignore any order state besides created - page refresh\n if self.state == Order::CREATED\n # create order_payment\n OrderPayment.create!(:user_id => self.user_id, :order_id => self.id, :gateway => gateway, \n :transaction_type => transaction_type, :confirmation_code => confirmation_code, \n :transaction_id => transaction_id, :amount => amount)\n # create coupons\n self.create_coupons!\n # update order\n self.update_attributes!(:state => Order::AUTHORIZED, :authorized_at => Time.zone.now)\n end\n end\n return true\n rescue ActiveRecord::RecordInvalid => invalid\n logger.error \"Order.process_authorization: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end",
"def logged_in_customer\n unless customer_logged_in?\n store_location\n flash[:danger] = \"Please log in1.\"\n redirect_to customer_login_url\n end\n end",
"def complete_order\n # Get the current user's last order (i.e. the current order)\n @order = @current_user.orders.last\n\n # Invoke an action in order.rb that 'moves' items from a user's cart to the current order\n @order.add_line_items_from_cart @cart\n\n # Invoke action in order.rb that updates stock levels\n @order.update_inventory\n\n # Destroy the user's cart\n @cart.destroy\n\n # Set a flash notification that the order was successful\n flash[:notification] = \"Order successful!!!\"\n\n # Redirect to orders#show\n redirect_to order_path(@order)\n end",
"def activate \n # credit card numbers should always be stored in the case of offline processing (no other option makes sense)\n #Spree::Config.set(:store_cc => true) \n \n Creditcard.class_eval do \n require 'openssl'\n require 'base64'\n \n # overrides filter_sensitive to make sure the stored values are encrypted.\n private\n def filter_sensitive \n # don't encrypt again, this way we can clone an order and its creditcard and keep text encrypted\n return unless encrypted_text.blank?\n gnupg = GnuPG.new :recipient => Spree::Pgp::Config[:email]\n public_key_text = Rails.cache.fetch('public_key') do\n File.read(\"#{RAILS_ROOT}/#{Spree::Pgp::Config[:public_key]}\")\n end\n gnupg.load_public_key public_key_text \n text = \"Number: #{number} Code: #{verification_value}\"\n self[:encrypted_text] = gnupg.encrypt(text)\n self[:number] = \"\"\n self[:verification_value] = \"\"\n end\n end\n \n # register Creditcards tab\n Admin::BaseController.class_eval do\n before_filter :add_creditcard_tab\n\n private\n def add_creditcard_tab\n @order_admin_tabs ||= []\n @order_admin_tabs << {:name => t('credit_cards'), :url => \"admin_order_creditcards_url\"} \n end\n end \n \n end",
"def set_account\n @account = current_user\n end",
"def set_tenant_and_account\n @account = current_user.account\n set_current_tenant @account\n end",
"def unsynchronized_customer( account_num )\r\n output_log account_num\r\n end",
"def save_account\n @account = copy_account_to_user(@account)\n wizard_save(@account)\n @account.save\n end",
"def new_customer\n # We are going to auth a customer. We indicate that in the session\n if current_customer\n redirect_to edit_customer_registration_path(current_customer), :notice => \"You are already signed in.\"\n else\n @providers = BuspassAdmin::Application.oauth_providers\n session[:tpauth] = :customer\n @options = \"?tpauth=customer&customer_auth=#{session[:session_id]}&failure_path=#{root_path}\"\n # We will render new_customer and then that will redirect to sessions#create on /auth/;provider/callback\n state_data = { :tpauth => :customer, :customer_auth => session[:session_id], :failure_path => root_path }\n state_urldata = CGI::escape(state_data.to_json)\n @fb_options = \"?state=#{state_urldata}\"\n end\n end",
"def logged_in_customer\n unless customer_logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to customer_login_url\n end\n end",
"def activate\r\n Marketplace::Database.instance.delete_deactivated_user(self)\r\n Marketplace::Database.instance.add_user(self)\r\n Marketplace::Activity.create(Activity.USER_REACTIVATE, self, \"#{self.name} has been reactivated\")\r\n end",
"def activate!\n @activated = true\n\n self.active = true\n \n # Authlogic resets the perishable token by default on save, but I'm leaving the call\n # to reset_perishable_token! here directly to help reveal intent (which's is kinda a\n # dead purpose after this long comment, but who cares).\n #\n # This also saves the record.\n #\n reset_perishable_token!\n end",
"def Login()\n # Login\n system(@tabLogin)\n Process.waitall\nend",
"def set_customer\n if signed_in?\n # technically we need nothing here\n end\n end",
"def set_authed_order\n @order = current_user.orders.find(params[:id])\n end",
"def commit_orders\r\n orders = @customer.open_orders.find_all_by_synchronized( false )\r\n sales_id = \"\"\r\n orders.each do |o| sales_id += \"'#{o.sales_id}', \" end \r\n @store_user.my_account_log(@customer,\"Commit Sales Order Updates: #{sales_id}\")\r\n\r\n if orders.empty? || ERP::SalesOrder.commit_orders( orders )\r\n flash.now[:message] = \"All changes have been commited.\"\r\n else\r\n flash.now[:message] = \"Operation Failed.\"\r\n end\r\n end",
"def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end",
"def do_pending\n make_activation_code\n # send the user an email with an activation code\n UserMailer.deliver_signup_notification(self)\n end",
"def complete_order customer\n puts \"========= Completing Order\"\n # Go to Cart Page\n @b.goto 'https://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n # Check if all items can be purchased\n sleep 5\n if @b.button(class: \"buy-now-disabled-info\").exists?\n raise \"Um dos produtos do carrinho não está mais disponível\"\n end\n @b.button(class: \"buy-now\").wait_until_present(timeout: 30)\n if !@b.button(class: \"buy-now\").exists?\n raise \"Produto sem estoque na Aliexpress\"\n else\n @b.button(class: \"buy-now\").click\n end\n\n # Check if current session if up\n self.check_if_session_is_up\n\n fullname = to_english(customer[\"first_name\"]+\" \"+customer[\"last_name\"])\n\n # Fill customer's address\n puts \"========= Adding customer informations\"\n @log.add_message('Adicionando informações do cliente')\n @b.text_field(name: \"contactPerson\").wait_until_present(timeout: 3)\n @log.add_message(fullname)\n @b.text_field(name: \"contactPerson\").set fullname\n @b.select_list(name: \"country\").select \"Brazil\"\n if customer['number'].nil?\n adds = customer[\"address_1\"]\n else\n adds = customer[\"address_1\"]+\" \"+customer['number']\n end\n @log.add_message(to_english(adds))\n @b.text_field(name: \"address\").set to_english(adds)\n @log.add_message(to_english(customer[\"address_2\"]))\n @b.text_field(name: \"address2\").set to_english(customer[\"address_2\"])\n # Wait for States to turn on select\n sleep 1\n state = self.state.assoc(customer[\"state\"])\n @b.div(class: \"sa-province-wrapper\").select_list.select state[1]\n @b.text_field(name: \"city\").set to_english(customer[\"city\"])\n postcode = customer['postcode'].gsub(/\\D/, '')\n @b.text_field(name: \"zip\").set postcode\n @b.text_field(name: \"phoneCountry\").set '55'\n @b.text_field(name: \"mobileNo\").set '941873849'\n @b.text_field(name: \"cpf\").set '35825265856'\n @b.a(class: \"sa-confirm\").click\n\n check_costumer_data @b, fullname\n\n # Placing order on desktop website\n @b.button(id: \"place-order-btn\").click\n\n puts \"========= Finishing Order\"\n @log.add_message('Finalizando Pedido')\n sleep 3\n if @b.span(class: \"order-no\").exists?\n # Return the number of the Order if there is no captcha\n @finished = true\n @b.span(class: \"order-no\").text\n else\n puts \"========= Captcha detected, going to mobile...\"\n @log.add_message('Captcha detectado, indo para carrinho mobile')\n @b.goto 'm.aliexpress.com/shopcart/detail.htm'\n @b.div(class: \"buyall\").wait_until_present(timeout: 30)\n @b.div(class: \"buyall\").click\n # Create the final order on mobile website to avoid captcha\n @b.button(id: \"create-order\").wait_until_present(timeout: 30)\n @b.button(id: \"create-order\").click\n @finished = true\n @b.div(class: \"desc_txt\").wait_until_present(timeout: 30)\n @b.div(class: \"desc_txt\").text\n end\n end",
"def account_authorized(account)\n session[:account_id] = account.public_send(BookingSyncEngine.bookingsync_id_key).to_s\n end",
"def user_and_pass_data\n sleep 5\n\t fill_in 'customer_login_email', with: $usr\n fill_in 'customer_login_password', with: $pas\n sleep 3\n end",
"def register_automatically(user, &block)\n # Automatic activation\n user.activate\n user.last_login_on = Time.now\n if user.save\n self.logged_user = user\n flash[:notice] = l(:notice_account_activated)\n redirect_to my_account_path\n else\n yield if block_given?\n end\n end",
"def process_with_active_merchant\n options = populate_options\n auth = authorize_payment(options)\n save!\n if APP_CONFIG['pre_and_post_authorization'] == true\n if auth.success == true\n capture_payment(options)\n save!\n end\n end\n end",
"def _threaded_mage_checkout\n @custom_number_of_users.times do\n start_time = Time.now\n add_to_cart @helper.get_yaml_data\n get_a_shipping_quote\n @helper.proceed_to_checkout\n # assert_section 'checkout'\n finalize_checkout_as_guest\n final_time = Time.now - start_time\n puts \"It took #{final_time} seconds to complete the order\"\n end\n end",
"def activate_user\n self.save\n self.send_user_notification_email\n end",
"def login\n make_login_call\n end",
"def run_autosync\n begin\n self.status = _(\"Synchronizing organisations.\")\n self.update_organisation_cache\n \n self.status = _(\"Synchronizing worktime.\")\n self.update_worktime_cache\n \n self.status = _(\"Automatic synchronization done.\")\n rescue => e\n self.status = sprintf(_(\"Error while auto-syncing: %s\"), e.message)\n puts Knj::Errors.error_str(e)\n ensure\n @sync_thread = nil\n end\n end",
"def load_current_account!\n super\n if(params[:job_id])\n @preload_job = Job.where(:message_id => params[:job_id]).last\n if(@preload_job && @preload_job.account_id && @preload_job.account_id != @account.id)\n redirect_to(\n :controller => controller_name,\n :action => action_name,\n :params => params.merge(:account_id => @preload_job.account_id)\n )\n end\n end\n end",
"def run()\n login()\n end",
"def solve\n if user.role == :customer\n EventDispatcher.new.customer_was_registered(user).dispatch!\n end\n end",
"def customer_log_in_as(customer, options = {})\n password = options[:password] || 'password'\n remember_me = options[:remember_me] || '1'\n if integration_test?\n post customer_login_path, session: { email: customer.email,\n password: password,\n remember_me: remember_me }\n else\n session[:customer_id] = customer.id\n end\n end",
"def update_other_applications(paid)\n ServiceRunnerJob.perform_later(\"OtherApps::UpdateBillingStatus\", @account, paid)\n end",
"def create_account\n @customer = Customer.find params[:id]\n fail unless @customer.email == params[:customer][:email]\n @customer.update_attributes!(customer_params)\n @customer_session = Authentication::CustomerSession.new(\n email: @customer.email,\n password: customer_params[:password]\n )\n @customer_session.save!\n end",
"def log_in_as(customer)\n session[:customer_id] = customer.id\n end",
"def create\n #to avoid unwanted/unsafe requests we replace params[:user]\n @user = User.new(user_params)\n if @user.save\n # =WANT THEM TO ACTIVATE ACCOUNT FIRST\n @user.send_activation_email\n flash[:info] = \"Please check your email to activate your account.\"\n redirect_to root_url\n #logs in a user after they make account\n # log_in(@user)\n # flash[:success] = \"Welcome to Twitter Clone!\"\n #redirect_to @user\n else\n render 'new'\n end\n end",
"def complete_order customer\n puts \"========= Completing Order\"\n # Go to Cart Page\n @b.goto 'https://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n # Check if all items can be purchased\n sleep 5\n if @b.button(class: \"buy-now-disabled-info\").exists?\n raise \"Um dos produtos do carrinho não está mais disponível\"\n end\n @b.button(class: \"buy-now\").wait_until_present(timeout: 30)\n if !@b.button(class: \"buy-now\").exists?\n raise \"Produto sem estoque na Aliexpress\"\n else\n @b.button(class: \"buy-now\").click\n end\n # Check if current session if up\n self.check_if_session_is_up\n # Fill customer's address\n puts \"========= Adding customer informations\"\n @log.add_message('Adicionando informações do cliente')\n @b.text_field(name: \"contactPerson\").wait_until_present(timeout: 3)\n @b.text_field(name: \"contactPerson\").set to_english(customer[\"first_name\"]+\" \"+customer[\"last_name\"])\n @b.select_list(name: \"country\").select \"Brazil\"\n if customer['number'].nil?\n @b.text_field(name: \"address\").set to_english(customer[\"address_1\"])\n else\n @b.text_field(name: \"address\").set to_english(customer[\"address_1\"]+\" \"+customer['number'])\n end\n @b.text_field(name: \"address2\").set to_english(customer[\"address_2\"])\n # Wait for States to turn on select\n sleep 1\n state = self.state.assoc(customer[\"state\"])\n @b.div(class: \"sa-province-wrapper\").select_list.select state[1]\n @b.text_field(name: \"city\").set to_english(customer[\"city\"])\n @b.text_field(name: \"zip\").set customer[\"postcode\"]\n @b.text_field(name: \"phoneCountry\").set '55'\n @b.text_field(name: \"phoneArea\").set '55'\n @b.text_field(name: \"phoneNumber\").set '11'\n @b.text_field(name: \"mobileNo\").set '941873849'\n @b.text_field(name: \"cpf\").set '35825265856'\n @b.a(class: \"sa-confirm\").click\n\n # Placing order on desktop website\n @b.button(id: \"place-order-btn\").click\n\n puts \"========= Finishing Order\"\n @log.add_message('Finalizando Pedido')\n sleep 3\n if @b.span(class:\"order-no\").exists?\n # Return the number of the Order if there is no captcha\n @finished = true\n @b.span(class:\"order-no\").text\n else\n puts \"========= Captcha detected, going to mobile...\"\n @log.add_message('Captcha detectado, indo para carrinho mobile')\n @b.goto 'm.aliexpress.com/shopcart/detail.htm'\n @b.div(class:\"buyall\").wait_until_present(timeout: 30)\n @b.div(class:\"buyall\").click\n # Create the final order on mobile website to avoid captcha\n @b.button(id:\"create-order\").wait_until_present(timeout: 30)\n @b.button(id:\"create-order\").click\n @finished = true\n @b.div(class:\"desc_txt\").wait_until_present(timeout: 30)\n @b.div(class:\"desc_txt\").text\n end\n end",
"def start_sync\n agent = Mechanize.new\n page = agent.get(ENV['warranty_sync_url'])\n form = page.form_with(name: \"form1\")\n form.txtMaterialNo = product_name\n form.txtSerialNo = serial_number\n form.txtPurchaseDate = I18n.l(purchased_on, format: :mmddyyyy)\n form.txtFirstName = first_name\n form.txtLastName = last_name\n form.txtAddress = \"\"\n form.txtCity = \"\"\n form.txtPostalCode = \"\"\n form.txtEmail = email\n\n begin\n if country.to_s.match(/^US$/i) || country.to_s.match(/United States/i)\n country = \"USA\"\n end\n form.field_with(name: \"ddlCountry\").option_with(text: country).click\n rescue\n # Couldn't select country\n end\n\n button = form.button_with(name: \"btnSubmit\")\n agent.submit(form, button)\n end",
"def activate\n\n # Add your extension tab to the admin.\n # Requires that you have defined an admin controller:\n # app/controllers/admin/yourextension_controller\n # and that you mapped your admin in config/routes\n\n #Admin::BaseController.class_eval do\n # before_filter :add_yourextension_tab\n #\n # def add_yourextension_tab\n # # add_extension_admin_tab takes an array containing the same arguments expected\n # # by the tab helper method:\n # # [ :extension_name, { :label => \"Your Extension\", :route => \"/some/non/standard/route\" } ]\n # add_extension_admin_tab [ :yourextension ]\n # end\n #end\n\n # make your helper avaliable in all views\n # Spree::BaseController.class_eval do\n # helper YourHelper\n # end\n \n Admin::OrdersController.class_eval do\n \n def charge_google_order\n @gateway = Gateway.find_by_clazz \"Google4R::Checkout::Frontend\"\n @gw = GatewayConfiguration.find_by_gateway_id(@gateway.id)\n if @gw.present? && @gw.gateway_option_values[0].value.present? && @gw.gateway_option_values[1].value.present?\n configuration = { :merchant_id =>@gw.gateway_option_values[0].value, :merchant_key => @gw.gateway_option_values[1].value, :use_sandbox => true }\n @frontend = Google4R::Checkout::Frontend.new(configuration)\n order = @frontend.create_charge_order_command\n o = Order.find_by_number(params[:id])\n order.google_order_number = o.google_order_number if o.google_order_number.present? \n order.amount = Money.new(5017, \"GBP\")\n puts \"=-=-=-=-=-_+_+_+-#{order.to_xml}\"\n @orders = order.send_to_google_checkout\n flash[:notice] = t('charged_google_checkout_order')\n redirect_to :back\n end\n end\n \n def cancel_google_checkout_order\n @gateway = Gateway.find_by_clazz \"Google4R::Checkout::Frontend\"\n @gw = GatewayConfiguration.find_by_gateway_id(@gateway.id)\n if @gw.present? && @gw.gateway_option_values[0].value.present? && @gw.gateway_option_values[1].value.present?\n configuration = { :merchant_id =>@gw.gateway_option_values[0].value, :merchant_key => @gw.gateway_option_values[1].value, :use_sandbox => true }\n @frontend = Google4R::Checkout::Frontend.new(configuration)\n order = @frontend.create_cancel_order_command\n o = Order.find_by_number(params[:id])\n order.google_order_number = o.google_order_number if o.google_order_number.present? \n order.reason = params[:reason]\n order.comment = params[:comment]\n @orders = order.send_to_google_checkout\n #puts \"=-=-=-=-=-_+_+_+-#{@orders}\"\n end\n end\n \n end\n \n \n OrdersController.class_eval do\n \n def edit\n # Use your own merchant ID and Key, set use_sandbox to false for production\n @gateway = Gateway.find_by_clazz \"Google4R::Checkout::Frontend\"\n @gw = GatewayConfiguration.find_by_gateway_id(@gateway.id)\n if @gw.present? && @gw.gateway_option_values[0].value.present? && @gw.gateway_option_values[1].value.present?\n configuration = { :merchant_id =>@gw.gateway_option_values[0].value, :merchant_key => @gw.gateway_option_values[1].value, :use_sandbox => true }\n @frontend = Google4R::Checkout::Frontend.new(configuration)\n @frontend.tax_table_factory = TaxTableFactory.new\n checkout_command = @frontend.create_checkout_command\n # Adding an item to shopping cart\n @order.line_items.each do |l|\n checkout_command.shopping_cart.create_item do |item| \n item.name = l.product.name\n item.description = l.product.description\n item.unit_price = Money.new(l.price, \"GBP\") \n item.quantity = l.quantity\n end\n end\n checkout_command.shopping_cart.private_data = { 'order_number' => @order.id } \n checkout_command.edit_cart_url = edit_order_url(@order)\n checkout_command.continue_shopping_url = order_url(@order)\n #Create a flat rate shipping method\n i = 50\n ShippingMethod.all.each do |ship_method| \n \n checkout_command.create_shipping_method(Google4R::Checkout::FlatRateShipping) do |shipping_method| \n shipping_method.name = ship_method.name #\"UPS Standard 3 Day\"\n shipping_method.price = Money.new(i, \"GBP\")#Money.new(5000, \"GBP\") \n shipping_method.create_allowed_area(Google4R::Checkout::UsCountryArea) do |area|\n area.area = Google4R::Checkout::UsCountryArea::ALL\n end \n i += 50\n end\n \n end \n @response = checkout_command.to_xml #send_to_google_checkout # \n # puts \"===========#{request.raw_post}\"\n end\n end\n \n show.before do\n session[:order_id] = nil\n end\n end\n \n end",
"def make_current\n Account.current_account = self\n end",
"def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.make_admin_if_first_user\n save(false)\n end",
"def create\n tpauth = Authentication.find session[:customer_oauth_id]\n if tpauth\n @customer = Customer.new(params[:customer])\n if Customer.count == 0\n # The first customer has administrative privileges.\n @customer.add_roles([:admin])\n end\n @customer.authentications << tpauth\n @customer.save\n session[:customer_id] = @customer.id\n redirect_to edit_customer_registration_path(@customer), :notice => \"Signed In!\"\n else\n redirect_to customer_sign_in_path, \"You need to authenticate first.\"\n end\n end",
"def app_checkout\n @order = Order.find(params[:id])\n\n (EffectiveOrders.authorized?(self, :update, @order) rescue false)\n\n checkout = EffectiveOrders.app_checkout[:service].call(order: @order)\n if checkout.success?\n order_purchased(details: payment_details(checkout), provider: 'app_checkout', card: 'none')\n else\n flash = EffectiveOrders.app_checkout[:declined_flash]\n order_declined(details: payment_details(checkout), message: flash, provider: 'app_checkout', card: 'none')\n end\n end",
"def activate\n self.activated_at = Time.now.utc\n self.perishable_token = nil\n save(false)\n end",
"def run\n SoopaStore.checkout.cashier = @cashier\n @cashier.checkout = SoopaStore.checkout\n SoopaStore.cashiers.add @cashier\n puts \"Time #{SoopaStore.current_time} : Cashier #{@cashier.eid} arrives & starts work\"\n end",
"def current_account\n load_session\n @current_account\n end",
"def proceed_to_checkout\n \n order = Order.new\n order.cart_id = @cart.id\n order.responseCode = 100\n order.responseDescription = \"Tests added to your account.\"\n order.save!\n \n cart = Cart.find(order.cart_id)\n \n # Add each cartitem to user's account.\n cart.cart_items.each do | cart_item |\n if cart_item.quiz_id != nil\n # Add Quiz\n quiz_user = QuizUser.new\n quiz_user.quiz_id = cart_item.quiz_id\n quiz_user.user_id = current_user.id\n quiz_user.save!\n end\n end\n \n redirect_to homes_index_path, notice: \"Test added to your account.\"\n end",
"def myaccount\n redirect_to user_path(current_user)\n end",
"def sync_with_service_department\n if needs_sync?\n begin\n start_sync\n update(synced_on: Date.today)\n rescue\n logger.debug \"Something went wrong sending registration: #{self.inspect}\"\n end\n end\n end",
"def order_upgrade\n @order.next\n @order.complete!\n # Since we dont rely on state machine callback, we just explicitly call this method for spree_store_credits\n if @order.respond_to?(:consume_users_credit, true)\n @order.send(:consume_users_credit)\n end\n @order.finalize!\n end",
"def open_user_account\n Account.create(user_id: self.id) \t\n end",
"def _other(*args, &block)\n Apartment::Tenant.process(other_customer.tenant_name) do\n block.call(*args)\n end\n end",
"def logged_in_customer\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_customer\n unless customer_logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def start(user, account_id)\n @greeting = \"Started data retrieval for - #{account_id}\"\n\n mail to: user.email\n end"
] |
[
"0.595816",
"0.5875038",
"0.58296734",
"0.5761117",
"0.5729202",
"0.5722417",
"0.5673489",
"0.5649308",
"0.56413364",
"0.5612919",
"0.5594063",
"0.5539273",
"0.5491705",
"0.54705316",
"0.5467064",
"0.54059744",
"0.53117275",
"0.52932996",
"0.52900213",
"0.5281833",
"0.52689004",
"0.52577245",
"0.5240407",
"0.52336466",
"0.52217877",
"0.5217086",
"0.5198493",
"0.5182285",
"0.5180863",
"0.5169869",
"0.5163135",
"0.51564133",
"0.5153502",
"0.5149085",
"0.51405394",
"0.51057065",
"0.51054776",
"0.50972986",
"0.50972044",
"0.5095473",
"0.50746727",
"0.50711703",
"0.50710315",
"0.506868",
"0.5064688",
"0.5064485",
"0.5064288",
"0.50605977",
"0.50556815",
"0.50549406",
"0.5053328",
"0.504938",
"0.5047747",
"0.503348",
"0.5030338",
"0.5022049",
"0.5020935",
"0.5019868",
"0.5006917",
"0.50006735",
"0.499693",
"0.4994505",
"0.49873438",
"0.49765864",
"0.49729317",
"0.4962232",
"0.4958739",
"0.49530688",
"0.49523896",
"0.49395543",
"0.4933858",
"0.49331492",
"0.493144",
"0.4925831",
"0.49213603",
"0.49166775",
"0.49156153",
"0.49106222",
"0.49057454",
"0.4903955",
"0.49019343",
"0.49005392",
"0.48996133",
"0.48882008",
"0.48869717",
"0.4872095",
"0.48691583",
"0.48667967",
"0.486525",
"0.48638415",
"0.4862853",
"0.4862507",
"0.4856836",
"0.4855619",
"0.48543078",
"0.48505053",
"0.48496515",
"0.48366454",
"0.48278782",
"0.48267072"
] |
0.6340605
|
0
|
Obtener los gastos del pedido
|
def order_expenses
total_expenses_per_subsection = {}
total_expenses_per_subsection.default = 0.0
details = self.order_details
details.each do |detail|
total_expenses_per_subsection[detail.subsection] += detail.last_value.amount
end
total_expenses_per_subsection
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def seleccionarCromosomas()\n #p \"--- Empieza el torneo:\"\n seleccion = []\n @tamMatingPool.times do\n competidor1 = @poblacion[Random.rand(@tamPoblacion)]\n competidor2 = @poblacion[Random.rand(@tamPoblacion)]\n evaluarCromosoma(competidor1)\n evaluarCromosoma(competidor2)\n ganador = competidor1.aptitud > competidor2.aptitud ? \n competidor1 : competidor2\n #p \"--- Ganador: #{ganador.genes}\"\n seleccion.push(ganador)\n end\n return seleccion\n end",
"def asignaturas_peda_por(profe)\n # per = Horario.where('professor_id = ?', profe.id).joins(:asignatura).where('lectiva=true')\n per = Horario.where('professor_id = ?', profe.id).joins(:asignatura)\n .where('asignaturas.lectiva=TRUE').order('asignaturas.orden')\n a = per.map do |h|\n [\"#{h.asignatura.name} #{h.curso.name} \", \"#{h.horas}\"]\n end\n\n end",
"def comisiones_asignadas\n asunto.comisiones if asunto\n end",
"def suma_gramos\n\t\t\t@proteinas + @carbohidratos + @lipidos\n\t\tend",
"def mostrar_palabras_clave_grupos \n \n puts \"Esta operación puede tardar un poco, le rogamos tenga paciencia por favor.\"\n puts\n puts\n coleccion = @hemeroteca.palabras_clave_grupos \n coleccion.each_index do |i|\n puts \"Grupo #{i+1}:\" \n puts \"---------\"\n puts coleccion[i].join(\", \")\n puts \n puts \n end\n if coleccion.empty? then\n puts \"Lo sentimos, no se han encontrado noticias.\" \n puts\n puts\n end \n \n end",
"def mostrar_partidos\n \n puts \" \"\n puts \"Quantidade de votos por partido\"\n \n for partido in @partido\n partido.mostrar_dados \n end\n end",
"def get_grasas\n @_100=((@grasas*100)/@peso)\n @ir_100=(@_100/70)*100\n @porcion=((@grasas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/70)*100\n [ @grasas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end",
"def pedidoDarAlta(pedido)\r\n @@pedidos.at(pedido - 1).darAlta()\r\n @@pedidos.at(pedido - 1).empaquetarPedido(@@paquetes, @@sinEntregar)\r\n end",
"def disponibles\n total = []\n heros.each do |h|\n next unless h.tesoro\n next unless h.tesoro[item + 's']\n h.tesoro[item + 's'].each do |e|\n (total << h.id) if e == id\n end\n end\n total\n end",
"def pontosanunciante\n\n\t\tUsuario.find(self.id_usuario).meuspontos\n\n\tend",
"def pega_sequencias_do_movimento(movimento)\n if movimento.movimentos_com_remocao_a_realizar.empty?\n return [[movimento]]\n else\n retorno = []\n movimento.movimentos_com_remocao_a_realizar.each do |movimento_com_remocao|\n retorno << [movimento] + [pega_sequencias_do_movimento(movimento_com_remocao)].flatten\n end\n end\n return retorno\n end",
"def index\n @gamerooms = Gameroom.all\n end",
"def index\n @ton_giaos = TonGiao.all\n end",
"def estados\n\t\tdevuelto = Array.new\n\t\t@renglones_reporte.each do |renglon|\n\t\t\tdevuelto << renglon.estado\n\t\tend\n\t\tdevuelto\n\tend",
"def lista_estoque()\n @client.get(Route.new([ROTA_DID_ESTOQUE]))\n end",
"def index\n @gentres = Gentre.all\n end",
"def index\n @sous_groupes = SousGroupe.all\n end",
"def index\n @gatos = Gato.all\n end",
"def index\n @pedidos = Pedido.all\n end",
"def index\n @produto_pedidos = ProdutoPedido.all\n end",
"def index\n @produto_pedidos = ProdutoPedido.all\n end",
"def index\n @coleccion = DetallePedido.all\n end",
"def list_obrigacoes(conta_id, estabelecimento_id)\n list_contas = JSON.parse(get_and_give_me_a_json(\"/estabelecimentos/obrigacoes/#{conta_id}/#{estabelecimento_id}/list\"))\n rtn = []\n list_contas.each do |u_map|\n obrig = Taxcalendario::Admin::Client::Entities::Obrigacao.new\n obrig.from_hash(u_map)\n rtn << obrig\n end\n rtn\n end",
"def index\n prepara_form\n @garagens = Garagem.all\n end",
"def tecnicos_postulados\n coleccion = []\n self.request.each do |request|\n info = {}\n info[:id] = request.id\n info[:article] = request.article\n info[:servicio] = request.service.description\n info[:tecnicos] = request.proposal\n coleccion.append(info)\n end\n coleccion\n end",
"def garments\n garments = []\n self.closets.map do |closet|\n closet.garments.map do |garment|\n garments.push({id: garment.id, name: garment.name, garment_style: garment.garment_style, garment_type: garment.garment_type, is_favorite: garment.is_favorite, is_clean: garment.is_clean, closet_id: garment.closet_id, image: garment.image, temperatures: garment.temperatures, user: garment.user, lowest_temp: garment.lowest_temp, highest_temp: garment.highest_temp, garment_weight: garment.garment_weight, temperatures: garment.temperatures, temperature_ranges: garment.temperature_ranges})\n end\n end\n garments\n end",
"def listar\n @todos_los_tipos = TipoComida.all.order(id: :asc)\n @titulo_link = \"Registrar nuevo tipo de comida\"\n end",
"def mostrar_dados\n puts \"Partido: #{@nome} - Votos: #{@votos}\" \n end",
"def parsearBotonesProducirDocumento()\n #SE PARSEAN LAS IMAGENES QUE DERIVAN EN BOTONES\n # boton_archivos_embebidos = nil\n #tab_archivos_embebidos = nil\n #Obtener todas imagenes del popup \"Iniciar Producción de Documento\"\n #PRESIONA EL BOTÓN - 'ProducirloYoMismo.png'\n claseDIV = 'z-window-highlighted-cl'\n #botonesImagenes = getBrowser().div(:class => claseDIV).images # ORIGINAL\n botonesImagenes = self.getElementosHTMLFactory().getElemento('div').obtenerImagenesPorClase(claseDIV)\n botonesImagenes.each do |imagen|\n rutaImagenSplit = imagen.src.split('/')\n nombreImagen = rutaImagenSplit[rutaImagenSplit.length - 1]\n #puts pic\n #if pic == 'ProducirloYoMismo.png'\n if nombreImagen == HISTORIAL\n @boton_historial = imagen\n end\n if nombreImagen == ENVIAR_REVISAR_PROD\n @boton_enviar_revisar_prod = imagen\n end\n if nombreImagen == ENVIAR_FIRMAR_PROD\n @boton_enviar_firmar_prod = imagen\n end\n if nombreImagen == FIRMAR_YO_MISMO_PROD\n #@boton_firmar_yo_mismo_prod \n self.setBoton_firmar_yo_mismo_prod(imagen)\n end\n end\n end",
"def to_s()\n [@nombre, @gei, @terreno, @proteinas, @lipidos, @glucidos]\n end",
"def cargar_comandos_jugadas_repetir_otro_sorteo(ticket, sorteo_origen , sorteo_destino)\n #Buscar todos los comandos de todas las jugadaslots de ese ticket con ese sorteo de origen.\n @array_jugadas_de_ese_sorteo_en_ese_ticket = Jugadalot.where(:ticket_id => ticket, :sorteot => Sorteot.where(:sigla => sorteo_origen.to_s).first.id)\n \n @comando_jugadas =[] # Defino el array que trenda todos los comando de las jugadas de este sorteo de ese ticket\n\n @array_jugadas_de_ese_sorteo_en_ese_ticket.each do |jugadalot|\n @comando_jugadas << jugadalot.comandojugada\n end\n \n #Hacer un solo string con todos los comando_jugadas.join(\"*\") unidos por caracter especial \"*\" ok. ted.\n @comando_jugadas = @comando_jugadas.join(\"*\")\n\n #Hacer un string.replace pattern .01 a .02 (sorteo_origen, sorteo_destino)\n sorteo_origen = \".\" + sorteo_origen\n sorteo_destino = \".\" + sorteo_destino\n\n @comando_jugadas.gsub(sorteo_origen, sorteo_destino)\n #dejar que siga evaluando hacia abajo... ok ted. Bloque de codigo guardar jugadas.\n \n end",
"def simulacion\n @ordenes = Orden.where(:estado => \"Recolectada\")\n end",
"def index\n @asistencia_domingos = AsistenciaDomingo.all\n end",
"def list \n @@Ordenadores\n end",
"def guardar_todo\n tags = Tag.find(:all, :conditions=>['enlazados=0 OR enlazados!=ocurrencias']) #Hallamos todas la palabras clave\n actualizaciones=0 \n for tag in tags\n actualizaciones+=guardando tag\n enlazar tag.id\n end\n \n contando\n \n mensaje='Número de links guardados correctamente: <strong>'+actualizaciones.to_s+'</strong><br/>' \n flash[:notice] = mensaje\n \n respond_to do |format|\n format.html { redirect_to(admin_tags_path) }\n format.xml { head :ok }\n end\n end",
"def index\n @pedidos_has_pratos = PedidosHasPrato.all\n end",
"def index\n @gatineos = Gatineo.all\n end",
"def index\n @grupopermissaos = Grupopermissao.all\n end",
"def ObtenerHijos(menu,padreid)\n\t totaldeRegistros1 = self.ContarHijos(menu,padreid)\n\t if totaldeRegistros1>0\n\t @tira = @tira+\" children: [ \"\n\t @opcionMenus = OpcionMenu.where(\"menu_id = ? AND padre_id = ?\", menu.id.to_s, padreid).order(orden: :asc)\n\t i=0\n\t @opcionMenus.each do |arbol|\n if arbol.hijos.length >0\n @tira = @tira+\" { text: ' <i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span class= \\\"no-padding\\\"> \" + arbol.nombre + \" </span>', cls:'no-padding waves-effect',id: '\" + arbol.id.to_s + \"', href: '', \"\n else\n @tira = @tira+\" { text: ' <i class= \\\" \" + arbol.icono.to_s + \"\\\" ></i> <span class= \\\"no-padding\\\"> \" + arbol.nombre + \" </span>', cls:'no-padding waves-effect',id: '\" + arbol.id.to_s + \"', href: '\" + arbol.url.to_s + \"', \"\n end\n\t self.ObtenerHijos(menu,arbol.id)\n\t i=i+1\n if i<totaldeRegistros1\n @tira = @tira+\" }, \"\n else\n @tira = @tira+\" } ] \"\n\t end\n\t end\n\t else\n\t @tira = @tira+\" leaf: true \"\n\t end\n end",
"def index\n @detpedidos = Detpedido.all\n end",
"def guarda_fotos_nombres_servicios\n ficha_naturalista_por_nombre if !proveedor || proveedor.naturalista_id.blank? # Para encontrar el naturalista_id si no existe el proveedor\n guarda_nombres_comunes_todos\n guarda_fotos_todas\n end",
"def index\n @soatseguros = Soatseguro.all\n end",
"def index\n @anios = Ordenanza.select(:anio).uniq.map do | ord | ord.anio end\n\n @temas = Ordenanza.select(:tema).uniq.map do | ord | ord.tema end\n\n #TODO: Borrar\n @ordenanzas = Ordenanza.limit(10)\n end",
"def index\n @gestacaos = Gestacao.all\n end",
"def getPontEntre(n1, n2)\n\n # Tableau temporaire visant à contenir l'index des cases formant le pont\n arr = [] \n\n # Cas où la case est le voisin du haut\n if n1.northNode == n2 # Ile HAUT\n\n for y2 in (n1.row-1).downto(0)\n if(self.get_child_at(n1.column,y2) == n2) \n break;\n\t\t\t\telse\n self.get_child_at(n1.column,y2).set_directionPont(2)\n arr << self.get_child_at(n1.column,y2)\n end\n\t\t\tend\n # Cas où la case est le voisin de droite\n elsif n1.eastNode == n2 #Ile droit\n\n for x2 in (n1.column+1).upto(self.lignes-1)\n if(self.get_child_at(x2,n1.row) == n2) \n break;\n\t\t\t\telse\n self.get_child_at(x2,n1.row).set_directionPont(1)\n arr << self.get_child_at(x2,n1.row)\n end\n\t\t\tend\n # Cas où la case est le voisin de gauche \n elsif n1.westNode == n2 # Ile gauche\n\n for x2 in (n1.column-1).downto(0)\n if(self.get_child_at(x2,n1.row) == n2) \n break;\n else\n self.get_child_at(x2,n1.row).set_directionPont(1)\n arr << self.get_child_at(x2,n1.row)\n end\n end\n\n # Cas où la case est le voisin du bas\n elsif n1.southNode == n2 # Ile bas\n for y2 in (n1.row+1).upto(self.colonnes-1)\n if(self.get_child_at(n1.column,y2) == n2) \n break;\n else\n self.get_child_at(n1.column,y2).set_directionPont(2)\n arr << self.get_child_at(n1.column,y2)\n end\n\t\t\tend\n end \n return arr\n end",
"def crear_rangos_entradas(horas, dia)\n horas.inject([]){|arr, v|\n arr << ( Time.zone.parse(\"#{dia} #{v[0]}\" )..Time.zone.parse(\"#{dia} #{v[1]}\") )\n arr\n }\n end",
"def index\n @sousgroupes = Sousgroupe.all\n end",
"def proximos\n @lista = Array.new\n estabelecimentos = Estabelecimento.all\n if (params[:token] != nil)\n user = Usuario.find_by_token(params[:token])\n @favoritos = Favorito.find_all_by_usuario_id(user.id)\n estabelecimentos.each do |estab|\n estab.favorito = false\n @favoritos.each do |fav|\n if (fav.estabelecimento_id == estab.id)\n estab.favorito = true\n break\n end\n end \n end\n end\n \n raio = params[:raio]\n if (raio == nil)\n raio = 1000\n end\n estabelecimentos.each do |estab|\n dist = distancia(params[:latitude].to_f, params[:longitude].to_f,estab.latitude, estab.longitude)\n if (dist.to_f <= raio.to_f && dist.to_f != 0.0)\n if (estab.favorito == nil)\n estab.favorito = false\n end\n @lista.push(estab)\n end\n end\n \n respond_to do |format|\n format.html # proximos.html.erb\n format.json { render :json => @lista, :include => {:precos =>{:only => :valor, :include =>:produto } , \n :caracteristicas => {:only => [:nome, :id]} } }\n end\n \n end",
"def get_proteinas\n @_100=((@proteinas*100)/@peso)\n @ir_100=(@_100/50)*100\n @porcion=((@proteinas*@gramos_porciones)/@peso)\n @ir_porcion=(@porcion/50)*100\n\t\t#p\"| #{@proteinas} | #{@_100} | #{@ir_100.round(1)}% | #{@porcion} | #{@ir_porcion.round(1)}% |\"\n [ @proteinas , @_100 , @ir_100.round(1) , @porcion , @ir_porcion.round(1) ]\n end",
"def index\n @agentes = Agente.where(\"estado_agente_id = ?\", 1).order(:apellido)\n end",
"def index\n @ocs_generadas = OcsGenerada.order(id: :desc).page(params[:page]).per(300)\n end",
"def troca\n @remetente = Sobrevivente.where(id: params[:de]).first\n @destinatario = Sobrevivente.where(id: params[:para]).first\n\n enviar = {agua: 1, comida: 2, medicamento: 3, municao: 4}\n receber = {agua: 0, comida: 2, medicamento: 3, municao: 8}\n\n trocou = @remetente.troca(@destinatario, enviar, receber)\n\n render json: { status: trocou }\n end",
"def index\n @pedido_produtos = PedidoProduto.where(pedido_id: @pedido.id)\n end",
"def index\n @pergunta_subgrupos = QuestaoSubgrupo.all\n end",
"def to_s\n\t\t\t\"#{@nombre}: #{@proteinas}g de proteínas, #{@glucidos}g de glúcidos y #{@lipidos}g de lípidos\"\n\t\tend",
"def cargar_resultados\n preguntas.each do |pregunta|\n pregunta.respuestas.each do |respuesta|\n # resultados = ResultadoPregunta.where(recorrido: recorrido.id, pregunta: pregunta, respuesta: respuesta).count\n sql = \"select count(1)\n from resultado_preguntas r_preg join resultado_recorridos r_rec on r_preg.resultado_recorrido_id = r_rec.id join\n recorridos recorrido on r_rec.recorrido_id = recorrido.id\n where recorrido.id = #{recorrido.id} and r_preg.pregunta_id = #{pregunta.id} and r_preg.respuesta_id = #{respuesta.id}\"\n respuesta.cantidad_elegida = ActiveRecord::Base.connection.execute(sql)[0][\"count\"].to_i\n # respuesta.cantidad_elegida = resultados\n end\n end\n end",
"def index\n @segundos = Segundo.all\n end",
"def devolver_proteinas\n\t\treturn @proteinas\n\tend",
"def index\n\t\tauthorize! :index, DetalleGasto\n @detalle_gastos = DetalleGasto.all\n end",
"def dieta_gases_diarios(gramos)\n gases_diarios = dieta_gases_anuales(gramos)/365\n return gases_diarios.round(3)\n end",
"def get_relations\n # Descobrir as relacoes:\n # Orientados\n # Projetos de Pesquisa\n # Producoes Bibliograficas\n # Consultar o RP de cada uma\n # Somar os RPs e retornar\n orientados = self.get_relations_of_orientados\n projetos = self.get_relations_of_projetos_pesquisa\n producoes = self.get_relations_of_producoes_bibliograficas\n\n relations = (orientados | projetos | producoes).delete self.id\n return relations.to_a\n end",
"def index\n @sugestaos = Sugestao.all\n end",
"def index\r\n @usuario_gustos = UsuarioGusto.all\r\n end",
"def index\n @antropos = Antropo.all\n end",
"def nombres_comunes\n datos = eval(naturalista_info.decodifica64)\n datos = datos.first if datos.is_a?(Array)\n return [] unless datos['taxon_names'].present?\n nombres_comunes_faltan = []\n\n # Nombres comunes de la base de catalogos\n nom_comunes = especie.nombres_comunes\n nom_comunes = nom_comunes.map(&:nombre_comun).map{ |nom| I18n.transliterate(nom).downcase }.sort if nom_comunes\n\n datos['taxon_names'].each do |datos_nombres|\n next unless datos_nombres['is_valid']\n next if datos_nombres['lexicon'] == 'Scientific Names'\n\n # Nombre comun de NaturaLista\n nombre = I18n.transliterate(datos_nombres['name']).downcase\n lengua = datos_nombres['lexicon']\n\n if nom_comunes.present?\n next if nom_comunes.include?(nombre)\n end\n nombres_comunes_faltan << \"#{especie.catalogo_id},\\\"#{datos_nombres['name']}\\\",#{lengua},#{especie.nombre_cientifico},#{especie.categoria_taxonomica.nombre_categoria_taxonomica},http://naturalista.conabio.gob.mx/taxa/#{naturalista_id}\"\n end\n\n nombres_comunes_faltan\n end",
"def datos_descarga(taxa)\n return unless taxa.any?\n self.taxones = []\n\n taxa.each do |taxon|\n self.taxon = taxon\n asigna_datos\n self.taxones << taxon\n end\n end",
"def mostra_tudo\n apius.mostra_resumo\n apide.mostra_resumo\n apifr.mostra_resumo\n apimt.mostra_resumo\n apies.mostra_resumo\n apigm.mostra_resumo\n apibc.mostra_resumo\n end",
"def mostrar_candidatos\n \n puts \" \"\n puts \"Quantidade de votos por candidato\"\n #Buca o candidato em seu array\n for candidato in @candidato\n candidato.mostrar_dados \n end \n end",
"def ganador(puntos)\n\n if(puntos[0] < puntos[1])\n print \"El Ganador es el jugador 2\\n\"\n elsif(puntos[0] > puntos[1])\n print \"El Ganador es el jugador 1\\n\"\n else\n print \"Esto es un empate!\\n\"\n end\n end",
"def asignaturas\n @seccion = \"Asignaturas\"\n @titulo = \"Asignaturas\"\n if params[:orden]\n case params[:orden]\n when \"Código\"\n @orden = \"codigo\"\n when \"Nombre\"\n @orden = \"nombre\"\n when \"Créditos\"\n @orden = \"unidades_credito\"\n when \"Tipo\"\n @orden = \"tipo\"\n else\n @orden = \"codigo\"\n end\n else\n @orden = \"codigo\"\n end\n \n @carreras = [\"Biología\", \"Computación\", \"Geoquímica\", \"Física\", \"Matemática\", \"Química\", \"Complementaria\"]\n @categorias = ['Código', 'Nombre', 'Créditos','Tipo'] #Este es el orden que se mostrará en el select de la vista\n @categoria_seleccionada = params[:orden]\n\n @asignatura_datos = [] #En este arreglo se guardan los pares \"Codigo - Nombre\" de cada asignatura para mostrar en el campo de busqueda\n Asignatura.order('nombre').all.each do |asignatura|\n #En este foro se agregan uno a uno los valores de cada asignatura al arreglo de la manera indicada arriba\n @asignatura_datos << asignatura.codigo.to_s + \" - \" + asignatura.nombre.to_s\n end\n end",
"def getCompletedQuests\n completed = []\n $PokemonGlobal.quests.completed_quests.each do |s|\n completed.push(s.id)\n end\n return completed\nend",
"def index\n @glosarios = Glosario.busqueda(params[:page],params[:generico], params[:buscar], 20)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @glosarios }\n end\n end",
"def datos(opc={})\n return [] unless cadena_especies.present?\n\n # Por default muestra todos\n Especie.caso_rango_valores('especies.id',cadena_especies).order('nombre_cientifico ASC').limit(opc[:limit] ||= 300000).each do |taxon|\n self.taxon = taxon\n asigna_datos\n self.taxones << taxon\n end\n end",
"def pantallaPuntosRondas\n\t\tpuntos = \"\"\n\t\trondas = \"\"\n\n\t\t# Limpiamos pantalla\n\t\t@app.clear\n\t\t@app.background \"fondo.jpg\"\n\n\t\t@boxes = @app.stack :top => \"180\", :left => \"330\"\n\t\t@boxes.para \"Rondas\"\n\t\t@r = @boxes.edit_line\n \t@boxes.para \"Puntos\"\n \t@pu = @boxes.edit_line\n \t@enviar = @boxes.button \"OK\"\n \t@enviar.click do\n\t \t@rondas = @r.text\n\t\t\t@puntos = @pu.text\n\t\t\tif (@rondas == \"\" and @puntos == \"\")\n\t\t\t\t@boxes.append \"Debe indicar un numero de rondas o puntos.\"\n\t\t\telse\n\t\t\t\tpantallaJuego\n\t\t\tend\n\t\tend\n \t\n\tend",
"def index\n @groomsmen = Groomsman.all\n end",
"def dieta_gases_anuales(gramos)\n aux = @head\n suma_gases = 0\n i = 0\n while (!aux.nil?)\n suma_gases += aux[:value].auxiliar(gramos[i])\n aux = aux[:next]\n i = i+1\n end\n return suma_gases.round(2)\n\n end",
"def lipidos\n\t\treturn @lipidos*@cantidad\n\tend",
"def index\n @gastos_balanceados = GastosBalanceado.all\n end",
"def agentes_serial\n Representante.find(self.agente_ids_serial).map(&:nombre)\n end",
"def index\n @titulo = \"Listado de Pedidos\"\n @clase = \"Pedidos\"\n @pedidos = Pedido.all\n end",
"def annotate_GO(ids,db=\"uniprot\",field=\"dr\") #annotate with GO from uniprot cross refferences\n annotations=[]\n ids.each do |id|\n resp = InteractionNetwork.fetch(\"http://togows.org/entry/#{db}/#{id}/#{field}.json\")\n \n if resp\n res=JSON.parse(resp.body)[0]\n res[\"GO\"].each do |term| #dr format is hashes --> list of lists GO lists have three elements: GO-id,GOterm(class:definition)\n if term[1]=~/P:/ #P=biological processes class\n goid=term[0]\n goterm=term[1].match(/:(.+)/)[1]\n annotations << [goid,goterm]\n end\n end\n return annotations.uniq # some GO terms are repeated in this database\n end\n end \n end",
"def set_detalle_gasto\n @detalle_gasto = DetalleGasto.find(params[:id])\n end",
"def calcula_tramos(proyecto_id)\n proyecto = Proyecto.find(params[:proyecto_id].to_i) \n dretmax = proyecto.dretmax\n vanomax = proyecto.vanomax\n pant = nil\n tant = nil\n \n Tramo.where(:proyecto_id => proyecto_id).each {|t|\n t.reltramovanos.destroy_all\n if (t.dimgeom!=nil )\n t.dimgeom.destroy\n end \n t.destroy\n } \n Vano.where(:proyecto_id => proyecto_id).destroy_all\n \n \n puntos = Punto.where(:proyecto_id => proyecto_id).order(:secuencia)\n n = 0\n m = puntos.count-1\n \n puntos.each {|p|\n if (n==0)\n tramo = Tramo.new\n tramo.ttramo_id = 1 #arranque\n tramo.cantidad = 1\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Arranque en \" + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n tant = tramo\n \n elsif (n<m) #desvios intermedios\n vano = Vano.new\n vano.nombre = \"Vanos entre \" + pant.punto + ' y ' + p.punto\n if (p.distancia < vanomax)\n vano.vano = p.distancia\n else\n vano.vano = p.distancia / (( p.distancia/vanomax).to_i + 1 )\n end \n vano.proyecto_id = proyecto_id\n vano.cond_e_id = proyecto.cond_e_id\n vano.cond_g_id = proyecto.cond_g_id\n vano.save\n vano.calcvano\n vant = vano\n \n if (p.distancia > dretmax)\n tramo = Tramo.new\n tramo.ttramo_id = 4 #retension\n tramo.cantidad = (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Retensiones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n if (p.distancia > vanomax)\n tramo = Tramo.new\n tramo.ttramo_id = 5 #alineacion\n tramo.cantidad =(p.distancia/vanomax).to_i - (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Alineaciones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n tramo = Tramo.new\n tramo.ttramo_id = 2 #desvio\n tramo.cantidad = 1\n tramo.angulo = p.angulo\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Desvio de \" + p.angulo.to_i.to_s + \"° en \" + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tant.id\n rel.angulo = pant.angulo\n rel.save\n tant = tramo\n \n else #terminal\n vano = Vano.new\n vano.nombre = \"Vanos entre \" + pant.punto + ' y ' + p.punto \n if (p.distancia < vanomax)\n vano.vano = p.distancia\n else\n vano.vano = p.distancia / (( p.distancia/vanomax).to_i + 1 )\n end \n vano.proyecto_id = proyecto_id\n vano.cond_e_id = proyecto.cond_e_id\n vano.cond_g_id = proyecto.cond_g_id\n vano.save\n vano.calcvano\n\n if (p.distancia > dretmax)\n tramo = Tramo.new\n tramo.ttramo_id = 4 #retension\n tramo.cantidad = (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Retensiones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n if (p.distancia > vanomax)\n tramo = Tramo.new\n tramo.ttramo_id = 5 #alineacion\n tramo.cantidad =(p.distancia/vanomax).to_i - (p.distancia/dretmax).to_i\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Alineaciones entre \" + pant.punto + ' y ' + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = 0\n rel.save\n end\n tramo = Tramo.new\n tramo.ttramo_id = 3 #terminal\n tramo.cantidad = 1\n tramo.angulo = 0\n tramo.hlibre = proyecto.hlibre\n tramo.secuencia = Tramo.where(:proyecto_id =>proyecto_id).maximum(:secuencia).to_i+10\n tramo.nombre = \"Terminal en \" + p.punto\n tramo.proyecto_id = proyecto_id\n tramo.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tramo.id\n rel.angulo = p.angulo\n rel.save\n rel = Reltramovano.new\n rel.vano_id = vano.id\n rel.tramo_id = tant.id\n rel.angulo = pant.angulo\n rel.save\n \n end\n \n n+=1\n pant = p\n }\n \n Tramo.where(:proyecto_id=>proyecto_id).each { |t|\n t.calcabezal\n }\n end",
"def index\n @pedidos = Pedido.all\n @projetos = Projeto.all\n end",
"def split_order\n # Lineas de productos identificadas por taxonomias\n @taxonomias = Spree::Taxon.where(parent_id: [1])\n # Creamos el hash de array donde almacenaremos las lineas de productos por taxonomias.\n @productos_por_taxonomias = Hash.new\n # LLenamos el hash\n @taxonomias.each do |taxonomia|\n @productos_por_taxonomias[taxonomia.name] = []\n end\n @order.line_items.each do |item|\n item.variant.product.taxons.each do |taxon|\n if @productos_por_taxonomias[taxon.parent.name]\n @productos_por_taxonomias[taxon.parent.name].append(item)\n end\n end\n end\n end",
"def totalGramos\n\t\tgramos = 0\n\t\ttotal = 0\n\t\t@platos.each do |alimento|\n\t\t\tgramos += alimento.gramos\n\t\tend\n\t\treturn gramos.round(2)\n\tend",
"def parsearBotonesFirmarDocumento()\n #SE PARSEAN LAS IMAGENES QUE DERIVAN EN BOTONES\n # boton_archivos_embebidos = nil\n #tab_archivos_embebidos = nil\n #Obtener todas imagenes del popup \"Iniciar Producción de Documento\"\n #PRESIONA EL BOTÓN - 'ProducirloYoMismo.png'\n claseDIV = 'z-window-highlighted-cl'\n #botonesImagenes = getBrowser().div(:class => claseDIV).images # ORIGINAL\n botonesImagenes = self.getElementosHTMLFactory().getElemento('div').obtenerImagenesPorClase(claseDIV)\n botonesImagenes.each do |imagen|\n rutaImagenSplit = imagen.src.split('/')\n nombreImagen = rutaImagenSplit[rutaImagenSplit.length - 1]\n #puts pic\n #TO DO getters / setters\n if nombreImagen == HISTORIAL\n @boton_historial = imagen\n end\n if nombreImagen == ENVIAR_REVISAR_PROD\n @boton_enviar_revisar_prod = imagen\n end\n if nombreImagen == ENVIAR_FIRMAR_PROD\n @boton_enviar_firmar_prod = imagen\n end\n if nombreImagen == FIRMAR_CERTIFICADO\n self.setBoton_firmar_certificado(imagen)\n end\n end\n end",
"def obtener_entrega(entrega, curso)\n curso = obtener_entregas_curso(curso)\n index = 0\n entregas_curso = curso.entregas\n tamanio_vector = entregas_curso.size\n while (index < tamanio_vector)\n if (entregas_curso[index].id == entrega.id)\n entrega = entregas_curso[index]\n index = tamanio_vector\n end\n index += 1\n end\n entrega\n end",
"def repartir jugadores, jugador_inicial\n\t\t# Repite esta secuencia el tamaño maximo de la baraja menos 2. Una vez menos por el indice del array que es empieza a cero. Otra vez menos por la salida controlada.\n\t\tjugador_que_toca = jugador_inicial\n\t\tfor i in (0.. Constantes::TAMANO_MAX_BARAJA - 2)\n\t\t\t# rand (x) produce un numero entero entre 0 y x-1\n\t\t\tindice = rand (Constantes::TAMANO_MAX_BARAJA - i)\n\t\t\t# la carta elegida al azar es @baraja[indice]\n\t\t\t# asigna la carta al jugador que le toca en el reparto (circular)\n\t\t\tj1 = jugadores[jugador_que_toca]\n\t\t\t# Si la mano de un jugador (array de cartas) no esta creado\n\t\t\tif j1.mano_jugador == nil\n\t\t\t\tthen\n\t\t\t\t# lo crea con la carta seleccionada como unico elemento\n\t\t\t\tj1.mano_jugador = [@baraja [indice]]\n\t\t\telse\n\t\t\t\t# si ya esta creado (array vacio o con elementos) inserta al final del array la carta seleccionada\n\t\t\t\tj1.mano_jugador << @baraja[indice]\n\t\t\tend \n\t\t\t# pasa al siguiente jugador\n\t\t\tjugador_que_toca = Util.siguiente_jugador jugador_que_toca\n\t\t\t#saca la carta de la baraja\n\t\t\t@baraja = @baraja - [@baraja[indice]]\n\n\t\tend\n\t\t# queda un elemento en el array de baraja\n\t\t# sera para el ultimo jugador y estara en @baraja[0]\n\t\tj1 = jugadores[jugador_que_toca]\n\t\tj1.mano_jugador << @baraja[0]\n\t\t# pasa al siguiente jugador para que es al que le tocara jugar\n\t\tjugador_que_toca = Util.siguiente_jugador jugador_que_toca\n\tend",
"def questionsDuGroupe(id_groupe)\n\n # array contient la liste des questions\n questions = Array.new\n\n # récupérer la liste des id_question\n # et traiter chaque id_question\n Groupe.where(etat: false, id_groupe: id_groupe).order('id_question ASC').find_each do |id_question|\n \n questions << QuestionService.instance.afficherQuestionParId(id_question.id_question)\n \n end\n \n questionsDuGroupe = questions\n\n\n end",
"def contas_a_pagar\n @movimentos = Movimento.find(:all,:conditions => [\"data_pagamento is null and entidade_id = ? and tipo_movimento = 'D'\", current_usuario.entidade_id])\n end",
"def detalle_gasto_params\n params.require(:detalle_gasto).permit(:titulo, :descripcion, :monto, :concepto_gasto_id, :informe_gastos_id, :voluntario_id, :comprobante_id)\n end",
"def hojas_arbol_nodo\n children_array = []\n\n nivel_categoria = @especie.categoria_taxonomica.nivel1\n ancestry = @especie.is_root? ? @especie.id : \"#{@especie.ancestry_ascendente_directo}/%#{@especie.id}%\"\n\n taxones = Especie.select_basico(['ancestry_ascendente_directo', 'conteo', 'categorias_taxonomicas.nivel1']).datos_basicos.\n categoria_conteo_join.where(\"categoria='7_00' OR categoria IS NULL\").where(\"ancestry_ascendente_directo LIKE '#{ancestry}'\").\n where(\"nombre_categoria_taxonomica IN ('#{CategoriaTaxonomica::CATEGORIAS_OBLIGATORIAS.join(\"','\")}')\").\n where(\"nivel1=#{nivel_categoria + 1} AND nivel3=0 AND nivel4=0\"). # Con estas condiciones de niveles aseguro que es una categoria principal\n where(estatus: 2)\n\n taxones.each do |t|\n children_hash = hash_arbol_nodo(t)\n\n # Acumula el resultado del json anterior una posicion antes de la actual\n children_array << children_hash\n end\n\n render :json => children_array.to_json\n end",
"def publicado\n\t\t\t# Usado para mostrar el capitulo 14 - Following\n\t\t\t# Ejecuta una consulta SQL con id escapado\n\t\t#Microentrada.where(\"usuario_id = ?\", id) \n\t\t\t# siguiendo_ids = usuario.siguiendo.map(&:id)\n\t\t#Microentrada.where(\"usuario_id IN (?) OR usuario_id = ?\", siguiendo_ids, id) \n\t\t\t# Mediante el sub-select, la operacion se mantiene en la BD\n\t\tsiguiendo_ids = \"SELECT seguido_id FROM relaciones WHERE seguidor_id = :usuario_id\"\n\t\tMicroentrada.where(\"usuario_id IN (#{siguiendo_ids}) OR usuario_id = :usuario_id\", usuario_id: id)\n\t\t\t# equivalente a: \n\t\t#microentradas\n\tend",
"def vizinhos_inimigos(territorio)\n r = []\n territorio.vizinhos.each do |v|\n v = get_pais(v)\n r.push v if v.owner != self\n end\n return r\n end",
"def busqueda(g, d, h, nro_nodos, nodos_visitados, nro_nodos_en_caminos)\r\n #Luego, en esta variable dependiendo de si estamos en un objeto DFS o BFS, se definira el orden\r\n #en el que se seleccionaran los nodos para la busqueda. Ademas, esta variable tendra los elementos\r\n #adyacentes del nodo d ya sea en una pila o en una cola. \r\n pila_o_cola = self.orden_nodos(g,d)\r\n\r\n #pila_o_cola.estructura.each {|elem| puts elem}\r\n\r\n #Verificamos si la pila o cola, de adyacentes, incluye a \"h\"\r\n if pila_o_cola.estructura.include? h \r\n\r\n #De ser asi, se incluye el numero de nodos del recorrido que llevo a \"h\"\r\n nro_nodos_en_caminos << nro_nodos\r\n\r\n #Si la pila o cola no incluye a \"h\"\r\n else\r\n\r\n #Entonces mientras no este vacia, se recorre la estructura\r\n while not(pila_o_cola.vacio)\r\n\r\n #Luego se remueve un nodo de la estructura, que sera el siguiente que se usara\r\n #como \"inicio\" de la busqueda\r\n siguiente_nodo = pila_o_cola.remover\r\n\r\n #Si el nodo en cuestion no ha sido visitado\r\n if not(nodos_visitados.include? siguiente_nodo)\r\n #Lo agregamos al arreglo de visitados\r\n nodos_visitados << siguiente_nodo\r\n #Y hacemos una llamada recursiva al metodo busqueda pero esta vez partiendo\r\n #del nodo antes tomado. En esta llamada aumentamos el numero de nodos (nro_nodos)\r\n #en 1\r\n busqueda(g, siguiente_nodo, h , nro_nodos + 1 , nodos_visitados, nro_nodos_en_caminos)\r\n end\r\n end\r\n end\r\n\r\n #Luego de que acaba todo el procesamiento verificamos si en el arreglo \"nro_nodos_en_caminos\"\r\n #esta vacio, si es asi entonces significa que el nodo \"h\" no fue alcanzado entonces\r\n if nro_nodos_en_caminos.empty?\r\n #retornamos -1\r\n return -1\r\n end\r\n\r\n #Finalmente, si sobrevivimos todo lo anterior, llegados a este punto retornamos el numero de nodos que\r\n #fueron recorridos de \"d\" a \"h\". Recordamos que el arreglo \"nro_nodos_en_caminos\" contiene para todos los\r\n #caminos de \"d\" a \"h\", el numero de nodos recorridos.\r\n\r\n ## OJO: En este caso se retornara el nro de nodos recorridos del camino mas corto. ##\r\n\r\n #Sin embargo, si se quisiera el nro de nodos de solo el primer camino por el que se metio y encontro a \"h\"\r\n #bastaria con solo retornar \"nro_nodos_en_caminos[0]\".\r\n #Por otra parte, si se quisiera para cada camino el nro de nodos recorridos entonces basta con retornar\r\n #el arreglo completo, etc.\r\n \r\n return \"#{nro_nodos_en_caminos.min} nodos recorridos.\"\r\n end",
"def index\n @grooming_services = GroomingService.all\n end",
"def espacios_disponibles_motos\n Space.where(sp_state: false, sp_type: 'MOTO').count\n end",
"def emisiones\n grtotal = 0\n sum = 0\n\t\t#recorre las dos listas a la vez para sacar los gases emitidos\n\t\t# de cada ingrediente segun el peso de este\n @lista.zip(@listagr).each do |normal, gr|\n cant = gr/1000.0\n sum += normal.gases*cant\n end\n @gei = sum\n\n end",
"def plieguesCutaneos\n\t\tpliegues = []\n\t\tpliegues << mediaTricipital\n\t\tpliegues << mediaBicipital\n\t\tpliegues << mediaSubescapular\n\t\tpliegues << mediaSuprailiaco\n\t\treturn pliegues\n\tend",
"def estudiantes\n\t\t@seccion = \"Estudiantes\"\n @titulo = \"Estudiantes\"\n\t\tif params[:orden]\n\t\t\t@orden = params[:orden]\n\t\telse\n\t\t\t@orden = \"Cédula\"\n\t\tend\n\n #Guardo todos los estudiantes\n if Estudiante.all().size > 0\n case @orden\n \twhen \"Cédula\"\n \t\t@usuarios = Usuario.order('cedula').where(:id => Estudiante.all)\n \twhen \"Nombre\"\n \t\t@usuarios = Usuario.order('nombre').where(:id => Estudiante.all)\n \twhen \"Apellido\"\n \t\t@usuarios = Usuario.order('apellido').where(:id => Estudiante.all)\n \twhen \"Correo\"\n \t\t@usuarios = Usuario.order('correo').where(:id => Estudiante.all)\n \tend\n end\n\n\t\t@categorias = ['Cédula', 'Nombre', 'Apellido', 'Correo'] #Este es el orden que se mostrará en el select de la vista\n\n\t\t@estudiante_datos = [] #En este arreglo se guardan los pares \"Cedula - Nombre Apellido\" de cada usuario para mostrar en el campo de busqueda\n\t\tUsuario.order('nombre').where(:id => Estudiante.all).each do |usuario|\n\t\t\t#En este foro se agregan uno a uno los valores de cada estudiante al arreglo de la manera indicada arriba\n\t\t\t@estudiante_datos << usuario.cedula.to_s + \" - \" + usuario.nombre_y_apellido.to_s\n\t\tend\n\tend"
] |
[
"0.6171888",
"0.6007692",
"0.5996773",
"0.59466803",
"0.59261495",
"0.5922203",
"0.58206743",
"0.57493687",
"0.57386327",
"0.563453",
"0.55999255",
"0.55995333",
"0.55964905",
"0.5578748",
"0.55403274",
"0.55248624",
"0.5522956",
"0.5521221",
"0.5499267",
"0.54951817",
"0.54951817",
"0.5481017",
"0.5476107",
"0.5474659",
"0.54352176",
"0.5423139",
"0.5414742",
"0.5413442",
"0.5404957",
"0.54005224",
"0.53765273",
"0.5371284",
"0.5366095",
"0.5362505",
"0.5361075",
"0.53500646",
"0.5329759",
"0.5321913",
"0.53138053",
"0.53100234",
"0.53061664",
"0.5287841",
"0.5286319",
"0.5274588",
"0.5272084",
"0.52665454",
"0.5265019",
"0.5264056",
"0.5256045",
"0.5255769",
"0.5252577",
"0.52466327",
"0.5239383",
"0.5225681",
"0.52170604",
"0.5216711",
"0.5214813",
"0.5197698",
"0.5191891",
"0.5191542",
"0.5187996",
"0.5179693",
"0.517779",
"0.5175666",
"0.5174619",
"0.51731277",
"0.51664096",
"0.5166337",
"0.51597834",
"0.5155255",
"0.51547325",
"0.5147312",
"0.51472545",
"0.5143028",
"0.51319426",
"0.5123949",
"0.5118109",
"0.511766",
"0.5116202",
"0.5111502",
"0.51099443",
"0.51086",
"0.5105975",
"0.5105858",
"0.5104735",
"0.51013416",
"0.5100467",
"0.51000553",
"0.50965637",
"0.50933665",
"0.50933033",
"0.5092967",
"0.5092438",
"0.5089702",
"0.50864685",
"0.5085587",
"0.5082229",
"0.50811964",
"0.50803846",
"0.50802714",
"0.50766045"
] |
0.0
|
-1
|
Public: Returns the MIME type for the file. Examples ImageFile.new('example.png') => 'image/png' ImageFile.new('example.svg') => 'image/svg+xml' Returns a String representation of the MIME type.
|
def filetype
`file --mime-type -b #{@file_path}`.chomp
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def mimetype\n mtype = MIME::Types.of(@filename).first\n if (mtype)\n mimetype = MIME::Type.simplified(mtype)\n end\n mimetype\n end",
"def mime_type\n MIME_TYPES[@file_type]\n end",
"def mime_type\n ::Mime::Type.lookup(image.mime_type)\n end",
"def mime_type\n type = MIME::Types.type_for(self.filename)\n type.empty? ? nil : type.first\n end",
"def mime_type file_name\n mime_types = MIME::Types.of(file_name)\n mime_type = mime_types.empty? ? \"application/octet-stream\" : mime_types.first.content_type\n end",
"def mimetype(file)\n mime_type = MIME::Types.type_for(file.class == File ? File.basename(file) : file)\n if mime_type.size == 0\n mime_type = MIME::Types['text/plain'] \n end\n mime_type\n end",
"def mimetype(file)\n mime_type = MIME::Types.type_for(file.class == File ? File.basename(file) : file)\n if mime_type.size == 0\n mime_type = MIME::Types['text/plain'] \n end\n mime_type\n end",
"def mimetype(file)\n mime_type = MIME::Types.type_for(file.class == File ? File.basename(file) : file)\n if mime_type.size == 0\n mime_type = MIME::Types['text/plain'] \n end\n mime_type\n end",
"def get_mime_type file\n FileMagic.new(FileMagic::MAGIC_MIME).file(file).split(';').first\n end",
"def file_mimetype\n if file_formats.first\n file_formats.first.mimetype\n end\n end",
"def file_content_type\n types = MIME::Types.type_for(original_filename)\n types.first\n end",
"def mime_type(file)\n header = file.read(8)\n unless header\n file.open\n header = file.read(8)\n end\n file.pos = 0\n if ( /^\\x89PNG/n.match(header) ) \n return \"image/png\"\n elsif (/^GIF8[79]a/n.match(header) )\n return \"image/gif\"\n elsif( /^\\xff\\xd8/n.match(header) )\n return \"image/jpeg\"\n elsif( /^BM/n.match(header) )\n return \"image/bmp\"\n end\n end",
"def mime_type(file)\n type = nil\n\n if (file =~ /\\.(.+?)$/)\n type = ExtensionMimeTypes[$1.downcase]\n end\n\n type || \"text/plain\"\n end",
"def mime_type\n self.class.mime_type\n end",
"def image_type\n ImageScience.fif_to_string(@file_type)\n end",
"def mime_type\n _mime_type ? _mime_type.to_s : 'text/plain'\n end",
"def get_content_type file\n mime_type = MIME::Types.type_for(file.original_filename)\n return mime_type.first ? mime_type.first : nil\n end",
"def mime_type_for(file)\n filename = if file.is_a?(String)\n file\n else\n file.destination_path\n end\n\n case File.extname(filename)\n when '.ttf', '.otf'\n 'application/vnd.ms-opentype'\n else\n MIME::Types.of(filename).first.content_type\n end\n end",
"def mime_for_file(file)\n path = file.is_a?(File) ? file.path : file\n MIME::Types.type_for(path)[0] || 'application/octet-stream'\n end",
"def mime_type\n MIME_TYPE\n end",
"def get_mime_type(file)\n if !file.nil?\n extension = File.extname(file)\n return Rack::Mime::MIME_TYPES[extension] || 'text/plain'\n end\n \n return 'text/plain'\n end",
"def mime_type(image_path)\n IMAGE_MIME_TYPES[File.extname(image_path)]\n end",
"def mime_type\n Blob.mime_type(self.name)\n end",
"def mime_type\n return @mime_type\n end",
"def mimetype\n return attributes['mimetype'] if attributes['mimetype']\n return \"image/png\" if content =~ /^.PNG/\n return \"application/octet-stream\"\n end",
"def get_content_type(file)\n t = MIME::Types.of(file)\n t.first.content_type unless t.empty?\n end",
"def mimetype\n process_upload\n return @file.file.file.content_type\n end",
"def mime_type\n @metadata[:mime_type]\n end",
"def mime_type_of(f)\n MIME::Types.of(f).last || default_mime_type\n end",
"def content_type\n file.try(:content_type)\n end",
"def mime_type\n metadata[\"mime_type\"]\n end",
"def mimetype; @mimetype ||= `file -b --mime-type '#@fname'`.strip; end",
"def mime_type\n if source.present?\n source.mime_type\n end\n end",
"def mime_type\n @attributes[:mime_type]\n end",
"def file_type\n FILE_TYPES[@file_type]\n end",
"def file_extension_content_type filename\n types = MIME::Types.type_for(filename)\n types.empty? ? nil : types.first.content_type\n end",
"def content_type\n @mime_type\n end",
"def _mime_type\n if defined? @_mime_type\n @_mime_type\n else\n guesses = ::MIME::Types.type_for(extname.to_s)\n\n # Prefer text mime types over binary\n @_mime_type = guesses.detect { |type| type.ascii? } || guesses.first\n end\n end",
"def file_mimetype\n @descriptive_detail.file_mimetype\n end",
"def mime_type\n @mime_type ||= message.mime_type\n end",
"def mime_type\n meta['mime_type'] || app.mime_type_for(ext)\n end",
"def mime_type(media_type = nil)\n types = MIME::Types.type_for(path)\n return if types.empty?\n if media_type\n media_type = media_type.to_s\n media_types = types.select { |m| m.media_type == media_type }\n if media_types.length > 1\n sub_types = media_types.select { |m| m.sub_type == format }\n media_types = sub_types if sub_types.any?\n end\n types = media_types if media_types.any?\n end\n types.first.content_type if types.any?\n end",
"def mime_type\n @metadata[:mime_type] || Mime::Type.lookup_by_extension(s3obj.content_type || ::File.extname(filename)[1..-1])\n end",
"def file_set_mime_type\n file_set.mime_type.first\n end",
"def mime_type\n term = format_controlled_vocabulary.all.find { |x| x.definition == info_service.driver }\n term ? term.value : primary_file.mime_type\n end",
"def content_type(path, filename)\n type = (filename.match(/\\.(\\w+)$/)[1] rescue \"octet-stream\").downcase\n case type\n when %r\"jp(e|g|eg)\" then \"image/jpeg\"\n when %r\"tiff?\" then \"image/tiff\"\n when %r\"png\", \"gif\", \"bmp\" then \"image/#{type}\"\n when \"txt\" then \"text/plain\"\n when %r\"html?\" then \"text/html\"\n when \"js\" then \"application/js\"\n when \"csv\", \"xml\", \"css\" then \"text/#{type}\"\n else\n # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.\n content_type = (`file -b --mime-type #{path}`.split(':').last.strip rescue \"application/x-#{type}\")\n content_type = \"application/x-#{type}\" if content_type.match(/\\(.*?\\)/)\n content_type\n end\n end",
"def content_type\n @content_type || file.content_type\n end",
"def document_type\n FileUtility.get_file_type(@file_name)\n end",
"def content_type(file_name)\n # Just grabbing the extension\n extension = ::File.extname(file_name.downcase)[1..-1]\n return @extension_map[extension] if @extension_map.key?(extension)\n 'application/octet-stream'\n end",
"def content_type\n self.file_content_type\n end",
"def mime_type\n term = format_controlled_vocabulary.all.find { |x| x.definition == info_service.driver }\n term ? term.value : original_file.mime_type\n end",
"def mimetype\n MIME::Types.type_for(parent_image.path).first.content_type\n end",
"def mime_type\n raise NotImplementedError.new 'This is only a function body for documentation'\n end",
"def mime_type type\n @app.mime_type type\n end",
"def resource_type\n return self.mime_type.slice(/^application\\/vnd.google-apps.(.+)$/, 1) || \"file\"\n end",
"def inferred_mime_type\n format_extension = path.format&.to_s\n MIME::Types.type_for(format_extension).first if format_extension\n end",
"def type\n stype = \"file\"\n stype = \"atom\" if @filepath.nil? and !@metadata.empty?\n stype = \"multipart\" if !@filepath.nil? and !@metadata.empty?\n stype\n end",
"def geo_mime_type\n return unless file_set\n file_set.mime_type.first\n end",
"def mime_type(type)\n roda_class.mime_type(type)\n end",
"def mime_type\n @mime_type ||= Rack::Mime.mime_type(\".#{ext}\")\n end",
"def mime_type\n Rack::Mime.mime_type(extname)\n end",
"def type_for(filename, platform = false)\r\n # call the original method\r\n type = mime_type_for(filename, platform)\r\n \r\n if type.empty? then\r\n case File.extname(filename)\r\n when '.cod'\r\n type = MIME::Type.from_array('application/vnd.rim.cod', 'cod', '8bit', 'linux')\r\n when '.apk'\r\n type = MIME::Type.from_array('application/vnd.android.package-archive', 'apk', '8bit', 'linux')\r\n when '.aetx'\r\n type = MIME::Type.from_array('application/x-aetx', 'aetx', '8bit', 'linux')\r\n when '.xap'\r\n type = MIME::Type.from_array('application/x-silverlight-app', 'xap', '8bit', 'linux')\r\n end\r\n end\r\n return type\r\n end",
"def file_type file_name\n File.extname(file_name).gsub(/^\\./, '').downcase\n end",
"def type(path)\n magic(path, Magic::MIME_TYPE)\n end",
"def mimetype\n return @mimetype if defined? @mimetype\n\n type = metadata['Content-Type'].is_a?(Array) ? metadata['Content-Type'].first : metadata['Content-Type']\n\n @mimetype = MIME::Types[type].first\n end",
"def get_content_type(filename)\n ext = File.extname(filename) # get the extension\n type = 'application/octed-stream'\n type = 'text/html' if ext == '.html' || ext == '.htm'\n type = 'text/plain' if ext == '.txt' || ext == '.rb'\n type = 'text/css' if ext == '.css'\n type = 'image/jpeg' if ext == '.jpeg' || ext == '.jpg'\n type = 'image/gif' if ext == '.gif'\n type = 'image/png' if ext == '.png'\n type = 'image/bmp' if ext == '.bmp'\n type = 'text/xml' if ext == '.xml' || ext == '.xsl'\n type # same as: return type\n end",
"def content_type\n if stat.directory?\n \"text/html\"\n else\n mime_type(file_path, DefaultMimeTypes)\n end\n end",
"def file_type(file_path)\n return 'file' if File.file? file_path\n return 'directory' if File.directory? file_path\n return 'unknown'\n end",
"def mime_type_for(filename, override = nil)\n override || Mime.type_for(filename)\n end",
"def mime_type\n # image/vnd.microsoft.icon won't render in IE8\n Rack::Mime::MIME_TYPES.merge!('.ico' => 'image/x-icon')\n Rack::Mime.mime_type(File.extname(@path))\n end",
"def get_mime_type(path)\n return false unless path.include? '.'\n filetype = path.split('.').last\n\n return case\n when [\"html\", \"htm\"].include?(filetype)\n \"text/html\"\n when \"txt\" == filetype \n \"text/plain\"\n when \"css\" == filetype\n \"text/css\"\n when \"js\" == filetype\n \"text/javascript\"\n when [\"png\", \"jpg\", \"jpeg\", \"gif\", \"tiff\"].include?(filetype)\n \"image/#{filetype}\"\n when [\"zip\",\"pdf\",\"postscript\",\"x-tar\",\"x-dvi\"].include?(filetype)\n \"application/#{filetype}\"\n else false\n end\n end",
"def stringy_media_type\n request.content_mime_type.to_s\n end",
"def mime_type; end",
"def mime_type; end",
"def mime_type; end",
"def mime_type; end",
"def file_type_class\n self.file_type.downcase.split.join('-') + '-file'\n end",
"def ftype() File.ftype(path) end",
"def mime_type\n has_content_type? ? header[:content_type].string : nil rescue nil\n end",
"def mime_type type\n Rack::Mime.mime_type type\n end",
"def content_type_string\n Mime::Type.lookup_by_extension(content_type).to_s\n end",
"def file_type(file_name)\n @file_class.extname(file_name).gsub( /^\\./, '' ).downcase \n end",
"def get_file_type\n\n @image.uploads.each do |upload|\n filename_arr = upload.content_type.to_s.split('/')\n @image.file_type = filename_arr[1].upcase\n end\n\n end",
"def file_type\n attachments.order(position: 'asc').first.file_type\n rescue StandardError => exc\n logger.error(\"Message for the log file #{exc.message}\")\n 'application/pdf'\n end",
"def extract_content_type\n if image_content_type == \"application/octet-stream\" && !image_file_name.blank?\n content_types = MIME::Types.type_for(image_file_name)\n self.image_content_type = content_types.first.to_s unless content_types.empty?\n end\n end",
"def determine_mime_type(path_to_asset_file, asset_type)\n case asset_type\n when 'IMAGE', 'HTML_IMAGE'\n return 'image/%s' % File.extname(path_to_asset_file)\n when 'VIDEO'\n return 'video/%s' % File.extname(path_to_asset_file)\n else\n return 'application/octet-stream'\n end\n end",
"def file_type\r\n\t\t@file_type\r\n\tend",
"def ftype\n :file\n end",
"def content_type\n %x(file -bi \"#{self.path}\").chomp.scan(/^[a-z0-9\\-_]+\\/[a-z0-9\\-_]+/).first\n end",
"def file_type(file_name)\n return file_name[file_name.rindex(\".\") + 1, file_name.size]\n end",
"def file_type( file_name )\n File.extname( file_name ).gsub( /^./, '' ).downcase\n end",
"def mime_type_for(format, temp_object=nil)\n registered_mime_types[file_ext_string(format)] || (temp_object.mime_type if temp_object.respond_to?(:mime_type)) || fallback_mime_type\n end",
"def mimetype\n return @mimetype if defined? @mimetype\n\n content_type = metadata['Content-Type'].is_a?(Array) ? metadata['Content-Type'].first : metadata['Content-Type']\n @mimetype = Henkei.mimetype(content_type)\n end",
"def file_type\n self['fileRef']['explicitFileType'] || self['fileRef']['lastKnownFileType']\n end",
"def mime_type\n parser_for(:variable_mime_type, variable_attributes) || \"text/plain\"\n end",
"def dor_file_mimetype\n public_xml_doc.xpath('//contentMetadata/resource/*/@mimetype').map(&:text)\n end",
"def mime_type\n\t\tsuffix_without_dot = extname ? extname.sub(/\\A\\./){''}.downcase : nil\n\n\t\tMechanize::Util::DefaultMimeTypes[suffix_without_dot]\n\tend",
"def extract_mime_type(io)\n if io.respond_to?(:mime_type)\n io.mime_type\n elsif io.respond_to?(:content_type)\n io.content_type\n end\n end",
"def content_type(ext)\n case ext\n when \"gif\": \"image/gif\"\n when \"jpg\": \"image/jpeg\"\n when \"png\": \"image/png\"\n else \"application/octet-stream\"\n end\nend",
"def media_type(meta, file)\n tags = meta.inject(&:merge)\n tags.fetch 'MIMEType', Rack::Mime.mime_type(File.extname(file))\n end"
] |
[
"0.7961362",
"0.7944223",
"0.7868649",
"0.77883315",
"0.7780258",
"0.7764791",
"0.7764791",
"0.7764791",
"0.7695291",
"0.7667072",
"0.7619885",
"0.7605528",
"0.75919974",
"0.7589919",
"0.7582616",
"0.75706893",
"0.75662553",
"0.75644946",
"0.75519556",
"0.75504404",
"0.7546756",
"0.75315106",
"0.7528351",
"0.75261843",
"0.75224787",
"0.751568",
"0.7492768",
"0.74864864",
"0.7476821",
"0.74306583",
"0.7425632",
"0.74116594",
"0.73917454",
"0.73675",
"0.73472375",
"0.72927487",
"0.72774744",
"0.72395736",
"0.7225119",
"0.7207845",
"0.7187535",
"0.7184954",
"0.71666837",
"0.7143704",
"0.7126349",
"0.71226174",
"0.71169865",
"0.71135026",
"0.7070232",
"0.70666075",
"0.7053015",
"0.7049836",
"0.7021481",
"0.7014648",
"0.7014521",
"0.699393",
"0.6989236",
"0.69786805",
"0.6976963",
"0.696493",
"0.6962912",
"0.69222033",
"0.6913077",
"0.69060117",
"0.68951297",
"0.6868008",
"0.6867523",
"0.68551093",
"0.68516296",
"0.6838824",
"0.6829577",
"0.6815286",
"0.6805826",
"0.6805826",
"0.6805826",
"0.6805826",
"0.68052155",
"0.6801313",
"0.6793482",
"0.67539185",
"0.6743706",
"0.6735879",
"0.6725887",
"0.6718971",
"0.6706463",
"0.66960627",
"0.6677764",
"0.6665255",
"0.666409",
"0.6646442",
"0.6643153",
"0.6636164",
"0.66307104",
"0.66171575",
"0.6616025",
"0.6615783",
"0.6614493",
"0.6604185",
"0.65989316",
"0.6593042"
] |
0.78429806
|
3
|
Public: Formats a datauri based HTML IMG tag for the file. Returns the entire IMG tag as a String.
|
def as_img_tag()
"<img src='#{self.encode}' />"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def data_uri(image)\n mime_type = image.svg? ? 'image/svg+xml' : image.mime_type\n \"'data:#{mime_type};base64,#{Base64.encode64(image.blob).gsub(/\\r?\\n/, '')}'\"\n end",
"def to_data_uri\n \"url(data:image/svg+xml;base64,#{to_base64});\"\n end",
"def data_uri\n data = Base64.encode64(File.open(@path, 'r').read).gsub(/\\n/, '')\n \"data:#{mime_type};base64,#{data}\"\n end",
"def if_data_img (data, classes = \"\", data_attrs = \"\")\n if data && !data.empty?\n \"<img src='#{images_path}/#{data}' class='#{classes}' #{data_attrs} />\"\n end\n end",
"def img_encode_base64(data)\n content_type = data.content_type.split('/')\n return nil unless content_type[0] == 'image' &&\n ['jpeg', 'png', 'gif'].include?(content_type[1])\n\n \"data:image/#{content_type[1]};base64, #{Base64.encode64(data.read)}\"\n end",
"def to_erb\n url = @img['src']\n url.sub!(\"/images/\", \"\")\n data_pixel = ''\n\n # resolve special data-pixel-density-2 case\n if @img.to_s.include? 'data-pixel-density-2'\n data_value = @img['data-pixel-density-2']\n data_value.sub!(\"/images/\", \"\")\n data_pixel = \", 'data-pixel-density-2': image_path('#{data_value}')\"\n end\n\n options_str = process_options\n\n if url.include?(\"<%= \") && url.include?(\" %>\")\n url.sub!(\"<%= \", '#{')\n url.sub!(\" %>\", \"}\")\n url_string = \"\\\"#{url.to_s}\\\"\"\n\n \"<%= image_tag(#{url_string}#{options_str}#{data_pixel})%>\"\n else\n \"<%= image_tag('#{url}'#{options_str}#{data_pixel})%>\"\n end\n end",
"def imgdata\n url_usable = fetchable # fetchable may set the thumbdata\n thumbdata || (url if url_usable)\n end",
"def format_base64_images(text, id)\n\n matchString = /src=\"data:image\\/(\\w+?);base64,(.*?)\"/\n matches = text.scan(matchString)\n matches.each_with_index do |(mimetype, b64), ix|\n\n unless b64.nil?\n filename = 'post' + id.to_s + '-' + ix.to_s + '.' + mimetype\n fullfilespec = \"#{Rails.public_path}/#{filename}\"\n File.open(fullfilespec, 'wb') do |f|\n f.write(Base64.decode64(b64))\n end\n text.sub!(matchString, \"src='#{filename}'\")\n end\n\n end\n text\n end",
"def image_tag(image)\n raw \"<img src=\\\"/images/\" + image + \"\\\"/>\"\n end",
"def to_html\n \"<img src='#{@url}' height='#{@height}' width='#{width}' />\"\n end",
"def image_tag( file_or_url, options = {} )\n\n # if the file is from ActiveStorage, convert it, then convert it into a URL\n file_or_url = polymorphic_url( file_or_url ) unless file_or_url.is_a?( String )\n file_or_url = asset_url_for( file_or_url ) unless file_or_url.match?( /^(http(s)?\\:|data\\:|system\\/|\\/)/ )\n\n # set/default some attrs\n options[:src] = file_or_url\n options[:alt] ||= ''\n\n # return the IMG tag\n tag( :img, options )\n\n end",
"def inline_image_src(content_type, data)\n #base64_data = escape_javascript(Base64.encode64(data))\n base64_data = Base64.encode64(data)\n return \"data:#{content_type};base64,#{base64_data}\"\n end",
"def image path, attrs = {}\n Tagz.tag :img, { :src => path }.merge(attrs)\n end",
"def image(options = {}, html_options = {})\n html_options[:src] = if options.is_a?(String) then options else self.url_for(options) end\n html_options[:alt] ||= File.basename(html_options[:src], '.*').split('.').first.capitalize\n\n if html_options[:size]\n html_options[:width], html_options[:height] = html_options[:size].split(\"x\")\n html_options.delete :size\n end\n\n tag(\"img\", html_options)\n end",
"def image(name, html_options = {})\n %Q{<img src=\"img/#{name}.png\" alt=\"#{name}\" #{%Q{id=\"#{html_options[:id]}\"} if html_options[:id]} #{%Q{class=\"#{html_options[:class]}\"} if html_options[:class]} #{%Q{style=\"#{html_options[:style]}\"} if html_options[:style]}/>}\n end",
"def imgdata fallback_to_url=true\n if picref && (href = picref.imgdata || (fallback_to_url && picref.url)).present?\n href\n end\n end",
"def image_element(url, name)\n abs_url = @base_url + url\n size = content_size(abs_url)\n\n ret = \"<image url=#{abs_url.encode(xml: :attr)} name=#{name.encode(xml: :attr)} size=\\\"#{size}\\\">\\n\"\n ret += \"<checksum type=\\\"sha256\\\" disposition=#{(abs_url + '.sha256').encode(xml: :attr)}/>\\n\"\n ret += \"</image>\"\n ret.html_safe\n end",
"def image_tag(image, opts={})\n if is_uri?(image)\n path = image\n else\n path = url(\"/images/#{image}\")\n end\n return \"<img src=\\\"#{path}\\\"#{parse_options(opts)} />\"\n end",
"def encoded_picture\n \"data:image/#{self.extension};base64,#{File.open('public/images/' + self.picture,'rb').read}\"\n end",
"def add_image(data)\n regex = /(?<=ppageno\\s0'>)/\n data.gsub(regex) {\"\\n<img src='/page_images/#{self.filename}.jpg'>\"}\n end",
"def update_image_src img, options = {}\n if FedenaSetting.s3_enabled? #and options[:s3].present? and options[:s3]) \n image_url = options[:style].present? ? img.url(options[:style].to_sym,false):img.url(:original,false)\n image_url = image_url.gsub('&','&') if image_url.present? \n image_url\n # return (verify_http_https_file image_url) ? (image_tag image_url).gsub('&','&') : ''\n else\n image_path = img.path\n return \"file://#{Rails.root.join(image_path)}\"\n # return image_tag \"file://#{Rails.root.join(image_path)}\", options\n end\n end",
"def render_image(image)\n id_attr = image.id ? %( id=\"attachment_#{image.id}\") : \"\"\n lines = []\n lines << %(<figure#{id_attr} class=\"image embedded\">)\n lines << %(<div class=\"img\"><img src=\"#{encode(image.url)}\" alt=\"#{encode(image.alt_text)}\"></div>)\n lines << image.figcaption_html if image.figcaption?\n lines << \"</figure>\"\n lines.join\n end",
"def auto_image(html)\n return html.gsub(%r{http(s?):[a-z0-9/.\\-_%~/\\=\\?\\:]+(.gif|.jpg|.jpeg|.png|.bmp|.tif|.tiff)(?:\\?[\\w\\=\\.]+)?}i,\n '<img src=\"\\0\"/>')\n end",
"def to_s\n @result_html = ''\n @images_urls.each do |url|\n @result_html += \"<img src=\\\"#{url}\\\"/>\"\n end\n @result_html.html_safe\n end",
"def pet_image_tag\n return '' if pet.image_id.to_s.empty?\n\n html.div class: 'pet' do\n h2 'Actual image'\n img src: \"#{UrlAws}#{pet.image_id}\"\n end\n end",
"def to_html\r\n return '' unless image?\r\n %(<div>\r\n <a href=\"#{@url}\" target=\"_blank\">\r\n <img src=\"#{@image_url}\">\r\n </a>\r\n </div>)\r\n end",
"def icon aFileName, aAlt = nil, aTitle = nil\n aTitle ||= aAlt\n\n %{<img class=\"icon\" src=\"icons/#{aFileName}\" alt=\"#{aAlt}\" title=\"#{aTitle}\" />}\n end",
"def convert_img(el, opts)\n alt_text = el.attr['alt'].to_s#.gsub(ESCAPED_CHAR_RE) { $1 ? \"\\\\#{$1}\" : $2 }\n src = el.attr['src'].to_s\n if src.empty?\n \"![#{alt_text}]()\"\n else\n title = parse_title(el.attr['title'])\n link = if src.count(\"()\") > 0\n \"<#{src}>\"\n else\n src\n end\n \"\"\n end\n end",
"def make_img_tag(x)\n\n\"<img src='\" + x +\"'/>\"\n\nend",
"def with_data_uris(css)\n css.gsub(IMAGE_REPLACER) do |url|\n \"url(\\\"data:#{mime_type($1)};base64,#{encoded_contents($1)}\\\")\"\n end\n end",
"def sss_image_tag url, options = {}\n options[:url] = url\n url = Builder.new(options).build_url()\n '<img src=\"#{url}\">'\n end",
"def image(path, options = {})\n o = Hash(options).map { |k, v| \"#{k}='#{v}'\" }.join(' ')\n\n asset_html(path, [IMAGE_CDN.chomp, o].join(' '),\n [IMAGE_LOCAL.chomp, o].join(' '), options)\n end",
"def image_url\n if image.present?\n image\n else\n \"http://loremflickr.com/320/240/#{CGI.escape name}\"\n end\n end",
"def image_string_creator\r\n n = []\r\n n << \"src:\".ljust(TO_S_SIZE) + self.src.to_s\r\n n << \"file date:\".ljust(TO_S_SIZE) + self.fileCreatedDate.to_s\r\n n << \"file size:\".ljust(TO_S_SIZE) + self.fileSize.to_s\r\n n << \"width:\".ljust(TO_S_SIZE) + self.width.to_s\r\n n << \"height:\".ljust(TO_S_SIZE) + self.height.to_s\r\n n << \"alt:\".ljust(TO_S_SIZE) + self.alt.to_s\r\n return n\r\n end",
"def image_tag(src, html_options = {})\n src = \"#{Compass.configuration.images_dir}/#{src}\" unless src =~ /^(https?:|\\/)/\n tag(:img, html_options.merge(:src=>src))\n end",
"def image_content_return_url(url, width, height, alt = '')\n url = CGI::escape(url)\n width = CGI::escape(width.to_s)\n height = CGI::escape(height.to_s)\n alt = CGI::escape(alt)\n\n \"#{content_return_url}?return_type=image_url&url=#{url}&width=#{width}&height=#{height}&alt=#{alt}\"\n end",
"def semantic_entry_image(e, style, max_width=nil, popup=true, use_alt_img=false)\n c = '<figure vocab = \"http://schema.org/\" typeof=\"ImageObject\"> '.html_safe\n sc = e.raw_title.blank? ? e.image_caption : e.raw_title\n c += \"<meta property='name' content='#{sc}'> \".html_safe\n c += \"<div class='#{style.to_s} image_wrapper'>\".html_safe\n c += image_with_style(e, style, max_width, popup, use_alt_img)\n c += '</div>'.html_safe\n unless e.image_caption.blank? || style == :home\n c += \"<figcaption class='caption'> <div class='caption-inner' property='description'>#{e.image_caption}</div> </figcaption> \".html_safe\n end\n c += '</figure>'.html_safe\n end",
"def image_tag(url, options={})\n options = { :src => image_path(url) }.update(options)\n options[:alt] ||= image_alt(url) unless url.to_s =~ /\\A(?:cid|data):|\\A\\Z/\n tag(:img, options)\n end",
"def icon\n \"#{data_content_type.gsub(/[\\/\\.]/,'-')}.png\"\n end",
"def icon\n \"#{data_content_type.gsub(/[\\/\\.]/,'-')}.png\"\n end",
"def logo_base_64\n 'data:image/png;base64, ' + Base64.encode64(File.open(\"#{Rails.root}/app/assets/images/logo_orgao.png\", 'rb').read).to_s\n end",
"def imgdata\n # If the image capture hasn't completed, return the url\n thumbdata.present? ? thumbdata : url\n end",
"def to_s\n image\n end",
"def image\n if formatted_image.present?\n formatted_image\n else\n original_image\n end\n end",
"def image_markup(image)\n render_to_string(\n file: 'bootsy/images/_image',\n formats: [:html],\n locals: { image: image },\n layout: false\n )\n end",
"def image\n require 'digest/md5'\n \"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(author_email.downcase)}\"\n end",
"def svg_image(image)\n raw image.data\n rescue Dragonfly::Job::Fetch::NotFound\n \"Image missing\"\n end",
"def svg_image(image)\n raw image.data\n rescue Dragonfly::Job::Fetch::NotFound\n \"Image missing\"\n end",
"def epub_html\n edited_html.gsub('img src=\"http://', 'img src=\"https://')\n end",
"def full_image_uri\n return nil if image.nil?\n return image if image.start_with?('http://')\n return 'http://bookmarket.webhop.org/' + image\n end",
"def image url, alt=url\n \"\"\n end",
"def process_image_tag(tag)\n parts = tag.split('|')\n return if parts.size.zero?\n\n name = parts[0].strip\n\n path = if file = media_file_exist?(name)\n file\n elsif name =~ /^https?:\\/\\/.+(jpg|png|gif|svg|bmp)$/i\n name\n end\n\n if path\n opts = parse_image_tag_options(tag)\n containered = false\n\n classes = [] # applied to whatever the outermost container is\n attrs = [] # applied to the image\n\n align = opts['align']\n if opts['float']\n containered = true\n align ||= 'left'\n if %w{left right}.include?(align)\n classes << \"float-#{align}\"\n end\n elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)\n attrs << %{align=\"#{align}\"}\n elsif align\n if %w{left center right}.include?(align)\n containered = true\n classes << \"align-#{align}\"\n end\n end\n\n if width = opts['width']\n if width =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{width=\"#{width}\"}\n end\n end\n\n if height = opts['height']\n if height =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{height=\"#{height}\"}\n end\n end\n\n if alt = opts['alt']\n attrs << %{alt=\"#{alt}\"}\n end\n\n attr_string = attrs.size > 0 ? attrs.join(' ') + ' ' : ''\n\n if opts['frame'] || containered\n classes << 'frame' if opts['frame']\n %{<span class=\"#{classes.join(' ')}\">} +\n %{<span>} +\n %{<img src=\"#{path}\" #{attr_string}/>} +\n (alt ? %{<span>#{alt}</span>} : '') +\n %{</span>} +\n %{</span>}\n else\n %{<img src=\"#{path}\" #{attr_string}/>}\n end\n end\n end",
"def maiko_image_for(url, format)\n return \"#\" if url.nil? || format.nil?\n\n re = /\\/(?=[^\\/]*$).*\\..*/\n [url.gsub(re, ''), format].join('/')\n end",
"def getImg(width=64, height=64)\n if self.image\n self.image+\"?width=#{width}&height=#{height}\"\n else\n \"no_image.png\"\n end\n end",
"def image\n Pathname.new(\"#{PATH}#{self.path}\").open{|file|\n return Base64.strict_encode64(file.read)\n }\n end",
"def image_tag src = nil, opts = {}\n src.is_a?(Hash) && (opts = src.dup) && (src = nil)\n opted_src = opts.delete(:src)\n src ||= opted_src || raise('Please provide image URL as first argument or :src option')\n opts[:alt] ||= ::File.basename(src, ::File.extname(src))\n \"<img src=\\\"%s\\\" %s />\\n\" % [\n opted_src ? opted_src : assets_url(src),\n __e__.assets__opts_to_s(opts)\n ]\n end",
"def photo_filename\n url = read_attribute(\"photo_url\")\n if ! url.blank?\n url.gsub(/\\/images\\//,\"\")\n else\n \"\"\n end\n end",
"def main_image_with_base64=(data)\n image = data\n\n if data.is_a?(String) && data.include?(\"data:image\")\n parts = data.split(',')\n\n meta = parts.first\n content_type = meta.split(';').first.gsub!('data:', '')\n extension = content_type.split('/').last\n extension = (extension == 'jpeg') ? 'jpg' : extension\n\n image = Paperclip.io_adapters.for(data)\n\n image.content_type = content_type\n image.original_filename = [rand(10_000), extension].join('.')\n \n end\n\n self.main_image_without_base64 = image\n end",
"def image_tag src = nil, opts = {}\n src.is_a?(Hash) && (opts = src.dup) && (src = nil)\n opted_src = opts.delete(:src)\n src ||= opted_src || raise('Please provide image URL as first argument or :src option')\n opts[:alt] ||= ::File.basename(src, ::File.extname(src))\n \"<img src=\\\"%s%s\\\" %s>\\n\" % [\n opted_src ? opted_src : assets_url(src),\n opts.delete(:ext),\n __e__assets__opts_to_s(opts)\n ]\n end",
"def process_image_tag(tag)\n parts = tag.split('|')\n return if parts.size.zero?\n\n name = parts[0].strip\n path = if file = find_file(name)\n ::File.join @wiki.base_path, file.path\n elsif name =~ /^https?:\\/\\/.+(jpg|png|gif|svg|bmp)$/i\n name\n end\n\n if path\n opts = parse_image_tag_options(tag)\n\n containered = false\n\n classes = [] # applied to whatever the outermost container is\n attrs = [] # applied to the image\n\n align = opts['align']\n if opts['float']\n containered = true\n align ||= 'left'\n if %w{left right}.include?(align)\n classes << \"float-#{align}\"\n end\n elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align)\n attrs << %{align=\"#{align}\"}\n elsif align\n if %w{left center right}.include?(align)\n containered = true\n classes << \"align-#{align}\"\n end\n end\n\n if width = opts['width']\n if width =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{width=\"#{width}\"}\n end\n end\n\n if height = opts['height']\n if height =~ /^\\d+(\\.\\d+)?(em|px)$/\n attrs << %{height=\"#{height}\"}\n end\n end\n\n if alt = opts['alt']\n attrs << %{alt=\"#{alt}\"}\n end\n\n attr_string = attrs.size > 0 ? attrs.join(' ') + ' ' : ''\n\n if opts['frame'] || containered\n classes << 'frame' if opts['frame']\n %{<span class=\"#{classes.join(' ')}\">} +\n %{<span>} +\n %{<img src=\"#{path}\" #{attr_string}/>} +\n (alt ? %{<span>#{alt}</span>} : '') +\n %{</span>} +\n %{</span>}\n else\n %{<img src=\"#{path}\" #{attr_string}/>}\n end\n end\n end",
"def image_hwstring(width, height)\n out = ''\n if width\n out += 'width=\"' + width.to_i.to_s + '\" '\n end\n if height\n out += 'height=\"' + height.to_i.to_s + '\" '\n end\n out\n end",
"def xf_image_tag (src, attrs = {})\n attrs = attrs.symbolize_keys()\n content = \"\"\n caption = attrs.delete(:caption)\n unless caption.nil?\n content += typeWithAttrs(\"caption\", caption, nil, xhtml2prefix)\n end\n width = attrs.delete(:width)\n unless width.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-width\", :value => width}, xhtml2prefix)\n end\n height = attrs.delete(:height)\n unless height.nil?\n content += typeWithAttrs(\"param\", nil, {:name => \"mcs-aspect-ratio-height\", :value => height}, xhtml2prefix)\n end\n attrs[:src] = src\n typeWithAttrs(\"object\", content, attrs, xhtml2prefix)\n end",
"def image (link, title, alt)\n\n if (parse = parse_link link).present?\n if parse[:id].present?\n else\n imgOutput = image_tag(parse[:url], :size => parse[:size], :title => title, :alt => alt, :class => parse[:class])\n if alt.present?\n content_tag :div, imgOutput + \"<br />\".html_safe + alt, :class => \"inline-image caption\"\n else\n content_tag :div, imgOutput, :class => \"inline-image\"\n end\n end\n end\n\n end",
"def find_image(data)\n tags = Nokogiri::HTML(data)\n imgs = tags.css('img').map { |i| i['src'] }\n imgs.each do |img|\n if (img.include?(\".jpg\") || img.include?(\".png\"))\n return img\n end\n end\n return nil\n end",
"def set_binary_image_from_uri!\n unless SvgInlineFileExtractor.use_mini_magick?\n raise MiniMagickMissing, '#set_binary_image_from_uri! requires the MiniMagick gem to be installed.'\n end\n SvgInlineFileExtractor.with_temp_image(nokogiri_element.value) do |temp_image|\n format = SvgInlineFileExtractor.identify_image(temp_image).to_s.downcase\n nokogiri_element.value = \"data:image/#{format};base64,#{encode(temp_image)}\"\n nokogiri_element.name = 'href'\n end\n true\n end",
"def image\n (object.image_url.nil? || object.image_url.empty?) ? h.content_tag(:span,\"\",class: \"glyphicon glyphicon-picture\") : h.image_tag(object.image_url)\n end",
"def absolute_image_tag(*args)\n raw(image_tag(*args).sub( /src=\"(.*?)\"/, \"src=\\\"#{request.protocol}#{request.host_with_port}\" + '\\1\"'))\n end",
"def image_url\n\t\t\t@data[\"image\"][\"source\"]\n\t\tend",
"def image(link, title, alt_text)\n src = if link[%r{^(http[s]?|/)}]\n link\n else\n PostPicture.friendly.find_by(slug: link).try(:image).try(:small) || ''\n end\n %(<figure class=\"post-figure\"><a href='#{src}'><img src='#{src}' alt='#{alt_text}' /></a><figcaption>#{title}</figcaption></figure>)\n end",
"def to_iruby\n gif_base64 = Base64.encode64(plot)\n ['text/html', \"<img src=\\\"data:image/gif;base64, #{gif_base64}\\\">\"]\n end",
"def image_src\n lambda do |text|\n hash = parse_text(text)\n image = find_image(hash)\n image.asset_digest_path\n end\n end",
"def urls_to_images(options = {})\n wrap_with = options[:wrap_with] || ['','']\n html_options = options[:html_options] || ''\n @modified_string.gsub!(\n /(\\s|^|\\A|\\n|\\t|\\r)((http|https):\\/\\/.*?\\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF))([,.])?(\\s|$|\\n|\\Z|\\t|\\r)/,\n \"#{wrap_with[0]}<img src=\\\"\\\\2\\\" alt=\\\"\\\" #{html_options}/>\\\\6#{wrap_with[1]}\"\n )\n self\n end",
"def image_tag(source, options = {})\n options[:src] = url_for(source)\n tag(\"img\", options)\n end",
"def page_asset_image_tag(image_file_name)\n %{<img src=\"#{page_assets_link_base}#{image_file_name}\" />}\n end",
"def url_to_image(source, options = T.unsafe(nil)); end",
"def format\n \"image/jpeg\"\n end",
"def avatarise(avatar)\n if avatar.respond_to? :read\n \"data:image/jpg;base64,#{Base64.strict_encode64(avatar.read)}\"\n else\n avatar\n end\n end",
"def service_icon(name, size = 24, alt = nil)\n alt ||= name\n %Q{<img src=\"#{service_image(name, size)}\" alt=\"#{alt}\" />}\n end",
"def light_image_tag(source, options = {})\n options.symbolize_keys!\n src = options[:src] = path_to_image(source)\n unless src =~ /^(?:cid|data):/ || src.blank?\n options[:alt] = options.fetch(:alt){ image_alt(src) }\n end\n if size = options.delete(:size)\n options[:width], options[:height] = size.split(\"x\") if size =~ %{^\\d+x\\d+$}\n end\n if mouseover = options.delete(:mouseover)\n options[:onmouseover] = \"this.src='#{path_to_image(mouseover)}'\"\n options[:onmouseout] = \"this.src='#{src}'\"\n end\n\n content_tag(:a, tag(\"img\", options), :href => src, :class => \"image-link\")\n # content_tag :a, :class => \"image-link\" do\n # content_tag :img, options\n # end\n # tag(\"a\", href: src) do\n # tag(\"img\", options)\n # end\n end",
"def ubiquo_image_tag(name, options={})\n options[:src] ||= ubiquo_image_path(name)\n options[:alt] ||= \"Ubiquo image\"\n tag('img', options)\n end",
"def transform_src\n CGI.escapeHTML(@src)\n end",
"def image(full_path, opts = {})\n image_name = template.add_image(full_path)\n output = '<draw:frame text:anchor-type=\"as-char\" '\n opts[:width] && output << %Q(svg:width=\"#{opts[:width]}cm\" )\n opts[:height] && output << %Q(svg:height=\"#{opts[:height]}cm\")\n output << '>'\n output << %Q(<draw:image xlink:href=\"Pictures/#{image_name}\" )\n output <<\n 'xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>'\n output << '</draw:frame>'\n end",
"def facebook_image_tag(name,options={})\n tag \"img\",:src=>\"http://#{ENV['FACEBOOKER_STATIC_HOST']}#{image_path(name)}\"\n end",
"def img(image_src, options = {})\n image_src = case image_src.to_s\n when /^\\/images/\n image_src\n when /^images/\n '/' + image_src\n when /^\\//\n image_src\n else\n '/images/' + image_src\n end\n image_src = \"#{get_resource_root(image_src)}#{image_src}?#{configatron.mack.assets.stamp}\"\n non_content_tag(:img, {:src => image_src}.merge(options))\n end",
"def wp_get_attachment_image(attachment_id, size = 'thumbnail', icon = false, attr = '')\n html = ''\n image = wp_get_attachment_image_src(attachment_id, size, icon)\n unless image.blank?\n src, width, height = image\n hwstring = image_hwstring(width, height)\n size_class = size\n if size_class.kind_of?(Array)\n size_class = size_class.join('x')\n end\n attachment = get_post( attachment_id )\n default_attr = {\n src: src,\n class: \"attachment-#{size_class} size-#{size_class}\",\n alt: strip_tags(get_post_meta(attachment_id, '_wp_attachment_image_alt', true ))\n }\n default_attr[:alt].strip! unless default_attr[:alt].nil?\n attr = Railspress::Functions.wp_parse_args(attr, default_attr)\n\n # Generate 'srcset' and 'sizes' if not already present.\n if attr[:srcset].blank?\n image_meta = wp_get_attachment_metadata( attachment_id )\n\n if image_meta.kind_of?(Array)\n size_array = [ width.to_i.abs, height.to_i.abs ]\n srcset = wp_calculate_image_srcset( size_array, src, image_meta, attachment_id )\n sizes = wp_calculate_image_sizes( size_array, src, image_meta, attachment_id )\n\n if srcset && ( sizes || !attr[:sizes].empty? )\n attr[:srcset] = srcset\n\n if attr[:sizes].empty\n attr[:sizes] = sizes\n end\n end\n end\n end\n\n # Filters the list of attachment image attributes.\n attr = apply_filters( 'wp_get_attachment_image_attributes', attr, attachment, size)\n attr.transform_values!{|v| esc_attr(v) }\n html = \"<img #{hwstring}\".gsub(/\\s$/, '')\n attr.each_pair do |name, value|\n html += \" #{name}=\" + '\"' + value + '\"'\n end\n html += ' />'\n end\n return html\n end",
"def social_image\n @social_image ||= social_image_card&.format(:text)&.render_source\n end",
"def picdata\n case\n when !picurl || (picurl =~ /^data:/)\n picurl\n when thumbnail && thumbnail.matches?(url, picurl) && (thumbnail.thumbdata =~ /^data:/)\n thumbnail.thumbdata\n else\n picurl unless picurl.blank?\n end\n end",
"def transform_images( str, rs )\n\t\t\t@log.debug \" Transforming images %p\" % str\n\n\t\t\t# Handle reference-style labeled images: ![alt text][id]\n\t\t\tstr.\n\t\t\t\tgsub( ReferenceImageRegexp ) {|match|\n\t\t\t\t\twhole, alt, linkid = $1, $2, $3.downcase\n\t\t\t\t\t@log.debug \"Matched %p\" % match\n\t\t\t\t\tres = nil\n\t\t\t\t\talt.gsub!( /\"/, '"' )\n\n\t\t\t\t\t# for shortcut links like ![this][].\n\t\t\t\t\tlinkid = alt.downcase if linkid.empty?\n\n\t\t\t\t\tif rs.urls.key?( linkid )\n\t\t\t\t\t\turl = escape_md( rs.urls[linkid] )\n\t\t\t\t\t\t@log.debug \"Found url '%s' for linkid '%s' \" % [ url, linkid ]\n\n\t\t\t\t\t\t# Build the tag\n\t\t\t\t\t\tresult = %{<img src=\"%s\" alt=\"%s\"} % [ url, alt ]\n\t\t\t\t\t\tif rs.titles.key?( linkid )\n\t\t\t\t\t\t\tresult += %{ title=\"%s\"} % escape_md( rs.titles[linkid] )\n\t\t\t\t\t\tend\n\t\t\t\t\t\tresult += EmptyElementSuffix\n\n\t\t\t\t\telse\n\t\t\t\t\t\tresult = whole\n\t\t\t\t\tend\n\n\t\t\t\t\t@log.debug \"Replacing %p with %p\" % [ match, result ]\n\t\t\t\t\tresult\n\t\t\t\t}.\n\n\t\t\t\t# Inline image style\n\t\t\t\tgsub( InlineImageRegexp ) {|match|\n\t\t\t\t\t@log.debug \"Found inline image %p\" % match\n\t\t\t\t\twhole, alt, title = $1, $2, $5\n\t\t\t\t\turl = escape_md( $3 )\n\t\t\t\t\talt.gsub!( /\"/, '"' )\n\n\t\t\t\t\t# Build the tag\n\t\t\t\t\tresult = %{<img src=\"%s\" alt=\"%s\"} % [ url, alt ]\n\t\t\t\t\tunless title.nil?\n\t\t\t\t\t\ttitle.gsub!( /\"/, '"' )\n\t\t\t\t\t\tresult += %{ title=\"%s\"} % escape_md( title )\n\t\t\t\t\tend\n\t\t\t\t\tresult += EmptyElementSuffix\n\n\t\t\t\t\t@log.debug \"Replacing %p with %p\" % [ match, result ]\n\t\t\t\t\tresult\n\t\t\t\t}\n\t\tend",
"def url\n source_url || reporter.photo_urlformat(uniqueid, 's')\n end",
"def default_photo\n file_path = File.join(Rails.root, 'public', 'images', 'small', 'trip_default_image.png')\n base64_image = Base64.encode64(File.read(file_path))\n \"data:image/jpg;base64,#{base64_image}\"\n end",
"def mobile_image_with_base64=(data)\n image = data\n\n if data.is_a?(String) && data.include?(\"data:image\")\n parts = data.split(',')\n\n meta = parts.first\n content_type = meta.split(';').first.gsub!('data:', '')\n extension = content_type.split('/').last\n extension = (extension == 'jpeg') ? 'jpg' : extension\n\n image = Paperclip.io_adapters.for(data)\n\n image.content_type = content_type\n image.original_filename = [rand(10_000), extension].join('.')\n \n end\n\n self.mobile_image_without_base64 = image\n end",
"def imgurl\n picref.imgurl if picref\n end",
"def image_url(source, options = T.unsafe(nil)); end",
"def image_for(file_name, dest = '')\n prefix = data_path.dup\n file_name = file_name.split('/').last unless file_name.empty?\n file_name = file_name.gsub(/.svg/i, '.png')\n case dest\n when 'mobile_inspire'\n \"#{prefix}/inspire/mobile/#{file_name}\"\n when 'desktop_inspire'\n \"#{prefix}/inspire/desktop/#{file_name}\"\n when 'thumbnails'\n \"#{prefix}/thumbnails/#{file_name}\"\n when 'show_image_desk'\n \"#{prefix}/show_images/desktop/#{file_name}\"\n when 'show_image_mob'\n \"#{prefix}/show_images/mobile/#{file_name}\"\n when 'show'\n \"#{prefix}/show_images/show/#{file_name}\"\n end\n end",
"def image_tag(source, options = {})\n options.symbolize_keys!\n\n options[:src] = path_to_image(source)\n options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize\n\n if size = options.delete(:size)\n options[:width], options[:height] = size.split(\"x\") if size =~ %r{^\\d+x\\d+$}\n end\n\n if mouseover = options.delete(:mouseover)\n options[:onmouseover] = \"this.src='#{image_path(mouseover)}'\"\n options[:onmouseout] = \"this.src='#{image_path(options[:src])}'\"\n end\n\n tag(\"img\", options)\n end",
"def image\n lambda do |text|\n begin \n hash = parse_text(text)\n image = find_image(hash)\n src = get_image_src(hash, image)\n\n unless image.nil?\n engine = gen_haml('image.haml')\n engine.render(nil, {:src => src, :id => hash['id'], :class_name => hash['class'], :alt => hash['alt'], :title => hash['title'], :itemprop => hash['itemprop'], :height => hash['height'], :width => hash['width']})\n end\n rescue NoMethodError => e\n Rails.logger.error \"#{e} could not find image with the params: #{text}\"\n end\n end\n end",
"def offer_photo_image_tag(offer, alt = \"photo\")\n attachment, style = offer.photo, :standard\n # Transitional code for S3\n attachment_url = attachment.url(style)\n if attachment_url[\"missing\"]\n url = attachment_url\n else\n url = \"#{attachment.url(style)}\"\n end\n image_tag(url, :src => url, :class => \"photo\", :id => \"offer_#{offer.id}_photo\", :alt => alt)\n end",
"def get_img_url_from_html(html_path)\n\t\tf = File.open(html_path)\n\t\tdoc = Nokogiri::HTML(f)\n\t\timg_url = doc.css('img').attribute('src').value\n\t\tf.close\n\t\timg_url\n\tend",
"def image_uri\n return \"/image_store/#{id}.#{image_type}\"\n end",
"def image\n #__log_activity\n # __debug_route\n response = Faraday.get(params[:url]) # TODO: caching\n image_data = Base64.encode64(response.body)\n mime_type = response.headers['content-type']\n render plain: image_data, format: mime_type, layout: false\n end"
] |
[
"0.655535",
"0.6232312",
"0.6125246",
"0.6061649",
"0.59991056",
"0.5890778",
"0.58529246",
"0.58281356",
"0.5805518",
"0.5791674",
"0.57703424",
"0.5752037",
"0.5677066",
"0.5651576",
"0.56212115",
"0.5584148",
"0.55580264",
"0.55569035",
"0.55525017",
"0.5548703",
"0.5547221",
"0.55374545",
"0.5514788",
"0.5513652",
"0.55134684",
"0.5509984",
"0.5508357",
"0.5498965",
"0.5484988",
"0.5465238",
"0.54500586",
"0.5438671",
"0.5430471",
"0.54288036",
"0.5376707",
"0.53697777",
"0.5361463",
"0.5351397",
"0.5347787",
"0.5347787",
"0.53301007",
"0.53184694",
"0.5302493",
"0.5297784",
"0.52794623",
"0.52733445",
"0.52557987",
"0.52557987",
"0.52247024",
"0.5211421",
"0.52110416",
"0.5210208",
"0.520144",
"0.51955444",
"0.51725465",
"0.51644987",
"0.5141606",
"0.5133342",
"0.51309496",
"0.5126272",
"0.5124388",
"0.51166594",
"0.5109126",
"0.5095636",
"0.509416",
"0.50930715",
"0.5089595",
"0.5054763",
"0.50534",
"0.50474745",
"0.50435686",
"0.50416046",
"0.50329506",
"0.50280815",
"0.5028073",
"0.5024115",
"0.5015608",
"0.50045514",
"0.50031173",
"0.49990976",
"0.4989003",
"0.49852142",
"0.498312",
"0.49828532",
"0.49800733",
"0.49783215",
"0.4977461",
"0.4975908",
"0.4973617",
"0.4966548",
"0.49660447",
"0.49649402",
"0.4962847",
"0.49610263",
"0.49606693",
"0.49596134",
"0.49516144",
"0.49486026",
"0.49426937",
"0.49372005"
] |
0.6632851
|
0
|
Public: Formats a CSS background image rule for the file, and wraps it in a class definition. klass The name of the class to use for the CSS rule. Optional. If ommitted, the default will the basename of the file path. Returns the class wrapped CSS background rule as a String.
|
def as_css_background_with_class(klass=nil)
klass=File.basename(@file_path).tr('.','_') unless klass
".#{klass} {\n #{self.as_css_background}\n}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def as_css_background()\n \"background: url(#{self.encode}) no-repeat;\"\n end",
"def class_file klass_name\n name = klass_name.split('::').last\n File.join class_path(klass_name), \"cdesc-#{name}.ri\"\n end",
"def file_linker(klass = nil)\n klass ? @file_linker = klass : get_inherited_attribute(\"@file_linker\")\n end",
"def make_class(klass)\n %Q{\n <td class=\"class_item\" colspan=\"#{klass.intervals}\">\n <p>#{klass.name} - #{klass.location}</p>\n <p>#{klass.type}</p>\n </td>}\n end",
"def css_class *a; CssString.new a.flatten.unshift(self).join '.' end",
"def sprite_piece(path, css_class = nil, options = {})\n css_class ||= File.basename(path, File.extname(path)).split('/').join('-')\n @sprite_pieces.add(path, css_class, options)\n end",
"def css(klass='', opts={})\n if klass.is_a?(Hash)\n opts = klass\n klass = ''\n end\n mentos(:css, ['html', klass], opts)\n end",
"def fetch_style_class\n\t\tstyles = Dir.entries(\"./styles\").select do |entry|\n\t\t File.extname(entry).eql? \".rb\"\n\t\tend\n\n\t\tstyle_def = styles.detect do |style|\n\t\t File.basename(style, \".rb\") == @options[:style].to_s\n\t\tend\n\n\t\traise Errors::InvalidStyle unless style_def\n\n\t\trequire \"./styles/#{style_def}\"\n\n\t\tstyle_class_name = classify File.basename(style_def, \".rb\")\n\t\tstyle_class = Styles.const_get style_class_name\n\t\tstyle_class.new(@options)\n\n\t end",
"def thumb_url_for(format)\n if Smartthumbs::Config.get_option(:assume_klass).to_s == self.class.to_s\n \"/th/#{format.to_s}/#{self.id}.#{st_extension}\"\n else\n \"/th/#{self.class.to_s.underscore.parameterize}/#{format.to_s}/#{self.id}.#{st_extension}\"\n end\n end",
"def defined_classname filename\r\n script = File.new filename\r\n script.each_line do |line|\r\n if line =~ /class(.*)[<|\\z]/ \r\n script.close\r\n return $1.strip\r\n end\r\n end \r\n script.close \r\n \"\"\r\nend",
"def class_path klass_name\n File.join @path, *klass_name.split('::')\n end",
"def scan_img_from_css(css_content=\"\")\n background_regex=/background(.*);/\n images_regex_1=/\\('(.*)'\\)/\n images_regex_2=/\\(\"(.*)\"\\)/\n images_regex_3=/\\('..\\/(.*)'\\)/\n images_regex_4=/\\(\"..\\/(.*)\"\\)/\n images_regex_5=/\\((.*)\\)/\n images_regex_6=/\\(..\\/(.*)\\)/\n case css_content\n when /\\('/.match css_content\n #url('images/bg.png')\n when /\\(\"/.match css_content\n #url('images/bg.png')\n when /\\('..\\//.match css_content\n #url('../images/bg.png')\n when /\\(\"..\\//.match css_content\n #url(\"../images/bg.png\")\n when /\\(..\\//.match css_content\n #url(../images/bg.png)\n else\n #url(images/bg.png)\n end\n end",
"def add_klass\n @klass = params[:klass]\n end",
"def mkRes(klass, spec, *args)\n\t\tif(klass < FileRes)\n\t\t\tif(File.extname(args[0]).downcase == \"\")\n\t\t\t\text = @buildMgr.settings.getSettings(spec + MakeRb::SettingsKey[:resourceClass => klass])[:fileExt] || \"\"\n\t\t\t\targs[0] += ext\n\t\t\tend \n\t\t\tklass.new(buildMgr, spec, (@tprefix||\"\")+args[0], *(args[1..-1]))\n\t\telse\n\t\t\tklass.new(buildMgr, spec, *args)\n\t\tend\n\tend",
"def custom_background\n css = \"\"\n css += \"background-color: #{self.background_color};\" unless self.background_color.blank?\n if self.background_image_file_name.blank?\n css += \"background-image: none; \"\n else\n css += \"background-image: url('#{self.background_image.url(\"original\", false)}'); \"\n css += \"background-position: center top; \"\n css += \"background-repeat: repeat-y; \"\n end\n css\n end",
"def render pad, lineno, text\n fullname = File.join(@path, text)\n klass = get_category fullname\n $log.info \"fullname is #{fullname}, #{klass} \"\n # some links throw up an error of no such file\n _stat = File.stat(fullname) rescue File.lstat(fullname)\n @fg = @hash[klass][0]\n bg = @hash[klass][1]\n @bg = bg #if bg\n bg = @hash[klass][2] \n @attr = bg # if bg \n prefix = @prefix[klass] || \" \"\n #@left_margin_text = prefix\n ftext = format_message( text, _stat, prefix)\n\n super pad, lineno, ftext\n end",
"def klass\r\n unless @klass\r\n require class_file\r\n @klass = lookup_class\r\n @klass.spec = self\r\n end\r\n @klass\r\n end",
"def get_background_css(params)\n active_record_object = params[:active_record_object]\n record_id = params[:record_id]\n link = params[:link]\n\n if (active_record_object && !record_id) || \n (!active_record_object && record_id)\n raise ArgumentError, \"get_background_css must have both :active_record_object and :record_id params\"\n end\n\n if active_record_object && record_id\n image = active_record_object.find(record_id).background_image\n elsif link\n image = link\n end\n\n if image != nil\n \"background: url(#{image})\"\n else\n return\n end\n end",
"def klass_name\n \"#{params[:klass_name].classify}\"\n end",
"def icon_css_class\n case file_mime_type\n when *ARCHIVE_FILE_TYPES\n then \"archive\"\n when *AUDIO_FILE_TYPES\n then \"audio\"\n when *IMAGE_FILE_TYPES\n then \"image\"\n when *VIDEO_FILE_TYPES\n then \"video\"\n when \"application/x-shockwave-flash\"\n then \"flash\"\n when \"image/x-psd\"\n then \"psd\"\n when \"text/plain\"\n then \"text\"\n when \"application/rtf\"\n then \"rtf\"\n when \"application/pdf\"\n then \"pdf\"\n when \"application/msword\"\n then \"word\"\n when \"application/vnd.ms-excel\"\n then \"excel\"\n when *VCARD_FILE_TYPES\n then \"vcard\"\n else \"file\"\n end\n end",
"def klass=(klass)\n if klass.class == String\n # XXX sth like klass.split(/,/) and remove whitespace\n @klass = klass.to_a\n elsif klass.class == Hash\n @klass = klass\n else\n raise \"unsupported class #{klass.class} for klass.\"\n end\n end",
"def make_classy( line, file_identifier )\n\t\t# TODO: should add file name to end of class\n\t\tStayClassy::Builder::DEFAULT_CLASS_TAGS.each do |tag|\n\t\t\tif line.include?( \"<#{ tag }\" ) && !line.include?( \"class=\" )\n\t\t\t\tline = line.gsub( \"<#{ tag }\", \"<#{ tag } class=\\\"#{ @prefix }#{ tag }_#{ file_identifier }\\\"\" )\n\t\t\tend\n\t\tend\n\t\treturn line\n\tend",
"def packagize(klass)\n klass = klass.to_s.split('::') unless klass.is_a? Array\n klass_name = klass.pop\n klass.map{|e| underscore(e) }.join('.') + \".#{klass_name}\"\n end",
"def file2klass(str)\n\t\t\tstr.split(\"/\").map {|c|\n\t\t\t\tc.split(/_/).collect {|i| i.capitalize }.join(\"\")\n\t\t\t}.join(\"::\")\n\t\tend",
"def inject_into_class(path, klass, *args, &block)\n config = args.last.is_a?(Hash) ? args.pop : {}\n config[:after] = /class #{klass}\\n|class #{klass} .*\\n/\n insert_into_file(path, *(args << config), &block)\n end",
"def klass2file(str)\n\t\t\tstr.split(/::/).map {|c|\n\t\t\t\tc.scan(/[A-Z][a-z0-9]*/).join(\"_\").downcase\n\t\t\t}.join(\"/\")\n\t\tend",
"def extract_class_name(filename)\n filename.split('/')[2..-1].collect { |i| i.camelize }.join('::').chomp(\".rb\")\n end",
"def css_class(hay, needle); end",
"def klass\n @klass ||= path. # #<Pathname:db/seeds/countries.yml>\n basename. # #<Pathname:countries.yml>\n to_s. # \"countries.yml\"\n split('.'). # [\"countries\", \"yml\"]\n first. # \"countries\"\n classify. # \"Countries\"\n singularize. # \"Country\"\n constantize # Country\n end",
"def klass\n if @klass.is_a?(Class)\n @klass\n else\n unless /\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z/ =~ @klass.to_s\n raise NameError, \"#{@klass.inspect} is not a valid constant name!\"\n end\n \n Object.module_eval(\"::#{$1}\", __FILE__, __LINE__)\n end\n end",
"def class_name_for_class_file(subtree, class_file)\n the_classes_directory = classes_directory(subtree)\n subpath_string = FilePath.new(class_file).relative_path_from(the_classes_directory).to_s\n subpath_string = $1 if subpath_string =~ /^(.*)\\.class\\s*$/\n subpath_string.gsub!(\"/\", \".\")\n subpath_string.gsub!(\"\\\\\", \".\")\n subpath_string\n end",
"def ruby_to_css_class(ruby_name)\n return \"\" unless ruby_name\n ruby_name.to_s.gsub('_','-')\n end",
"def getStyle(filename)\n DEFAULT_FILE_TYPES.invert[File.extname(filename)]\n end",
"def assign_thumbnail_class_to_attachment_class\n @thumbnail_class = @options[:thumbnail_class] || @klass.const_set(:Thumbnail, Class.new(@klass))\n if @thumbnail_class.is_a?(String) ; @thumbnail_class = @thumbnail_class.constantize; end\n th_task = self\n\n # create thumbnails association\n @klass.class_eval do\n unless reflect_on_association(:thumbnails)\n has_many th_task.options[:thumbnails_association], :class_name => \"::#{base_class.name}\", :foreign_key => th_task.options[:parent_foreign_key], :dependent => :destroy\n end\n end\n\n # modify a thumbnail class to be used as the thumbnail for this attachment\n @thumbnail_class.class_eval do\n # The attachment ID used in the full path of a file\n def attachment_path_id\n parent_id\n end\n\n unless reflect_on_association(:parent)\n belongs_to th_task.options[:parent_association], :class_name => \"::#{th_task.klass.base_class.name}\", :foreign_key => th_task.options[:parent_foreign_key]\n end\n\n validates_presence_of th_task.options[:parent_foreign_key]\n\n # ensure that the thumbnails task is not carried over to the thumbnail class,\n # and also ensure that get_image_size is the first task.\n attachment_tasks do\n load :resize\n unqueue :thumbnails, :get_image_size\n prepend :get_image_size, :with => th_task.options[:with]\n end\n end\n\n @thumbnail_class_processed = true\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def klass\n @klass ||= begin\n @klass_name.split('::').inject(Object){|n,i| n.const_get(i)}\n rescue NameError => e\n end\n end",
"def concat_css(filename, mode)\n result = \"\"\n CssSplitter.split_file(filename).each do |part|\n if part[:type] == :source\n result += part[:value] if mode == :css\n else\n if mode == :css\n result += \"url('\" + part[:value].sub(/^.*?([^\\/]+)$/, '\\1') + \"')\"\n else\n result += filename.sub(/[^\\/]*$/, '') + part[:value] + \"\\n\"\n end\n end\n end\n return result\n end",
"def get_style_rules\n computed_style_rules = Hash.new\n if self.style_layer and self.type == Layer::LAYER_NORMAL\n # this means its a style layer and it has image to be set as background \n computed_style_rules[:background] = \"url('../../#{self.image_path}') no-repeat\"\n computed_style_rules[:'background-size'] = \"100% 100%\"\n computed_style_rules[:'background-repeat'] = \"no-repeat\"\n end\n\n style_rules = Array.new\n\n # Get the computed styles for background image for NORMAL layer\n style_rules += Compassify::styles_hash_to_array computed_style_rules\n\n # Get all the other css3 styles for the layer\n style_rules += StylesGenerator.get_styles self\n\n return style_rules\n end",
"def output_class\n 'PictureTag::OutputFormats::' + titleize(PictureTag.preset['markup'])\n end",
"def css_class_standard(hay, needle); end",
"def css_class_builtin(hay, needle); end",
"def generate_class klass, template_file = nil\n setup\n\n current = klass\n\n template_file ||= @template_dir + 'class.rhtml'\n\n debug_msg \" working on %s (%s)\" % [klass.full_name, klass.path]\n out_file = @outputdir + klass.path\n rel_prefix = @outputdir.relative_path_from out_file.dirname\n search_index_rel_prefix = rel_prefix\n search_index_rel_prefix += @asset_rel_path if @file_output\n\n asset_rel_prefix = rel_prefix + @asset_rel_path\n svninfo = get_svninfo(current)\n\n @title = \"#{klass.type} #{klass.full_name} - #{@options.title}\"\n\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io|\n here = binding\n # suppress 1.9.3 warning\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\n here.local_variable_set(:svninfo, svninfo)\n here\n end\n end",
"def eval_string(klass, attrib)\n s = <<EOS\n class #{klass}\n def #{attrib}\n @#{attrib}\n end\n\n def #{attrib}=(value)\n @#{attrib} = value\n end\n end\nEOS\n return s\nend",
"def filename_to_class (f)\n f.split('/').map {|i| i.capitalize.gsub(/_([a-z])/) {|s| $1.upcase }}.\n join('::')\nend",
"def klass\n @klass ||= @options[:klass] || __get_class_value(:klass)\n end",
"def base_filename; class_to_filename(name.gsub(/.*:/, '')); end",
"def render_background\n case @theme_options[:background_colors]\n when Array\n @base_image = render_gradiated_background(*@theme_options[:background_colors])\n when String\n @base_image = render_solid_background(@theme_options[:background_colors])\n else\n @base_image = render_image_background(*@theme_options[:background_image])\n end\n end",
"def css_template_filename\n self.class.name.downcase.gsub(/.*::/,'') << '.css.erb'\n end",
"def classname_from_file(file)\n the_process_class = File.basename(file)\n\n the_process_class['.rb'] = '' if the_process_class['.rb']\n\n if (/[A-Z]/ =~ the_process_class) != 0\n the_process_class = the_process_class.capitalize\n end\n\n match_found = the_process_class.scan(/_[a-z]/)\n if match_found\n # Ruby 1.8 : 'ab'[1] => 98 and 'ab'[1, 1] => 'b'\n # Ruby 1.9 + : 'ab'[1] => 'b' and 'ab'[1, 1] => 'b'\n match_found.each { |str| the_process_class[str] = str[1, 1].capitalize }\n end\n\n the_process_class\n end",
"def thumbnail_class\n attachment_options[:thumbnail_class] = attachment_options[:thumbnail_class].constantize unless attachment_options[:thumbnail_class].is_a?(Class)\n attachment_options[:thumbnail_class]\n end",
"def build_imagecss\n return unless options.Build_Image_Width_Css\n\n puts_cyan \"Middlemac is creating `#{options.File_Image_Width_Css}`.\"\n\n out_array = []\n\n Dir.glob(\"#{app.source}/Resources/**/*.{jpg,png,gif}\").each do |fileName|\n # fileName contains complete path relative to this script.\n # Get just the name and extension.\n base_name = File.basename(fileName)\n\n # width\n if File.basename(base_name, '.*').end_with?('@2x')\n width = (FastImage.size(fileName)[0] / 2).to_i.to_s\n else\n width = FastImage.size(fileName)[0].to_s;\n end\n\n # proposed css\n out_array << \"img[src$='#{base_name}'] { max-width: #{width}px; }\"\n end\n\n File.open(options.File_Image_Width_Css, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def thumbnail(pathtype)\n filename = file.delete \".\"\n path = File.dirname(send(pathtype))\n File.join path, \"#{filename}_thumb.png\"\n end",
"def format_class(klass, helper_config)\n @klass_config.delete(klass)\n @config[klass.to_s] = helper_config\n true\n end",
"def genFileContent(cls, bld)\r\n Utils.instance.genFunctionDependencies(cls, bld)\r\n Utils.instance.genUses(cls.uses, bld)\r\n Utils.instance.genNamespaceStart(cls.namespace, bld)\r\n\r\n classDec = cls.model.visibility + \" class \" + cls.name\r\n\r\n inheritsFrom = Array.new\r\n\r\n for baseClass in cls.baseClasses\r\n inheritsFrom << baseClass.name\r\n end\r\n if cls.interfaceNamespace.hasItems?()\r\n inheritsFrom << Utils.instance.getStyledClassName(\"i \" + getUnformattedClassName(cls))\r\n end\r\n\r\n for par in (0..inheritsFrom.size)\r\n if par == 0 && inheritsFrom[par] != nil\r\n classDec << \" : \" << inheritsFrom[par]\r\n elsif inheritsFrom[par] != nil\r\n classDec << \", \" << inheritsFrom[par]\r\n end\r\n end\r\n\r\n bld.startClass(classDec)\r\n\r\n render_functions(cls, bld)\r\n\r\n bld.endClass\r\n\r\n Utils.instance.genNamespaceEnd(cls.namespace, bld)\r\n end",
"def draw(klass, filename, *args)\n klass.new(@graph, *args).draw_to(@directory.join(\"#{filename}.png\"))\n end",
"def getStyledClassName(className)\r\n return CodeNameStyling.getStyled(className, @langProfile.classNameStyle)\r\n end",
"def run(filename, css); end",
"def postprocess_css_sprited(opts)\n # The images should already be sliced appropriately, as we are\n # called by the css method, which calls slice_images.\n\n # We will need the position of all sprites, so generate the sprite\n # definitions now:\n generate_sprite_definitions(opts)\n\n css = @css.gsub(/_sc_chance:\\s*[\"'](.*?)[\"']/) {|match|\n slice = @slices[$1]\n sprite = sprite_for_slice(slice, opts)\n\n output = \"background-image: chance_file('#{sprite[:name]}')\\n\"\n\n if slice[:x2]\n width = sprite[:width] / slice[:proportion]\n height = sprite[:height] / slice[:proportion]\n output += \"; -webkit-background-size: #{width}px #{height}px\\n\"\n output += \"; -moz-background-size: #{width}px #{height}px\\n\"\n output += \"; background-size: #{width}px #{height}px\\n\"\n end\n\n output\n }\n\n css.gsub!(/-chance-offset:\\s?\"(.*?)\" (-?[0-9]+) (-?[0-9]+)/) {|match|\n slice = @slices[$1]\n\n slice_x = $2.to_i - slice[:sprite_slice_x]\n slice_y = $3.to_i - slice[:sprite_slice_y]\n\n # If it is 2x, we are scaling the slice down by 2, making all of our\n # positions need to be 1/2 of what they were.\n if slice[:x2]\n slice_x /= slice[:proportion]\n slice_y /= slice[:proportion]\n end\n\n \"background-position: #{slice_x}px #{slice_y}px\"\n }\n\n css\n\n end",
"def baseline(klass)\n @baseline_klass = klass\n end",
"def image_class(class_name)\r\n @@super_image_class = class_name\r\n end",
"def klass\n @klass ||=\n if klass_name\n klass_name.constantize\n else\n nil\n end\n end",
"def get_class_name(file_name)\n file_name += \".rb\" unless file_name =~ /\\.rb$/\n f = File.open(file_name, \"r\")\n f.readlines.each { |line| return $1.strip if line =~ /class\\ (.*)<\\ ?Test/ }\n f.close\n end",
"def class_to_basefile class_name\n\t\t\treturn \"#{base_dir}/#{class_name.gsub(\"::\", \"/\")}\"\n\t\tend",
"def add_class klass\n @display.print_class klass\n end",
"def import_class(klass)\n definitions << self.class.from_class(klass, scoped_options)\n end",
"def css_class\n result = [self.project.try(:css_class), self.try(:format).try(:css_class)].join(' ')\n result = 'other' unless CSS_CLASSES.include?(result)\n result += ' invisible' unless self.is_visible\n result\n end",
"def touch_cpp_class(klass)\n h_file = klass + '.h'\n cpp_file = klass + '.cpp'\n\n raise \"Would overwrite #{h_file}!\" if File::exists?(h_file)\n raise \"Would overwrite #{cpp_file}!\" if File::exists?(cpp_file)\n\n File.open(h_file, 'w') do |f|\n guard = h_file.gsub('.', '_').upcase\n f.puts <<-EOS.gsub(/^ {6}/, '')\n /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */\n #ifndef #{guard}\n #define #{guard}\n\n class #{klass}\n {\n public:\n #{klass}();\n\n private:\n\n };\n\n #endif // #{guard}\n EOS\n end\n\n File.open(cpp_file, 'w') do |f|\n f.puts <<-EOS.gsub(/^ {6}/, '')\n /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */\n #include \"#{h_file}\"\n\n #{klass}::#{klass}()\n {\n // ctor code\n }\n EOS\n end\nend",
"def component(klass)\n if @replacements && @replacements.has_key?(klass)\n @replacements[klass]\n\n else\n klass\n end\n end",
"def class_to_filename (c)\n c.split(/::/).map {|i| i.gsub(/([A-Z])/, '_\\1').sub(/_/, '').downcase}.\n join('/')\nend",
"def url_path_class=(klass)\n @_url_path_class = klass\n end",
"def append_class! klass\n return if already_marked? klass\n if has_class_attribute?\n add_class_to_attribute klass\n else\n add_class_and_attribute klass\n end\n end",
"def get_class_name(formula_file)\n string = formula_file.match(/(#{@formulas_dir.split('/').last}.*#{@formula})\\.rb$/)[1]\n string = string.sub(/^[a-z\\d]*/) { $&.capitalize }\n string.gsub(/(?:_|(\\/))([a-z\\d]*)/) { \"#{$1}#{$2.capitalize}\" }.gsub('/', '::') # rubocop:disable PerlBackrefs\n end",
"def path(klass)\n return @@path[klass] if defined?(@@path)\n end",
"def css_class\n @css_class ||= \"project #{status.gsub(' ','-').downcase}\"\n end",
"def add_classes(rule_set, class_array)\n rule_set.each_selector do |selector|\n selector_name = selector.to_s.strip\n if selector_name[0] == '.'\n selector_name = selector_name[1, selector_name.length]\n unless class_array.include?(selector_name)\n class_array << selector_name\n end\n end\n end\n end",
"def extract_class_name(filename)\n File.basename(filename).chomp(\".rb\").camelize\n end",
"def actionscript_file_to_class_name file\n name = file.dup\n name.gsub!(/^#{path}\\//, '')\n name.gsub!(/^#{test}\\//, '')\n name.gsub!(/^#{src}\\//, '')\n name.gsub!(/.as$/, '')\n name.gsub!(/#{File::SEPARATOR}/, '.')\n return name\n end",
"def add_class file_path\n\n cleaned_html = AsdocTidy.clean_for_rexml(file_path)\n class_html\t = REXML::Document.new cleaned_html\n\n class_name = File.basename( file_path, \".html\" )\n log( \"Adding #{class_name}..\" )\n\n @class_names.push(class_name)\n add_as_element(class_html,METHOD,@method_names)\n add_as_element(class_html,PROTECTED_METHOD,@protected_method_names)\n add_as_element(class_html,CONSTANT,@constant_names)\n add_as_element(class_html,PROPERTY,@property_names)\n add_as_element(class_html,PROTECTED_PROPERTY,@protected_properties)\n\n gen_method_completions(class_html,METHOD)\n gen_method_completions(class_html,PROTECTED_METHOD)\n\n end",
"def css_class(feature)\n \"#{css_class_prefix}_#{feature.to_s}\"\n end",
"def bp_class class_param\n class_param.blank? ? '' : class_param.strip().html_safe\n end",
"def klass\n @properties.map { |symbol|\n symbol.to_s\n }.join(\" \") unless @properties.empty?\n end",
"def type\n class_to_filename(self.class.to_s.sub(/.*:/, ''))\n end",
"def image_filename(ext)\n return @skin + '/' + ext\n end",
"def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row #{self.kind}Row #{@tag}Row\" end",
"def file_type_class\n self.file_type.downcase.split.join('-') + '-file'\n end",
"def method_file klass_name, method_name\n method_name = method_name.split('::').last\n method_name =~ /#(.*)/\n method_type = $1 ? 'i' : 'c'\n method_name = $1 if $1\n method_name = method_name.gsub(/\\W/) { \"%%%02x\" % $&[0].ord }\n\n File.join class_path(klass_name), \"#{method_name}-#{method_type}.ri\"\n end",
"def cache_file_for(klassname)\n File.join cache_file_path, klassname.gsub(/:+/, \"-\")\n end",
"def formatter_for(klass) # :nodoc:\n check_modules = true\n until klass.nil?\n formatter = @class_formatters[klass.name]\n return formatter if formatter\n\n if check_modules\n _, formatter = @module_formatters.detect { |mod, f| klass.include?(mod) }\n check_modules = false\n return formatter if formatter\n end\n\n klass = klass.superclass\n end\n end",
"def is_a?(klass)\n @file.is_a?(klass)\n end",
"def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row\" end",
"def inherited(klass)\n return unless klass.name\n\n type = klass.name.gsub(/([A-Z])/) { |a| \"_#{a.downcase}\" }.gsub(\"::\", \"/\")[1..-1].intern\n klass.star_type(type)\n end",
"def get_path(klass)\n result = klass.to_s.split('::').inject([Object]) do |acc,el|\n parent = acc[-1]\n raise NameError unless Module === parent\n acc << parent.const_get(el.to_sym) unless el.empty?\n acc\n end\n result.shift if result[0] == result[1] # If klass is 'Object' or '::Object'\n result\n end",
"def file_class\n @file_class ||\n if superclass.respond_to?(:file_class)\n superclass.file_class\n else\n ::Gollum::File\n end\n end",
"def generate_body_class\n c = controller.controller_path.split('/').each { |c| c.parameterize.dasherize }\n c = c.join(' ') + ' ' + controller.action_name.parameterize.dasherize\n c += ' ' + @step.to_s # include the wicked step\n c.strip\n end",
"def readable_klass(klass_name)\n\t\tklass_name.blank? ? '' : klass_name.underscore.humanize.titleize\n\tend",
"def determine_image_type_from_ext(ext)\n case ext\n when 'jpg' then RGB\n else ARGB\n end\n end"
] |
[
"0.51849985",
"0.50258887",
"0.49501657",
"0.4906297",
"0.48422053",
"0.47846317",
"0.47634044",
"0.47355697",
"0.4717101",
"0.47041813",
"0.46950427",
"0.46693936",
"0.46611258",
"0.46506253",
"0.46431187",
"0.46363416",
"0.45550895",
"0.4537252",
"0.45228663",
"0.45189008",
"0.44945952",
"0.44906786",
"0.44661722",
"0.44540018",
"0.44409153",
"0.4396342",
"0.4388537",
"0.43752572",
"0.43688834",
"0.43638596",
"0.43539",
"0.43494406",
"0.43407714",
"0.4326626",
"0.43262243",
"0.43262243",
"0.43262243",
"0.4315135",
"0.4315135",
"0.4311786",
"0.430621",
"0.42799956",
"0.4275526",
"0.42713803",
"0.42582783",
"0.42476857",
"0.42463732",
"0.42377797",
"0.42322385",
"0.42110753",
"0.42002732",
"0.41868532",
"0.41826493",
"0.41797507",
"0.41786817",
"0.41785413",
"0.41625848",
"0.41536984",
"0.41533193",
"0.4149717",
"0.41336793",
"0.4128224",
"0.4127056",
"0.4126926",
"0.40934712",
"0.40769526",
"0.40730256",
"0.40698278",
"0.4064431",
"0.40559226",
"0.40538153",
"0.40534773",
"0.40508398",
"0.40443566",
"0.40373054",
"0.40319625",
"0.40267292",
"0.40224692",
"0.40182838",
"0.40134463",
"0.39989227",
"0.39974603",
"0.39921123",
"0.39915735",
"0.39887697",
"0.39879826",
"0.3987014",
"0.39861888",
"0.39860398",
"0.39857513",
"0.39834204",
"0.39827433",
"0.39785898",
"0.3977468",
"0.3974527",
"0.39726642",
"0.39702812",
"0.3970019",
"0.396897",
"0.39681762"
] |
0.82585263
|
0
|
Public: Formats a CSS background image rule for the file. Returns the CSS background rule as a String.
|
def as_css_background()
"background: url(#{self.encode}) no-repeat;"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def custom_background\n css = \"\"\n css += \"background-color: #{self.background_color};\" unless self.background_color.blank?\n if self.background_image_file_name.blank?\n css += \"background-image: none; \"\n else\n css += \"background-image: url('#{self.background_image.url(\"original\", false)}'); \"\n css += \"background-position: center top; \"\n css += \"background-repeat: repeat-y; \"\n end\n css\n end",
"def as_css_background_with_class(klass=nil)\n klass=File.basename(@file_path).tr('.','_') unless klass\n \".#{klass} {\\n #{self.as_css_background}\\n}\"\n end",
"def get_background_css(params)\n active_record_object = params[:active_record_object]\n record_id = params[:record_id]\n link = params[:link]\n\n if (active_record_object && !record_id) || \n (!active_record_object && record_id)\n raise ArgumentError, \"get_background_css must have both :active_record_object and :record_id params\"\n end\n\n if active_record_object && record_id\n image = active_record_object.find(record_id).background_image\n elsif link\n image = link\n end\n\n if image != nil\n \"background: url(#{image})\"\n else\n return\n end\n end",
"def get_style_rules\n computed_style_rules = Hash.new\n if self.style_layer and self.type == Layer::LAYER_NORMAL\n # this means its a style layer and it has image to be set as background \n computed_style_rules[:background] = \"url('../../#{self.image_path}') no-repeat\"\n computed_style_rules[:'background-size'] = \"100% 100%\"\n computed_style_rules[:'background-repeat'] = \"no-repeat\"\n end\n\n style_rules = Array.new\n\n # Get the computed styles for background image for NORMAL layer\n style_rules += Compassify::styles_hash_to_array computed_style_rules\n\n # Get all the other css3 styles for the layer\n style_rules += StylesGenerator.get_styles self\n\n return style_rules\n end",
"def scan_img_from_css(css_content=\"\")\n background_regex=/background(.*);/\n images_regex_1=/\\('(.*)'\\)/\n images_regex_2=/\\(\"(.*)\"\\)/\n images_regex_3=/\\('..\\/(.*)'\\)/\n images_regex_4=/\\(\"..\\/(.*)\"\\)/\n images_regex_5=/\\((.*)\\)/\n images_regex_6=/\\(..\\/(.*)\\)/\n case css_content\n when /\\('/.match css_content\n #url('images/bg.png')\n when /\\(\"/.match css_content\n #url('images/bg.png')\n when /\\('..\\//.match css_content\n #url('../images/bg.png')\n when /\\(\"..\\//.match css_content\n #url(\"../images/bg.png\")\n when /\\(..\\//.match css_content\n #url(../images/bg.png)\n else\n #url(images/bg.png)\n end\n end",
"def copyStyleSheet()\r\n scriptFileName = Pathname.new($0)\r\n scriptDirectory = scriptFileName.dirname\r\n cssInputFileName = scriptDirectory.join(@@cssBaseName)\r\n cssOutputFileName = @outputDir.join(@@cssBaseName)\r\n @options[:log].begin(\"Copying style sheet \\\"#{cssInputFileName.to_s}\\\"\")\r\n cssInputFile = File.open(cssInputFileName, \"r:UTF-8\")\r\n css = cssInputFile.read()\r\n cssInputFile.close()\r\n\r\n [:imageWidth, :imageHeight, :backgroundImage].each { |key|\r\n stringToReplace = \"\\#\\{\" << key.to_s << \"\\}\"\r\n if key == :backgroundImage\r\n if @options[:backgroundImage]\r\n url = Pathname.new(@options[:backgroundImage]).basename\r\n value = \"background-image: url(\\\"#{url}\\\");\"\r\n else\r\n value = \"\"\r\n end\r\n else\r\n value = @options[key].to_s\r\n end\r\n css.gsub!(stringToReplace, value)\r\n }\r\n\r\n cssOutputFile = File.open(cssOutputFileName, \"w:UTF-8\")\r\n cssOutputFile.write(css)\r\n cssOutputFile.close()\r\n @options[:log].end()\r\n end",
"def build_imagecss\n return unless options.Build_Image_Width_Css\n\n puts_cyan \"Middlemac is creating `#{options.File_Image_Width_Css}`.\"\n\n out_array = []\n\n Dir.glob(\"#{app.source}/Resources/**/*.{jpg,png,gif}\").each do |fileName|\n # fileName contains complete path relative to this script.\n # Get just the name and extension.\n base_name = File.basename(fileName)\n\n # width\n if File.basename(base_name, '.*').end_with?('@2x')\n width = (FastImage.size(fileName)[0] / 2).to_i.to_s\n else\n width = FastImage.size(fileName)[0].to_s;\n end\n\n # proposed css\n out_array << \"img[src$='#{base_name}'] { max-width: #{width}px; }\"\n end\n\n File.open(options.File_Image_Width_Css, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def concat_css(filename, mode)\n result = \"\"\n CssSplitter.split_file(filename).each do |part|\n if part[:type] == :source\n result += part[:value] if mode == :css\n else\n if mode == :css\n result += \"url('\" + part[:value].sub(/^.*?([^\\/]+)$/, '\\1') + \"')\"\n else\n result += filename.sub(/[^\\/]*$/, '') + part[:value] + \"\\n\"\n end\n end\n end\n return result\n end",
"def style\n File.read(@folder + \"/data/style.css\")\n end",
"def setBackground(backgroundImageURL)\n if backgroundImageURL != nil\n @backgroundImage = backgroundImageURL\n self.backgroundColor = UIColor.colorWithPatternImage(UIImage.imageNamed(backgroundImageURL))\n else\n @backgroundImage = nil\n end\n end",
"def to_s(format=:css)\n case format\n when :css\n \"#%.2x%.2x%.2x\" % [r, g, b]\n when :css_rgb\n \"rgb(%.2f,%.2f,%.2f)\" % [r, g, b]\n when :rgb\n \"%.3f, %.3f, %.3f\" % [r / 255, g / 255, b / 255]\n end\n end",
"def render_background\n case @theme_options[:background_colors]\n when Array\n @base_image = render_gradiated_background(*@theme_options[:background_colors])\n when String\n @base_image = render_solid_background(@theme_options[:background_colors])\n else\n @base_image = render_image_background(*@theme_options[:background_image])\n end\n end",
"def escape_css(string); end",
"def to_s\n \"#{foreground}#{background}\"\n end",
"def css(file)\n\t\t\t\"<link rel='stylesheet' type='text/css' href='#{file}'>\"\n\t\tend",
"def featured_img(img)\n \"background-image: linear-gradient(to bottom, rgba(11, 11, 13, 0.3), rgba(0, 0, 0, 0.923)), url('#{img}')\"\n end",
"def create_style_rule(rule); end",
"def rules_and_comments_to_css(items, style, args)\n r = ''\n if items.size > 0\n item_strs = items.map do |item|\n item.to_css(style,\n :context => :ruleset,\n :depth => (args.depth + 1))\n end\n r << style.subrule_before\n r << item_strs.join('')\n end\n\n # Remove trailing \\n's\n r.gsub! /\\n+$/, \"\\n\"\n r\n end",
"def attachment_background_tag(selector, attachment, options={})\n\t\t\tresolutions = attachment_resolutions(attachment, options)\n\t\t\tsmallest_resolution = resolutions.sort_by{ |resolution| resolution[:width].to_f * resolution[:height].to_f }.first\n\n\t\t\tcontent = <<-EOS\n#{selector} {\n\tbackground-image: url('#{smallest_resolution[:src]}') !important;\n}\nEOS\n\t\t\tresolutions.each do |resolution|\n\t\t\t\tmedia = \"(min-width: #{resolution[:breakpoint_min]}px)\"\n\t\t\t\tmedia = \"#{media} and (max-width: #{resolution[:breakpoint_max]}px)\" if resolution[:breakpoint_max]\n\n\t\t\t\tcontent = content + <<-EOS\n@media #{media} {\n\t#{selector} {\n\t\tbackground-image: url('#{resolution[:src]}') !important;\n\t}\n}\nEOS\n\t\t\tend\n\n\t\t\tcontent_tag( :style, raw( content ) )\n\n\t\tend",
"def service_icon_background(service)\n if service.respond_to?(:icon)\n service_name = service.icon\n else\n service_name = \"#{service}.png\"\n end\n %Q{style=\"background: transparent url('#{service_image(service_name, 24)}') no-repeat scroll left top;\"}\n end",
"def image_background(scale, image_path)\n image = Magick::Image.read(image_path)\n if scale != 1.0\n image[0].resize!(scale) # TODO: Resize with new scale (crop if necessary for wide graph)\n end\n image[0]\n end",
"def postprocess_css_sprited(opts)\n # The images should already be sliced appropriately, as we are\n # called by the css method, which calls slice_images.\n\n # We will need the position of all sprites, so generate the sprite\n # definitions now:\n generate_sprite_definitions(opts)\n\n css = @css.gsub(/_sc_chance:\\s*[\"'](.*?)[\"']/) {|match|\n slice = @slices[$1]\n sprite = sprite_for_slice(slice, opts)\n\n output = \"background-image: chance_file('#{sprite[:name]}')\\n\"\n\n if slice[:x2]\n width = sprite[:width] / slice[:proportion]\n height = sprite[:height] / slice[:proportion]\n output += \"; -webkit-background-size: #{width}px #{height}px\\n\"\n output += \"; -moz-background-size: #{width}px #{height}px\\n\"\n output += \"; background-size: #{width}px #{height}px\\n\"\n end\n\n output\n }\n\n css.gsub!(/-chance-offset:\\s?\"(.*?)\" (-?[0-9]+) (-?[0-9]+)/) {|match|\n slice = @slices[$1]\n\n slice_x = $2.to_i - slice[:sprite_slice_x]\n slice_y = $3.to_i - slice[:sprite_slice_y]\n\n # If it is 2x, we are scaling the slice down by 2, making all of our\n # positions need to be 1/2 of what they were.\n if slice[:x2]\n slice_x /= slice[:proportion]\n slice_y /= slice[:proportion]\n end\n\n \"background-position: #{slice_x}px #{slice_y}px\"\n }\n\n css\n\n end",
"def stylesheet_url(source)\n URI.join(current_host, path_to_stylesheet(source)).to_s\n end",
"def formatted_source_file(source_file); end",
"def url_to_stylesheet(source, options = T.unsafe(nil)); end",
"def ayty_background_list_responsible_for_style(issue, issue_id_play)\n if issue.id.to_s == issue_id_play.to_s\n return \"background: #5CACEE\"\n end\n status_id = issue.status_id.to_i\n return case status_id\n when 8,31\n \"background: #A0A0A0\"\n when 9,11\n \"background: #FF9664\"\n when 25,14\n \"background: #00C864\"\n when 22,23\n \"background: #FA5050\"\n when 34,13\n \"background: #C8FFC8\"\n when 32\n \"background: #C878C8\"\n when 15,16,17\n \"background: #508250\"\n else\n \"\"\n end\n end",
"def background(bgcolor)\n names_to_code(\"on_\" + bgcolor)\n end",
"def format_file(file)\n out = ''\n\n file.magic_numbers.each do |num|\n if @color\n val = red(num.value)\n line = yellow(num.line)\n path = pink(file.path)\n else\n val = num.value\n line = num.line\n path = file.path\n end\n\n out << \"#{path}:#{line} detected magic number #{val}\\n\"\n end\n\n out\n end",
"def compile_css(ios, mark_source=false)\n header = \"/*** %s ***/\\n\"\n Dir.glob(File.join(@ctx_app_root, \"**/*#{STYLESHEET_EXT}\")) do |file|\n if File.file? file\n ios << header % file.sub(\"#{@ctx_app_root}/\", '') if mark_source\n ios << File.read(file) << \"\\n\"\n end\n end\n ios\n end",
"def getStyledFileName(fileName)\r\n return CodeNameStyling.getStyled(fileName, @langProfile.fileNameStyle)\r\n end",
"def btnCSS(hypothesis)\n\t\t\"\n\t\t\tbutton {\n\t\t\t\tbackground-image: image(#{@frame.user.settings.hypothesesColors[hypothesis.id]});\n\t\t\t}\n\t\t\"\n\tend",
"def path_to_stylesheet(source, options = T.unsafe(nil)); end",
"def getTwitterProfileBackgroundImageUrl\n # Find a string in the HTML that looks like:\n # background-image: url(https://si0.twimg.com/profile_banners/44409004/1348689662/web);\n regex = '\\sbackground-image: url\\((https://si0.twimg.com/profile_banners/.+/web)\\);'\n if @web_page.match(regex)\n return @web_page.match(regex)[1]\n end\n return nil\n end",
"def url(style=nil)\n base_path = \"/images/#{filename}\"\n style ? base_path << \"?style=#{style}\" : base_path\n end",
"def maiko_image_for(url, format)\n return \"#\" if url.nil? || format.nil?\n\n re = /\\/(?=[^\\/]*$).*\\..*/\n [url.gsub(re, ''), format].join('/')\n end",
"def background(pos, string)\n $background = \"\"\n if pos[0]\n background = pos[1].even? ? \"\\e[1;100m\" : \"\\e[47m\"\n else\n background = pos[1].odd? ? \"\\e[1;100m\" : \"\\e[47m\"\n end\n background + string\n end",
"def format\n \"image/jpeg\"\n end",
"def put_background_color_to(str, color)\n str.colorize(background: :\"#{color}\")\n end",
"def add_bg_color(str, color)\n color = color.to_s.sub(\"bg_\", \"\").to_sym\n str = reset_prev_formatting str, :bg_color\n \"\\e[#{TC_CONFIG[:bg_colors][color].to_s}m#{str}\"\n end",
"def output_file(style_name)\n overrides = {}\n if (format = styles[style_name][:format])\n overrides[:extension] = format\n end\n attachment.interpolate_path(style_name, overrides)\n end",
"def select_background_type(b1, b2)\n # figures out if b requires a url or an rgb color\n def figure_out(b) \n if b == nil\n output = 'display: none;'\n return output\n elsif b.split(\" \").first == 'background'\n raw = b.split(\"background\")[1]\n image_name = raw[1..raw.length]\n output = \"background-image: url('/assets/patterns/\"+image_name+\".jpg'); background-size: 100%;\"\n return output\n else \n # b2 is going to be an rgb color.\n output = 'background-color: '+b \n return output\n end \n end\n\n background1 = figure_out(b1)\n background2 = figure_out(b2)\n\n html = [background1, background2]\n\n return html\n end",
"def parse_stylesheet(src, current_pos)\n #return super(src, current_pos)\n\n group = 1\n\n style_name = []\n style_type = \"\"\n style_id = 0\n\n while (true)\n case(src[current_pos])\n when '{' then\n group += 1\n current_pos += 1\n when '\\\\' then\n ctrl, val, current_pos = parse_control(src, current_pos + 1)\n\n case(ctrl)\n #when *[:s,:cs,:ds,:ts,:tsrowd] then\n when *[:s,:cs,:ds,:ts] then\n style_type = ctrl\n style_id = val\n end\n when '}' then\n group -= 1\n break if group == 0\n current_pos += 1\n when ';' then\n #ssname = style_name.join.gsub(/[ ]+/, '_')\n ssname = style_name.join\n puts \"Style #{style_type} #{style_id} #{ssname}\" if @@DEBUG_OUTPUT or true\n @doc.add_style(\n :style_id => style_id,\n :style_name => ssname\n )\n style_name = []\n style_type = \"\"\n style_id = -1\n current_pos += 1\n #when *[\"\\r\", \"\\n\", \" \"]\n when *[\"\\r\", \"\\n\"]\n current_pos += 1\n else\n style_name << src[current_pos]\n current_pos += 1\n end\n end\n\n current_pos\n end",
"def picture_styles(card)\n if card.picture?\n \"color:#{card.foreground_color};\n background-color:#{card.background_color};\n background-image: url(\\\"#{card.picture.url}\\\");\n background-repeat: no-repeat;\n background-position: center;\n background-size: auto 50%;\n font-family:#{card.font_style};\"\n else\n \"color:#{card.foreground_color};\n background-color:#{card.background_color};\n font-family:#{card.font_style};\"\n end\n end",
"def escape_css_content(content)\n content.\n gsub('\\\\', '\\\\\\\\005c ').\n gsub(\"\\n\", '\\\\\\\\000a ').\n gsub('\"', '\\\\\\\\0022 ').\n gsub('/', '\\\\\\\\002f ')\n end",
"def open_background_color_span\n \"<span style=\\\"background-color:##{self.html_color};\\\">\"\n end",
"def format_icon_path format\n return 'icons/'.concat(format).concat('.png')\n end",
"def make_css\n template = ERB.new TEMPLATE\n result = template.result binding\n (0..3).each { result.gsub!(/\\n;\\n/m, \";\\n\") }\n @result = result.gsub /^$\\n/, ''\n end",
"def syntax\n :scss\n end",
"def css_bundle_filepath(files)\n bundle_filepath(WebResourceBundler::ResourceFileType::CSS, files)\n end",
"def pathToCell(state)\n\t\treturn File.dirname(__FILE__) + \"/../../Assets/\" + @resolution +\"/Common/Backgrounds/\"+ @size +\"/\"+ state +\".png\"\n\tend",
"def generate_css\n needs = affected_files.map { |m| File.extname(m)[1..-1].to_sym }\n \n original_ext = File.extname(@original_file)[1..-1]\n needs << original_ext.to_sym unless needs.include? original_ext\n\n WebifyRuby::Css.link_to = @link_to\n \n if should_write_css?\n WebifyRuby::Css.relative_from = @link_to ? nil : @css\n end\n \n css = WebifyRuby::Css.new(File.basename(@file, \".*\"), @file, *needs)\n @styles = css.result\n\n @css_file = css.write @css if should_write_css?\n end",
"def formatRules config\n\tresult = \"\"\n\t\n\t# rule set filename is not indicated from the name of the rule set, so a mapping is used\n\trulesetFiles = {\"Android\" => \"android\",\"Basic\" => \"basic\",\"Braces\" => \"braces\",\"Clone Implementation\" => \"clone\",\"Code Size\" => \"codesize\",\"Comments\" => \"comments\",\"Controversial\" => \"controversial\",\"Coupling\" => \"coupling\",\"Design\" => \"design\",\"Empty Code\" => \"empty\",\"Finalizer\" => \"finalizers\",\"Import Statements\" => \"imports\",\"J2EE\" => \"j2ee\",\"JavaBeans\" => \"javabeans\",\"JUnit\" => \"junit\",\"Jakarta Commons Logging\" => \"logging-jakarta-commons\",\"Java Logging\" => \"logging-java\",\"Migration\" => \"migrating\",\"Naming\" => \"naming\",\"Optimization\" => \"optimizations\",\"Strict Exceptions\" => \"strictexception\",\"String and StringBuffer\" => \"strings\",\"Security Code Guidelines\" => \"sunsecure\",\"Type Resolution\" => \"typeresolution\",\"Unnecessary\" => \"unnecessary\",\"Unused Code\" => \"unusedcode\"}\n\t\n\tfor r in config[\"pmd\"][\"rules\"] do\n\t\tresult += \"java-\" + rulesetFiles[r] + \",\"\n\tend\n\treturn result[0..-2]\nend",
"def css_path\n path.split(/\\//).map { |part|\n part.length == 0 ? nil : part.gsub(/\\[(\\d+)\\]/, ':nth-of-type(\\1)')\n }.compact.join(\" > \")\n end",
"def create\n @category = Category.new(category_params)\n\n respond_to do |format|\n if @category.save\n data_file = \"app/assets/stylesheets/application.scss\"\n File.open(data_file, 'a') do |f|\n f.puts \".#{remove_accents(@category.name)} {\n border-left: solid 5px #{@category.color};\n margin: 20px 5px;\n }\"\n end\n format.html { redirect_to @category, notice: 'Category was successfully created.' }\n format.json { render :show, status: :created, location: @category }\n else\n format.html { render :new }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def style_conversion; end",
"def css_path; end",
"def css_path; end",
"def formatted_description\n RuleDescription::Formatter.new(description).format\n end",
"def getStyle\r\n return File.read('css/style.css') if File.file?('css/style.css')\r\n raise \"CSS file not found!\"\r\n end",
"def to_css chain = :desc, css = []\n self.traverse :branch do |path, node|\n properties = node.inject(\"\") do |s, (k, v)| \n v.is_a?(String) ? (s + \"#{k}: #{CGI.unescape(v)}; \") : s # Add the property to the list\n end\n css << path * ( chain == :desc ? ' ' : ' > ') + \" { \" + properties + \"}\" # Add the rule-set to the CSS\n end\n css.join \"\\n\"\n end",
"def style_path(path_prefix, type)\n @record.name =~ /\\.#{type}$/ ? \"#{path_prefix}Stylesheets/#{@record.name}\" : \"#{path_prefix}Stylesheets/#{@record.name}.#{type}\"\n end",
"def image_string_creator\r\n n = []\r\n n << \"src:\".ljust(TO_S_SIZE) + self.src.to_s\r\n n << \"file date:\".ljust(TO_S_SIZE) + self.fileCreatedDate.to_s\r\n n << \"file size:\".ljust(TO_S_SIZE) + self.fileSize.to_s\r\n n << \"width:\".ljust(TO_S_SIZE) + self.width.to_s\r\n n << \"height:\".ljust(TO_S_SIZE) + self.height.to_s\r\n n << \"alt:\".ljust(TO_S_SIZE) + self.alt.to_s\r\n return n\r\n end",
"def css_render\n css_list.join(\"\\n\")\n end",
"def style_url(id)\n \"/beerstyles/a/#{id}/\"\n end",
"def thumbnail\n \"template_\" + self.template.stylesheets + \".png\"\n end",
"def determine_rotatable_background_image\n if @@background_images.empty? || params[:load_bg]\n @@background_images = load_background_images\n end\n\n @background_image = @@background_images[\"hour_#{Time.now.hour}\"] || @@background_images[:default]\n end",
"def render pad, lineno, text\n fullname = File.join(@path, text)\n klass = get_category fullname\n $log.info \"fullname is #{fullname}, #{klass} \"\n # some links throw up an error of no such file\n _stat = File.stat(fullname) rescue File.lstat(fullname)\n @fg = @hash[klass][0]\n bg = @hash[klass][1]\n @bg = bg #if bg\n bg = @hash[klass][2] \n @attr = bg # if bg \n prefix = @prefix[klass] || \" \"\n #@left_margin_text = prefix\n ftext = format_message( text, _stat, prefix)\n\n super pad, lineno, ftext\n end",
"def background(image)\n\t\tself.add(Background.new(image), self)\n\tend",
"def sass_file_url; end",
"def file_path\n 'main.css'\n end",
"def getTwitterProfileBackgroundImage\n # Look for the URL of the background image.\n if url=getTwitterProfileBackgroundImageUrl\n return fetchRemoteImage(url)\n else\n # Use the default image.\n default_image_filepath = File.expand_path(\"../img/grey_header_web.png\", __FILE__)\n sourceImage = IO.read(default_image_filepath)\n return [sourceImage, 'png']\n end\n end",
"def background_color\n return @background_color\n end",
"def mix_background element, opt, ctx\n\n # Background color of the image, if populated.\n bgcolor = detect_bgcolor(opt)\n\n # Set the background color if the element has one.\n element.style[BACKGROUND_COLOR] = bgcolor if bgcolor\n\n # Automatically include background gradient support when\n # mixing in background color.\n mix_background_gradient element, opt, ctx\n\n end",
"def url(style_name = reflection.default_style)\n interpolate_url(style_name)\n end",
"def filename\n \"property-#{property.picture}\"\n end",
"def assemble_css\n renderer = Liquid::Template.parse(@stylesheet.data)\n renderer.render(global_template_data, :filters => liquid_filters)\n end",
"def formatting\n return \"\\e[0;32m%c/%C |%b>%i| %e\\e[0m\"\n end",
"def stylesheet_path\n File.join(@sprites.configuration.sprite_stylesheets_path, @stylesheet_path || stylesheet_file_name)\n end",
"def syntax\n\t\t\t\t:scss\n\t\t\tend",
"def to_s(*args)\n @to_s ||= (style == :compressed ? super().strip : super())\n rescue Sass::SyntaxError => e\n e.add_backtrace_entry(@filename)\n raise e\n end",
"def highlight_file(filename, options = T.unsafe(nil), format = T.unsafe(nil)); end",
"def to_uri(f, prefix, path)\n fn = (prefix + f.gsub(path, '')).squeeze('/')\n\n # Switch the extension ('x.sass' => 'x.css')\n file_ext = File.extname(fn).to_s[1..-1]\n out_ext = AssetPack.tilt_formats[file_ext]\n\n fn = fn.gsub(/\\.#{file_ext}$/, \".#{out_ext}\") if file_ext && out_ext\n\n fn\n end",
"def run(filename, css); end",
"def update_profile_background(file, tile = false)\n perform_post(\"account/update_profile_background_image.#{Twitter.format}\", build_multipart_bodies(:image => file).merge(:tile => tile))\n end",
"def to_s\n rule.inspect\n end",
"def stylesheet_path(source)\n return source if source =~ /^http/\n source.gsub!(/\\.css$/, '')\n source_name = source; source_name << \".css\" unless source =~ /\\.css$/\n result_path = source_name if source =~ %r{^/} # absolute path\n result_path ||= uri_root_path(\"stylesheets\", source_name)\n stamp = File.exist?(result_path) ? File.mtime(result_path) : Time.now.to_i\n \"#{result_path}?#{stamp}\"\n end",
"def background_name\n return timed_background_name($game_temp.battleback_name) unless $game_temp.battleback_name.to_s.empty?\n\n zone_type = $env.get_zone_type\n zone_type += 1 if zone_type > 0 || $env.grass?\n log_debug(\"Background : ZoneType = #{zone_type} / BGName = #{BACKGROUND_NAMES[zone_type]}\")\n return timed_background_name(BACKGROUND_NAMES[zone_type].to_s)\n end",
"def custom_css\n File.read file_path(\"#{name}.css\") if custom_css?\n end",
"def update!(**args)\n @background_attachment = args[:background_attachment] if args.key?(:background_attachment)\n @background_color_argb = args[:background_color_argb] if args.key?(:background_color_argb)\n @background_gradient_color_stop_argb = args[:background_gradient_color_stop_argb] if args.key?(:background_gradient_color_stop_argb)\n @background_gradient_repeat = args[:background_gradient_repeat] if args.key?(:background_gradient_repeat)\n @background_gradient_type = args[:background_gradient_type] if args.key?(:background_gradient_type)\n @background_image_repeat = args[:background_image_repeat] if args.key?(:background_image_repeat)\n @background_image_url = args[:background_image_url] if args.key?(:background_image_url)\n @background_image_x_pos = args[:background_image_x_pos] if args.key?(:background_image_x_pos)\n @background_image_y_pos = args[:background_image_y_pos] if args.key?(:background_image_y_pos)\n @background_size = args[:background_size] if args.key?(:background_size)\n @background_size_height = args[:background_size_height] if args.key?(:background_size_height)\n @background_size_width = args[:background_size_width] if args.key?(:background_size_width)\n @border_color_argb_bottom = args[:border_color_argb_bottom] if args.key?(:border_color_argb_bottom)\n @border_color_argb_left = args[:border_color_argb_left] if args.key?(:border_color_argb_left)\n @border_color_argb_right = args[:border_color_argb_right] if args.key?(:border_color_argb_right)\n @border_color_argb_top = args[:border_color_argb_top] if args.key?(:border_color_argb_top)\n @border_pixel_width_bottom = args[:border_pixel_width_bottom] if args.key?(:border_pixel_width_bottom)\n @border_pixel_width_left = args[:border_pixel_width_left] if args.key?(:border_pixel_width_left)\n @border_pixel_width_right = args[:border_pixel_width_right] if args.key?(:border_pixel_width_right)\n @border_pixel_width_top = args[:border_pixel_width_top] if args.key?(:border_pixel_width_top)\n @border_style_bottom = args[:border_style_bottom] if args.key?(:border_style_bottom)\n @border_style_left = args[:border_style_left] if args.key?(:border_style_left)\n @border_style_right = args[:border_style_right] if args.key?(:border_style_right)\n @border_style_top = args[:border_style_top] if args.key?(:border_style_top)\n @clip = args[:clip] if args.key?(:clip)\n @direction = args[:direction] if args.key?(:direction)\n @display_prop = args[:display_prop] if args.key?(:display_prop)\n @font_family = args[:font_family] if args.key?(:font_family)\n @font_size = args[:font_size] if args.key?(:font_size)\n @font_style = args[:font_style] if args.key?(:font_style)\n @font_weight = args[:font_weight] if args.key?(:font_weight)\n @foreground_color_argb = args[:foreground_color_argb] if args.key?(:foreground_color_argb)\n @has_background = args[:has_background] if args.key?(:has_background)\n @list_style_image_url = args[:list_style_image_url] if args.key?(:list_style_image_url)\n @list_style_type = args[:list_style_type] if args.key?(:list_style_type)\n @margin_bottom = args[:margin_bottom] if args.key?(:margin_bottom)\n @margin_left = args[:margin_left] if args.key?(:margin_left)\n @margin_right = args[:margin_right] if args.key?(:margin_right)\n @margin_top = args[:margin_top] if args.key?(:margin_top)\n @opacity = args[:opacity] if args.key?(:opacity)\n @overflow_x = args[:overflow_x] if args.key?(:overflow_x)\n @overflow_y = args[:overflow_y] if args.key?(:overflow_y)\n @padding_bottom = args[:padding_bottom] if args.key?(:padding_bottom)\n @padding_left = args[:padding_left] if args.key?(:padding_left)\n @padding_right = args[:padding_right] if args.key?(:padding_right)\n @padding_top = args[:padding_top] if args.key?(:padding_top)\n @position = args[:position] if args.key?(:position)\n @referenced_resource_index = args[:referenced_resource_index] if args.key?(:referenced_resource_index)\n @text_align = args[:text_align] if args.key?(:text_align)\n @text_decoration = args[:text_decoration] if args.key?(:text_decoration)\n @text_shadow_color_argb = args[:text_shadow_color_argb] if args.key?(:text_shadow_color_argb)\n @visibility = args[:visibility] if args.key?(:visibility)\n @z_index = args[:z_index] if args.key?(:z_index)\n end",
"def with_data_uris(css)\n css.gsub(IMAGE_REPLACER) do |url|\n \"url(\\\"data:#{mime_type($1)};base64,#{encoded_contents($1)}\\\")\"\n end\n end",
"def background_color(color); end",
"def file_urls\n return { :original => file.url(:original) } unless image?\n file.styles.keys.inject({}){ |hash, style| hash.merge!(style => file.url(style)) }\n end",
"def make_bg(bg_size = nil)\n begin\n img = Magick::Image.from_blob(resize_thumb(bg_size))[0]\n img.quantize.colorize(COLORIZE_LEVEL, COLORIZE_LEVEL, COLORIZE_LEVEL, '#d2f0ff').to_blob\n ensure\n GC.start\n end\n end",
"def build_css(style_hash)\n q = ''\n q << style_hash.collect { |k, v|\n if not v.empty?\n q2 = ( k =~ /\\./ ? ( k[-1..-1] == '.' ? \"#{k[0..-2]}\" : \"#{k}\" ) : \"##{k}\" )\n q2 << ' {' << v.collect{| k2, v2 | \" #{k2}: #{v2}\" }.join( ';' ) << ' }'\n q2\n end\n }.join(\"\\n\")\n return q\n end",
"def image\n if formatted_image.present?\n formatted_image\n else\n original_image\n end\n end",
"def background_color\n ::Color::RGB.from_applescript(advanced_typing_apparatus.background_color).html\n end",
"def format_file(str)\n return str unless context.file\n return str.map { |s| format_file(s) } if str.is_a? Array\n context.file.format(str.to_s)\n end",
"def background=(image)\n self.images.find_or_create_by(:flag => 'background').update(:storage => image) rescue nil\n end",
"def bg_properties \n color_properties.select {|key, value| key.include?(\"background\") }\n end",
"def getStyle(filename)\n DEFAULT_FILE_TYPES.invert[File.extname(filename)]\n end"
] |
[
"0.6116016",
"0.6110001",
"0.5880279",
"0.56555027",
"0.55505973",
"0.54491764",
"0.51739293",
"0.505619",
"0.48845205",
"0.48193994",
"0.4815815",
"0.48022708",
"0.47672442",
"0.4752824",
"0.47404608",
"0.4730031",
"0.47261375",
"0.47046033",
"0.4703655",
"0.4641412",
"0.46383414",
"0.46048576",
"0.45406112",
"0.4540481",
"0.45339528",
"0.45241088",
"0.45068362",
"0.44923666",
"0.4484291",
"0.44798",
"0.44778597",
"0.4471108",
"0.4463335",
"0.44594082",
"0.44529986",
"0.44332236",
"0.4430047",
"0.44263017",
"0.44009262",
"0.43811753",
"0.43663055",
"0.43627813",
"0.43593505",
"0.43501082",
"0.4347393",
"0.43468872",
"0.4336382",
"0.4335755",
"0.43311587",
"0.43088466",
"0.43058583",
"0.43043202",
"0.43019852",
"0.42767125",
"0.42740697",
"0.42736736",
"0.42736736",
"0.42498147",
"0.4242623",
"0.42375088",
"0.42363754",
"0.42349395",
"0.42335856",
"0.4227137",
"0.42255998",
"0.42252496",
"0.42240584",
"0.42224368",
"0.42212144",
"0.4199006",
"0.41987738",
"0.41960555",
"0.4189723",
"0.41886553",
"0.41879424",
"0.4185047",
"0.41809973",
"0.4174566",
"0.41575447",
"0.41571882",
"0.41546386",
"0.4153143",
"0.41461152",
"0.41344136",
"0.41292754",
"0.41249767",
"0.41238236",
"0.4119951",
"0.41144142",
"0.41091117",
"0.4107779",
"0.41075468",
"0.4101277",
"0.40996334",
"0.409278",
"0.4091465",
"0.40891322",
"0.4082313",
"0.40802538",
"0.407936"
] |
0.66690105
|
0
|
Public: Encodes file into a CSS string representation. Returns the Base64 encoded String with filetype information embedded.
|
def encode()
"data:#{self.filetype};base64," + self.raw_encode
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def base64_encode\n Base64.encode64(file_contents)\n end",
"def encode_attachment(file_path:, file_type: nil)\n # try to find file_type\n if file_type.nil?\n content_types = MIME::Types.type_for(file_path)\n file_type = content_types.first.content_type if content_types.any?\n end\n\n # if file_type not found in previous step\n if file_type.nil?\n raise('File type not found. Specify a file_type argument.')\n end\n\n file_contents = open(file_path) { |f| f.read }\n encoded = Base64.encode64(file_contents)\n mime_padding = \"data:#{file_type};base64,\"\n mime_padding + encoded\n end",
"def raw_encode()\n return Base64.encode64(File.read @file_path).delete(\"\\n\") if RUBY_VERSION < \"1.9.0\"\n Base64.strict_encode64(File.read @file_path)\n end",
"def encode_file(filename, format, options = T.unsafe(nil)); end",
"def file_characterization_attributes\n {\n mime_type: mime_type\n }\n end",
"def encoded_contents(image_path)\n Base64.encode64(File.read(image_path)).gsub(/\\n/, '')\n end",
"def file_encoding(file)\n output = %x{file --mime-encoding #{file} 2>&1}.chomp\n regexp = Regexp.new(\"#{file}: (\\\\S+)\")\n matched = output.match(regexp)\n encoding = matched[1] if matched\n encoding = begin Encoding.find(encoding) rescue nil end\n end",
"def encoded_contents(asset_path)\n data = open(asset_path, 'rb'){|f| f.read }\n Base64.encode64(data).gsub(/\\n/, '')\n end",
"def include_file(filepath)\n content = File.read(filepath)\n mime = MimeMagic.by_path(filepath)\n if mime.text?\n return content\n elsif mime.image?\n return Base64.strict_encode64(content)\n else\n raise \"File '${filepath}' of type '${mime}' can't be included as text\"\n end\n end",
"def encode64\n Base64.strict_encode64(compress)\n end",
"def encode_file\n # open 'orginal' to read from\n # fr = File.open(\"#{original_datei}\", 'r') dann muss die Datei explizit geschlossen werden\n File.open(\"#{original_datei}\", 'r') {|fr|\n # create 'encoded' to write to\n File.open(\"encoded_#{original_datei}\",'w') { |fw|\n # encode each letter and then write to 'encoded'\n fr.each_byte{|byte|\n fw << encode(byte).chr\n }\n }\n }\n end",
"def raw_mime_dir_value\n Base64.strict_encode64(@value)\n end",
"def compress!\n compress\n \n File.open(@input_file, 'w') do |file|\n file.puts @compressed_css\n end\n end",
"def encode64( png )\n return Base64.encode64(png)\n end",
"def icon_css_class\n case file_mime_type\n when *ARCHIVE_FILE_TYPES\n then \"archive\"\n when *AUDIO_FILE_TYPES\n then \"audio\"\n when *IMAGE_FILE_TYPES\n then \"image\"\n when *VIDEO_FILE_TYPES\n then \"video\"\n when \"application/x-shockwave-flash\"\n then \"flash\"\n when \"image/x-psd\"\n then \"psd\"\n when \"text/plain\"\n then \"text\"\n when \"application/rtf\"\n then \"rtf\"\n when \"application/pdf\"\n then \"pdf\"\n when \"application/msword\"\n then \"word\"\n when \"application/vnd.ms-excel\"\n then \"excel\"\n when *VCARD_FILE_TYPES\n then \"vcard\"\n else \"file\"\n end\n end",
"def to_s\n return unless filename\n\n result = []\n result << \"%= lang:#{language}#{highlight}\"\n result << '\\begin{code}'\n result.concat(raw_code)\n result << '\\end{code}'\n\n rescue CodeInclusionException => e\n code_error(e.message)\n end",
"def css(file)\n\t\t\t\"<link rel='stylesheet' type='text/css' href='#{file}'>\"\n\t\tend",
"def build_imagecss\n return unless options.Build_Image_Width_Css\n\n puts_cyan \"Middlemac is creating `#{options.File_Image_Width_Css}`.\"\n\n out_array = []\n\n Dir.glob(\"#{app.source}/Resources/**/*.{jpg,png,gif}\").each do |fileName|\n # fileName contains complete path relative to this script.\n # Get just the name and extension.\n base_name = File.basename(fileName)\n\n # width\n if File.basename(base_name, '.*').end_with?('@2x')\n width = (FastImage.size(fileName)[0] / 2).to_i.to_s\n else\n width = FastImage.size(fileName)[0].to_s;\n end\n\n # proposed css\n out_array << \"img[src$='#{base_name}'] { max-width: #{width}px; }\"\n end\n\n File.open(options.File_Image_Width_Css, 'w') { |f| out_array.each { |line| f.puts(line) } }\n\n end",
"def file_to_url_safe_base64(file)\n file_temp_path = file.tempfile.path\n Base64.urlsafe_encode64(File.open(file_temp_path, \"rb\").read)\n end",
"def encode_picture(file,output)\n enc = Base64.encode64(File.open(file,'rb'){|io| io.read})\n File.open(Rails.public_path.to_s + '/images/'+ output,'w') do |f|\n enc.gsub!(\"\\n\",'')\n f.write enc\n end\nend",
"def get_file_extension(file)\n if(file.extension == 'png' || file.extension == 'jpg' || file.extension == 'gif' || file.extension == 'jpeg')\n \"<div class='icon_image_file fl mr10'></div>\"\n elsif(file.extension == 'pdf')\n \"<div class='icon_pdf fl mr10'></div>\"\n elsif(file.extension == 'xls' || file.extension == 'xlsx')\n \"<div class='icon_xls fl mr10'></div>\"\n elsif(file.extension == 'ppt')\n \"<div class='icon_ppt fl mr10'></div>\"\n elsif(file.extension == 'docx' || file.extension == 'doc')\n \"<div class='icon_doc fl mr10'></div>\"\n else\n \"<div class='icon_file fl mr10'> </div>\"\n end\n end",
"def to_s\r\n\t\tSCAsmFile.buffer_as_scasm_file(@contents)\r\n\tend",
"def concat_css(filename, mode)\n result = \"\"\n CssSplitter.split_file(filename).each do |part|\n if part[:type] == :source\n result += part[:value] if mode == :css\n else\n if mode == :css\n result += \"url('\" + part[:value].sub(/^.*?([^\\/]+)$/, '\\1') + \"')\"\n else\n result += filename.sub(/[^\\/]*$/, '') + part[:value] + \"\\n\"\n end\n end\n end\n return result\n end",
"def format_file(file)\n out = ''\n\n file.magic_numbers.each do |num|\n if @color\n val = red(num.value)\n line = yellow(num.line)\n path = pink(file.path)\n else\n val = num.value\n line = num.line\n path = file.path\n end\n\n out << \"#{path}:#{line} detected magic number #{val}\\n\"\n end\n\n out\n end",
"def make_base64_file(fname)\n b64 = Base64.strict_encode64(File.read(fname))\n File.write(B64NAME, b64)\n B64NAME\nend",
"def readfile(file_path)\n\n @file_path = file_path\n @name = File.basename(file_path)\n @mime_type = get_mime_type_from_ext(File.extname(file_path))\n\n file = File.open(file_path, \"rb\")\n encoded_string = Base64.encode64(file.read)\n @content = encoded_string\n\n end",
"def compress_file(file)\n type = file[/\\.(css|js)$/, 1]\n minfile = file.sub /(?=\\.(css|js)$)/, \"-min\"\n\n # SECURITY NOTICE:\n # some fields come from user specificated source\n # e.g. charset can be ' gbk && sudo rm / '\n # This is dangerous especially when this script \n # acts as a web service.\n result = %x[\n java -jar #{@options[:core_jar_path]} \\\n --type #{type} \\\n --charset #{@options[:charset]} \\\n -o #{minfile} #{file}\n ] \n\n puts \"#{file} => #{minfile}\"\n result\n end",
"def data_uri\n data = Base64.encode64(File.open(@path, 'r').read).gsub(/\\n/, '')\n \"data:#{mime_type};base64,#{data}\"\n end",
"def encode\n ::Base64.encode64(@string)\n end",
"def render_file_icon file\n if file.filename.split(\".\").last == \"pdf\"\n img_tag = \"#{image_tag(\"file_icons/pdf.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"flv\"\n img_tag = \"#{image_tag(\"file_icons/flv.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"gif\"\n img_tag = \"#{image_tag(\"file_icons/gif.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"zip\"\n img_tag = \"#{image_tag(\"file_icons/zip.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"mp3\"\n img_tag = \"#{image_tag(\"file_icons/mp3.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"swf\"\n img_tag = \"#{image_tag(\"file_icons/swf.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"doc\"\n img_tag = \"#{image_tag(\"file_icons/doc.png\", :plugin => :alchemy)}\"\n elsif file.filename.split(\".\").last == \"jpg\"\n img_tag = \"#{image_tag(\"file_icons/jpg.png\", :plugin => :alchemy)}\"\n else\n img_tag = \"#{image_tag(\"file_icons/file.png\", :plugin => :alchemy)}\"\n end\n end",
"def to_s\n file_file_name.to_s\n end",
"def with_data_uris(css)\n css.gsub(IMAGE_REPLACER) do |url|\n \"url(\\\"data:#{mime_type($1)};base64,#{encoded_contents($1)}\\\")\"\n end\n end",
"def compress\n # Remove single & multi-line comments\n @compressed_css = @original_css.gsub(/\\/\\*.*?\\*\\//m, '')\n \n tokens = @compressed_css.split(/[ \\t\\n]/) - ['']\n @compressed_css = ''\n\n tokens.each_with_index do |token, i|\n previous_token = tokens[i-1] if i > 0\n\n unless (previous_token && previous_token.match(/[:;}{,]\\Z/)) || token.match(/\\A[\\{]/)\n @compressed_css << ' '\n end\n @compressed_css << token\n end\n \n @compressed_css.strip!\n @compressed_size = @compressed_css.length\n @ratio = @compressed_size / @original_size.to_f\n @compressed_css\n end",
"def best_mime_encoding\n if self.is_ascii?\n :none\n elsif self.length > (self.mb_chars.length * 1.1)\n :base64\n else\n :quoted_printable\n end\n end",
"def to_s\n @file.to_s\n end",
"def encoded\n if @stream\n if @str.respond_to?(:rewind)\n @str.rewind\n end\n Base64.encode(@str.read)\n else\n Base64.encode(@str)\n end\n end",
"def encode(bmp_file, file_name)\n load_files(bmp_file, file_name) \n \n i = 0 \n encoded_image_array = @image_array.bytes.map do |byte|\n if i < @text.size\n if @text[i] == '1' \n byte |= 1 << 0 \n elsif @text[i] == '0'\n byte &= ~(1 << 0)\n end\n i += 1 \n else\n byte &= ~(1 << 0)\n end \n byte\n end \n \n File.open(\"output.bmp\", \"w\") do |f|\n f.write create_image(encoded_image_array.pack('C*').force_encoding('utf-8'))\n end\n \n end",
"def filetype\n `file --mime-type -b #{@file_path}`.chomp\n end",
"def to_s\n @file_text\n end",
"def to_s\n @file_text\n end",
"def mimetype; @mimetype ||= `file -b --mime-type '#@fname'`.strip; end",
"def as_string()\n\n data_map = IniFile.new( :filename => @file_path, :encoding => 'UTF-8' )\n data_map = IniFile.load( @file_path ) if File.file? @file_path\n return data_map.to_s\n\n end",
"def file_characterization_attributes\n {\n bounds: info_service.bounds,\n mime_type: mime_type\n }\n end",
"def mime_type(file)\n header = file.read(8)\n unless header\n file.open\n header = file.read(8)\n end\n file.pos = 0\n if ( /^\\x89PNG/n.match(header) ) \n return \"image/png\"\n elsif (/^GIF8[79]a/n.match(header) )\n return \"image/gif\"\n elsif( /^\\xff\\xd8/n.match(header) )\n return \"image/jpeg\"\n elsif( /^BM/n.match(header) )\n return \"image/bmp\"\n end\n end",
"def decode_file\n # Open 'encoded' to read from\n File.open(\"encoded_#{original_datei}\",'r') { |fr|\n # Open 'decoded' to write to\n File.open(\"decoded_#{original_datei}\",'w') { |fw|\n fr.each_byte { |byte|\n # \"decode\" each byte and write to 'decoded'\n fw << encode(byte, -schluessel).chr\n }\n }\n }\n\n end",
"def process\n format = directives.fetch(:format, 'jpg')\n encode_file(format, directives)\n end",
"def base64(value)\n {\"Fn::Base64\" => value}\n end",
"def generate_css\n needs = affected_files.map { |m| File.extname(m)[1..-1].to_sym }\n \n original_ext = File.extname(@original_file)[1..-1]\n needs << original_ext.to_sym unless needs.include? original_ext\n\n WebifyRuby::Css.link_to = @link_to\n \n if should_write_css?\n WebifyRuby::Css.relative_from = @link_to ? nil : @css\n end\n \n css = WebifyRuby::Css.new(File.basename(@file, \".*\"), @file, *needs)\n @styles = css.result\n\n @css_file = css.write @css if should_write_css?\n end",
"def img_encode_base64(data)\n content_type = data.content_type.split('/')\n return nil unless content_type[0] == 'image' &&\n ['jpeg', 'png', 'gif'].include?(content_type[1])\n\n \"data:image/#{content_type[1]};base64, #{Base64.encode64(data.read)}\"\n end",
"def send_file_with_mime_type file_path\n # more MIME types: http://de.selfhtml.org/diverses/mimetypen.htm\n kind_of_plain_text = %w{ txt php js css rb yml log }\n kind_of_html = %w{ htm html shtml }\n\n case split_to_filename_and_extension(file_path).last.downcase\n when /jp(e*)g/ then type = 'image/jpeg'\n when 'gif' then type = 'image/gif'\n when 'png' then type = 'image/png'\n when 'bmp' then type = 'image/bmp'\n when 'xml' then type = 'text/xml'\n when 'pdf' then type = 'application/pdf'\n when *kind_of_plain_text then type = 'text/plain'\n when *kind_of_html then type = 'text/html'\n else type = 'application/octet-stream'\n end\n\n if Settings.x_accel_redirect\n send_file_via_nginx_x_accel_redirect file_path, type\n else\n send_file File.expand_path(file_path), :disposition => 'inline', :type => type, :x_sendfile => Settings.x_sendfile\n end\n end",
"def to_s\n \"#{@name}, #{@mime_type}\"\n end",
"def get_mime_type file\n FileMagic.new(FileMagic::MAGIC_MIME).file(file).split(';').first\n end",
"def to_s\n save_path = nil\n if @typecode\n save_path = @path\n @path = @path + TYPECODE_PREFIX + @typecode\n end\n str = super\n if @typecode\n @path = save_path\n end\n\n return str\n end",
"def output_file(style_name)\n overrides = {}\n if (format = styles[style_name][:format])\n overrides[:extension] = format\n end\n attachment.interpolate_path(style_name, overrides)\n end",
"def mime_for_file(file)\n path = file.is_a?(File) ? file.path : file\n MIME::Types.type_for(path)[0] || 'application/octet-stream'\n end",
"def encoded_contents(asset_path)\n return @asset_contents[asset_path] if @asset_contents[asset_path]\n data = read_binary_file(asset_path)\n @asset_contents[asset_path] = Base64.encode64(data).gsub(/\\n/, '')\n end",
"def file_to_base64 (photo)\n\t\tputs [photo].pack('m0')\n\t\t#Convierte de formato '/xFF' a Base64 para poder mostrar la foto en la vista\n\t\treturn [photo].pack('m0')\n\tend",
"def mime_type(file)\n type = nil\n\n if (file =~ /\\.(.+?)$/)\n type = ExtensionMimeTypes[$1.downcase]\n end\n\n type || \"text/plain\"\n end",
"def convert_to_encoded_string(data_type, value)\r\n return KB_NIL if value.nil?\r\n\r\n case data_type\r\n when :YAML\r\n y = value.to_yaml\r\n if y =~ ENCODE_RE\r\n return y.gsub(\"&\", '&').gsub(\"\\n\", '&linefeed;').gsub(\r\n \"\\r\", '&carriage_return;').gsub(\"\\032\", '&substitute;'\r\n ).gsub(\"|\", '&pipe;')\r\n else\r\n return y\r\n end\r\n when :String\r\n if value =~ ENCODE_RE\r\n return value.gsub(\"&\", '&').gsub(\"\\n\", '&linefeed;'\r\n ).gsub(\"\\r\", '&carriage_return;').gsub(\"\\032\",\r\n '&substitute;').gsub(\"|\", '&pipe;')\r\n else\r\n return value\r\n end \r\n when :Memo\r\n return value.filepath\r\n when :Blob\r\n return value.filepath\r\n else\r\n return value.to_s\r\n end\r\n end",
"def encode_with(coder)\n coder['class'] = self.class.name.sub(/Sprockets::/, '')\n coder['logical_path'] = logical_path\n coder['pathname'] = relativize_root_path(pathname).to_s\n coder['content_type'] = content_type\n coder['mtime'] = mtime.iso8601\n coder['length'] = length\n coder['digest'] = digest\n end",
"def hashFromFile(file, auth, algo)\n u = URI::NI.buildFromFile(auth, file, nil, algo)\n type=`file --mime-type #{file}`.split[1]\n u.contentType!(type)\n u\nend",
"def raw_code\n @raw_code ||= (File.read path).to_s.force_encoding(Encoding::UTF_8)\n end",
"def get_content_type(file)\n t = MIME::Types.of(file)\n t.first.content_type unless t.empty?\n end",
"def to_s\r\n\t\tbuffer_as_applesoft_file(@contents)\r\n\tend",
"def format_content(old_content)\n file_content = Base64.decode64(old_content) << @content\n return new_file_content = Base64.encode64(file_content)\n end",
"def get_mime_type(file)\n if !file.nil?\n extension = File.extname(file)\n return Rack::Mime::MIME_TYPES[extension] || 'text/plain'\n end\n \n return 'text/plain'\n end",
"def compile(filename)\n check_cookie\n Native::magic_compile(@cookie, filename);\n end",
"def get_url_encoded_file(file)\n begin\n file.gsub!('https','http')\n uri = URI.parse(URI.escape(URI.unescape(file)))\n return uri\n end\n end",
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def base64\n binary = open { |io| io.read }\n result = Base64.strict_encode64(binary)\n binary.clear # deallocate string\n result\n end",
"def output(file)\n\t\tIO.binwrite(file, @decoded.pack('L*'))\n\tend",
"def run(filename, css); end",
"def file(file, simplified = simplified?)\n simplify_mime(fm_file(file), simplified)\n end",
"def encode(value)\n Base64.encode64 value\n end",
"def mime_type\n _mime_type ? _mime_type.to_s : 'text/plain'\n end",
"def to_file(style = default_style)\n if @queued_for_write[style]\n @queued_for_write[style]\n elsif exists?(style)\n tempfile = Tempfile.new instance_read(:file_name)\n tempfile.binmode\n tempfile.write file_contents(style)\n tempfile.flush\n tempfile.rewind\n tempfile\n else\n nil\n end\n\n end",
"def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end",
"def file_characterization_attributes\n {\n geometry: info_service.geom,\n mime_type: mime_type\n }\n end",
"def writeencoding; end",
"def actionscript_file_to_class_name file\n name = file.dup\n name.gsub!(/^#{path}\\//, '')\n name.gsub!(/^#{test}\\//, '')\n name.gsub!(/^#{src}\\//, '')\n name.gsub!(/.as$/, '')\n name.gsub!(/#{File::SEPARATOR}/, '.')\n return name\n end",
"def encoded_to_file(encoded_file, file_name = nil)\n extension = file_name ? \".#{file_name.match(/[^\\.]+$/)}\" : ''\n temp_file = Tempfile.new([SecureRandom.hex(3), extension])\n temp_file.binmode\n temp_file.write(Base64.decode64(encoded_file))\n temp_file.close\n temp_file\n end",
"def asset_data_base64(logical_file_path)\n asset = (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(logical_file_path)\n throw \"Could not find asset '#{logical_file_path}'\" if asset.nil?\n base64 = Base64.encode64(asset.to_s).gsub(/\\s+/, \"\")\n \"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}\"\n end",
"def image\n Pathname.new(\"#{PATH}#{self.path}\").open{|file|\n return Base64.strict_encode64(file.read)\n }\n end",
"def getStyledFileName(fileName)\r\n return CodeNameStyling.getStyled(fileName, @langProfile.fileNameStyle)\r\n end",
"def base64\n binary = open { |io| io.read }\n result = Base64.encode64(binary).chomp\n binary.clear # deallocate string\n result\n end",
"def get_stager_code\r\n b64_fname = \"/tmp/#{Rex::Text.rand_text_alpha(6)}.bin\"\r\n bin_fname = \"/tmp/#{Rex::Text.rand_text_alpha(5)}.bin\"\r\n register_file_for_cleanup(b64_fname, bin_fname)\r\n p = Rex::Text.encode_base64(generate_payload_exe)\r\n\r\n c = \"File.open('#{b64_fname}', 'wb') { |f| f.write('#{p}') }; \"\r\n c << \"%x(base64 --decode #{b64_fname} > #{bin_fname}); \"\r\n c << \"%x(chmod +x #{bin_fname}); \"\r\n c << \"%x(#{bin_fname})\"\r\n c\r\n end",
"def guess_mime_encoding\n # Grab the first line and have a guess?\n # A multiple of 4 and no characters that aren't in base64 ?\n # Need to allow for = at end of base64 string\n squashed = self.tr(\"\\r\\n\\s\", '').strip.sub(/=*\\Z/, '')\n if squashed.length.remainder(4) == 0 && squashed.count(\"^A-Za-z0-9+/\") == 0\n :base64\n else\n :quoted_printable\n end\n # or should we just try both and see what works?\n end",
"def get_cpt_file(file)\n \"#{File.expand_path(file)}.cpt\"\n end",
"def codify(txt)\n enclose('code', txt)\n end",
"def encode(str)\n @base64 = Base64.encode64(str)\n end",
"def as_css_background_with_class(klass=nil)\n klass=File.basename(@file_path).tr('.','_') unless klass\n \".#{klass} {\\n #{self.as_css_background}\\n}\"\n end",
"def mime_type\n MIME_TYPES[@file_type]\n end",
"def mime_type_for(file)\n filename = if file.is_a?(String)\n file\n else\n file.destination_path\n end\n\n case File.extname(filename)\n when '.ttf', '.otf'\n 'application/vnd.ms-opentype'\n else\n MIME::Types.of(filename).first.content_type\n end\n end",
"def get_content_type file\n mime_type = MIME::Types.type_for(file.original_filename)\n return mime_type.first ? mime_type.first : nil\n end",
"def encoded_picture\n \"data:image/#{self.extension};base64,#{File.open('public/images/' + self.picture,'rb').read}\"\n end",
"def default_encoding\n (@media_type == \"text\") ? \"quoted-printable\" : \"base64\"\n end",
"def payload\n Base64.encode64(File.open(file, 'rb').read)\n end",
"def base64_encode value\n encoded_str = Base64.urlsafe_encode64 value, padding: false\nend",
"def to_propertyfile_escaped_s\n to_s.to_propertyfile_escaped_s\n end"
] |
[
"0.62018394",
"0.60733205",
"0.6025695",
"0.5805515",
"0.55570173",
"0.53412",
"0.53347754",
"0.52877456",
"0.5252136",
"0.52432954",
"0.5236314",
"0.52030176",
"0.5185328",
"0.51304704",
"0.51236224",
"0.5106166",
"0.5062003",
"0.5047567",
"0.5035784",
"0.502976",
"0.50028515",
"0.49797678",
"0.49676976",
"0.49600852",
"0.4905811",
"0.4884622",
"0.4865343",
"0.48649684",
"0.48624447",
"0.48609135",
"0.48439145",
"0.4843437",
"0.48352507",
"0.48263",
"0.48175922",
"0.48124918",
"0.48088893",
"0.47957212",
"0.47839227",
"0.47839227",
"0.4778587",
"0.47618106",
"0.47554013",
"0.4747687",
"0.47384462",
"0.47383356",
"0.47334868",
"0.4731942",
"0.4730093",
"0.47295398",
"0.47273424",
"0.47246853",
"0.4720658",
"0.47184083",
"0.47059658",
"0.47052252",
"0.46904916",
"0.46856302",
"0.46818724",
"0.46800226",
"0.46781084",
"0.46766385",
"0.46755493",
"0.46717328",
"0.46660087",
"0.46626592",
"0.46537176",
"0.46528208",
"0.46389535",
"0.46389535",
"0.4633305",
"0.46307656",
"0.461697",
"0.46039575",
"0.46004462",
"0.45923036",
"0.45855117",
"0.45785052",
"0.45785052",
"0.4577789",
"0.4573491",
"0.4568505",
"0.45672876",
"0.4567148",
"0.45585614",
"0.45534968",
"0.4550595",
"0.4541138",
"0.45406255",
"0.4536547",
"0.4535294",
"0.45246714",
"0.45186886",
"0.4518046",
"0.45177323",
"0.45147756",
"0.4514295",
"0.4506761",
"0.45032302",
"0.45020002"
] |
0.6224828
|
0
|
Public: file into its raw Base64 string representation. Returns the Base64 encoded String.
|
def raw_encode()
return Base64.encode64(File.read @file_path).delete("\n") if RUBY_VERSION < "1.9.0"
Base64.strict_encode64(File.read @file_path)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def base64\n binary = open { |io| io.read }\n result = Base64.strict_encode64(binary)\n binary.clear # deallocate string\n result\n end",
"def base64\n binary = open { |io| io.read }\n result = Base64.encode64(binary).chomp\n binary.clear # deallocate string\n result\n end",
"def base64_encode\n Base64.encode64(file_contents)\n end",
"def file_to_url_safe_base64(file)\n file_temp_path = file.tempfile.path\n Base64.urlsafe_encode64(File.open(file_temp_path, \"rb\").read)\n end",
"def base64\n content = storage.read(id)\n base64 = Base64.encode64(content)\n base64.chomp\n end",
"def make_base64_file(fname)\n b64 = Base64.strict_encode64(File.read(fname))\n File.write(B64NAME, b64)\n B64NAME\nend",
"def base64(stuff)\n Base64.encode64(stuff).delete(\"\\n\")\n end",
"def file_to_base64 (photo)\n\t\tputs [photo].pack('m0')\n\t\t#Convierte de formato '/xFF' a Base64 para poder mostrar la foto en la vista\n\t\treturn [photo].pack('m0')\n\tend",
"def to_base64\n base64 = [to_s].pack('m').delete(\"\\n\")\n base64.gsub!('/', '~')\n base64.gsub!('+', '-')\n base64\n end",
"def encode()\n \"data:#{self.filetype};base64,\" + self.raw_encode\n end",
"def base64\n self[:data]\n end",
"def b64_e(data)\n Base64.encode64(data).chomp\n end",
"def payload\n Base64.encode64(File.open(file, 'rb').read)\n end",
"def encoded_contents(image_path)\n Base64.encode64(File.read(image_path)).gsub(/\\n/, '')\n end",
"def base64digest\n DigestUtils.pack_base64digest(digest)\n end",
"def base64_encode\n [self].pack('m').chop\n end",
"def encode_base64(text)\n Base64.strict_encode64(text).strip\n end",
"def to_base64\n Base64.strict_encode64 to_escp\n end",
"def to_base64\n\t\treturn Base64.encode64(self)\n\tend",
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def convert_to_base64(csv)\n Base64.encode64(csv)\n end",
"def raw_to_base_64(byte_array)\n return \"\" if byte_array == []\n ((3 - (byte_array.length % 3)) % 3).times { byte_array << 0 }\n c1 = BASE_64_CHARS[byte_array[0] >> 2]\n c2 = BASE_64_CHARS[(byte_array[0] % 4) * 16 + (byte_array[1] >> 4)]\n c3 = BASE_64_CHARS[(byte_array[1] % 16) * 4 + (byte_array[2] >> 6)]\n c4 = BASE_64_CHARS[byte_array[2] % 64]\n c1 + c2 + c3 + c4 + raw_to_base_64(byte_array[3..-1])\nend",
"def decoded\n Base64.decode64(@base64 || \"\")\n end",
"def encoded\n if @stream\n if @str.respond_to?(:rewind)\n @str.rewind\n end\n Base64.encode(@str.read)\n else\n Base64.encode(@str)\n end\n end",
"def encode64\n Base64.strict_encode64(compress)\n end",
"def to_base64\n [self].pack(\"m\")\n end",
"def encode_base64\n [self].pack(\"m*\")\n end",
"def encoded_contents(asset_path)\n data = open(asset_path, 'rb'){|f| f.read }\n Base64.encode64(data).gsub(/\\n/, '')\n end",
"def decode64\n Base64.strict_decode64(unwrap)\n end",
"def encode_attachment(file_path:, file_type: nil)\n # try to find file_type\n if file_type.nil?\n content_types = MIME::Types.type_for(file_path)\n file_type = content_types.first.content_type if content_types.any?\n end\n\n # if file_type not found in previous step\n if file_type.nil?\n raise('File type not found. Specify a file_type argument.')\n end\n\n file_contents = open(file_path) { |f| f.read }\n encoded = Base64.encode64(file_contents)\n mime_padding = \"data:#{file_type};base64,\"\n mime_padding + encoded\n end",
"def postgres_base64_data(data)\n [data].pack(\"m*\").gsub(/\\r?\\n/,\"\")\n end",
"def encoded_to_file(encoded_file, file_name = nil)\n extension = file_name ? \".#{file_name.match(/[^\\.]+$/)}\" : ''\n temp_file = Tempfile.new([SecureRandom.hex(3), extension])\n temp_file.binmode\n temp_file.write(Base64.decode64(encoded_file))\n temp_file.close\n temp_file\n end",
"def base64(digits)\n string(BASE64_DIGITS, digits)\n end",
"def encode\n ::Base64.encode64(@string)\n end",
"def raw_mime_dir_value\n Base64.strict_encode64(@value)\n end",
"def bin_to_base64(bin)\nreturn bin.scan(/....../).map { |x| $BASE64[x.to_i(2)] }.join\nend",
"def asset_data_base64(logical_file_path)\n asset = (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(logical_file_path)\n throw \"Could not find asset '#{logical_file_path}'\" if asset.nil?\n base64 = Base64.encode64(asset.to_s).gsub(/\\s+/, \"\")\n \"data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}\"\n end",
"def base64_decode\n unpack('m').first\n end",
"def encode64( png )\n return Base64.encode64(png)\n end",
"def encode_base64!\n self.replace(self.encode_base64)\n end",
"def base64_encode value\n encoded_str = Base64.urlsafe_encode64 value, padding: false\nend",
"def readfile(file_path)\n\n @file_path = file_path\n @name = File.basename(file_path)\n @mime_type = get_mime_type_from_ext(File.extname(file_path))\n\n file = File.open(file_path, \"rb\")\n encoded_string = Base64.encode64(file.read)\n @content = encoded_string\n\n end",
"def get_file_as_string(filename)\n data = ''\n f = File.open(filename, \"r\")\n f.each_line do |line|\n data += line\n end\n return data\n end",
"def get_file_as_string(filename)\n data = ''\n f = File.open(filename, \"r\") \n f.each_line do |line|\n data += line\n end\n return data\n end",
"def base64(value)\n {\"Fn::Base64\" => value}\n end",
"def b64_encode(string)\n Base64.encode64(string).tr(\"\\n=\",'')\n end",
"def image\n Pathname.new(\"#{PATH}#{self.path}\").open{|file|\n return Base64.strict_encode64(file.read)\n }\n end",
"def convert_to_file(params_array)\n file_data = split_base64(params_array[:data])\n\n filename = \"/tmp/#{params_array[:filename]}\"\n\n File.open(filename, \"w\") do |tempfile|\n tempfile.binmode\n tempfile << Base64.decode64(file_data[:data])\n tempfile.rewind\n end\n\n File.open(filename)\n end",
"def decode_base64\n #self.unpack(\"m*\").first\n # This should be the above line but due to a bug in the ruby base64 decoder\n # it will only decode base64 where the lines are in multiples of 4, this is\n # contrary to RFC2045 which says that all characters other than the 65 used\n # are to be ignored. Currently we remove all the other characters but it \n # might be better to use it's advice to only remove line breaks and white\n # space\n self.tr(\"^A-Za-z0-9+/=\", \"\").unpack(\"m*\").first\n end",
"def get_base64_image(image)\n image_base64 = Base64.encode64(open(image) { |io| io.read })\n filter_image = image_base64.gsub(/\\r/,\"\").gsub(/\\n/,\"\")\n end",
"def get_file_as_string(filename)\n data = \"\"\n File.open(filename, \"r\").each_line do |line|\n data += line\n end\n data\n end",
"def encode(string)\n Base64.encode64(string).gsub(/\\n/, \"\")\n end",
"def to_s\n @str ||= Base64.encode64(get_digest).gsub(/\\s/, '')\n end",
"def encode_bytes(raw_bytes)\n Base64.urlsafe_encode64(raw_bytes)\n end",
"def to_s\n @file.to_s\n end",
"def as_string()\n\n data_map = IniFile.new( :filename => @file_path, :encoding => 'UTF-8' )\n data_map = IniFile.load( @file_path ) if File.file? @file_path\n return data_map.to_s\n\n end",
"def get_raw\n\n path = File.join(self.get_dir, self.id.to_s + Email::EXT_RAW)\n\n if File.exist?(path)\n return open(path) { |f| f.read }\n else\n return ''\n end\n end",
"def data_uri\n data = Base64.encode64(File.open(@path, 'r').read).gsub(/\\n/, '')\n \"data:#{mime_type};base64,#{data}\"\n end",
"def strict_encode64(bin)\n return Base64.strict_encode64(bin) if Base64.respond_to? :strict_encode64\n Base64.encode64(bin).tr(\"\\n\",'')\n end",
"def base64_encode(string)\n SSL.base64_encode(string)\n end",
"def base64_encode(string)\n SSL.base64_encode(string)\n end",
"def safe_string(str)\n b64str = Base64.strict_encode64(str)\n \"echo #{b64str} | base64 --decode\"\n end",
"def encode(str)\n @base64 = Base64.encode64(str)\n end",
"def blob_to_base64 (photo)\n\t\t#Convierte de formato '/xFF' a Base64 para poder mostrar la foto en la vista\n\t\treturn \"data:image/jpeg;base64,\" + [photo].pack('m0')\n\tend",
"def write_base64(data_stream)\n write_with_children \"base64\" do\n while (buf = data_stream.read(WRITE_BUFFER_SIZE)) != nil do\n @io << [buf].pack('m').chop\n end\n end\n end",
"def get_mms_message_encode64\n #encoded=Base64.encode64(s)\n return Base64.encode64(self.get_mms_message)\n end",
"def bytes\n Base64.decode64(data)\n end",
"def b64encode_it(contents = nil)\r\n\t\t\tunless contents.nil?\r\n\t\t\t\tx = Base64.encode64(contents)\r\n\t\t\t\treturn x\r\n\t\t\tend\r\n\t\tend",
"def base64(text, charset=\"iso-2022-jp\", convert=true)\n if convert\n if charset == \"iso-2022-jp\"\n text = NKF.nkf('-j -m0', text)\n end\n end\n text = [text].pack('m').delete(\"\\r\\n\")\n \"=?#{charset}?B?#{text}?=\"\n end",
"def urlsafe_encode64(bin)\n strict_encode64(bin).tr(\"+/\", \"-_\")\n end",
"def data\n Base64::decode64(@data)\n end",
"def to_encoded_str\n string_io = StringIO.new\n self.encode string_io\n string_io.string\n end",
"def base64(length: T.unsafe(nil), padding: T.unsafe(nil), urlsafe: T.unsafe(nil)); end",
"def from_base64\n unpack(\"m\").first\n end",
"def encode_str(str)\n require \"base64\"\n encoded_str=Base64.encode64(str)\n return encoded_str\nend",
"def to_b64(strict: false)\n if strict\n Base64.strict_encode64(@value)\n else\n Base64.encode64(@value)\n end\n end",
"def encode(value)\n Base64.encode64 value\n end",
"def zip_file\n Base64.decode64(result.zip_file)\n end",
"def hex_to_bin_to_base64(hex_encoded_string)\n bin = Lib.hex_to_bin(hex_encoded_string)\n Lib.bin_to_base64([bin])\nend",
"def to_s\n @file_text\n end",
"def to_s\n @file_text\n end",
"def b64d(input)\n if input\n return helpers.base64Decode(input)\n end\n return \"\".to_java_bytes\n end",
"def hex_to_base64(s)\n [[s].pack(\"H*\")].pack('m*')\nend",
"def encoded_contents(asset_path)\n return @asset_contents[asset_path] if @asset_contents[asset_path]\n data = read_binary_file(asset_path)\n @asset_contents[asset_path] = Base64.encode64(data).gsub(/\\n/, '')\n end",
"def data; Marshal.load(Base64.decode64(read_attribute(:data))); end",
"def e64(s)\n return unless s\n CGI.escape Base64.encode64(s)\n end",
"def serialize\n Base64.encode64(Marshal.dump(self.to_hash)).chop\n end",
"def base64_decode(string)\n SSL.base64_decode(string)\n end",
"def base64_decode(string)\n SSL.base64_decode(string)\n end",
"def encode64(bin)\n [bin].pack(\"m\")\n end",
"def encode64(bin)\n [bin].pack(\"m\")\n end",
"def u64(s)\n return unless s\n Base64.decode64 CGI.unescape(s)\n end",
"def img_encode_base64(data)\n content_type = data.content_type.split('/')\n return nil unless content_type[0] == 'image' &&\n ['jpeg', 'png', 'gif'].include?(content_type[1])\n\n \"data:image/#{content_type[1]};base64, #{Base64.encode64(data.read)}\"\n end",
"def decode_base64!\n self.replace(self.decode_base64)\n end",
"def get_stager_code\r\n b64_fname = \"/tmp/#{Rex::Text.rand_text_alpha(6)}.bin\"\r\n bin_fname = \"/tmp/#{Rex::Text.rand_text_alpha(5)}.bin\"\r\n register_file_for_cleanup(b64_fname, bin_fname)\r\n p = Rex::Text.encode_base64(generate_payload_exe)\r\n\r\n c = \"File.open('#{b64_fname}', 'wb') { |f| f.write('#{p}') }; \"\r\n c << \"%x(base64 --decode #{b64_fname} > #{bin_fname}); \"\r\n c << \"%x(chmod +x #{bin_fname}); \"\r\n c << \"%x(#{bin_fname})\"\r\n c\r\n end",
"def decode(value)\n Base64.decode64 value\n end",
"def file2string filename\n string = FileOps::load filename\n if FileOps::encrypted? filename then\n password = Cipher::ask_password\n string = Cipher::decrypt string, password\n end\n [string, password]\n end",
"def get_file_as_string(filename)\n data = ''\n\n File.open(filename, \"r\") { |f|\n data = f.read\n }\n \n return data\nend",
"def encoded_picture\n \"data:image/#{self.extension};base64,#{File.open('public/images/' + self.picture,'rb').read}\"\n end"
] |
[
"0.8243077",
"0.8152603",
"0.8091158",
"0.77152807",
"0.75076354",
"0.73864985",
"0.7129103",
"0.70412093",
"0.6953615",
"0.6900227",
"0.67988527",
"0.6794249",
"0.67909104",
"0.6775498",
"0.67481357",
"0.67096156",
"0.66520727",
"0.6636371",
"0.66254175",
"0.6582562",
"0.6582562",
"0.6565841",
"0.6564835",
"0.6535167",
"0.650926",
"0.64627415",
"0.63824654",
"0.6366082",
"0.6349293",
"0.62950855",
"0.627275",
"0.6262295",
"0.6235619",
"0.6231528",
"0.6213927",
"0.6192555",
"0.61916155",
"0.61548996",
"0.615306",
"0.6146833",
"0.6115747",
"0.61046875",
"0.60976934",
"0.6075192",
"0.60601664",
"0.6032049",
"0.6029219",
"0.60146356",
"0.6013152",
"0.6008304",
"0.6000107",
"0.5999132",
"0.5998255",
"0.59762555",
"0.5969645",
"0.59686345",
"0.59527165",
"0.59413105",
"0.59397054",
"0.5928437",
"0.59144187",
"0.59144187",
"0.5894871",
"0.5892446",
"0.58819497",
"0.5843423",
"0.58394134",
"0.58340836",
"0.58317304",
"0.5820221",
"0.5803861",
"0.5799358",
"0.57699364",
"0.57690847",
"0.5765452",
"0.5765342",
"0.57506233",
"0.5750001",
"0.5739262",
"0.57334137",
"0.5717539",
"0.5717539",
"0.57123554",
"0.5709854",
"0.5697276",
"0.56883144",
"0.5679737",
"0.5668837",
"0.56640947",
"0.56640947",
"0.56630886",
"0.56630886",
"0.56583554",
"0.564972",
"0.5630238",
"0.55877435",
"0.55852824",
"0.5559377",
"0.5551395",
"0.55490404"
] |
0.83455765
|
0
|
Protected: is the file of an image format we support? Returns a Boolean representing image format validity.
|
def valid_image_format?
VALID_FILE_MIMETYPES.include? self.filetype
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid?\n image_resource? && supported_format?\n end",
"def valid_file?\n if @image.size.zero?\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n unless @image.content_type =~ /^image/\n errors.add(:image, \"is not a recognized format\")\n return false\n end\n if @image.size > 1.megabyte\n errors.add(:image, \"can't be bigger than 1 megabyte\")\n return false\n end\n return true\n end",
"def valid_file_format?\n VALID_FILE_FORMAT. include? uri_extension\n end",
"def image?\n file_type.match(/\\Aimage\\//).present?\n end",
"def valid_other_image_parameters?\n # check version of gif\n return Image.gif89a?(@file_temp_path) if @file_type == GIF_TYPE\n # check \"color system\" of \"jpeg, jpg\" file\n return Image.rgb_color_system?(@file_temp_path) if @file_type == JPEG_TYPE\n # always return true with \"png\" file\n true if @file_type == PNG_TYPE\n end",
"def valid_other_image_parameters?\n # check version of gif\n return Image.gif89a?(@file_temp_path) if @file_type == GIF_TYPE\n # check \"color system\" of \"jpeg, jpg\" file\n return Image.rgb_color_system?(@file_temp_path) if @file_type == JPEG_TYPE\n # always return true with \"png\" file\n true if @file_type == PNG_TYPE\n end",
"def valid_other_image_parameters?\n # check version of gif\n return Image.gif89a?(@file_temp_path) if @file_type == GIF_TYPE\n # check \"color system\" of \"jpeg, jpg\" file\n return Image.rgb_color_system?(@file_temp_path) if @file_type == JPG_TYPE\n # always return true with \"png\" file\n true if @file_type == PNG_TYPE\n end",
"def image?(file)\n file.content_type.include? 'image'\n end",
"def has_file_format?\n @file_format\n end",
"def image?\n (self.file_content_type =~ %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$})\n end",
"def is_image_type?\n file_content_type =~ %r(image)\n end",
"def image?()\n IMAGE_EXTS.include? extname\n end",
"def supported_format?\n !(@file_set.mime_type & self.class.supported_formats).empty?\n end",
"def image?\n IMAGE_EXTENSIONS.include? File.extname(filename)[1..-1]\n end",
"def image?\n %w(jpg jpeg gif png).include?(file_ext.downcase)\n end",
"def verify_file_type\n if file_name\n allowed_types = %w(jpeg jpg png gif)\n\n unless allowed_types.include? file_name.split('.')[1]\n errors.add(:file_name, 'File is not an image.')\n end\n end\n end",
"def image?\n ext = File.extname(@path)\n case ext.downcase\n when '.png', '.jpg', '.jpeg', '.gif'; return true\n else; return false\n end\n end",
"def image?\n self.file_content_type == 'image/png' || self.file_content_type == 'image/jpeg'\n end",
"def valid?\n # is it a valid pattern (i.e. does not contain funny characters)? @TODO\n # all characters are valid, except for the /, directory limiter., files cannot start with a dot (hidden files)\n # is the file a web-savvy image?\n valid_types = ['image/jpeg', 'image/png', 'image/gif']\n return false unless valid_types.include? @entry.metadata.mime_type\n # does the file have thumbnails?\n return false unless @entry.metadata.thumb_exists\n # is the file not the special, reserved thumb.*? (see thumb_for_dir)\n # @TODO: return false if basename.match /^thumb\\.[A-z]*$/\n return true\n end",
"def valid?\n validate!\n true\n rescue MiniMagick::Invalid\n false\n end",
"def is_image?\n ['jpg', 'jpeg', 'pjpeg', 'png', 'bmp', 'gif', 'x-png'].include? self.image_file_name.split('.').last\n end",
"def unsupported_format?\n case @format\n when *UNSUPPORTED_FORMATS then true\n else false\n end\n end",
"def is_raw_file?\n return true if mime_type.eql? \"image/x-adobe-dng\"\n\n # If that fails go with Plan B\n @raw_formats ||= [\"Digital Negative\", \"DNG EXIF\"]\n @raw_formats.each do |rf|\n return true if format_label.include? rf\n end\n\n # If you get here no matches were found\n false\n end",
"def image?\n picture_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end",
"def image_file?\n false\n end",
"def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n\n #The upload should have file suffix\n unless filename =~ /\\.(jpg)|(jpeg)|(png)|(gif)$/i\n errors.add_to_base(\"Please use image file with a filename suffix\")\n return false\n end\n\n #The file should be an image file.\n unless content_type =~ /^image/\n errors.add(:content_type, \"is not a recognized format\")\n return false\n end\n return true\n end",
"def image?\n return ( VALID_HEADERS.include? @hdr_reader )\n end",
"def derived_image?\n respond_to?(:format_name) && !format_name.blank?\n end",
"def valid?\n !(image_too_small? || image_too_big?)\n end",
"def hasImageFileExtension?(file)\n extensions = %w(cr2 jpg jpeg nef nrw dng)\n extensions.each { |extension|\n if file.downcase.include?(extension)\n return true\n end\n }\n return false\n end",
"def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.add(:base, \"Please enter an image filename\")\n return false\n end\n\n #The upload should have file suffix.\n unless filename =~ /\\.(jpg)|(jpeg)|(png)|(gif)$/i\n errors.add(:base, \"Please use image file with a filename suffix\")\n return false\n end\n\n #The file should be an image file.\n unless content_type =~ /^image/\n errors.add(:content_type, \"is not a recognized format\")\n return false\n end\n return true\n end",
"def image?\n !!( content_type =~ Transit.config.image_regexp )\n end",
"def image? new_file\n new_file.content_type.start_with? 'image'\n end",
"def file_valid?(file)\n mime = MIME::Types.type_for(file).first\n !mime.nil? && ACCEPTED_MIMES.include?(mime.content_type)\n end",
"def valid?\n return false if preservation_file.nil?\n (parent.try(:recording?) || parent.try(:image_resource?)) && supported_format?\n end",
"def image?(new_file)\n self.file.content_type.include? 'image'\n end",
"def is_image?\n if self.mimetype\n self.mimetype =~ %r(image)\n elsif self.file_upload_content_type\n self.file_upload_content_type =~ %r(image)\n end\n end",
"def should_process?(image_file, image_metadata)\n true\n end",
"def image?\n document_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end",
"def valid?\n valid_format? @format\n end",
"def image?\n photo_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end",
"def square_format?\n return (self.image_width == self.image_height) ? true : false\n end",
"def not_image?(file)\n !file.content_type.include? 'image'\n end",
"def valid?\n return false if @format.nil?\n format_validator = EnumAttributeValidator.new('String', [\"mp4\", \"gif\", \"mp3\", \"jpg\", \"png\", \"bmp\"])\n return false unless format_validator.valid?(@format)\n resolution_validator = EnumAttributeValidator.new('String', [\"preview\", \"mobile\", \"sd\", \"hd\", \"1080\"])\n return false unless resolution_validator.valid?(@resolution)\n aspect_ratio_validator = EnumAttributeValidator.new('String', [\"16:9\", \"9:16\", \"1:1\", \"4:5\", \"4:3\"])\n return false unless aspect_ratio_validator.valid?(@aspect_ratio)\n fps_validator = EnumAttributeValidator.new('Float', [12, 15, 23.976, 24, 25, 29.97, 30])\n return false unless fps_validator.valid?(@fps)\n scale_to_validator = EnumAttributeValidator.new('String', [\"preview\", \"mobile\", \"sd\", \"hd\", \"1080\"])\n return false unless scale_to_validator.valid?(@scale_to)\n quality_validator = EnumAttributeValidator.new('String', [\"low\", \"medium\", \"high\"])\n return false unless quality_validator.valid?(@quality)\n true\n end",
"def acceptable_image_type?(filespec, config)\n acceptable = true\n unless config[:image_acceptable_types].nil? || config[:image_acceptable_types].empty?\n dot_ext = File.extname filespec\n no_dot_ext = dot_ext.gsub('.', '')\n acceptable = config[:image_acceptable_types].include?(dot_ext) || config[:image_acceptable_types].include?(no_dot_ext)\n end\n acceptable\n end",
"def validFile? filename\n if !filename.kind_of? String\n return false\n elsif File.exists? filename\n return File.readable? filename\n else\n return false\n end\nend",
"def valid_image_data?\n\n #There should be image data.\n unless self.data?\n errors.add(:base, \"No image data.\")\n return false\n end\n\n #There should be large thumbnail data.\n unless self.large_thumb?\n errors.add(:base, \"No large thumbnail image data.\")\n return false\n end\n\n #There should be small thumbnail data.\n unless self.small_thumb?\n errors.add(:base, \"No small thumbnail image data.\")\n return false\n end\n\n return true\n end",
"def supported_format?\n !(@file_set.mime_type & self.class.supported_formats).empty? || preservation_file&.original_filename&.first&.downcase&.include?(\".wav\")\n end",
"def not_image?(new_file)\n !self.file.content_type.include? 'image'\n end",
"def process_as_image?(extension)\n ['.png', '.jpg', '.gif', '.psd', '.jpeg'].include? extension\nend",
"def file?\n case type\n when T_REGULAR then true\n when T_UNKNOWN then nil\n else false\n end\n end",
"def image?(options)\n if (styles = options[:styles]) && !styles.empty?\n styles.values.first.is_a?(String) &&\n styles.values.first.match(/^(\\d|x)/i)\n end\n end",
"def is_type_image?\n image_types.include? self.data_content_type\n end",
"def is_file?\n !file_type.empty?\n end",
"def valid_format?(format)\n return false if format.nil?\n\n FORMATS.include? format.to_sym\n end",
"def image?\n attachment_content_type =~ %r{^(image|(x-)?application)/(bmp|gif|jpeg|jpg|pjpeg|png|x-png)$}\n end",
"def is_image_type?\n photo_content_type =~ %r(image)\n end",
"def valid?\n formats.count > 0\n end",
"def is_image?\n content_type.split('/')[0] == \"image\"\n end",
"def valid?\n return false if @file_id.nil?\n true\n end",
"def portrait_format?\n return (self.image_width < self.image_height) ? true : false\n end",
"def should_validate?(_filename)\n raise NotImplementedError\n end",
"def validate_image_type\n if save_to_temp_file\n # Override whatever user gave us with result of \"file --mime\".\n self.upload_type =\n MimeMagic.by_magic(File.open(upload_temp_file)).try(&:type)\n if upload_type&.start_with?(\"image\")\n result = true\n else\n file = upload_original_name.to_s\n file = \"?\" if file.blank?\n errors.add(:image,\n :validate_image_wrong_type.t(type: upload_type, file: file))\n result = false\n end\n end\n self.content_type = upload_type\n result\n end",
"def is_supported_file_type?(filename)\n type = filename.split('.')[1]\n return VALID_EXTENSIONS.include?(type)\nend",
"def avatar_must_be_in_correct_format\n return unless avatar.present?\n\n # FileMagic.mime { |fm| fm.file(avatar.path) }\n valid_format = [\"image/png\", \"image/jpg\", \"image/jpeg\"].include?(avatar.content_type) && [\"image/png\", \"image/jpg\", \"image/jpeg\"].include?(MimeMagic.by_magic(avatar)&.type)\n errors.add(:avatar, :content_type_invalid) unless valid_format\n\n valid_size = avatar.size <= 2.megabytes\n errors.add(:avatar, :file_size_out_of_range, filesize: avatar.size) unless valid_size\n end",
"def file_has_valid_extension?\n file_extension = File.extname(@filename)\n ACCEPTED_FILE_EXTENSIONS.include? file_extension\n end",
"def check_image_format(img_header)\n hstr = img_header.unpack(\"H*\").first\n mime = { \"unk\" => \"application/octet-stream\",\n \"jpg\" => \"image/jpeg\",\n \"png\" => \"image/png\",\n \"gif\" => \"image/gif\",\n \"bmp\" => \"image/x-bmp\",\n \"pic\" => \"image/pict\",\n \"tif\" => \"image/tiff\" \n }\n \n result = \"unk\"\n result = \"jpg\" if hstr[0, 4] == \"ffd8\"\n result = \"png\" if hstr == \"89504e47\"\n result = \"gif\" if hstr == \"47494638\"\n resutl = \"bmp\" if hstr[0, 4] == \"424d\"\n result = \"pic\" if hstr[0, 6] == \"504943\"\n result = \"tif\" if hstr[0, 4] == \"4949\" || hstr[0, 4] == \"4d4d\"\n return result, mime[result]\n end",
"def image?\n self.sti_type == IMAGE_TYPE\n end",
"def is_png\n return @is_png unless @is_png.nil?\n @is_png = png_header == [137, 80, 78, 71, 13, 10, 26, 10].pack('C*')\n @is_png\n end",
"def raster_file?\n false\n end",
"def valid_image(image_path)\n image_path.exist? && image_path.size < 32.kilobytes\n end",
"def valid?\n return false if @save_format.nil?\n save_format_validator = EnumAttributeValidator.new('String', [\"VDX\", \"VSX\", \"VTX\", \"TIFF\", \"PNG\", \"BMP\", \"EMF\", \"JPEG\", \"PDF\", \"XPS\", \"GIF\", \"HTML\", \"SVG\", \"SWF\", \"XAML\", \"VSDX\", \"VSTX\", \"VSSX\", \"VSDM\", \"VSSM\", \"VSTM\"])\n return false unless save_format_validator.valid?(@save_format)\n return false if @area.nil?\n tiff_compression_validator = EnumAttributeValidator.new('String', [\"None\", \"Rle\", \"Ccitt3\", \"Ccitt4\", \"Lzw\"])\n return false unless tiff_compression_validator.valid?(@tiff_compression)\n image_color_mode_validator = EnumAttributeValidator.new('String', [\"None\", \"Grayscale\", \"BlackAndWhite\"])\n return false unless image_color_mode_validator.valid?(@image_color_mode)\n pixel_offset_mode_validator = EnumAttributeValidator.new('String', [\"Default\", \"HighSpeed\", \"HighQuality\", \"None\", \"Half\", \"Invalid\"])\n return false unless pixel_offset_mode_validator.valid?(@pixel_offset_mode)\n smoothing_mode_validator = EnumAttributeValidator.new('String', [\"Default\", \"HighSpeed\", \"HighQuality\", \"None\", \"AntiAlias\", \"Invalid\"])\n return false unless smoothing_mode_validator.valid?(@smoothing_mode)\n compositing_quality_validator = EnumAttributeValidator.new('String', [\"Default\", \"HighSpeed\", \"HighQuality\", \"GammaCorrected\", \"AssumeLinear\", \"Invalid\"])\n return false unless compositing_quality_validator.valid?(@compositing_quality)\n interpolation_mode_validator = EnumAttributeValidator.new('String', [\"Default\", \"Low\", \"High\", \"Bilinear\", \"Bicubic\", \"NearestNeighbor\", \"HighQualityBilinear\", \"HighQualityBicubic\", \"Invalid\"])\n return false unless interpolation_mode_validator.valid?(@interpolation_mode)\n return true\n end",
"def image?\n self.image.file?\n end",
"def image?\n self.image.file?\n end",
"def is_supported_format\n if zip? || csv?\n true\n else\n errors.add(:input, :unsupported_file_format)\n end\n end",
"def allow_only_images\n unless file.content_type =~ %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|gif|png|tif|raw|bmp|svg|)$}\n false\n end\n end",
"def acceptable_image\n return unless image.attached?\n\n errors.add(:image, 'is too big') unless image.byte_size <= 1.megabyte\n\n acceptable_types = %w[image/jpeg image/png]\n return if acceptable_types.include?(image.content_type)\n\n errors.add(:image, 'must be a JPEG or PNG')\n end",
"def uses_extension?\n @format =~ /\\.[^\\.]+$/\n end",
"def landscape_format?\n return (self.image_width > self.image_height) ? true : false\n end",
"def valid?(options = {})\n @error =\n if blank?\n \"source_data is blank\"\n elsif !valid_mime_type?\n \"source_data mime-type is invalid - #{mime_type}\"\n elsif one_pixel?\n \"source_data is a 1x1 image\"\n elsif size_too_big?\n \"source_data file size too big\"\n end\n @error.nil?\n end",
"def is_image_type?\n background_media.content_type =~ %r(image)\n end",
"def invalid_format?(format)\n return true unless FORMATS.include?(format)\n end",
"def check_acceptable_format\n raise ActiveRecord::RecordNotFound if [\"txt\", \"png\"].include?(params[:format] )\n end",
"def isImage\n if self.image.attached? && self.image.content_type.in?(\"%w{image/jpeg,image/png,image/jpg}\")\n return true\n else\n return false\n end\n end",
"def valid_readers_format?\n VALID_READER_FORMAT.include? uri_extension\n end",
"def valid?\n return false if !super\n pictures_compression_validator = EnumAttributeValidator.new('String', ['Dpi330', 'Dpi220', 'Dpi150', 'Dpi96', 'Dpi72', 'DocumentResolution'])\n return false unless pictures_compression_validator.valid?(@pictures_compression)\n external_fonts_handling_validator = EnumAttributeValidator.new('String', ['AddLinksToFontFiles', 'Embed', 'Vectorize'])\n return false unless external_fonts_handling_validator.valid?(@external_fonts_handling)\n true\n end",
"def check_if_image?\n !(attachment_content_type =~ /^image.*/).nil?\n end",
"def image?\n self.content_type.to_s.index(/image/).nil?\n end",
"def image?\n @image ||= !!(attachment_content_type =~ /^image\\/.+/)\n end",
"def image?\n self.type == \"Image\"\n end",
"def layer_file?(filename)\n !check_layer_pattern(filename).nil?\nend",
"def format(file)\n\n qemu_command = @options.qemu_img_binary || Itchy::BASIC_QEMU_COMMAND\n\n image_format_tester = Mixlib::ShellOut.new(\"#{qemu_command} info #{file}\")\n image_format_tester.run_command\n begin\n image_format_tester.error!\n rescue Mixlib::ShellOut::ShellCommandFailed, Mixlib::ShellOut::CommandTimeout,\n Mixlib::ShellOut::InvalidCommandOption => ex\n Itchy::Log.error \"[#{self.class.name}] Checking file format for\" \\\n \"#{file} failed!\"\n fail Itchy::Errors::FileInspectError, ex\n end\n file_format = image_format_tester.stdout.scan(FORMAT_PATTERN)[0].flatten.first\n unless KNOWN_IMAGE_FORMATS.include? file_format\n Itchy::Log.error \"Image format #{file_format} is unknown and not supported!\"\n fail Itchy::Errors::FileInspectError\n end\n if file_format.eql? \"raw\" then\n unless check_real_raw(file)\n\t Itchy::Log.error \"Image format is not a real RAW, it has no boot sector!\"\n fail Itchy::Errors::FileInspectError\n end\n end\n \n file_format\n end",
"def has_image?(image)\n # FIXME\n true\n end",
"def valid?\n html_version_validator = EnumAttributeValidator.new('String', [\"Xhtml\", \"Html5\"])\n return false unless html_version_validator.valid?(@html_version)\n metafile_format_validator = EnumAttributeValidator.new('String', [\"Png\", \"Svg\", \"EmfOrWmf\"])\n return false unless metafile_format_validator.valid?(@metafile_format)\n office_math_output_mode_validator = EnumAttributeValidator.new('String', [\"Image\", \"MathML\", \"Text\"])\n return false unless office_math_output_mode_validator.valid?(@office_math_output_mode)\n return true\n end",
"def file?\n type == :file\n end",
"def is_image?\n !(attachment_content_type =~ /^image.*/).nil?\n end",
"def is_supported? filename\n a = filename.split('.')\n $extensions.each do |e|\n return true if e == a.last.downcase\n end\n return false\n end",
"def image?\n image ? true : false\n end",
"def is_processed_image? picture\n model.class.to_s.underscore == \"pimage\"\n end",
"def accept_file(file, name, kind)\n logger.debug \"FileHelper is accepting file: filename=#{file.filename}, name=#{name}, kind=#{kind}\"\n\n fm = FileMagic.new(FileMagic::MAGIC_MIME)\n mime = fm.file file.tempfile.path\n logger.debug \"#{name} has MIME type: #{mime}\"\n\n valid = true\n\n case kind\n when 'image'\n accept = [\"image/png\", \"image/gif\", \"image/bmp\", \"image/tiff\", \"image/jpeg\", \"image/x-ms-bmp\"]\n when 'code'\n accept = [\"text/x-pascal\", \"text/x-c\", \"text/x-c++\", \"text/plain\", \"text/\"]\n when 'document'\n accept = [ # -- one day\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n # --\"application/msword\",\n \"application/pdf\" ]\n valid = pdf_valid? file.tempfile.path\n else\n logger.error \"Unknown type '#{kind}' provided for '#{name}'\"\n return false\n end\n\n # result is true when...\n mime.start_with?(*accept) && valid\n end"
] |
[
"0.833717",
"0.80348176",
"0.7844336",
"0.77031714",
"0.76832324",
"0.76832324",
"0.767027",
"0.75332147",
"0.75325483",
"0.75274813",
"0.73949313",
"0.73759717",
"0.7371084",
"0.73615336",
"0.7313972",
"0.7296801",
"0.7254463",
"0.7242669",
"0.7222223",
"0.72180223",
"0.71974397",
"0.7193991",
"0.71768296",
"0.7174585",
"0.71499956",
"0.71441257",
"0.7143356",
"0.71346706",
"0.7128057",
"0.71112084",
"0.71017617",
"0.7055674",
"0.7003004",
"0.70023835",
"0.698635",
"0.6979237",
"0.69721615",
"0.69287926",
"0.6923515",
"0.6896588",
"0.689007",
"0.6859148",
"0.6839628",
"0.6827175",
"0.67682225",
"0.675327",
"0.6747236",
"0.6738953",
"0.66991043",
"0.6689887",
"0.6682883",
"0.66756946",
"0.66634315",
"0.66543174",
"0.66490686",
"0.66424793",
"0.6639933",
"0.6631439",
"0.6623478",
"0.65745306",
"0.65662736",
"0.6562001",
"0.6556276",
"0.6554816",
"0.65491223",
"0.65468764",
"0.6529952",
"0.64979416",
"0.64880586",
"0.6475328",
"0.64737517",
"0.646529",
"0.64605206",
"0.64605206",
"0.64402646",
"0.64342195",
"0.6430822",
"0.64307976",
"0.64307237",
"0.64259946",
"0.6425616",
"0.64210254",
"0.6399347",
"0.6396532",
"0.63814",
"0.63807714",
"0.63623947",
"0.6347601",
"0.6345926",
"0.63444555",
"0.63438636",
"0.6339442",
"0.6331468",
"0.6330959",
"0.632605",
"0.63259524",
"0.63253915",
"0.6321865",
"0.6312248",
"0.63113827"
] |
0.876727
|
0
|
Add an element to the back of the queue.
|
def enqueue(value)
@count += 1
new_element = RubyDS::StackQueue::Element.new(value)
# If this is the first element, just assign the head and tail.
if @head.nil?
@head = new_element
@tail = @head
# Add the element as a new tail.
else
@tail.next = new_element
@tail = @tail.next
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def enqueue(element)\n # check if queue is full \n raise ArgumentError, \"Queue is full\" if (@back + 1) % MAX_BUFFER == @front \n # check if queue is empty\n # empty queue\n if @front < 0\n @front = @back = 0\n # overflow to wrap around\n elsif @back == MAX_BUFFER - 1 # raise block will check for a full queue\n @back = 0\n @store[@back] = element\n # okay to just add\n else \n @back += 1\n end \n @store[@back] = element\n end",
"def add_to_back(item)\n @array << item\n end",
"def enqueue(element)\n # if queue is full or the element you're trying to add = nil, item cannot be added to the queue\n if full? or element.nil?\n nil\n else\n # 1 subtracted from @tail because the queue is going to be one item longer now\n @tail = @tail.pred\n # last element in the queue is set equal to the element you passed in as an argument\n @store[@tail] = element\n # returns the Queue\n self\n end\n end",
"def enqueue(element)\n if element.class.name == \"RealQueue\"\n require 'pry'\n binding.pry\n end\n @store.unshift(element)\n self\n end",
"def pop()\n @queue.shift\n end",
"def push(element)\n @store.push(element)\n @top += 1\n end",
"def pop()\n @size -= 1 \n @queue.shift\n end",
"def enqueue(element)\n @items.push(element)\n nil\n end",
"def enqueue(element)\n @queue.insert(@queue.length, element)\n @head = @queue.first\n @tail = @queue.last\n end",
"def enqueue(element)\n # raise NotImplementedError, \"Not yet implemented\"\n #check if front is empty\n if @front == -1\n #then rear is 1 and front is now 0\n @rear = 1\n @front = 0\n #access the element in the store array\n @store[@front] = element\n #otherwise if front IS the rear, then the queue is full\n elsif @front == @rear \n raise Error,\"Tis Full\"\n #not empty\n #calculate new rear then set it as the element\n #set original rear to new rear\n else\n new_rear = (@rear + 1) % queue_size\n @store[@rear] = element\n @rear = new_rear\n end\n end",
"def enqueue(el)\n @queue << el\n el\n end",
"def push(element)\t\t\n\t\twhile !@q1.empty? do\n\t\t\t@q2.enq(@q1.pop) # Dequeue element from queue q1 and enque the same to q2\n\t\tend\n\t\t@q1.enq(element)\n\t\twhile !@q2.empty? do\n\t\t\t@q1.enq(@q2.pop) # Dequeue element from queue q2 and enque the same to q1\n\t\tend\t\n\tend",
"def dequeue\n\t\t@queue.shift\n\tend",
"def shift\n @lock.synchronize do\n @queue.shift\n end\n end",
"def queue(&b)\n @queue << b\n end",
"def dequeue\n @queue.shift\n end",
"def add!(item)\n @queue[item] = item\n end",
"def add(element)\n synchronize do\n @queue.push element\n @cond.signal\n end\n end",
"def add(element)\n synchronize do\n @queue.push element\n @cond.signal\n end\n end",
"def add(element)\n synchronize do\n @queue.push element\n @cond.signal\n end\n end",
"def add element\n add_last(element)\n end",
"def add element\n add_last(element)\n end",
"def _put_back_on_queue(message)\n future = nil\n _redis.multi do\n _redis.rpush(@queue, message)\n future = _redis.lrem(@in_progress_queue, 1, message)\n end\n removed = future.value\n if removed !=1\n RailsPipeline.logger.error \"ERROR: Didn't remove message from in_progress queue?!!!\"\n end\n end",
"def enqueue(el)\n @queue.push(el)\n end",
"def push(x)\n @queue << x\n end",
"def push(element)\n # we can't put nil onto the stack, and we can't add to the stack if it is full\n if full? or element.nil?\n nil\n else\n # we need to move our top marker to the new element, which is now the top\n @top = @top.succ\n # and we actually put that element here, in our new top index\n @store[@top] = element\n # explicit return of the stack, i think\n self\n end\n end",
"def remove\n @queue.shift\n end",
"def move_higher_in_queue\n return unless higher_item_in_queue\n\n acts_as_queue_class.transaction do\n higher_item_in_queue.increment_queue_position\n decrement_queue_position\n end\n end",
"def remove\n @queue.shift\n end",
"def remove\n @queue.shift\n end",
"def push(element)\n # add element to the head of @store\n @store.add_first(element)\n end",
"def enqueue(ele)\n @push_stack.push(ele)\n end",
"def dequeue; @queue.pop end",
"def push_back(data)\n insert(data, @size)\n end",
"def dequeue\n @q.shift\n end",
"def move_to_bottom_in_queue\n return unless in_queue?\n acts_as_queue_class.transaction do\n decrement_queue_positions_on_lower_items\n assume_bottom_queue_position\n end\n end",
"def enqueue(el)\n @queue.push(el)\n true\n end",
"def pop()\n @q.shift\n end",
"def enqueue(element)\n #if the array is already at the max length @size, or if the elemennt we are trying to add is nil, do nothing\n if full? or element.nil?\n nil\n else\n #subtracts 1 from @tail\n @tail = @tail.pred\n #sets the value of the element at the tail of the array to the value of element.\n @store[@tail] = element\n #returns it self\n self\n end\n end",
"def push(v)\n @que << v\n reheap(@que.size-1)\n self\n end",
"def enqueue(element)\n raise 'Queue is full' if self.full?\n\n @queue[@tail] = element\n\n # Check to see if the queue was first initialized\n if @head.nil?\n @head = 0\n end\n\n # Check to see if tail is the first element\n if @tail == @length - 1\n @tail = 0\n else\n @tail += 1\n end\n end",
"def add(element)\n @push_stack.push(element)\n end",
"def push(x)\n @q << x \n end",
"def peek; @queue[-1] end",
"def dequeue\n @items.shift\n end",
"def insert_last(value)\n if @queue.size < @size\n @queue.push(value)\n true\n else\n false\n end\n end",
"def queue(a)\n p \"Before: #{a}\"\n a.push(6)\n a.shift(1)\n p \"After: #{a}\"\nend",
"def enqueue(new_element)\n if is_empty?\n @front = @rear = 0\n elsif is_full\n puts \"Queue is full or create another array and copy queue\" \n return\n else\n @rear = (@rear + 1) % @size_of_array\n end\n @queue_array[@rear] = new_element\t\n end",
"def dequeue\n last_el = self.queue_var[-1]\n self.queue_var = self.queue_var[0...-1]\n last_el \n end",
"def insert_front(value)\n if @queue.size < @size\n @queue.unshift(value)\n true\n else\n false\n end\n end",
"def dequeue\n @store.shift\n end",
"def enqueue(el)\n self.queue_var = [el] + self.queue_var \n end",
"def push(x)\n @queue.push(x)\n nil\n end",
"def push(element)\n # if Stack is full or the element you're trying to add = nil, cannot add anything\n if full? or element.nil?\n nil\n else\n # +1 added to @top because there is one more item in the Stack\n @top = @top.succ\n # new item actually added to @store array\n @store[@top] = element\n # returns Stack\n self\n end\n end",
"def push(value)\n @count += 1\n new_element = RubyDS::StackQueue::Element.new(value)\n if @head.nil?\n @head = new_element\n else\n new_element.next = @head\n @head = new_element\n end\n end",
"def shift!\n shifted = @queue.shift\n\n return nil if shifted.nil?\n shifted[0]\n end",
"def shift\n return nil if empty?\n @que.shift\n end",
"def push(element)\n @store << element #putting the element into the array, thereby putting it into the stack\n end",
"def push(element)\n #if the stack is already full or the element is nil, do nothing\n if full? or element.nil?\n nil\n else\n #Add 1 to the value of @top\n @top = @top.succ\n #sets the value at the top of the stack to element\n @store[@top] = element\n #returns it self\n self\n end\n end",
"def push(val)\n resize! if self.length == self.capacity\n self.length += 1 \n self[length - 1] = val \n nil \n end",
"def push(x) \n @queue.insert(x)\n self\n end",
"def pop()\n new_queue = Queue.new\n until @queue.size == 1\n new_queue << @queue.pop\n end\n last = @queue.pop\n @queue = new_queue\n last\n end",
"def push(x)\n @size += 1\n @queue_in.push(x)\n end",
"def enqueue(element)\n @in.push(element)\n end",
"def add(value)\n @queue.push(value)\n end",
"def push(val)\n resize! if length == capacity\n self.length += 1\n self[length - 1] = val\n end",
"def enqueue(item)\n\t\t@queue << item\n\tend",
"def dequeue\n @data.shift\n end",
"def pushback(data)\n @pushback_buffer << data\n end",
"def queue notification\n @notification_queue.unshift notification\n end",
"def dequeue\n\t\t\tself.pop\n\t\tend",
"def push(val)\n resize! if @length == @capacity\n self.length += 1\n self[length - 1] = val\n\n nil\n end",
"def push(element)\n #if the stack is full or the element is nil don't add it to the stack\n if full? or element.nil?\n nil\n else\n #increment top by one\n @top = @top.succ\n #store the element in the new top's position\n @store[@top] = element\n #return the instance of the stack\n self\n end\n end",
"def push(element)\n #if the stack is full or the element is nil don't add it to the stack\n if full? or element.nil?\n nil\n else\n #increment top by one\n @top = @top.succ\n #store the element in the new top's position\n @store[@top] = element\n #return the instance of the stack\n self\n end\n end",
"def push(x)\n @store.unshift(x)\n end",
"def push(element); end",
"def pop\n _exchange\n end",
"def push(element)\n @store.push(element)\n self\n end",
"def dequeue\n # check if queue is empty \n raise ArgumentError, \"Queue is empty\" if self.empty? \n \n element = @store[@front]\n \n # check last element removed\n if (@front == @back)\n @front = @back = -1 \n elsif @front + 1 == MAX_BUFFER\n @front = 0\n # nominal case\n else\n @front += 1\n end\n\n return element\n end",
"def push(element)\r\n # IMPLEMENTME!\r\n end",
"def pop\n if @queue.empty?\n nil\n else\n tempArr = []\n while @queue.size > 1\n tempArr.push(@queue.remove)\n end\n tempItem = @queue.remove\n while !tempArr.empty?\n @queue.insert(tempArr.pop)\n end\n tempItem\n end\n end",
"def push(x)\n p = @stack.unshift(x)\n @q.insert(p)\n self\n end",
"def push(x)\n @size += 1\n @queue_in.push(x)\n end",
"def en_queue(value)\n return false if self.is_full\n\n @queue[@rear] = value\n if @rear == @queue.size - 1\n @rear = 0\n else\n @rear += 1\n end\n true\n end",
"def push(item)\n @stack.unshift(item)\n self.top = @stack[0]\n end",
"def push(x)\n @queue.push(x)\n i = 0 \n while i < @size\n @queue.push(@queue.shift)\n i += 1\n end\n \n @size += 1\n return\n end",
"def enqueue(element)\n # beginnig of if statement\n # if the method full? returns true or the value of the local var element is nil\n if full? or element.nil?\n # return nil\n nil\n # if the method full? returns false or the value of the local var element is not nil\n else\n # subtract one from the value of the instance var @tail\n # and assign the value back to the instance var @tail\n @tail = @tail.pred\n # assign the value of the local var element\n # to the position in the array @store at the value of @tail\n @store[@tail] = element\n # return the value self\n self\n # end the if/else statement\n end\n # end the enqueue method\n end",
"def pop() end",
"def enqueue(el)\n @maxqueue.push(el) if @maxqueue.length.zero?\n\n @store.push(el)\n while @maxqueue[0] < el\n @maxqueue.pop\n break if @maxqueue.length.zero?\n end\n @maxqueue.push(el)\n end",
"def move_lower_in_queue\n return unless lower_item_in_queue\n\n acts_as_queue_class.transaction do\n lower_item_in_queue.decrement_queue_position\n increment_queue_position\n end\n end",
"def push_to_queue(queue, item)\n queue.push(item)\nrescue Exception => e\n puts \"Rescued #{e}\"\nend",
"def dequeue\n @store.pop\n end",
"def push(obj)\n if @blocked\n raise \"Nothing can be added to queue. Queue is blocked.\"\n else\n super(obj)\n end\n end",
"def remove\n @queue.pop\n end",
"def pop\n if @q.empty?\n raise QueueEmptyError, \"tried to pop empty queue in #{@component.inspect}\"\n end\n obj = @q.shift\n @component.dec_queue_ready_count if @q.empty?\n obj\n end",
"def enqueue(object_)\n result_ = true\n if @push_ptr\n if @pop_ptr == @push_ptr\n if @drop_oldest\n @pop_ptr += 1\n @pop_ptr = 0 if @pop_ptr == @buffer.size\n result_ = false\n else\n return false\n end\n elsif @pop_ptr.nil?\n @pop_ptr = @push_ptr\n end\n @buffer[@push_ptr] = object_\n @push_ptr += 1\n @push_ptr = 0 if @push_ptr == @buffer.size\n else\n @buffer.push(object_)\n end\n result_\n end",
"def rear()\n self.is_empty ? -1 : @queue[@rear - 1]\n end",
"def push(obj)\n @mutex.synchronize{\n @que.push obj\n begin\n t = @waiting.shift\n t.wakeup if t\n rescue ThreadError\n retry\n end\n }\n end",
"def push(el)\n @stack.push(el)\n end",
"def move_to_top_in_queue\n return unless in_queue?\n acts_as_queue_class.transaction do\n increment_queue_positions_on_higher_items\n assume_top_queue_position\n end\n end"
] |
[
"0.7357119",
"0.73463136",
"0.7239424",
"0.7110687",
"0.7106543",
"0.70823455",
"0.7080123",
"0.70234406",
"0.7020333",
"0.70193166",
"0.70031816",
"0.6946783",
"0.6945872",
"0.69430137",
"0.6936727",
"0.6934237",
"0.69150364",
"0.69095725",
"0.69043934",
"0.69043934",
"0.68719894",
"0.68719894",
"0.6867104",
"0.6856311",
"0.68376434",
"0.68345356",
"0.682585",
"0.68245155",
"0.6807778",
"0.6806045",
"0.67846733",
"0.6782501",
"0.6781497",
"0.677273",
"0.6768559",
"0.67441493",
"0.6739854",
"0.6727071",
"0.67262644",
"0.6717868",
"0.66910225",
"0.6682836",
"0.66496676",
"0.6649005",
"0.66479784",
"0.6641782",
"0.6629415",
"0.66248536",
"0.6623295",
"0.66078395",
"0.6601394",
"0.65784323",
"0.6571978",
"0.65707433",
"0.6564274",
"0.65489686",
"0.65376043",
"0.65363306",
"0.652961",
"0.6517072",
"0.65138847",
"0.6513131",
"0.6511354",
"0.6508156",
"0.6505774",
"0.65021306",
"0.6500204",
"0.6499984",
"0.6498794",
"0.6497028",
"0.64807034",
"0.6477084",
"0.6457431",
"0.6457431",
"0.6446182",
"0.6432228",
"0.6430093",
"0.64231265",
"0.6416851",
"0.6414381",
"0.6403967",
"0.6396949",
"0.63895863",
"0.6374602",
"0.6363713",
"0.6346594",
"0.6345769",
"0.6342015",
"0.6340046",
"0.63269836",
"0.63197255",
"0.6277538",
"0.6260417",
"0.6258499",
"0.625468",
"0.6241423",
"0.62397057",
"0.6237208",
"0.6233972",
"0.6230101"
] |
0.643976
|
75
|
Remove the element from the head of the queue and return its value.
|
def dequeue
return nil if @head.nil?
# Remove the head element and return the value.
@count -= 1
old_node = @head
@head = @head.next
old_node.next = nil
# We can also nullify the tail if the head is nil now.
@tail = nil if @head.nil?
old_node.value
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pop()\n head = @head\n if head == nil then\n return nil\n end\n @head = head.prev\n return head.val\n end",
"def pop\n if @queue.empty?\n nil\n else\n tempArr = []\n while @queue.size > 1\n tempArr.push(@queue.remove)\n end\n tempItem = @queue.remove\n while !tempArr.empty?\n @queue.insert(tempArr.pop)\n end\n tempItem\n end\n end",
"def pop\n\t\tif (!@head) then return nil end\n\t\ttemp = @head\n\t\t@head = @head.get_next()\n\t\tif (@head) then @head.set_prev(nil)\n\t\telse @tail = nil\n\t\tend\n\t\t@size -= 1\n\t\treturn temp.get_item()\n\tend",
"def pop\n return nil if @head.nil?\n\n to_remove = @head\n @head = @head.next\n to_remove.next = nil\n @count -= 1\n\n to_remove.value\n end",
"def pop\n node = remove_node(head)\n return nil unless node\n self.size -= 1\n node.data\n end",
"def pop\r\n return nil if @head == nil\r\n res = @head\r\n @head = @head.next_node\r\n return res.value\r\n end",
"def pop()\n res = @pop_queue.shift()\n return res\n end",
"def pop()\n @queue.shift\n end",
"def pop()\n head_index = get_document(@head_index_key)\n tail_index = get_document(@tail_index_key)\n if tail_index > head_index # if there is an item in the queue\n increase_atomic_count(@head_index_key) #incremented new_head_index is ignored, but we are incrementing and popping value\n return get_document(\"#{@key}::#{head_index + 1}\")\n else # \n nil\n end\n end",
"def pop\n if empty?\n nil\n else\n @q.remove\n @stack.shift\n end\n end",
"def pop()\n \n return nil if @head.nil?\n \n result = @head\n \n @head.next_node.nil? ? @head = nil : @head = @head.next_node \n \n result.val\n end",
"def dequeue\n raise 'Queue is empty' if self.empty?\n\n el = @queue[@head]\n\n if @head == @length - 1\n @head = 0\n else\n @head += 1\n end\n\n if @head == @tail\n self.reset\n end\n\n return el\n end",
"def remove\n unless self.empty?\n swap(0, @store.length - 1)\n removed_node = @store.pop\n\n heap_down(0)\n\n return removed_node.value\n end\n end",
"def dequeue\n #if the queue is already empty, does nothing\n if empty?\n nil\n\n else\n #adds 1 to @tail\n @tail = @tail.succ\n #sets a local variable to the value at the top of the array\n dequeued = @store[@head]\n #adds nil to the tail of the array\n @store.unshift(nil)\n #takes off the element at the top of the array\n @store.pop\n #returns the value that was at the top of the array that has just been removed\n dequeued\n end\n end",
"def pop\n old = @tail\n if @tail == nil\n return nil\n else\n prev = @tail\n @tail = @tail.prev_value\n @length -= 1\n return prev.value\n end\n end",
"def dequeue\n # if queue is empty, cannot remove anything\n if empty?\n nil\n else\n # +1 added to @tail because the queue is going to be one item shorter now\n @tail = @tail.succ\n # dequeued is set equal to the item at the front of the queue\n dequeued = @store[@head]\n # adds a nil to the \"front\" of @store (but this is actually the back of the queue)\n @store.unshift(nil)\n # removes the last item from @store (first item in the queue)\n @store.pop\n # returns the item removed from the queue\n dequeued\n end\n end",
"def dequeue\n # check if queue is empty \n raise ArgumentError, \"Queue is empty\" if self.empty? \n \n element = @store[@front]\n \n # check last element removed\n if (@front == @back)\n @front = @back = -1 \n elsif @front + 1 == MAX_BUFFER\n @front = 0\n # nominal case\n else\n @front += 1\n end\n\n return element\n end",
"def dequeue\n @mutex.synchronize do\n # Check if the queue is empty.\n if @head == @tail # not using empty? to avoid extra synchronize block\n return nil\n end\n\n # Remove next object.\n object = @queue[@head]\n @queue[@head] = nil\n\n @head = (@head + 1) & @max_mask\n return object\n end\n end",
"def pop\n if @q.empty?\n raise QueueEmptyError, \"tried to pop empty queue in #{@component.inspect}\"\n end\n obj = @q.shift\n @component.dec_queue_ready_count if @q.empty?\n obj\n end",
"def pop\n entry = queue.pop[:payload]\n if (entry != :queue_empty)\n Marshal.load(entry)\n else\n nil\n end\n end",
"def pop()\n @q.shift\n end",
"def remove\n @queue.shift\n end",
"def remove()\n \n swap(0, @store.length - 1)\n removed = @store.pop()\n \n heap_down(0) unless @store.empty?\n \n return removed.value\n end",
"def pop\n value = @head.value\n @head = @head.next_node\n if isEmpty?\n @tail = nil\n end\n value\n end",
"def pop\n return_value = @head.value\n @head = @head.next_node\n return return_value\n end",
"def remove()\n return nil if @store.empty? \n swap(0, @store.length - 1)\n result = @store.pop.value\n \n heap_down(0) unless @store.empty?\n return result \n end",
"def remove\n @queue.shift\n end",
"def pop\n if @length == 0\n return nil\n elsif @length == 1\n node = @head\n @head = nil\n @tail = nil\n @length -= 1\n return node.value\n else\n node = @tail\n @tail = node.previous\n @length -= 1\n return node.value\n end\n end",
"def pop()\n @size -= 1 \n @queue.shift\n end",
"def pop\n if @tail != nil\n ret = @tail\n @tail = @tail.previous\n if @tail != nil\n @tail.next_node = nil\n end\n @length -= 1\n if @head == ret\n @head = nil\n end\n return ret.value\n elsif @head\n ret = @head\n @head = nil\n @length -= 1\n return ret.value\n else\n return nil\n end\n end",
"def pop\n if @tail != nil\n ret = @tail\n @tail = @tail.previous\n if @tail != nil\n @tail.next_node = nil\n end\n @length -= 1\n if @head == ret\n @head = nil\n end\n return ret.value\n elsif @head\n ret = @head\n @head = nil\n @length -= 1\n return ret.value\n else\n return nil\n end\n end",
"def remove\n @queue.shift\n end",
"def dequeue()\n node = @first\n @first = @first.next \n return node.value\n end",
"def pop\n if data\n element = data\n @data = data.next_node\n return element.value\n else\n return nil\n end\n end",
"def pop\n @mutex.synchronize do\n loop do\n if @queue.empty?\n @waiting.push Thread.current\n @mutex.sleep\n else\n return @queue.shift\n end\n end\n end\n end",
"def remove\n swap(0, self.heap.length-1, self.heap)\n value_to_remove = self.heap.pop\n self.sift_down(0, self.heap.length-1, heap)\n return value_to_remove\n end",
"def pop_head\n\n\t\tif(@head == nil)\n\t\t\treturn nil\n\t\t \telse\n\t\t val= @head\n\t\t node = @head.next\n\t\t @head = node\n\t\t if @head != nil\n\t\t \t@head.prev = nil\n\t\t else\n\t\t \t@tail = nil\n\t\t end\n\t\t @sz = @sz -1\n\t\tend\n\n\t\treturn val\n end",
"def remove()\n return nil if !@store\n\n swap(0, @store.length - 1)\n nope = @store.pop\n\n heap_down(0)\n return nope.value\n end",
"def pop\n item = @first.val\n @first = @first.next\n @last = nil if(@first == nil)\n @size -= 1\n item\n end",
"def pop\n @lock.synchronize do\n @queue.pop\n end\n end",
"def pop\n return nil if head.nil?\n\n curr = head\n if curr.next.nil?\n @head = nil\n return curr\n end\n curr = curr.next until curr.next.next.nil?\n last = curr.next\n curr.next = nil\n last.value\n end",
"def pop\n tmp = @data.value rescue nil\n @data = @data.next_node unless @data.nil?\n return tmp\n end",
"def remove_first\n raise 'No such element' if @size == 0\n elt = @head.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @head = @head.next\n @head.previous.next = nil\n @head.previous = nil\n end\n @size -= 1\n return elt\n end",
"def pop\n\t\treturn nil if @q1.empty?\n\t\t@q1.pop # Dequeue element from queue and return the same \n\tend",
"def remove()\n return if @store.empty?\n last = @store.length - 1\n curr = 0\n swap(last, curr)\n removed = @store.pop\n heap_down(curr)\n return removed.value\n end",
"def removeHead\n\t\tif @head != nil\n\t\t\tn = @head\n\t\t\t@head = n.nnode\n\t\t\tn.nnode = nil\n\t\t\treturn n.value\n\t\tend\n\tend",
"def remove()\n return if @store.empty?\n\n swap(0, @store.length - 1)\n banished = @store.pop\n heap_down(0)\n\n return banished.value\n end",
"def remove()\n removed = @store[0].value\n swap(0, @store.length - 1)\n @store.pop\n heap_down(0)\n return removed\n end",
"def remove\n if empty?\n raise \"Can't remove if queue is empty\"\n else\n @info.shift\n end\n end",
"def remove\n if empty?\n raise \"Can't remove if queue is empty\"\n else\n @info.shift\n end\n end",
"def remove\n if empty?\n raise \"Can't remove if queue is empty\"\n else\n @info.shift\n end\n end",
"def pop\n return nil if empty?\n @que.pop\n end",
"def remove\n # Can you delete any other node besides the root?\n return nil if @store.empty?\n\n swap(0, @store.length - 1)\n target = @store.pop\n\n heap_down(0)\n return target.value\n end",
"def shift!\n shifted = @queue.shift\n\n return nil if shifted.nil?\n shifted[0]\n end",
"def pop\n return nil unless @tail\n value = @tail[:data].pop\n @tail = @tail[:forward] while @tail and @tail[:data].size == 0\n @set.delete(value)\n value\n end",
"def remove_first\n raise 'Cannot remove element from an empty list.' if empty?\n\n # Extract the data off of the head node\n # Move the head to the next node\n data = @head.data\n @head = @head.next_node\n @size -= 1\n\n # removes the same element from @tail, if it was final element/node\n if empty?\n @tail = nil\n else\n # send to garbage collector\n @head.prev_node = nil\n end\n\n return data\n end",
"def remove_first\n raise 'Cannot remove element from an empty list.' if empty?\n\n # Extract the data off of the head node\n # Move the head to the next node\n data = @head.data\n @head = @head.next_node\n @size -= 1\n\n # removes the same element from @tail, if it was final element/node\n if empty?\n @tail = nil\n end\n\n return data\n end",
"def pop!\n @mutex.synchronize do\n loop do\n if @queue.empty?\n raise ThreadError, \"Empty Channel\"\n @waiting.push Thread.current\n @mutex.sleep\n else\n return @queue.shift\n end\n end\n end\n end",
"def remove\n @queue.pop\n end",
"def pop()\n return \"Stack is empty\" if is_empty\n\n if @head.next == nil\n temp = @head.value\n @head = nil\n return temp\n end\n\n temp = @head.value\n @head = @head.next\n @current_size -= 1\n\n return temp\n end",
"def pop\n if @head.nil?\n return false\n else \n temp = @head.value\n @head = @head.next_node\n return temp\n end\n end",
"def pop\n return unless @head\n popped = @head\n \n if @head.to\n new_head = @head.to\n new_head.from = nil\n @head = new_head\n size += 1\n else\n empty!\n end\n\n popped.obj\n end",
"def remove()\n if @head == nil\n puts \"There is nothing to remove.\"\n elsif @head.next == nil\n puts \"#{@tail.data} has been removed from the Queue.\"\n @head = nil\n @tail = nil\n else\n current = @head\n prev = current\n while current.next != nil\n prev = current\n current = current.next\n end\n puts \"#{@tail.data} has been removed from the Queue.\"\n current = prev\n current.next = nil\n @tail = current\n end\n end",
"def pop\r\n return nil if @top_node.nil?\r\n temp_node = @top_node\r\n @top_node = temp_node.next_node\r\n return temp_node.value\r\n end",
"def pop\n val = @head.next.obj\n @head.next = @head.next.next\n @head.next.prev = @head\n val\n end",
"def peek; @queue[-1] end",
"def remove\n raise QueueUnderflow if empty?\n result = @info.shift\n changed\n notify_observers(self, :remove, result)\n result\n end",
"def remove()\n return if @store.empty?\n \n # swap last item in heap with smallest value\n swap(0, -1)\n\n # remove smallest value\n removedNode = @store.pop\n\n # maintain heap structure\n heap_down() if @store.length > 1\n \n return removedNode.value\n end",
"def pop\n if head == nil\n \"Nothing to remove\"\n else\n prev = nil\n cur = head\n while cur.next_node != nil\n prev = cur\n cur = cur.next_node\n end\n prev.next_node = nil\n end\n end",
"def remove()\n return if @store.empty?\n if @store.size == 1\n return @store.pop\n end\n # swap the first and the last element in the underlying array\n @store[-1], @store[0] = @store[0], @store[-1]\n removed = @store.pop\n heap_down(0)\n return removed.value\n end",
"def pop\n node = @head\n if node.data == nil\n remove = \"\"\n else\n node = node.next_node until node.next_node.next_node.nil?\n remove = node.next_node.data\n node.next_node = nil\n end\n remove\n end",
"def pop\n # I RETURN A VALUE\n if @data != nil\n value = @data.value\n @data = @data.next_node\n return value\n end\n end",
"def pop\n\t\tlocation = @head.next_node\n\t\twhile location.next_node.next_node != nil\n\t\t\tlocation = location.next_node\n\t\tend\n\t\tlast = location.next_node\n\t\tlocation.next_node = nil\n\t\treturn last\n\t\tlocation = @head\n\tend",
"def ll_pop()\n current = @head\n \n if @num_nodes == 0\n return nil\n elsif @num_nodes == 1\n @head = nil\n @tail = nil\n else\n second = @head.get_Next()\n @head = second\n end\n \n @num_nodes -= 1\n return current.get_Data()\n end",
"def pop\n if @data\n top = @data.value\n @data = @data.next_node\n return top\n else\n return 'nil'\n end\n end",
"def pop\r\n if @data\r\n top_value = @data.value\r\n @data = @data.next_node\r\n else\r\n top_value = nil\r\n end\r\n return top_value\r\n end",
"def remove_last\n raise 'No such element' if @size == 0\n elt = @tail.value\n if @size == 1\n @head = nil\n @tail = nil\n else\n @tail = @tail.previous\n @tail.next.previous = nil\n @tail.next = nil\n end\n @size -= 1\n return elt\n end",
"def dequeue; @queue.pop end",
"def pop\n #if the stack is already empty do nothing\n if empty?\n nil\n else\n #set popped equal to the element at index @top, which isthe top of the stack\n popped = @store[@top]\n #set the value at the top of the stack to nil\n @store[@top] = nil\n # subtract 1 from the value of @top\n @top = @top.pred #@top--\n #returns the value that was popped\n popped\n end\n end",
"def remove()\n return nil if self.empty?\n\n # swap root node and last leaf node (swap head and rear of internal array) and pop it\n last_index = @store.length - 1\n swap(0, last_index)\n removed = @store.pop\n\n # ensure heap property via calling heap_down\n heap_down(0)\n return removed.value\n end",
"def pop\r\n top_item = data.value\r\n @data = data.next_node\r\n return top_item\r\n end",
"def pop\n # if Stack is empty, cannot remove anything\n if empty?\n nil\n else\n # popped set equal to last element in @store array\n popped = @store[@top]\n # sets last element in @store array to nil\n @store[@top] = nil\n # sets @top equal to @top - 1 (so -2 the first time through, then -3, etc.) - there is still an empty slot in @store at index -1, but no actual element there\n @top = @top.pred #@top--\n # returns the element that was removed from @store/popped from Stack\n popped\n end\n end",
"def pop\n return nil if @count == 0\n\n # get the index of the las titem\n @store.store.reverse.each_with_index do |ele, i|\n if ele != nil \n @last_ele = capacity() - (i+1) \n break\n end\n end\n #val = @store.store.delete_at(@last_ele)\n val = @store.store[@last_ele]\n @store.store[@last_ele] = nil\n @count -= 1\n return val\n end",
"def pop\r\n return nil if self.data == nil\r\n value = self.data.value\r\n @data = self.data.next_node\r\n return value\r\n end",
"def top()\n return @pop_queue.first\n end",
"def remove_at index\n return nil if empty?\n removed_value = @heap[index]\n last_item_index = size - 1\n swap_values_at(index, last_item_index)\n\n # Remove the actual value off the heap,\n # now that it's at the end/bottom of the heap\n @heap.pop\n remove_from_map(removed_value, last_item_index)\n\n # Return now, if this item was the last item already\n return removed_value if index == last_item_index\n\n # redefine our interested item, post-swap\n new_item_at_index = @heap[index]\n # Try to sink the item we moved, which now exists at `index`\n sink(index)\n # Otherwise try to swim it up, if it could not sink,\n # thus the \n swim(index) if @heap[index] == new_item_at_index\n\n return removed_value\n end",
"def pop\n current_node = @head\n prev_node = nil\n while current_node.next_node\n prev_node = current_node\n current_node = current_node.next_node\n end\n @tail = prev_node\n @tail.next_node = nil unless tail.nil?\n @size -= 1\n current_node.value\n end",
"def pop\n return nil if @elements.length == 0\n tmp = @elements.shift\n @elements.unshift @elements.pop\n heapify_down\n return tmp\n end",
"def remove_head\n\t\t\n\t\told_head = @head\n\n\t\tif old_head == nil\n\t\t\treturn nil\n\t\telse\n\t\t\t@head = old_head.next_node\n\t\tend\n\n\t\t# puts old_head.value\n\t\treturn old_head\n\n\tend",
"def pop\n return nil unless @tail\n\n popped = @tail\n @tail = @tail.head # remove tail\n @size -= 1\n\n popped.data\n end",
"def pop()\n min_dist = 1.0/0.0\n min_tuple = nil\n @queue.each{ |tuple|\n if(tuple.distance < min_dist)\n min_dist = tuple.distance\n min_tuple = tuple\n end\n }\n return @queue.delete(min_tuple)\n end",
"def pop\n # return nil if @length == 0\n # Tim did a fancy private method.....\n if @tail.nil?\n old_tail = nil\n else\n old_tail = @tail.value\n if @tail.previous.nil?\n @tail = nil\n else\n new_tail = @tail.previous\n @tail = new_tail\n end\n @length -= 1\n end\n # @tail.previous = new_tail.previous \n return old_tail\n\n end",
"def pop_head()\n nodo=@head\n aux=@head.next\n aux.prev=nil\n @head=aux\n return nodo\n end",
"def pop\n return nil if @data.nil?\n return_value = @data.value\n @data = @data.next_node\n return_value# I RETURN A VALUE\n end",
"def remove()\n return nil if empty? \n swap(0, @store.length - 1) # swap last element with root, O(n) to calc length\n old_top = @store.pop() # remove former root with O(1) time\n\n heap_down(0) unless empty?# bubble down new top element so lowest element in 0 index\n\n return old_top.value # return old min's value\n end",
"def remove_front\n value = self.head # save the first element\n self.head = value.next # the second element becomes the new first element\n value.next = nil # no longer in the list, so no next\n return value\n end",
"def pop\n return nil unless @head && @tail\n\n old_head = @tail.head\n old_data = @tail.data\n @tail = @tail.head\n @tail.tail = nil if @tail\n\n @size -= 1\n\n old_data\n end",
"def dequeue\n @queue.shift\n end",
"def pop\n if @head == nil\n return nil\n elsif @tail == @head\n @tail = nil\n @head = nil\n else\n aux = @tail\n @tail = aux.prev\n @tail.next = nil\n return aux\n end\n\n end",
"def dequeue\n # raise NotImplementedError, \"Not yet implemented\"\n #check if front is empty, if yes, return nil\n if @front == -1\n return nil\n #otherwise if front IS the rear, then the queue is full\n elsif @front == @rear\n raise Error, \"Full up here\"\n #not empty\n else \n #do same thing as the enqueue\n new_front = (@front + 1) % queue_size\n temp = @store[@front]\n @store[@front] = nil\n @front = new_front\n end\n return temp\n end"
] |
[
"0.79602504",
"0.7703563",
"0.7699247",
"0.76744",
"0.76257205",
"0.7612351",
"0.7593301",
"0.75242454",
"0.7507495",
"0.75018173",
"0.7497829",
"0.74805325",
"0.74422175",
"0.74391955",
"0.7430774",
"0.74054086",
"0.7385139",
"0.7366222",
"0.7355573",
"0.73520684",
"0.7320486",
"0.7288241",
"0.72514683",
"0.7244656",
"0.72361565",
"0.7233858",
"0.722531",
"0.7213475",
"0.7196181",
"0.7196144",
"0.7196144",
"0.71842897",
"0.7163938",
"0.71295077",
"0.7124526",
"0.7119196",
"0.7112668",
"0.7099669",
"0.7089724",
"0.70884407",
"0.70614153",
"0.70595866",
"0.70409524",
"0.7021178",
"0.70109904",
"0.7009946",
"0.7004413",
"0.7003752",
"0.69967127",
"0.69967127",
"0.69967127",
"0.69723934",
"0.6931709",
"0.69314486",
"0.6919005",
"0.69159794",
"0.6913306",
"0.6911781",
"0.691177",
"0.6911647",
"0.689284",
"0.68840075",
"0.68678445",
"0.6864568",
"0.68463373",
"0.6839841",
"0.6816572",
"0.6802739",
"0.67890316",
"0.678733",
"0.6784563",
"0.6779035",
"0.67639947",
"0.6763393",
"0.6762217",
"0.6760336",
"0.6756802",
"0.67542225",
"0.6744353",
"0.6741899",
"0.6739744",
"0.6734151",
"0.6733583",
"0.6732999",
"0.6732362",
"0.6726063",
"0.672161",
"0.6705336",
"0.6702386",
"0.66987604",
"0.66925776",
"0.66903806",
"0.6686797",
"0.6679852",
"0.66784614",
"0.66669184",
"0.6660002",
"0.6659873",
"0.6657358",
"0.66502136"
] |
0.765044
|
4
|
Clear out the entire queue.
|
def clear
@count = 0
@head = nil
@tail = nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clear\n queue.clear\n end",
"def clear\n @queue.clear\n end",
"def clear\n synchronize do\n @queue.clear\n end\n end",
"def clear\n synchronize do\n @queue.clear\n end\n end",
"def clear\n synchronize do\n @queue.clear\n end\n end",
"def clear\n LOCK.synchronize do\n @queue.each { |_, jes| jes.each(&:close) }\n @queue.clear\n end\n end",
"def clear\n @gate.synchronize do\n @queue = []\n @has_faulted = true\n end\n end",
"def clear\n @q.clear\n end",
"def clear\n @que.clear\n end",
"def clearQueue\n @itemList.clear()\n end",
"def flush\n @queue.clear\n end",
"def clear\n @q.clear\n end",
"def handle_queue_clear(args)\n @queue = [[]]\n end",
"def clear\n @que.clear\n end",
"def clear\n @que.clear\n end",
"def reset\n writeln('reset')\n clearQueue()\n end",
"def clear\n @queue.clear\n true\n end",
"def clear\n @que.clear\n self\n end",
"def clear()\n @result = \"\"\n @queue.clear\n @pipeline.pause\n end",
"def clear_queue\n @postponed_queries = []\n\n self\n end",
"def clear_data\n self.mutex.synchronize do\n self.seq = 0\n self.beg = 0\n self.cur = 0\n self.queue = Array.new( self.size )\n end\n end",
"def clear\n while not empty?\n pop\n end\n end",
"def clear()\n \t\t@result = \"\"\n \t\t@queue.clear\n \t\t#@pipeline.pause\n \tend",
"def clear\n jobs.each do |job|\n SidekiqUniqueJobs::Unlockable.unlock(job)\n end\n\n Sidekiq::Queues[queue].clear\n jobs.clear\n end",
"def purge\n @queue.purge\n end",
"def purge\n @queue.purge\n end",
"def purge\n @queue.purge\n end",
"def clear\n while peek\n pop\n end\n end",
"def flush; queue.close end",
"def clear\n LOCK.synchronize do\n @queue.each do |_, jobs|\n jobs.each do |job|\n job.close\n @registry.delete(job.id)\n end\n end\n\n @queue.clear\n end\n end",
"def reset!\n @queue = []\n @consumers = []\n end",
"def clear\n @sem.synchronize do\n @store.close!\n @size = 0\n end\n end",
"def clear_queue_values\n @queue_values = {}\n end",
"def clear\n @delivery_lock.synchronize do\n @messages.clear\n @buffer.clear\n end\n end",
"def clear_queues_cache\n channel.queues.clear\n end",
"def clear\n start\n end",
"def clear() end",
"def clear() end",
"def flush\n flushed_queue = nil\n @mutex.synchronize do\n flushed_queue = @queue.dup\n @queue.clear\n end\n return flushed_queue\n end",
"def clear()\n shutdown()\n @tasks = {}\n _clear()\n end",
"def empty()\n @queue.empty?\n end",
"def clear\n do_clear\n end",
"def flush_jobs\n queued_jobs&.each(&:call)&.clear\n end",
"def flush\n @queued = {}\n end",
"def clean\n clean_queued\n clean_running\n end",
"def clear_queue\n case @remove\n when 'one'\n puts \"Clearing e-mails #{@search_direction} #{@email}\"\n puts ''\n `exiqgrep -i #{@direction} #{@email} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n when 'all'\n if @valid_domain\n puts \"Removing all e-mails #{@search_direction} #{@domain}\"\n `exiqgrep -i #{@direction} #{@domain} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n else\n puts \"#{@domain} is not a valid local domain. Removing e-mails #{@search_direction} #{@email} instead\"\n `exiqgrep -i #{@direction} #{@email} | xargs -P10 -i exim -Mrm '{}' >/dev/null`\n end\n else\n puts \"Didn't remove any emails from the mailque\"\n end\n end",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clear\n\t\twhile self.length > 0\n\t\t\tremove self.head\n\t\tend\n\tend",
"def clean_queue!\n # Go through the song queue from start to end\n queued_songs.each_with_index do |song, index|\n if song['playAt'] + song['duration'] > Time.now.to_i\n # This song is still ok to have, trim of all the ones to the left\n $redis.ltrim(queue_key, index, -1)\n return\n end\n end\n\n # Okay, every song has played already, nuke it\n $redis.del(queue_key)\n end",
"def clear_queue(queue_name)\r\n execute :delete, \"#{queue_name}/messages\", {}, :x_ms_version => '2009-09-19'\r\n end",
"def flush\n until @work_queue.empty? && @requests.zero?\n @main_queue.drain!\n sleep 0.1\n end\n end",
"def clear\n @buffer.clear\n end",
"def remove\n @queue.pop\n end",
"def pour_out\n @queue.deq\n end",
"def empty()\n @queue.size == 0\n end",
"def clear()\n shutdown()\n @flows = {}\n _clear()\n end",
"def flushQueue() \n done=0\n while (!@data.empty?) do\n done=done+1\n @sender_plugin.send_data(@data.pop)\n end\n @@log.info \"Flushed \"+done.to_s\n end",
"def deq\n @queued = false\n nil\n end",
"def clear\n end",
"def clear\n end",
"def clear\n @heap.clear\n end",
"def flush\n Thread.exclusive do\n while !output_queue.empty? do\n write_message(output_queue.pop)\n end\n end\n end",
"def clear\n @head = nil\n @tail = nil\n @size = 0\n end",
"def clear\n end",
"def dequeue\n @items.delete_at(0)\n end",
"def clear\n\t\tmust_be_in_synchronize_block\n\t\t@collection.each_value do |server|\n\t\t\tif server.started?\n\t\t\t\tserver.stop\n\t\t\tend\n\t\tend\n\t\t@collection.clear\n\t\t@next_cleaning_time = nil\n\tend",
"def clear\n @store.fill(nil,0...@size)\n end",
"def clear\n @monitor.synchronize {\n new_buffer\n }\n end",
"def clear\n @lock.write_sync{ @data.clear }\n end",
"def clear_pending\n @async_requests.clear\n nil\n end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear; end",
"def clear\n return\n end",
"def clear\n io.truncate(0)\n io_index.clear\n self\n end",
"def clear_buffer!\n @out_mutex.synchronize do\n @buffer.clear\n end\n end",
"def clear\n end",
"def clear\n end",
"def clear\n end",
"def flush_queue()\n until @log_entries_queue.empty?\n self.send(@log_entries_queue.pop())\n sleep(SLEEP_TIME)\n end\n end",
"def clear_all\n clear\n clear_stored_requests\n end",
"def clear_intention_queue\n state.delete \"queued_actions\"\n nil\n end",
"def clear!; end",
"def clear!; end",
"def clear!; end",
"def clear_buffer\n @buffer.clear\n end",
"def remove\n @queue.shift\n end",
"def clear!\n @slots.map(&:clear!)\n @filled = 0\n end",
"def clear!\n messages = [ ]\n @messages_mutex.synchronize do\n @messages.size.times do\n messages << @messages.shift(true)\n end\n end\n messages\n end",
"def remove\n @queue.shift\n end",
"def pop\n @lock.synchronize do\n @queue.pop\n end\n end",
"def clear\n @count = 0\n @head = nil\n end",
"def clear_queue(queue_name)\n if queue_name.kind_of?(Class)\n queue_name = queue_name.instance_variable_get(\"@queue\")\n end\n if queue_name == :delayed\n Resque.reset_delayed_queue\n else\n Resque.redis.del(\"queue:#{queue_name}\")\n Resque.redis.del(\"resque:queue:#{queue_name}\")\n end\n end",
"def flush\n while !@queue.empty? || @worker.is_requesting?\n ensure_worker_running\n sleep(0.1)\n end\n end",
"def clear\n @stack.clear\n end",
"def clear\n @a.clear\n end"
] |
[
"0.8883973",
"0.8872733",
"0.8667855",
"0.86299276",
"0.86299276",
"0.83086",
"0.82932794",
"0.81419545",
"0.8133493",
"0.81137276",
"0.8069669",
"0.8065869",
"0.8046011",
"0.8008904",
"0.8008904",
"0.78929603",
"0.7851874",
"0.78505355",
"0.7633995",
"0.75614",
"0.7499195",
"0.74546593",
"0.74420315",
"0.741224",
"0.7379639",
"0.7379639",
"0.7379639",
"0.7348528",
"0.73458916",
"0.7329107",
"0.7212717",
"0.7210343",
"0.71217984",
"0.71189845",
"0.6992434",
"0.69881994",
"0.69698954",
"0.69698954",
"0.69677335",
"0.69371057",
"0.688299",
"0.68451303",
"0.6818707",
"0.68019086",
"0.679225",
"0.6775139",
"0.6768904",
"0.6768904",
"0.6768904",
"0.6766559",
"0.6761363",
"0.67498916",
"0.67482436",
"0.6742489",
"0.67370963",
"0.6733905",
"0.67177534",
"0.6694466",
"0.6664618",
"0.663748",
"0.663748",
"0.66371924",
"0.66214514",
"0.6617962",
"0.6614021",
"0.6606482",
"0.65971375",
"0.65970314",
"0.65928787",
"0.65923125",
"0.65898484",
"0.6573467",
"0.6573467",
"0.6573467",
"0.6573467",
"0.6573467",
"0.6573467",
"0.6573467",
"0.6566359",
"0.6563236",
"0.65603787",
"0.655914",
"0.655914",
"0.655914",
"0.65545374",
"0.6551338",
"0.6543008",
"0.6535719",
"0.6535719",
"0.6535719",
"0.65087324",
"0.65058607",
"0.65045303",
"0.6501475",
"0.64922214",
"0.64778227",
"0.64731055",
"0.64725363",
"0.6472229",
"0.6463142",
"0.64617646"
] |
0.0
|
-1
|
Get the number of elements that is in the queue.
|
def count
@count
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def queue_count()\n @queue.length\n end",
"def count\n\t\t@queue.length\n\tend",
"def queue_length\n @queues.inject(0) do |length, (_, queue)|\n length + queue.length\n end\n end",
"def size\n\n @queue.size\n end",
"def length\n @queue.length\n end",
"def queue_count\n @queues.length\n end",
"def length\n @queue.length\n end",
"def size\n @mutex.synchronize { @queue.size }\n end",
"def size\n @queue.size\n end",
"def size\n @queue.size\n end",
"def size\n @queue.size\n end",
"def size\n @queue.size\n end",
"def queue_count()\n cnt = 0\n @tasks.each_value { |task| cnt += task.queue_count() }\n cnt\n end",
"def size\n self.queued.inject(0) { |result, data| result + data.last.size }\n end",
"def queue_count()\n cnt = 0\n @flows.each_value { |f| cnt += f.queue_count() }\n cnt\n end",
"def sub_queue_count\n sub_queue_obj.count\n end",
"def size\n\t\t\t@sequence.size + @queue.size\n\t\tend",
"def queue_length\n mutex.synchronize { running? ? @queue.length : 666 }\n end",
"def queued_messages\n @queue.length\n end",
"def queue_size(queue)\n Resque.size(queue)\n end",
"def size\n @que.size\n end",
"def queued_messages\n @queue.length\n end",
"def total_count(queue)\n collection.find(conditions(queue)).count\n end",
"def size\n @q.size\n end",
"def queue_length\n @executor.getQueue.size\n end",
"def queue_size\n @redis.llen(\"xque:queue:#{@queue_name}\")\n end",
"def size\n return 0 if @head.nil?\n\n n = 0\n self.each { n += 1}\n return n\n end",
"def z_queue_size(queue)\n handle_pipeline(@redis.zcount(redis_key_for_queue(queue), 0, Float::INFINITY), &:to_i)\n end",
"def count\n elements.count\n end",
"def size\n Integer.new.tap do |count|\n each { |element| count += 1 }\n end\n end",
"def waitlist_size\n @queue.size\n end",
"def queue_length\n @job_queue.length\n end",
"def queue_length\n request_queue.length\n end",
"def work_queue_size()\n @work_queue.size\n end",
"def length\n @que.length\n end",
"def queue_length\n if system.empty?\n 0\n else\n system.length - 1\n end\n end",
"def queue_count()\n @work_queue.size + super()\n end",
"def message_count\n get_queue_message_count(address)\n end",
"def size\n # This is a a bit racy - we don't update these two queues atomically\n @queue.size + @active.size\n end",
"def length\n @que.length\n end",
"def length\n @que.length\n end",
"def size\n @count\n end",
"def size\n @count\n end",
"def size\n result, list = 0, self\n until list.empty?\n if list.cached_size?\n return result + list.size\n else\n result += 1\n end\n list = list.tail\n end\n result\n end",
"def num_waiting\n @waiting.size + @queue_wait.size\n end",
"def num_waiting\n @waiting.size + @queue_wait.size\n end",
"def size\n @elements.length\n end",
"def size\n if head.nil?\n return 0\n else\n count = 1 # remember, array with indexes 0,1,2,3 is size 4 !\n x = @head\n until x.next_node.nil? #problem alert\n count += 1\n x = x.next_node\n end\n\n return count\n end\n end",
"def size(name = '.+')\n queues_matching(name).map(&:size).reduce(0, :+)\n end",
"def size\n @elements.size\n end",
"def size()\n return nil if is_empty\n\n i = 0\n\n while @stack[i] != nil\n i += 1\n end\n\n return i\n end",
"def size()\n return nil if is_empty\n\n current = @head\n size = 0\n\n while current != nil\n size += 1\n current = current.next\n end\n\n return size\n end",
"def queue_size\n _get(\"/system/queue-size\") { |json| json }\n end",
"def size\n @elements.size\n end",
"def length\n @q.length\n end",
"def size\n return @items.length\n end",
"def nitems\n count = 0\n i = 0\n lim = self.__size\n while i < lim\n count += 1 unless self.__at(i)._equal?(nil)\n i += 1\n end\n count\n end",
"def queue_size(paypal_id)\n queue = @queue_map[paypal_id]\n if(queue.nil?)\n 0\n else\n queue.size\n end\n end",
"def count\r\n items.size\r\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.length\n end",
"def size\n return @items.size\n end",
"def size()\n\t\tif !@head\n\t\t\treturn 0\n\t\telse\n\t\t\tcount = 1;\n\t\t\tcurrentNode = @head\n\n\t\t\twhile currentNode.getNextNode() do\n\t\t\t\tcurrentNode = currentNode.getNextNode()\n\t\t\t\tcount = count + 1\n\t\t\tend\n\n\t\t\treturn count\n\t\tend\n\tend",
"def size\n return @items.size\n end",
"def number_of_elements_in_collection\n # collection here refers to the collection that is set with the initialize method\n # collection() is a private accessor method at the bottom of this class that accesses @collection\n collection.count\n end",
"def size\n counter = 0\n @items.each do |item|\n if item.nil?\n counter += 1\n else\n counter += item.length - 1\n end\n end\n counter\n end",
"def num_waiting\n @queue.num_waiting\n end",
"def size\n count = 0\n node = @front\n\n while node\n count += 1\n node = node.next_node\n end\n\n count\n end",
"def size\n @items.count\n end",
"def size\n @items.count\n end",
"def gevent_queue_size\r\n return @proc_queue.size\r\n end",
"def pending_size\n @redis.zcard(\"xque:pending:#{@queue_name}\")\n end",
"def get_size\n @buckets.length\n end",
"def quantityFields\n return @elements.length\n end",
"def size\n\t\treturn @items.size\n end",
"def message_count(queue)\n connect do |bunny|\n return bunny.queue(queue, :durable => true, :auto_delete => false).message_count\n end\n end",
"def size!\n @elements.values.map(&:size!).inject(0) {|total,size| total + size}\n end",
"def size?\n @queue.length\n end",
"def length\r\n elements.length\r\n end",
"def size\n \t@array.count\n end",
"def length()\n # If there are no items, return 0 for the length.\n if (!@tag.exists)\n return 0\n end\n\n # The number of items one less than the number of tags in the list.\n return @tag.length - 1\n end",
"def backlog\n @queue.size\n end",
"def count_elements\nend",
"def item_count\n @collection.size\n end",
"def size\n @list.map { |bin| bin.size }.reduce(0, :+)\n end",
"def count\n to_a.size\n end",
"def count\n to_a.size\n end",
"def count\n @data.size\n end",
"def size\n @ordered_elements.size\n end",
"def size\n\n @items.size\n end",
"def item_count\n @items.length\n end",
"def num_waiting\n @waiting.size\n end",
"def num_waiting\n @waiting.size\n end",
"def size\n @items.length\n end",
"def size\n return 0 if @head.nil?\n\n quantity = 1\n node = @head\n until node.next_node.nil?\n quantity += 1\n node = node.next_node\n end\n\n quantity\n end",
"def size\n @value.inject(0) {|acc, it| acc + it.size}\n end"
] |
[
"0.8229203",
"0.8112534",
"0.8011257",
"0.7988428",
"0.7940356",
"0.7922506",
"0.7897648",
"0.78780395",
"0.7871413",
"0.7833983",
"0.78334796",
"0.77582604",
"0.7656527",
"0.7626194",
"0.76113117",
"0.75368536",
"0.7505257",
"0.74618125",
"0.74428725",
"0.73599106",
"0.7305952",
"0.7271854",
"0.7268111",
"0.724707",
"0.7235062",
"0.7212236",
"0.7200012",
"0.71983606",
"0.7150924",
"0.7141305",
"0.7133156",
"0.7120752",
"0.7111794",
"0.7085302",
"0.7057892",
"0.70410997",
"0.7036648",
"0.7035307",
"0.701949",
"0.70144576",
"0.70144576",
"0.7007234",
"0.7007234",
"0.6970632",
"0.68970716",
"0.68970716",
"0.68948454",
"0.68866867",
"0.6867611",
"0.68397063",
"0.68343693",
"0.67977965",
"0.6794681",
"0.67929035",
"0.67816955",
"0.6780841",
"0.6762458",
"0.67616856",
"0.675611",
"0.67290276",
"0.67290276",
"0.67290276",
"0.67290276",
"0.67290276",
"0.67290276",
"0.67290276",
"0.67266583",
"0.67243034",
"0.6720428",
"0.67084765",
"0.67064935",
"0.6706053",
"0.6699828",
"0.66981584",
"0.66981584",
"0.6696132",
"0.6687651",
"0.6665746",
"0.66606313",
"0.66545695",
"0.66442484",
"0.6641975",
"0.6641964",
"0.66327405",
"0.6630898",
"0.6618273",
"0.6614283",
"0.6608248",
"0.6605593",
"0.66000843",
"0.6591084",
"0.6591084",
"0.6590642",
"0.6586506",
"0.65826267",
"0.6580963",
"0.65806794",
"0.65806794",
"0.658055",
"0.65749466",
"0.6563019"
] |
0.0
|
-1
|
Check whether this queue has any elements or not.
|
def empty?
@count == 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def any?\n !@queue.empty?\n end",
"def any?\n !@queue.empty?\n end",
"def any?\n !@queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def is_empty()\n @queue.count { _1 } == 0\n end",
"def is_empty()\n @queue.size == 0\n end",
"def empty?\n synchronize do\n return false if @publishing || @canceled || @stopping\n\n @items.empty? && @queue.empty?\n end\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queue.empty?\n end",
"def empty?\n @queued.empty?\n end",
"def empty?\n\t\t@queue.empty?\n\tend",
"def empty?\n @queue.empty?\n end",
"def empty?\n @q.empty?\n end",
"def empty?\n self.queue_size == 0\n end",
"def empty?\n @elements.empty?\n end",
"def empty?\n @que.empty?\n end",
"def empty()\n @queue.size == 0\n end",
"def empty()\n @queue.empty?\n end",
"def empty?\n @q.empty?\n end",
"def empty()\n @push_queue.empty? and @pop_queue.empty?\n end",
"def __empty?\n return false unless super\n __elements.values.all?(&:__empty?)\n end",
"def is_full()\n @queue.count { _1 } == @queue.size\n end",
"def has_elements?\n self.each_element{ |e| return true }\n return false\n end",
"def valid?\n @elements.size > 0\n end",
"def empty?\n @que.empty?\n end",
"def empty?\n @que.empty?\n end",
"def empty?\n @que.empty?\n end",
"def empty?\n # @head and @tail are equal to what they were when the Queue was created\n @head == -1 and @tail == 0\n end",
"def __empty?\n all?(&:__empty?)\n end",
"def queue_full?\n free_slots == 0\n end",
"def has_elements?\n return !( self.factures.size.eql?(0) && \n self.ventes.size.eql?(0) && \n self.produits.size.eql?(0) &&\n self.labours.size.eql?(0) &&\n self.pulves.size.eql?(0))\n end",
"def empty?\n @lock.synchronize { @used.size == 0 && @available.size == 0 }\n end",
"def empty()\n @q.empty?\n end",
"def is_empty()\n return @items.empty?\n end",
"def empty?\n self.count == 0\n end",
"def empty?\n self.count == 0\n end",
"def empty?\n count <= 0\n end",
"def empty?\n @items.count == 0\n end",
"def empty?\n size.zero?\n end",
"def is_full()\n @queue.size == @size\n end",
"def empty?\n count == 0\n end",
"def empty?\n count == 0\n end",
"def empty?\n size.zero?\n end",
"def empty?\n\t\tmust_be_in_synchronize_block\n\t\treturn @collection.empty?\n\tend",
"def size?\n @queue.length\n end",
"def empty?\n @size == 0\n end",
"def empty?\n @size == 0\n end",
"def is_empty?\n size == 0\n end",
"def empty?\n\t\t\tsize == 0\n\t\tend",
"def empty?\n all.empty?\n end",
"def isEmpty?()\r\n return @items == 0\r\n end",
"def empty?\n return @size == 0\n end",
"def empty?\n size == 0\n end",
"def empty?\n size == 0\n end",
"def empty?\n size == 0\n end",
"def empty?\n @items.empty?\n end",
"def empty?\n @items.empty?\n end",
"def empty?\n @front.empty? && @rear.empty?\n end",
"def empty?\n count == 0\n end",
"def empty?\n return true unless @all\n @all.empty?\n end",
"def empty?\n @buffers.values.all?(&:empty?)\n end",
"def empty?\n size.zero?\n end",
"def empty?\n size.zero?\n end",
"def empty?\n size.zero?\n end",
"def empty?\n size.zero?\n end",
"def empty?\n\t\t\t@ordered.empty?\n\t\tend",
"def any?\n ! empty?\n end",
"def isEmpty()\n if @head == nil\n puts \"This Queue is empty.\"\n else\n puts \"This Queue has data.\"\n end\n end",
"def empty?\n @size == 0\n end",
"def empty?\n @size == 0\n end",
"def pending_data?\n !pending_queues.empty?\n end",
"def is_empty?\r\n\t\t@items.empty?\r\n\tend",
"def empty?\n\t\treturn size.zero?\n\tend",
"def empty?\n cardinality == 0\n end",
"def has_items?\n return true if @items.empty? == false\n end",
"def empty?\n size == 0\n end",
"def is_empty?\n self.size == 0\n end",
"def empty?\n count.zero?\n end",
"def empty?\n count.zero?\n end",
"def empty?\n count.zero?\n end",
"def empty?\n items.empty?\n end",
"def full?\n # absolute value of @tail is equal to the number of slots in the queue (@size)\n @tail.abs == (@size)\n end",
"def is_full()\n if @q.count == @length\n true\n else\n false\n end\n end",
"def empty?\n @size.zero?\n end",
"def busy?\n\n @queue.size > 0\n end",
"def empty?\n @size == 0\n end",
"def empty?\n @size == 0\n end",
"def empty?\n return true if @elements.empty?\n return true if @elements == Set.new([Feature.empty])\n return false unless @elements.size == 1\n return @elements.first.empty?\n end",
"def empty?\n\t\tself.items\n\tend",
"def ready?\n inslots.values.all?{|inslot| queues[inslot.name].length > 0 }\n end",
"def empty?\n @element_repository.all.empty?\n end",
"def empty?\n # raise NotImplementedError, \"Not yet implemented\"\n if size > 0\n return false\n end\n return true\n end",
"def empty?\n return @items.nil?\n end",
"def empty?\n @is_empty\n end",
"def empty?\n return false\n end",
"def empty?(name = '.+')\n queues_matching(name).all?(&:empty?)\n end",
"def empty?\n size == 0 # Equivalent to (down == self)\n end",
"def empty?\n iterator.nil?\n end",
"def empty?()\n return @length == 0\n end"
] |
[
"0.8267314",
"0.82446474",
"0.8237614",
"0.80328417",
"0.8021648",
"0.8019214",
"0.8012361",
"0.80030036",
"0.80030036",
"0.80030036",
"0.79614896",
"0.78630674",
"0.7855992",
"0.78139675",
"0.758185",
"0.7548092",
"0.75063014",
"0.7502703",
"0.74777806",
"0.74256307",
"0.7362278",
"0.7338819",
"0.7335856",
"0.7327133",
"0.7314027",
"0.7312267",
"0.7297696",
"0.7297696",
"0.7297696",
"0.7281676",
"0.7266753",
"0.72551394",
"0.723057",
"0.72263384",
"0.7221321",
"0.7187421",
"0.7165797",
"0.7165797",
"0.7155438",
"0.71429837",
"0.7129015",
"0.71011764",
"0.70885897",
"0.70885897",
"0.7086211",
"0.70636016",
"0.7049201",
"0.70455325",
"0.70455325",
"0.7029144",
"0.7028589",
"0.7004556",
"0.7000996",
"0.6998134",
"0.6996034",
"0.6996034",
"0.6996034",
"0.69908315",
"0.69908315",
"0.6988271",
"0.69874895",
"0.69661593",
"0.6965957",
"0.6962049",
"0.6962049",
"0.6962049",
"0.6962049",
"0.69581926",
"0.6957116",
"0.6948266",
"0.6945404",
"0.6945404",
"0.69409317",
"0.6940057",
"0.6918755",
"0.69156706",
"0.69002056",
"0.6899097",
"0.6892437",
"0.68838924",
"0.68838924",
"0.68838924",
"0.68687457",
"0.68642527",
"0.68548775",
"0.68546075",
"0.6850665",
"0.684786",
"0.684786",
"0.6836619",
"0.68332815",
"0.6829657",
"0.6822884",
"0.6820249",
"0.6816579",
"0.6813764",
"0.6811193",
"0.6808936",
"0.68058807",
"0.6781721",
"0.67642224"
] |
0.0
|
-1
|
Get the value from the front of the queue.
|
def peek
@head ? @head.value : nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_front()\n if @queue.size > 0\n return @queue[0]\n end\n -1\n end",
"def front()\n self.is_empty ? -1 : @queue[@front]\n end",
"def peek()\n @queue.first\n end",
"def peek \n self.queue_var[-1]\n end",
"def peek\n\t\t@queue.first\n\tend",
"def peek; @queue[-1] end",
"def top()\n return @pop_queue.first\n end",
"def top()\n @queue[0]\n end",
"def peek\n if empty?\n nil\n else\n tempArr = []\n while @queue.size > 1\n tempArr.push(@queue.remove)\n end\n tempItem = @queue.remove\n while !tempArr.empty?\n @queue.insert(tempArr.pop)\n end\n @queue.insert(tempItem)\n tempItem\n end\n end",
"def front\n return -1 if self.is_empty\n @q[@tail]\n end",
"def front()\n return is_empty() ? -1 : @q[@front]\n end",
"def peek()\n @q.first\n end",
"def pop()\n @queue.shift\n end",
"def pop()\n res = @pop_queue.shift()\n return res\n end",
"def peek\n empty? ? nil : @head.value\n end",
"def dequeue\n # check if queue is empty \n raise ArgumentError, \"Queue is empty\" if self.empty? \n \n element = @store[@front]\n \n # check last element removed\n if (@front == @back)\n @front = @back = -1 \n elsif @front + 1 == MAX_BUFFER\n @front = 0\n # nominal case\n else\n @front += 1\n end\n\n return element\n end",
"def peek()\n @head.nil? ? nil : @head.val\n end",
"def peek\n @front\n end",
"def dequeue()\n node = @first\n @first = @first.next \n return node.value\n end",
"def peek\n raise QueueUnderflow if empty?\n @info[0]\n end",
"def shift!\n shifted = @queue.shift\n\n return nil if shifted.nil?\n shifted[0]\n end",
"def peek\n item = pop\n push(item)\n item\n end",
"def dequeue\n raise 'Queue is empty' if self.empty?\n\n el = @queue[@head]\n\n if @head == @length - 1\n @head = 0\n else\n @head += 1\n end\n\n if @head == @tail\n self.reset\n end\n\n return el\n end",
"def dequeue\n @q.shift\n end",
"def dequeue\n @queue.shift\n end",
"def pop()\n @q.shift\n end",
"def peek()\n if @queue_out.size == 0\n if @queue_in.size == 0\n return\n end\n\n while @queue_in.size > 0\n @queue_out.push(@queue_in.pop)\n end\n end\n\n return @queue_out.last\n end",
"def dequeue\n #if the queue is already empty, does nothing\n if empty?\n nil\n\n else\n #adds 1 to @tail\n @tail = @tail.succ\n #sets a local variable to the value at the top of the array\n dequeued = @store[@head]\n #adds nil to the tail of the array\n @store.unshift(nil)\n #takes off the element at the top of the array\n @store.pop\n #returns the value that was at the top of the array that has just been removed\n dequeued\n end\n end",
"def peek\n @first.val\n end",
"def peek_first\n raise 'No such element' if @size == 0\n @head.value\n end",
"def dequeue\n\t\t@queue.shift\n\tend",
"def first\n @current = self.head if self.head\n @current.value rescue nil\n end",
"def peek\n return self.heap[0]\n end",
"def dequeue\n # raise NotImplementedError, \"Not yet implemented\"\n #check if front is empty, if yes, return nil\n if @front == -1\n return nil\n #otherwise if front IS the rear, then the queue is full\n elsif @front == @rear\n raise Error, \"Full up here\"\n #not empty\n else \n #do same thing as the enqueue\n new_front = (@front + 1) % queue_size\n temp = @store[@front]\n @store[@front] = nil\n @front = new_front\n end\n return temp\n end",
"def peek()\n if @queue_out.size == 0 \n if @queue_in.size == 0 \n return \n end\n \n while @queue_in.size > 0 \n @queue_out.push(@queue_in.pop)\n end\n end\n \n return @queue_out.last\n end",
"def pop()\n head_index = get_document(@head_index_key)\n tail_index = get_document(@tail_index_key)\n if tail_index > head_index # if there is an item in the queue\n increase_atomic_count(@head_index_key) #incremented new_head_index is ignored, but we are incrementing and popping value\n return get_document(\"#{@key}::#{head_index + 1}\")\n else # \n nil\n end\n end",
"def get_next\n while next_item = @queue.peek\n if next_item.cancelled?\n @queue.shift\n else\n return next_item\n end\n end\n\n return nil\n end",
"def pop()\n head = @head\n if head == nil then\n return nil\n end\n @head = head.prev\n return head.val\n end",
"def peek\n return nil if empty?\n\n @heap[0]\n end",
"def pop\n if @queue.empty?\n nil\n else\n tempArr = []\n while @queue.size > 1\n tempArr.push(@queue.remove)\n end\n tempItem = @queue.remove\n while !tempArr.empty?\n @queue.insert(tempArr.pop)\n end\n tempItem\n end\n end",
"def peek\n self.head\n end",
"def top()\n return @head ? @head.val : nil\n end",
"def peek()\n return nil if @items.empty?\n return @items[-1]\n end",
"def peek()\n if @items.empty?\n return nil\n end\n return @items[-1]\n end",
"def get_rear()\n if @queue.size > 0\n return @queue[-1]\n end\n -1\n end",
"def dequeue\n @ivar.shift\n end",
"def peek()\n if @items.empty?\n return nil\n end\n return @items[-1]\n end",
"def peek()\n if @items.empty?\n return nil\n end\n return @items[-1]\n end",
"def dequeue\n # if queue is empty, cannot remove anything\n if empty?\n nil\n else\n # +1 added to @tail because the queue is going to be one item shorter now\n @tail = @tail.succ\n # dequeued is set equal to the item at the front of the queue\n dequeued = @store[@head]\n # adds a nil to the \"front\" of @store (but this is actually the back of the queue)\n @store.unshift(nil)\n # removes the last item from @store (first item in the queue)\n @store.pop\n # returns the item removed from the queue\n dequeued\n end\n end",
"def pop\n if @q.empty?\n raise QueueEmptyError, \"tried to pop empty queue in #{@component.inspect}\"\n end\n obj = @q.shift\n @component.dec_queue_ready_count if @q.empty?\n obj\n end",
"def top\n return nil if empty?\n @que.last\n end",
"def dequeue\n @data.shift\n end",
"def dequeue\n last_el = self.queue_var[-1]\n self.queue_var = self.queue_var[0...-1]\n last_el \n end",
"def pop\n @mutex.synchronize do\n loop do\n if @queue.empty?\n @waiting.push Thread.current\n @mutex.sleep\n else\n return @queue.shift\n end\n end\n end\n end",
"def peek\n return @push if !@push.nil?\n return nil if @input.nil?\n return nil if @input.empty?\n return nil if @index >= @input.size\n @input[@index]\n end",
"def dequeue\n @mutex.synchronize do\n # Check if the queue is empty.\n if @head == @tail # not using empty? to avoid extra synchronize block\n return nil\n end\n\n # Remove next object.\n object = @queue[@head]\n @queue[@head] = nil\n\n @head = (@head + 1) & @max_mask\n return object\n end\n end",
"def next\n @mutex.synchronize do\n until @close_now\n a = @queue.shift\n @logger.debug(\"#{@name}'s queue shifted to: #{a}\")\n if !a.nil?\n @full.broadcast\n @empty.broadcast\n return a\n else\n @logger.debug(\"#{@name}'s queue is currently closed?: #{closed?}\")\n return nil if closed?\n\n @empty.wait(@mutex)\n end\n end\n end\n end",
"def get_first\r\n # if the list is empty, head is nil\r\n if @head.nil?\r\n return nil\r\n else \r\n value = @head.data\r\n return value\r\n end\r\n end",
"def pop\n entry = queue.pop[:payload]\n if (entry != :queue_empty)\n Marshal.load(entry)\n else\n nil\n end\n end",
"def peek\n raise \"Stack Underflow - The stack is empty\" if self.is_empty?\n @store[top]\n end",
"def dequeue\n return nil if @head.nil?\n\n # Remove the head element and return the value.\n @count -= 1\n old_node = @head\n @head = @head.next\n old_node.next = nil\n\n # We can also nullify the tail if the head is nil now.\n @tail = nil if @head.nil?\n\n old_node.value\n end",
"def peek\n @store[0]\n end",
"def peek\n if empty?\n nil\n else\n @stack.first\n end\n end",
"def peek\n @store[0]\n end",
"def pop\r\n if @data\r\n top_value = @data.value\r\n @data = @data.next_node\r\n else\r\n top_value = nil\r\n end\r\n return top_value\r\n end",
"def pop()\n @size -= 1 \n @queue.shift\n end",
"def front\n # raise NotImplementedError, \"Not yet implemented\"\n return @front\n end",
"def peek(queue_index)\n self\n end",
"def peek\n @data[0]\n end",
"def front\n @items[0]\n end",
"def dequeue; @queue.pop end",
"def first\n return @front.head unless @front.empty?\n @rear.last # memoize?\n end",
"def pop\r\n top_item = data.value\r\n @data = data.next_node\r\n return top_item\r\n end",
"def dequeue\n @items.shift\n end",
"def peek\n head.data if head\n end",
"def peek\n raise IndexError.new if @data.size == 0\n return @data[0]\n end",
"def dequeue\n @store.shift\n end",
"def peek( queue_name )\n get( queue_name, :peek => true )\n end",
"def peek\n\t return nil if self.curr == 0\n\t self.arr[self.curr - 1]\n end",
"def insert_front(value)\n if @queue.size < @size\n @queue.unshift(value)\n true\n else\n false\n end\n end",
"def dequeue\n if @push_ptr\n if @pop_ptr\n object_ = @buffer[@pop_ptr]\n @buffer[@pop_ptr] = nil\n @pop_ptr += 1\n @pop_ptr = 0 if @pop_ptr == @buffer.size\n @pop_ptr = nil if @pop_ptr == @push_ptr\n object_\n else\n nil\n end\n else\n @buffer.shift\n end\n end",
"def first\n @head.val\n end",
"def dequeue\n return if @first.nil?\n data = @first.data\n @first = @first.next unless @first.nil?\n @last = nil if @first.nil?\n data\n end",
"def peek\n @stak.peek.value\n end",
"def peek\n store.last\n end",
"def pop\n if empty?\n nil\n else\n @q.remove\n @stack.shift\n end\n end",
"def top()\n x = pop()\n push(x)\n x\n end",
"def pop\n\t\treturn nil if @q1.empty?\n\t\t@q1.pop # Dequeue element from queue and return the same \n\tend",
"def get_first\n current = @head\n return nil if current.nil?\n \n return @head.data\n end",
"def pop\r\n return nil if @head == nil\r\n res = @head\r\n @head = @head.next_node\r\n return res.value\r\n end",
"def dequeue\n\t\treturn nil if @s1.empty?\n\t\t@s1.pop # Pop element from stack and return the same\n\tend",
"def get(index)\n case\n when index < 0 then return -1\n when index == 0 then return @head.val\n when index >= @length then return -1\n else\n current = @head\n for i in 0..(index-1)\n current = current.next\n end\n return -1 if current.nil?\n return current.val\n end\n end",
"def peek\n @cards.last.value\n end",
"def pop\r\n return nil if @top_node.nil?\r\n temp_node = @top_node\r\n @top_node = temp_node.next_node\r\n return temp_node.value\r\n end",
"def dequeue\n return @front if front.nil?\n\n oldFront = @front\n\n @front = oldFront.next_node\n\n if @front.nil? || @front.next_node.nil?\n @rear = @front\n end\n\n oldFront\n end",
"def peekMin()\n @store[1]\n end",
"def peek\n first.nil? ? nil : first.data\n end",
"def peek\r\n @arr[0]\r\n end",
"def higher_item_in_queue\n return nil unless in_queue?\n acts_as_queue_class.find(:first, :conditions =>\n \"#{queue_scope_condition} AND #{queue_position_column} = #{(send(queue_position_column).to_i - 1).to_s}\"\n )\n end",
"def peek \n return @ivar[0]\n end"
] |
[
"0.8424925",
"0.80432934",
"0.798497",
"0.79037225",
"0.78644633",
"0.7761924",
"0.75996387",
"0.75815016",
"0.7550961",
"0.75461745",
"0.7521103",
"0.73299253",
"0.72913563",
"0.7272172",
"0.72375524",
"0.7235174",
"0.72348344",
"0.72030675",
"0.7198472",
"0.71963775",
"0.7173931",
"0.710036",
"0.7080866",
"0.7065639",
"0.7035018",
"0.7025837",
"0.7012623",
"0.70102596",
"0.69694746",
"0.69660044",
"0.68963087",
"0.68936175",
"0.6872519",
"0.68722695",
"0.6860581",
"0.68599313",
"0.6817669",
"0.681605",
"0.6810337",
"0.67939687",
"0.6763891",
"0.6734105",
"0.67286",
"0.67267025",
"0.67166334",
"0.6709415",
"0.6693143",
"0.6693143",
"0.6669723",
"0.66601354",
"0.6623685",
"0.65954185",
"0.65854174",
"0.6577441",
"0.65602535",
"0.6547349",
"0.6540508",
"0.6540094",
"0.6539897",
"0.65070605",
"0.6500731",
"0.64953303",
"0.64947367",
"0.6476272",
"0.647426",
"0.64718014",
"0.64618796",
"0.64606225",
"0.64448076",
"0.6443719",
"0.6427059",
"0.6418665",
"0.64082146",
"0.6403467",
"0.63943696",
"0.6391295",
"0.6379404",
"0.6362155",
"0.6356656",
"0.63541776",
"0.6335309",
"0.6333085",
"0.6328329",
"0.6324136",
"0.6320557",
"0.63084614",
"0.63068235",
"0.630491",
"0.630202",
"0.63007236",
"0.62984353",
"0.6286015",
"0.6284043",
"0.6262214",
"0.62592006",
"0.6258709",
"0.6256002",
"0.62544405",
"0.6234888",
"0.6228628"
] |
0.7386244
|
11
|
An access token will allow you to make requests for the system. We support only one type of token: client_credentials. You can try this API with configuring client parameters in Console Tab below. Test OAuthClientId is b30359c21700fd6f2b91154adcb7b37bab3e7e0a33e22682e5dd149d7a6ac4df and OAuthClientSecret is 4bc4335faad41d6a23cd059e495005f00496a64e34e6187b1d72695a8debd28c
|
def create_authentication(accept,
content_type,
body)
# Prepare query url.
_path_url = '/oauth/token'
_query_builder = Configuration.get_base_uri
_query_builder << _path_url
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'Accept' => accept,
'Content-Type' => content_type
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: body.to_json
)
_context = execute_request(_request)
validate_response(_context)
# Return appropriate response type.
decoded = APIHelper.json_deserialize(_context.response.raw_body)
OAuthResponse.from_hash(decoded)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def oauth_app_access_token(client_id, client_secret)\n self.oauth_access_token(client_id, client_secret, :type => 'client_cred')\n end",
"def get_client_token\n request = Typhoeus::Request.new(\n TOKEN_ENDPOINT,\n method: :post,\n body: {\n 'grant_type' => \"client_credentials\",\n 'client_id' => ID,\n 'client_secret' => SECRET,\n })\n request.run\n response = request.response\n access_token = response.body.access_token\n end",
"def get_client_access_token(options = {})\n get_access_token('client_credentials', options)\n end",
"def oauth_access_token(client_id, client_secret, options={})\n url = self.format_url('/oauth/access_token', {\n :client_id => client_id,\n :client_secret => client_secret\n }.merge(options || {}))\n \n response = self.perform_get(url)\n response_hash = {}\n response.split('&').each do |value|\n value_pair = value.split('=')\n response_hash[value_pair[0]] = value_pair[1]\n end\n response_hash\n end",
"def get_access_token()\n url = URI.parse(TOKEN_ENDPOINT)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n req = Net::HTTP::Post.new(url.path)\n req.basic_auth(@clientId, @clientSecret)\n req.set_form_data({'grant_type' => 'client_credentials'})\n res = http.request(req)\n JSON.parse(res.body)['access_token']\n end",
"def access_token\n OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret)\n end",
"def fetch_access_token\n client.unauthenticated_request(:POST, '/v1/security/oauth2/token',\n grant_type: 'client_credentials',\n client_id: client.client_id,\n client_secret: client.client_secret)\n end",
"def access_token\n @access_token ||= ShakeTheCounter::Authentication.renew_access_token(client_id: id, client_secret: secret, refresh_token: refresh_token)[\"access_token\"]\n end",
"def request_api_token(client_id, client_secret, options = {})\n options.merge!({\n body: {\n grant_type: 'client_credentials',\n client_id: client_id,\n client_secret: client_secret,\n scope: 'alexa::proactive_events'\n }\n })\n\n HTTParty.post(ACCESS_TOKEN_REQUEST_URL, options)\n end",
"def build_token(access_token)\n return OAuth2::AccessToken.new CLIENT, access_token\n end",
"def sign_in_as_client(params = {}, options = {})\n params = {\n 'grant_type' => 'client_credentials'\n }.merge(oauth_client_params).merge(params)\n\n @access_token = get_token(params, options)\n end",
"def access_token\n @access_token ||= AccessToken.new(caller_service: caller_service, authorizator_service: authorizator_service)\n end",
"def create\n client.authorization_code = params[:code]\n access_token = client.access_token!\n puts access_token\n end",
"def access_token\n @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)\n end",
"def access_token\n @attributes[:access_token] || client.token\n end",
"def access_token\n @attributes[:access_token] || client.token\n end",
"def access_token\n @attributes[:access_token] || client.token\n end",
"def access_token\n @oauth_access_token ||= ::OAuth::AccessToken.new(consumer, @access_token, @access_secret)\n end",
"def authenticate\n if @client_id.length < 1 || @client_secret.length < 1\n raise SdkException.new('missing parameters: client_id, client_secret')\n end\n url_with_params = @@auth_endpoint + '?grant_type=client_credentials&scope=data'\n response = RestClient::Request.execute(\n url: url_with_params,\n user: @client_id,\n password: @client_secret,\n method: :post\n )\n body = JSON.parse(response.body)\n @access_token = body['access_token']\n self\n end",
"def access_token\n @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)\n end",
"def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend",
"def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend",
"def access_token\n @access_token ||= begin\n if oauth_options[:oauth_verifier]\n request_token.get_access_token(:oauth_verifier => oauth_options[:oauth_verifier])\n else\n request_token.get_access_token\n end\n end\n end",
"def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n raise \"Please set your CLIENT_ID\" if CLIENT_ID.nil?\n raise \"Please set your CLIENT_SECRET\" if CLIENT_SECRET.nil?\n\n # Build our params hash\n params = {\n client_id: CLIENT_ID,\n client_secret: CLIENT_SECRET,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\nend",
"def get_access_token(authz_code = nil)\n if @config.grant_type == 'client_credentials'\n $LOG.i \"getting access token\"\n\t @access_token = @oauth2_client.client_credentials.get_token\n $LOG.i \"got access token\", @access_token\n else\n $LOG.i \"getting access and refresh token pair\"\n\t @access_token = @oauth2_client.auth_code.get_token(authz_code, :redirect_uri => @config.redirect_uri)\n $LOG.i \"got access and refresh token pair\", @access_token\n end\n\n\trefresh_config_from_access_token\n\n\t@access_token\n end",
"def token\n @request = Request.new(params)\n\n if authenticate_client!\n response = @request.client_credentials.get_access_token\n\n respond_to do |format|\n format.html { redirect_to Http::Uri.build(@request.redirect_uri, response.to_hash) }\n format.json { render json: response.to_json, location: @request.redirect_uri }\n end\n else\n respond_to do |format|\n format.html { redirect_to Http::Uri.build(@request.redirect_uri, Oauth::Error::UnauthorizedClient.to_hash) }\n format.json { render json: Oauth::Error::UnauthorizedClient.to_json, location: @request.redirect_uri }\n end\n end\n end",
"def request_access_token\n # An `OAuth::Consumer` object can make requests to the service on\n # behalf of the client application.\n\n # Ask service for a URL to send the user to so that they may authorize\n # us.\n request_token = CONSUMER.get_request_token\n authorize_url = request_token.authorize_url\n\n # Launchy is a gem that opens a browser tab for us\n Launchy.open(authorize_url)\n\n # Because we don't use a redirect URL; user will receive a short PIN\n # (called a **verifier**) that they can input into the client\n # application. The client asks the service to give them a permanent\n # access token to use.\n puts \"Login, and type your verification code in\"\n oauth_verifier = gets.chomp\n access_token = request_token.get_access_token(\n :oauth_verifier => oauth_verifier\n )\nend",
"def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: Rails.application.secrets.FORGE_CLIENT_ID,\n client_secret: Rails.application.secrets.FORGE_CLIENT_SECRET,\n grant_type:'client_credentials',scope:'data:read data:write bucket:create'\n \n })\n return JSON.parse(response.body)['access_token']\n end",
"def app_access_token\n @app_access_token ||= oauth_client.get_app_access_token\n end",
"def request_wiz_api_token(client_id, client_secret)\n # Retrieve an OAuth access token to be used against Wiz API\"\n headers = { \"content-type\" => \"application/x-www-form-urlencoded\" }\n payload = \"grant_type=client_credentials&client_id=#{client_id}&client_secret=#{client_secret}&audience=beyond-api\"\n auth_url = \"#{@auth_endpoint}.wiz.io/oauth/token\"\n access_code_call = http_post(auth_url, headers, payload)\n JSON.parse(access_code_call)[\"access_token\"]\n end",
"def access_token\n creds = JSON.parse(File.read(FILE_CREDS))\n authorization = Google::Auth::UserRefreshCredentials.new(\n client_id: creds['installed']['client_id'],\n client_secret: creds['installed']['client_secret'],\n scope: SCOPE,\n refresh_token: refresh_token,\n expires_at: (Time.now+100).utc,\n grant_type: 'authorization_code')\n authorization.fetch_access_token!\n authorization.access_token\nend",
"def get_access_tokens(authorization_grant_code)\n # headers = { 'Content-Type': 'application/x-www-form-urlencoded' } # turns out didn't need this\n params = {\n 'grant_type': 'authorization_code',\n 'access_type': 'offline',\n 'code': authorization_grant_code,\n 'client_id': client_id,\n 'redirect_uri': redirect_uri\n }\n response = HTTParty.post(\n 'https://api.tdameritrade.com/v1/oauth2/token',\n body: params\n )\n\n if response.status == 200\n @access_token = response[\"access_token\"]\n @refresh_token = response[\"refresh_token\"]\n end\n\n response\n end",
"def get_access_token\n response = RestClient.post(\"#{API_URL}/authentication/v1/authenticate\",\n { client_id: CLIENT_ID, client_secret: CLIENT_SECRET, grant_type:'client_credentials',scope:'data:read data:write bucket:create' })\n return JSON.parse(response.body)['access_token']\nend",
"def data_acc_token(code, client_id, client_secret, grant_type=\"authorization_code\", redirect_uri=REDIRECT_URL)\n \"client_id=#{client_id}&client_secret=#{client_secret}&grant_type=#{grant_type}&code=#{code}&redirect_uri=#{redirect_uri}\"\n end",
"def get_access_token_from_auth_code(auth_code, client_id, client_secret, redirect_uri, environment = nil)\n environment ||= \"mypurecloud.com\"\n\n tokenFormData = {\n \"grant_type\" => \"authorization_code\",\n \"code\" => auth_code,\n \"redirect_uri\" => redirect_uri\n }\n\n tokenResponse =JSON.parse RestClient.post \"https://#{client_id}:#{client_secret}@login.#{environment}/token\", tokenFormData\n\n return tokenResponse['access_token'];\n end",
"def obtain_tokens(fqdn, client_id, client_secret, scope, tokens_file)\n read_tokens(tokens_file)\n \n response = RestClient.post \"#{fqdn}/oauth/access_token\", :grant_type => 'client_credentials', :client_id => client_id, :client_secret => client_secret, :scope => scope\n\t\n from_json = JSON.parse(response.to_str)\n @access_token = from_json['access_token']\n @refresh_token = from_json['refresh_token']\n write_tokens(tokens_file)\nend",
"def bearer_token\n # Put the url together\n url = \"#{API_HOST}#{TOKEN_PATH}\"\n\n # Build our params hash\n params = {\n client_id: @client_id,\n client_secret: @client_secret,\n grant_type: GRANT_TYPE\n }\n\n response = HTTP.post(url, params: params)\n parsed = response.parse\n\n \"#{parsed['token_type']} #{parsed['access_token']}\"\n end",
"def authenticate!(client_id, client_secret, code)\n response = Faraday.post \"https://github.com/login/oauth/access_token\", {client_id: client_id, client_secret: client_secret, code: code}, {'Accept' => 'application/json'}\n\n @access_token = JSON.parse(response.body)[\"access_token\"]\n\n end",
"def get_oauth_access_token(session_code)\n result = Octokit.exchange_code_for_token(session_code, CLIENT_ID, CLIENT_SECRET)\n result[:access_token]\n end",
"def get_access_token\n # Get the current token hash from session\n token_hash = session[:azure_token]\n\n client = OAuth2::Client.new(CLIENT_ID,\n CLIENT_SECRET,\n :site => 'https://login.microsoftonline.com',\n :authorize_url => '/common/oauth2/v2.0/authorize',\n :token_url => '/common/oauth2/v2.0/token')\n\n token = OAuth2::AccessToken.from_hash(client, token_hash)\n\n # Check if token is expired, refresh if so\n if token.expired?\n new_token = token.refresh!\n # Save new token\n session[:azure_token] = new_token.to_hash\n access_token = new_token.token\n else\n access_token = token.token\n end\n end",
"def oauth_access_token\n session[:access_token]\n end",
"def oauth2_token_client_credentials\n @token = Oauth2Token.create :client_application=>@client_application, :user=>@client_application.user, :scope=>params[:scope]\n render :json=>@token\n end",
"def oauth2_token_client_credentials\n @token = Oauth2Token.create :client_application=>@client_application, :user=>@client_application.user, :scope=>params[:scope]\n render :json=>@token\n end",
"def access_token\n Rails.cache.fetch(\"googl_access_token\", expires_in: 50.minutes) do \n request = { query: { client_id: ENV['GOOGL_CLIENT_ID'],\n client_secret: ENV['GOOGL_CLIENT_SECRET'],\n refresh_token: ENV['GOOGL_REFRESH_TOKEN'],\n grant_type: \"refresh_token\"} }\n\n result = self.class.post(\"/oauth2/v3/token\", request)\n\n result.parsed_response[\"access_token\"]\n end\n end",
"def access_token( user_token = nil, user_secret = nil )\n\t\t( user_token && user_secret ) ? @access_token = OAuth::AccessToken.new( self.consumer, user_token, user_secret ) : @access_token\n end",
"def get_access_token! env\n params = session(env).delete(:access_token_params)\n ::OAuth::AccessToken.from_hash consumer, params if params\n end",
"def get_access_token! env\n params = session(env).delete(:access_token_params)\n ::OAuth::AccessToken.from_hash consumer, params if params\n end",
"def oauth2_access_token\n belongs_to :client, :null => false\n\n string :token, :null => false\n string :scope\n datetime :expires_at\n end",
"def init_oauth_access_token\n @oauth_access_token = OAuth2::AccessToken.new(\n User.new_oauth_client,\n read_attribute(:access_token),\n {\n :refresh_token => read_attribute(:refresh_token),\n :expires_at => read_attribute(:access_token_expires_at)\n }\n )\n end",
"def get_access_token\n uri = URI.parse(@token_url)\n http = Net::HTTP.new(uri.host, uri.port)\n req = Net::HTTP::Post.new(uri.request_uri)\n auth = Base64.encode64(@login + ':' + @password).gsub(\"\\n\", \"\")\n req['Authorization'] = \"Basic #{auth}\"\n send = 'grant_type=client_credentials'\n req.body = send\n res = http.request(req)\n if res.code == \"200\"\n data = res.body\n result = JSON.parse(data)\n @access_token = result['access_token']\n else\n puts \"Invalid getting access token\"\n exit\n end\n end",
"def oauth2_token_client_credentials\n @token = Oauth2Token.create(:client_application => @client_application, :scope=>params[:scope])\n render :json => @token\n end",
"def get_access_token_json\n HTTParty.post(get_request_access_token_url)\n end",
"def request_access_token(code, params={})\n params[:redirect_uri] ||= \"http://localhost\"\n opts = {}\n opts[:mode] = :query\n opts[:param_name] = \"oauth2_access_token\"\n @access_token = oauth2_client.auth_code.get_token(code, params, opts)\n rescue OAuth2::Error => e\n raise LinkedIn::Errors::UnauthorizedError.new(e.code), e.description\n end",
"def find_oauth_access_token\n end",
"def get_access_token(options={})\n response=consumer.token_request(consumer.http_method,(consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path),self,options)\n OAuth::AccessToken.new(consumer,response[:oauth_token],response[:oauth_token_secret])\n end",
"def access_token\n end",
"def access_token\n return false unless session[:oauth]\n access_token = OAuth2::AccessToken.from_hash client, session[:oauth].dup\n if access_token.expired?\n access_token = OAuth2::AccessToken.from_hash(client, session[:oauth].dup).refresh!\n session[:oauth] = access_token.to_hash\n end\n @access_token ||= access_token\n end",
"def bearer_token\n response = HTTParty.post(\n \"#{MS_BASE_URL}/#{@tenant_id}/#{TOKEN_REQUEST_PATH}\",\n multipart: true,\n body: {\n client_id: Rails.application.credentials[Rails.env.to_sym][:microsoft_client_id],\n client_secret: Rails.application.credentials[Rails.env.to_sym][:microsoft_client_secret],\n scope: 'https://graph.microsoft.com/.default',\n grant_type: 'client_credentials'\n }\n )\n\n return false unless response.code == 200\n\n JSON.parse(response.body)['access_token']\n end",
"def get_access_token(request_token = @request_token)\n # response = @consumer.token_request(@consumer.http_method,\n # (@consumer.access_token_url? ? @consumer.access_token_url : @consumer.access_token_path),\n # request_token,\n # {},\n # headers)\n\n # @access_token = ::OAuth::AccessToken.new(@consumer, response[:oauth_token], response[:oauth_token_secret])\n @access_token = request_token.get_access_token\n end",
"def test_get_access_token\n end",
"def get_access_token\n client = Google::APIClient.new(\n :application_name => \"BBXiaoWo\",\n :application_version => \"1.0\"\n )\n prediction = client.discovered_api('prediction', 'v1.5')\n \n key = Google::APIClient::KeyUtils.load_from_pkcs12(P12_PATH, 'notasecret')\n \n client.authorization = Signet::OAuth2::Client.new(\n :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',\n :audience => 'https://accounts.google.com/o/oauth2/token',\n :scope => 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.profile',\n :issuer => '128823476752-40rmv6upgfe37q2u64eftmoe493uffin@developer.gserviceaccount.com',\n :signing_key => key,\n )\n client.authorization.fetch_access_token!\n client.authorization.access_token\n end",
"def test_that_authentication_returns_access_token\n response = MercadoPago::Authentication.access_token(CREDENTIALS[:client_id], CREDENTIALS[:client_secret])\n assert response['access_token']\n end",
"def current_access_token\n client = Restforce.new :username => ENV['SFDC_PUBLIC_USERNAME'],\n :password => ENV['SFDC_PUBLIC_PASSWORD'],\n :client_id => ENV['SFDC_CLIENT_ID'],\n :client_secret => ENV['SFDC_CLIENT_SECRET'],\n :host => ENV['SFDC_HOST']\n client.authenticate!.access_token\n end",
"def from_access_token(access_token)\n Authentication::OAuth2::AccessTokenAuthentication\n .new(access_token)\n end",
"def xauth_token\n consumer = oauth_consumer\n request_token = consumer.get_request_token\n consumer.get_access_token(\n request_token, {},\n {\n :x_auth_mode => 'client_auth',\n :x_auth_username => cred['username'],\n :x_auth_password => cred['password']\n }\n )\n end",
"def authorize_client session_token\n base_url = \"#{APP_CONFIG['okta_base_url']}/oauth2/v1/authorize\"\n redirect_uri = \"#{APP_CONFIG['okta_openid_redirect_uri']}\"\n client_id = \"#{APP_CONFIG['okta_client_id']}\"\n scopes = [\"openid\", \"email\", \"groups\"].join(\"%20\")\n url = \"#{base_url}?sessionToken=#{session_token}&redirect_uri=#{redirect_uri}&response_type=id_token&client_id=#{client_id}&scope=#{scopes}&response_mode=fragment\"\n\n begin\n HttpClient.get(url)\n rescue HTTParty::RedirectionTooDeep => e\n open_id_token = e.response.header['location']\n end\n open_id_token.split('=').last\n end",
"def initialize(client_id:, client_secret:, token:, refresh_token:, expires_at:)\n @basic_token = Base64.strict_encode64(\"#{client_id}:#{client_secret}\")\n\n @oauth2_client = OAuth2::Client.new(client_id, client_secret,\n authorize_url: 'https://www.fitbit.com/oauth2/authorize',\n token_url: 'https://api.fitbit.com/oauth2/token')\n\n opts = { refresh_token: refresh_token,\n expires_at: expires_at }\n @access_token = OAuth2::AccessToken.new(@oauth2_client, token, opts)\n end",
"def remote_oauth_token\n token = client_application.client_credentials.get_token(:scope => SCOPE_FOR_A_SERVICE_TO_TALK_TO_AUTHORIZATOR_SERVICE)\n raise Response::Error::AccessToken.new(data:(token && token.params)) if (!token or token.token.empty?)\n token\n end",
"def get_token\n begin\n @response = RestClient.post(\n @consumer[:token_request_url],\n client_id: @consumer[:client_id],\n client_secret: @consumer[:client_secret],\n grant_type: @consumer[:grant_type],\n resource: @consumer[:resource]\n )\n\n @consumer[:token] = 'Bearer ' + JSON.parse(@response)['access_token']\n @consumer[:token_expiry] = JSON.parse(@response)['expires_on']\n rescue => error\n puts(\"ERROR - Token Request Failed - #{error}\")\n end\n @consumer[:token]\n end",
"def get_tokens\n resource = \"/oauth/access_token\"\n\n begin\n response = @connection.post resource do |request|\n request.params['client_id'] = @api_key\n request.params['client_secret'] = @secret_key\n request.params['grant_type'] = @grant_type\n request.params['scope'] = 'SPEECH,STTC,TTS'\n end\n\n result = process_response(response)\n\n if result[:access_token].nil? || result[:refresh_token].nil?\n raise RuntimeError, \"Unable to complete oauth: #{response[:error]}\"\n else\n @access_token = result[:access_token]\n @refresh_token = result[:refresh_token]\n end\n rescue => e\n raise RuntimeError, e.to_s\n end\n end",
"def access_token(master)\n @auth_url = '/authorization/token'\n consumer = OAuth2::Client.new(master.client_id,\n master.client_secret,\n {:site => \n {:url => master.site, \n :ssl => {:verify => OpenSSL::SSL::VERIFY_NONE,\n :ca_file => nil\n }\n },\n :authorize_url => @auth_url,\n :parse_json => true})\n \n response = consumer.request(:post, @auth_url, {:grant_type => 'password', \n :client_id => master.client_id,\n :client_secret => master.client_secret,\n :username => master.username, \n :password => master.password},\n 'Content-Type' => 'application/x-www-form-urlencoded')\n\n OAuth2::AccessToken.new(consumer, response['access_token']).token\n \n end",
"def get_access_token name = nil\n oauth_instance(name).get_access_token(oauth_request_env)\n end",
"def oauth2_access_token(code, options={})\n query = {\n :client_id => Config.client_id,\n :client_secret => Config.client_secret,\n :grant_type => 'authorization_code',\n :redirect_uri => Config.redirect_uri,\n :code => code\n }\n return send_request(:POST, PATH[:oauth2_access_token], query, false, options)\n end",
"def set_access_token\n access_tokens.create(token: SecureRandom.urlsafe_base64(20))\n end",
"def call_token_api(params, clientId, clientSecret)\n return call_api(\"/api/auth/token\", {\n \"parameters\" => URI.encode_www_form(params),\n \"clientId\" => clientId,\n \"clientSecret\" => clientSecret\n })\nend",
"def get_access_token\n\t\treturn @credentials.get_access_token\n\tend",
"def get_auth_token\n log_step \"start\", \"get_auth_token\"\n login_url = \"https://login.microsoft.com\"\n token_url = \"#{login_url}/#{@tenant}/oauth2/token?api-version=1.0\"\n body = {\n client_id: @client_id,\n client_secret: @client_secret,\n grant_type: 'client_credentials',\n resource: @resource\n }\n response = HTTParty.post \"#{token_url}\", body: body\n @access_token = response['access_token']\n log_step 'auth_token', @access_token\nend",
"def access_token\n ENV['KARATEKIT_ACCESS_TOKEN']\n end",
"def get_access_token\n auth = storage['authentication']\n return auth['access_token'] if auth && auth['expires'] > Time.now.to_i\n\n auth = authenticate_client\n storage['authentication'] = auth\n auth['access_token']\n end",
"def get_tokens\n\t\tresource = \"/oauth/access_token\"\n\t\t\n\t\tbegin\n\t\t\tresponse = @connection.post resource do |request|\n\t\t\t\trequest.params['client_id'] = @api_key\n\t\t\t\trequest.params['client_secret'] = @secret_key\n\t\t\t\trequest.params['grant_type'] = @grant_type\n\t\t\t\trequest.params['scope'] = @scope\n\t\t\tend\n\t\t\t\n\t\t\tresult = process_response(response)\n\t\t\t\n\t\t\tif result[:access_token].nil? || result[:refresh_token].nil?\n\t\t\t\traise RuntimeError, \"Unable to complete oauth: #{response[:error]}\"\n\t\t\telse \n\t\t\t\t@access_token = result[:access_token]\n\t\t\t\t@refresh_token = result[:refresh_token]\n\t\t\tend\n\t\trescue => e\n\t\t\traise RuntimeError, e.to_s\n\t\tend\n\tend",
"def get_access_token(app_id, app_secret, code)\n url = ACCESS_TOKEN_URL\n\n # set body\n query = {\n \"app_id\" => app_id,\n \"app_secret\" => app_secret,\n \"code\" => code\n }\n\n # hash it\n payload = URI.encode(query.map{|k,v| \"#{k}=#{v}\"}.join(\"&\"))\n\n # send post request\n response = send_post_request(url, payload, 'application/x-www-form-urlencoded')\n\n return JSON.parse(response)\n end",
"def get_token(params = {}, access_token_opts = {}, access_token_class = AccessToken)\n params = ActiveSupport::HashWithIndifferentAccess.new(params)\n params.reverse_merge!(grant_type: \"client_credential\", appid: id, secret: secret)\n\n opts = {:raise_errors => options[:raise_errors], :parse => params.delete(:parse)}\n if options[:token_method] == :post\n headers = params.delete(:headers)\n opts[:body] = params\n opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'}\n opts[:headers].merge!(headers) if headers\n else\n opts[:params] = params\n end\n response = request(options[:token_method], token_url, opts)\n raise Error.new(response) if options[:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token'])\n @token = access_token_class.from_hash(self, response.parsed.merge(access_token_opts))\n end",
"def authorize(token, token_secret)\n\t\t\t@access_token = OAuth::AccessToken.new(@client, token, token_secret)\n\t\tend",
"def get_access_token\n raise HyvesException, 'You need an request token to make get an access token' if request_token.nil?\n @access_token = request_token.get_access_token\n\n @userid = request_token.response[\"userid\"]\n @expiredate = Time.at(request_token.response[\"expiredate\"].to_i) if not request_token.response[\"expiredate\"].nil?\n\n @access_token\n end",
"def build_client(access_token)\n begin\n client = Octokit::Client.new(access_token: access_token)\n client.user.login\n rescue Octokit::Unauthorized\n raise 'Please enter valid Personal Auth Token'\n end\n client\n end",
"def get_access_token(auth_code)\n @access_token = @oauth_client.auth_code.get_token(auth_code, :redirect_uri => @redirect_uri)\n @token = @access_token.token\n @refresh_token = @access_token.refresh_token\n @token_expires_at = @access_token.expires_at\n end",
"def get_access_token\n @oauth_access_token = oauth_request.get_access_token\n @authenticated_user_uri = oauth_consumer.token_request_response[\"Content-Location\"]\n end",
"def access_token\n ENV[ACCESS_TOKEN_KEY_NAME]\n end",
"def authenticate\n response = post('login')\n @access_token = response['access-token']\n @client_id = response['client-id']\n end",
"def client_context\n # Use static access token from environment. However, here we have access\n # to the current request so we could configure the token to be retrieved\n # from a session cookie.\n { access_token: GitHub::Application.secrets.github_access_token }\n end",
"def get_access(params: nil, host:)\n result = TokenAdapter.new.(client_id: ENV['CLIENT_ID'],\n secret: ENV['CLIENT_SECRET'],\n code: params[:code],\n code_verifier: extract_verifier(params),\n redirect_uri: redirect_callbacks_url(host: host))\n {id_token: validate_id_token(result[\"id_token\"]), result: result}\n end",
"def request_token\n authconfig=Configuration.new\n authconfig.base_path=\"\"\n authClient=ApiClient.new(authconfig)\n authApi=AsposeDiagramCloud::OAuthApi.new(authClient)\n config=@api_client.config\n data, _status_code, _headers=authApi.o_auth_post(config.api_key['grant_type'],config.api_key['app_sid'],config.api_key['api_key'])\n #print(data.access_token)\n @api_client.default_headers[\"Authorization\"] =\"Bearer \" + data.access_token\n end",
"def request_token\n authconfig=Configuration.new\n authconfig.base_path=\"\"\n authClient=ApiClient.new(authconfig)\n authApi=AsposeDiagramCloud::OAuthApi.new(authClient)\n config=@api_client.config\n data, _status_code, _headers=authApi.o_auth_post(config.api_key['grant_type'],config.api_key['app_sid'],config.api_key['api_key'])\n #print(data.access_token)\n @api_client.default_headers[\"Authorization\"] =\"Bearer \" + data.access_token\n end",
"def access_token\n @rubytter.instance_variable_get(:@access_token)\n end",
"def get_access_token(code)\n @code = code\n @access_token ||= client.web_server.get_access_token( @code, :redirect_uri => callback_url)\n end",
"def access_token\n refresh! if access_token_expires_at&.<= Time.now + 60 # time drift margin\n @access_token\n end",
"def access_token\n @access_token\n end",
"def get_access_token! name = nil\n oauth_instance(name).get_access_token!(oauth_request_env)\n end",
"def init_access_token(params)\n @access_token = request_token.get_access_token(params)\n end",
"def get_access_token(grant_type, options = {})\n object_from_response(GogoKit::OAuthToken,\n GogoKit::OAuthTokenRepresenter,\n :post,\n oauth_token_endpoint,\n body: token_request_body(grant_type, options),\n headers: token_request_headers)\n end",
"def prepare_access_token(oauth_token, oauth_token_secret)\n consumer = OAuth::Consumer.new(\"zuDJxQuK96WA2s0k0g3tqHr6r\", \"PhiNIibo53GYGhXgoWJ1UDBoKDVGqhaeCmTiSWCwz3VKucxfTD\",\n { :site => \"https://api.twitter.com\",\n :scheme => :header\n })\n # now create the access token object from passed values\n token_hash = { :oauth_token => oauth_token,\n :oauth_token_secret => oauth_token_secret\n }\n access_token = OAuth::AccessToken.from_hash(consumer, token_hash )\n \n RestClient.add_before_execution_proc do |req, params|\n access_token.sign! req\n end\n\n return access_token\nend"
] |
[
"0.8234712",
"0.79407114",
"0.7793352",
"0.77001613",
"0.76731515",
"0.75661206",
"0.75511414",
"0.7549023",
"0.75379056",
"0.75216854",
"0.7497651",
"0.73689955",
"0.73288167",
"0.73119366",
"0.72915244",
"0.72915244",
"0.72915244",
"0.7288346",
"0.72859627",
"0.7274727",
"0.7261831",
"0.7252257",
"0.7243626",
"0.7240125",
"0.72231674",
"0.72164357",
"0.72141993",
"0.72109354",
"0.7176673",
"0.71358305",
"0.71230495",
"0.7112899",
"0.71105117",
"0.71024424",
"0.7094468",
"0.70937407",
"0.70548016",
"0.7054206",
"0.7038885",
"0.70287657",
"0.7025354",
"0.70190823",
"0.70190823",
"0.70172125",
"0.69857603",
"0.6979658",
"0.6969454",
"0.69654346",
"0.69289905",
"0.69275707",
"0.69208455",
"0.6916564",
"0.69082236",
"0.68950796",
"0.6892979",
"0.68811065",
"0.6869971",
"0.686394",
"0.6861258",
"0.68461347",
"0.6845954",
"0.6844687",
"0.6843938",
"0.68352646",
"0.683187",
"0.6831086",
"0.6819852",
"0.68111897",
"0.6809808",
"0.6809079",
"0.67988956",
"0.679853",
"0.6776923",
"0.6775474",
"0.67654866",
"0.6761772",
"0.67595494",
"0.6739425",
"0.6735783",
"0.6726151",
"0.6721084",
"0.67184937",
"0.67105204",
"0.6686448",
"0.6686047",
"0.6683389",
"0.6683103",
"0.6682169",
"0.66820663",
"0.66788626",
"0.6667391",
"0.66666144",
"0.66666144",
"0.66613007",
"0.66520876",
"0.66516453",
"0.6651482",
"0.66495997",
"0.664844",
"0.6648071",
"0.66430646"
] |
0.0
|
-1
|
Finds objects by PID
|
def find(pid)
digital_object_record = ::DigitalObjectRecord.find_by(pid: pid)
if digital_object_record.nil?
raise Hyacinth::Exceptions::DigitalObjectNotFoundError, "Couldn't find DigitalObject with pid #{pid}"
end
# Retry after Fedora timeouts / unreachable host
fobj = nil
Retriable.retriable DigitalObject::Base::RETRY_OPTIONS do
fobj = ActiveFedora::Base.find(pid)
end
digital_object = DigitalObject::Base.get_class_for_fedora_object(fobj).new
digital_object.init_from_digital_object_record_and_fedora_object(digital_object_record, fobj)
digital_object
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_by_pid(pid)\n find(pid)\n rescue Hyacinth::Exceptions::DigitalObjectNotFoundError\n return nil\n end",
"def find_by_pid(pid)\n @proc_table = Array.new\n ProcFetch.get_process(:processid => pid).each do |proc_attrs|\n @proc_table.push(ProcInfo.new(proc_attrs))\n end\n childs_tree\n end",
"def find(id)\n @objects[id]\n end",
"def find id\n @objs_list[id] if @objs_list\n end",
"def find_by_watchdog_pid(pid, options = {})\n return list(options).detect { |instance| instance.watchdog_pid == pid }\n end",
"def find_pids(name)\n\tproc_pid = []\n\t@client.sys.process.get_processes.each do |proc|\n\t\tif proc['name'].downcase == name.downcase\n\t\t\tproc_pid << proc['pid']\n\t\tend\n\tend\n\treturn proc_pid\nend",
"def [](pid)\n pid = pid.to_i\n @running_processes[pid] ||= find_by_pid(pid)\n end",
"def get_children_process(pid)\n\t`ps --ppid #{pid} | grep -v PID | awk '{print $1}'`.split(\"\\n\")\n\t#Could not find a Ruby way to do this\nend",
"def find(*ids)\n if Georeferencer.configuration.perform_caching && perform_object_caching != false\n ids.uniq!\n uncached_ids = ids.reject {|i| Georeferencer.configuration.cache.read(\"#{cache_key_base}/#{i}\").present?}\n [super(*uncached_ids)].flatten.reject(&:blank?).collect do |object|\n Georeferencer.configuration.logger.debug(\"Caching #{cache_key_base}/#{object.id}\")\n Georeferencer.configuration.cache.write(object.cache_key, object)\n end\n all_objects = ids.collect do |id|\n Georeferencer.configuration.cache.read(\"#{cache_key_base}/#{id}\")\n end\n\n all_objects.each {|o| o.run_callbacks(:find)}\n all_objects.length == 1 ? all_objects.first : all_objects\n else\n super\n end\n end",
"def existing_instances(filter=\"\")\r\n instances_raw = `ps xao pid,pgid,command | grep '#{process_name} #{name_grep_string} #{filter}' | grep -iv #{Process.pid} | awk '{print $1 \"\\t\" $2 \"\\t\" $3}'`\r\n instances_raw.split(\"\\n\").map do |row|\r\n pid, group, command = row.split(\"\\t\")\r\n ProcessInfo.new(pid.to_i, group.to_i, command)\r\n end\r\n end",
"def find_soffice_pid\n %x(pgrep #{soffice_pname}).presence&.to_i\n end",
"def pgrep(uuid)\n command = %Q(/usr/bin/pgrep -u $(id -u #{uuid}))\n pids, _, rc = Utils.oo_spawn(command, quiet: true, timeout: 300)\n\n case rc\n when 0\n pids.split(\"\\n\")\n when 1\n Array.new\n else\n raise RuntimeError, %Q(watchman search for running processes failed: #{command} (#{rc}))\n end\n end",
"def find(id); end",
"def find(id); end",
"def find_object(name); end",
"def pids\n @pids ||= {}\n end",
"def lookup(id)\n\t\t@objects[id]\n\tend",
"def find(id)\n end",
"def objects(params=nil)\n params ? map.objects.find(params) : map.objects\n end",
"def find(id)\n all.find { |obj| obj.id == id }\n end",
"def child_pids(pid)\n\tkids = []\n\tDir.foreach('/proc') do |entry|\n\t\tnext unless entry =~ /^\\d+$/\n\t\tnext if parent_pid(entry) != pid\n\t\tkids << entry.to_i\n\tend\n\tkids\nend",
"def find_by_name(name)\n @proc_table = Array.new\n ProcFetch.get_process({:name => name}).each do |proc_attrs|\n @proc_table.push(ProcInfo.new(proc_attrs))\n end\n childs_tree\n end",
"def execute\n klass.collection.find(selector, process_options) || []\n end",
"def find_object(path)\n path_array = path.split(/\\//)\n n = CGI::unescape(path_array.shift)\n #puts \"looking for #{n} #{path} #{path_array.inspect}\"\n \n children.each do |c|\n # look for an object with named by n\n if c.name == n\n return c if path_array.empty?\n return c.find_object(path_array.join('/'))\n end\n end\n return nil\n end",
"def find(id)\n find_result\n end",
"def search_of_pids(search)\n return '' unless search.present?\n\n search.query_params.merge('pids_only' => true)\n end",
"def initialize_queue\n repository.search('pid~druid*').map { |x| x.pid }\n end",
"def find_published\n return self if PidUtils.published?(pid)\n self.class.find(PidUtils.to_published(pid))\n end",
"def find name\n object = objects.find { |o| o.name == name.to_s }\n end",
"def pids_by_regexp(regexp)\n matched = {}\n process_tree.each do |pid,process|\n matched[pid] = process if process[:cmd] =~ regexp\n end\n matched\n end",
"def find(id, params = {})\n from_base id, params\n end",
"def find_object(project, id)\n find_milestone_with_finder(project, id: id)\n end",
"def get_pids\n pids_ports = []\n pids = `pgrep -f thin`.split\n pids.each do |t|\n # only works for linux i'm affraid\n # using lsof (list open files) \n\n # removed by someara to address munin permissions issue\n ## port = `lsof -p #{t} | grep LISTEN`.split[8]\n ## port = port.split(\":\")[1]\n port = `ps -ef | grep #{t} | grep -v grep | grep thin | awk '{ print $10 }' | awk -F: '{ print $2 }' | tr --delete '()'`.chomp\n pids_ports << [t,port]\n end\n pids_ports\n end",
"def instance_by_id(id)\n instances.detect { |x| x.id == id } # ID should always be unique\n end",
"def find(id)\n res = transmit(\"peek #{id}\")\n Job.new(client, res)\n rescue Beaneater::NotFoundError\n nil\n end",
"def get_children_pids(pid)\n pid = pid.to_i\n unless process_tree.key? pid\n log \"No such pid: #{pid}\"\n return []\n end\n process_tree[pid][:children].inject([pid]) do |all_children_pids, child_pid|\n all_children_pids + get_children_pids(child_pid)\n end\n end",
"def pids\n return [] unless @pid\n return @component_objects.clone if manifest.content_model == PAGE_CONTENT_MODEL || manifest.content_model == NEWSPAPER_PAGE_CONTENT_MODEL\n return ([ @pid ] + @component_objects.clone)\n end",
"def find_object\n @object = @model_class.find_by_id(params[:id].to_i)\n end",
"def search_by_name(process_name)\n if process_name =~ /^\\/.*\\/$/\n process_name.slice!(0)\n process_name = Regexp.new(/#{process_name.chop}/)\n find_all\n else\n find_by_name(process_name)\n end\n\n process_list = Array.new\n\n @proc_table.each do |process|\n if process_name.is_a? Regexp\n process_list << process if process.name =~ process_name || process.commandline =~ process_name\n else\n process_list << process if process.name.to_s.downcase == \"#{process_name.to_s.downcase}\" || process.commandline.to_s.downcase == \"#{process_name.to_s.downcase}\"\n end\n end\n\n process_list = nil if process_list.empty?\n\n return process_list\n end",
"def list_pids\n access_processes do |processes|\n processes.keys\n end\n end",
"def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find_object_from_link(parent_object, id)\n find_object(parent_object, id)\n end",
"def collect_objects\n results = []\n generate_objects! if object_ids.nil?\n begin\n object_ids.each do |model_name, ids|\n results << model_name.to_s.constantize.find(ids)\n end\n results.flatten\n rescue ActiveRecord::RecordNotFound\n generate_objects!\n collect_objects\n end\n end",
"def find_plugin level, object_list\r\n\r\n # find_plugin_1 level, object_list\r\n # print \"find_plugin: n_visted=\", @@n_visited, \" (len=\", @@visited.length, \") found=\", @@n_found, \" proxy=\", @@n_plugin_proxy, \"\\n\"\r\n end",
"def find_by_id(id)\n children.find { |child| child[:tab_id] == id }\n end",
"def find(name)\n instances.find { |instance| instance.name == (name) }\n end",
"def find_locally(id)\n if @all.present?\n @all.find { |model| model.id == id }\n end\n end",
"def collect_objects\n results = []\n begin\n object_ids.each do |model_name, ids|\n results << model_name.to_s.constantize.find(ids)\n end\n results.flatten\n # rescue ActiveRecord::RecordNotFound\n # generate_objects!\n # collect_objects\n end\n end",
"def get_object_by_id(class_name, id)\n obj = nil\n get_objects_of_class(class_name).each do |o|\n if o.id == id\n obj = o\n break\n end\n end\n obj\n end",
"def daemon_pids\n prog_name = Log2mail::PROGNAME\n own_pid = Process.pid\n # FIXME: finding daemon pids by using pgrep is NOT 'optimal' :-)\n `pgrep -f #{prog_name}`.split.map(&:to_i) - [own_pid]\n end",
"def show\n @pid = params[:pid]\n end",
"def find(args, mode); end",
"def object_url pid, options = nil\n url_for(\"objects\" + ((\"/#{CGI::escape(pid.to_s.gsub('info:fedora/', ''))}\" if pid) || ''), options)\n end",
"def pid\n @pid\n end",
"def find(id)\n raise NotImplementedError\n end",
"def find(*parse_ids, type: :parallel, compact: true)\n # flatten the list of Object ids.\n parse_ids.flatten!\n parse_ids.compact!\n # determines if the result back to the call site is an array or a single result\n as_array = parse_ids.count > 1\n results = []\n\n if type == :batch\n # use a .in query with the given id as a list\n results = self.class.all(:id.in => parse_ids)\n else\n # use Parallel to make multiple threaded requests for finding these objects.\n # The benefit of using this as default is that each request goes to a specific URL\n # which is better than Query request (table scan). This in turn allows for caching of\n # individual objects.\n results = parse_ids.threaded_map do |parse_id|\n next nil unless parse_id.present?\n response = client.fetch_object(parse_class, parse_id)\n next nil if response.error?\n Parse::Object.build response.result, parse_class\n end\n end\n # removes any nil items in the array\n results.compact! if compact\n\n as_array ? results : results.first\n end",
"def show\n render :text=>\"PID is invalid\", status: :bad_request and return if !params[:pid].include?(\":\")\n\n #parse pid for item identity; format TS[B|M]:[id]\n pid_bits = params[:pid].split(\":\")\n id = pid_bits.last\n resource_type = pid_bits.first[2].upcase\n if resource_type == \"B\"\n object = Bibl.find(id)\n elsif resource_type == \"M\"\n object = MasterFile.find(id)\n else\n # see if it is an old-style PID\n object = Bibl.find_by(pid: params[:pid])\n if object.nil?\n object = MasterFile.find_by(pid: params[:pid])\n end\n render :text=>\"PID is invalid\", status: :bad_request and return if object.nil?\n end\n\n render :xml=> Hydra.solr(object)\n end",
"def read_persons(pid)\n read_individual_field = Hydra.config[:permissions][:read][:individual]\n doc = permissions_doc(pid)\n rp = edit_persons(pid) | ((doc == nil || doc.fetch(read_individual_field,nil) == nil) ? [] : doc.fetch(read_individual_field,nil))\n logger.debug(\"[CANCAN] read_persons: #{rp.inspect}\")\n return rp\n end",
"def factory_instaces(pid)\n regex = pid.gsub(/\\./, '\\.') + '\\.'\\\n '[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}'\n config_list.scan(/#{regex}/)\n end",
"def find_votable\n params.each do |name, value|\n if name =~ /(.+)_id$/\n return $1.classify.constantize.find(value)\n end\n end \n return nil\n end",
"def find(record_id)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{record_id}\")\n results_as_objects = []\n\n results.each do |result_hash|\n results_as_objects << self.new(result_hash)\n end\n return results_as_objects.first \n end",
"def instance_find(path)\n result = $evm.instance_find(path)\n # Returns Hash\n #$evm.log('info',\"Instance:<#{path}> properties:<#{result.inspect}>\") if @debug\n return result\n end",
"def find_all_by_id(id)\n find_all_by(:id, id)\n end",
"def find(id)\n # Your code Here\n @candidates.each do |element|\n \tif element[:id] == id\n \t\tpp element\n \tend\n end\n pp nil\n\nend",
"def objects_for_bin_id(binned_array,id)\n (r = binned_array.find { |v| v[:id] == id} )? r[:objects] : []\n end",
"def find_by_id(goid)\n self[goid]\n end",
"def load_pid_from_file\n best_match = @options[:possible_pid_files].inject([]) do |matches, pid_file|\n begin\n log.debug(\"Considering reading PID from `#{pid_file}'\")\n possibility = [File.atime(pid_file), File.read(pid_file).to_i]\n log.debug(\" - created #{possibility[0]}, contains PID: #{possibility[1]}\")\n matches << possibility\n rescue Errno::EACCES, Errno::ENOENT\n end; matches\n end.compact.sort.last\n best_match[1] if best_match\n end",
"def find_by_id(id)\n find(id)\n end",
"def find_from_search(*ids)\n unless ids.blank?\n results = {}\n ids.flatten.dice(20).each do |set|\n query = (set.map { |id| \"(id:\\\"#{id}\\\")\" }).join(' || ')\n search_results = search_for(query, :qt => 'standard', :rows => set.length)\n search_results.models.each do |result|\n results[result.id] = result\n end\n end\n ids.flatten.map { |id| results[id] }\n else\n []\n end\n end",
"def find(id)\n # this .find is from the ruby documentation on the Array class\n @rooms.find { |room| room.id == id }\n end",
"def find(*args)\n list = []\n if args.first == :all\n result = Rhom::RhomDbAdapter::select_from_table(Rhom::TABLE_NAME,\n '*',\n {\"source_id\"=>get_source_id,\"update_type\"=>'query'},\n {\"order by\"=>'object'})\n else\n obj = strip_braces(args.first.to_s)\n result = Rhom::RhomDbAdapter::select_from_table(Rhom::TABLE_NAME,\n '*',\n {\"object\"=>obj})\n end\n list = get_list(result)\n if list.length == 1\n return list[0]\n end\n list\n end",
"def find(id)\n @entries_by_id[id]\n end",
"def find(*args)\n ids = args.__find_args__\n raise_invalid if ids.any?(&:nil?)\n for_ids(ids).execute_or_raise(ids, args.multi_arged?)\n end",
"def query_podcast_with_id(pod_id)\n @db[PODCAST].where(podcast_id: pod_id)\n end",
"def find_from_search(*ids)\n unless ids.blank?\n results = {}\n ids.flatten.dice(20).each do |set|\n query = (set.map { |id| \"(id:\\\"#{id}\\\")\" }).join(' || ')\n search_results = search_for(query, :qt => 'standard', :rows => set.length)\n search_results.models.each do |result|\n results[result.id] = result\n end\n end\n ids.flatten.map { |id| results[id] }.compact\n else\n []\n end\n end",
"def find_obj\n @obj = eval(resource_name).find_by(id: params[:id])\n end",
"def find(id)\n @lock.synchronize do\n begin\n ref = @items[id]\n return unless ref\n ref.__getobj__\n rescue WeakRef::RefError\n # :nocov:\n @items.delete id\n nil\n # :nocov:\n end\n end\n end",
"def find_procname(pid)\n\tname = nil\n\t@client.sys.process.get_processes.each do |proc|\n\t\tif proc['pid'] == pid.to_i\n\t\t\tname = proc['name']\n\t\tend\n\tend\n\treturn name\nend",
"def pidof(program)\n pids = []\n full = cmd_exec('ps -elf').to_s\n full.split(\"\\n\").each do |pid|\n pids << pid.split(' ')[3].to_i if pid.include? program\n end\n pids\n end",
"def find(id)\n\nend",
"def load_objects\n instance_variable_set(\"@#{model_name.underscore.pluralize}\", (@instances = model.where(params || {}) rescue nil))\n end",
"def find_modules\n find_engine\n find_storage\n find_pod\n end",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def find_by_id(id)\n find_by(:id, id)\n end",
"def pmids \n @pmids ||= []\n end",
"def find_object(parent_object, id)\n raise NotImplementedError, \"#{self.class} must implement method: #{__callee__}\"\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def find(id)\n fetch([name, id]) do\n super\n end\n end",
"def find(name)\n list.select do |vm|\n vm.name.to_s.index(name.to_s) && vm.running?\n end.first\n end",
"def get_by_objectpath objpath\n STDERR.puts \"#{self.class}.get_by_objectpath #{objpath}\" if Wbem.debug\n @client.get_instance(objpath)\n end",
"def find(id)\n @candidates.each do |person|\n if person[:id] === id\n return person\n end\n end\n return nil\nend",
"def command_find(prefix)\n items = @database.find_matches(prefix)\n items.each { |i|\n puts i.to_s\n }\n end",
"def find(id)\n\t@candidates.detect { |candidate| candidate[:id] == id }\nend",
"def find(id)\n @candidates.each do |item|\n if item[:id]==id\n @result = item\n end\n end\n @result\nend",
"def find_many(ids, *args)\n return [] if ids.blank?\n hashes = multi_get(ids.collect(&:to_s), *args)\n\n hashes.inject([]) do |res, (key, data)|\n res << instantiate(key, data) unless data.empty?\n end\n end",
"def find(id)\n found_id = redis.get \"#{klass}:id:#{id}\"\n\n if found_id\n object = self.new\n object.send(:id=, found_id.to_i)\n object\n end\n end",
"def find(id)\n klass.find(id)\n end",
"def find item\n\tend",
"def locate\n processes = includes.reduce(all_processes, &by_inclusion_patterns)\n processes = excludes.reduce(processes, &by_exclusion_patterns)\n processes = filters.reduce(processes, &by_filter)\n end"
] |
[
"0.6867694",
"0.68519914",
"0.64181954",
"0.60357606",
"0.597268",
"0.5891712",
"0.5781331",
"0.56871605",
"0.5666202",
"0.56644475",
"0.56605536",
"0.56494606",
"0.5618857",
"0.5618857",
"0.56036776",
"0.5569835",
"0.5562159",
"0.5543509",
"0.5523924",
"0.5511818",
"0.5507588",
"0.5465288",
"0.5434728",
"0.5423184",
"0.54122436",
"0.5409088",
"0.53629684",
"0.535204",
"0.53398144",
"0.533707",
"0.5336013",
"0.53267705",
"0.5314693",
"0.53120375",
"0.53114504",
"0.5306287",
"0.5302776",
"0.52845246",
"0.5272526",
"0.5241087",
"0.5238821",
"0.5213451",
"0.5208269",
"0.5202919",
"0.52026623",
"0.5200443",
"0.51987654",
"0.5195907",
"0.5195894",
"0.51894987",
"0.5182292",
"0.51726794",
"0.51680064",
"0.51672715",
"0.5161225",
"0.5155892",
"0.51490116",
"0.51461804",
"0.5130538",
"0.51114756",
"0.5108576",
"0.5103034",
"0.50996405",
"0.5097931",
"0.509629",
"0.50903267",
"0.50802034",
"0.50729793",
"0.50720894",
"0.50684834",
"0.50609463",
"0.5057357",
"0.5031827",
"0.5029449",
"0.50279355",
"0.5027753",
"0.50249577",
"0.50217885",
"0.50206995",
"0.5018722",
"0.5004917",
"0.500188",
"0.49998048",
"0.49995777",
"0.49987966",
"0.49985158",
"0.49971712",
"0.49966332",
"0.4996053",
"0.4992396",
"0.498504",
"0.49800867",
"0.49728623",
"0.49724033",
"0.4961791",
"0.49607164",
"0.49598306",
"0.49594206",
"0.49594083",
"0.49561763"
] |
0.6058934
|
3
|
Like self.find(), but returns nil when a DigitalObject isn't found instead of raising an error
|
def find_by_pid(pid)
find(pid)
rescue Hyacinth::Exceptions::DigitalObjectNotFoundError
return nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find(pid)\n digital_object_record = ::DigitalObjectRecord.find_by(pid: pid)\n\n if digital_object_record.nil?\n raise Hyacinth::Exceptions::DigitalObjectNotFoundError, \"Couldn't find DigitalObject with pid #{pid}\"\n end\n\n # Retry after Fedora timeouts / unreachable host\n fobj = nil\n Retriable.retriable DigitalObject::Base::RETRY_OPTIONS do\n fobj = ActiveFedora::Base.find(pid)\n end\n\n digital_object = DigitalObject::Base.get_class_for_fedora_object(fobj).new\n digital_object.init_from_digital_object_record_and_fedora_object(digital_object_record, fobj)\n digital_object\n end",
"def find\n fail NotImplementedError\n end",
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def find\n raise \"Method not implemented\"\n end",
"def find(id)\n raise NotImplementedError\n end",
"def find_record(xero_id)\n raise_must_override\n end",
"def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end",
"def find_by_id(id)\n find_by_id!(id)\n rescue TopdeskAPI::Error::RecordNotFound\n nil\n end",
"def find!(id)\n find(id) || raise(RecordNotFound, id)\n end",
"def find_object\n url = get_object_url()\n\n response = self.send_request('HEAD', url)\n\n case response.code\n when '404'\n return\n when '200'\n response = self.send_request('GET', url)\n @obj = JSON.parse(response.body)['_source']\n else\n fail(\"Fail to retrieve object '%s' (HTTP response: %s/%s)\" %\n [url, response.code, response.body])\n end\n end",
"def find(id)\n find_by_id(id).tap { |result|\n if result.nil?\n raise RecordNotFound, \"#{self.class.name}#find with ID #{id.inspect} was not found\"\n end\n }\n end",
"def find(id)\n finder_or_run(:find, id)\n end",
"def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end",
"def find(id); end",
"def find(id); end",
"def find\n super.first\n end",
"def find_one(options = {})\n @find_one ||=\n if primary_key_set?\n without_collection_params { super() }\n else\n klass.new_collection_from_result(limit(1).fetch(options)).first\n end\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def find(id)\n @adapter.find(collection, id).tap do |record|\n raise Lotus::Model::EntityNotFound.new unless record\n end\n end",
"def find_by_id(id)\n raise NotImplementedError.new\n end",
"def safe_obj_by_key!(obj_key)\n safe_obj_by_key(obj_key) or raise ActiveRecord::RecordNotFound\n end",
"def find! id, options = {}\n\n find( id, options ) ||\n raise( MongoMapper::DocumentNotFound.new(\"#{self.to_s} with id #{id} not found\") )\n\n end",
"def afind_one(spec_or_object_id=nil, opts={})\n spec = case spec_or_object_id\n when nil\n {}\n when BSON::ObjectId\n {:_id => spec_or_object_id}\n when Hash\n spec_or_object_id\n else\n raise TypeError, \"spec_or_object_id must be an instance of ObjectId or Hash, or nil\"\n end\n afind(spec, opts.merge(:limit => -1)).next_document\n end",
"def prepare_find\n raise Error.new('Cannot find an event without an ID') if id.blank?\n self\n end",
"def find_record(item, no_raise: false, meth: nil, **opt)\n # noinspection RubyMismatchedReturnType\n return item if item.nil? || item.is_a?(record_class)\n meth ||= __method__\n record = error = id = nil\n\n id_key = opt.key?(:id_key) ? opt[:id_key] : id_column\n if id_key\n opt.merge!(item) if item.is_a?(Hash)\n opt.reverse_merge!(id_term(item, **opt))\n id = opt[id_key] || opt[alt_id_key(opt)]\n if id && (id_key == id_column)\n record = record_class.find(id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif id\n record = record_class.find_by(id_key => id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n else\n error = \"#{id_key} value given\"\n end\n error &&= \"No #{record_name} #{error}\"\n else\n error = \"#{record_name}: :id_key set to nil\"\n end\n\n if record\n record\n elsif !id\n Log.info { \"#{meth}: #{error} (no record specified)\" }\n raise_failure(:file_id) unless no_raise\n elsif no_raise\n # noinspection RubyMismatchedReturnType\n Log.warn { \"#{meth}: #{error} (skipping)\" }\n else\n Log.error { \"#{meth}: #{error}\" }\n raise_failure(:find, item) unless no_raise\n end\n end",
"def find(id)\n find_result\n end",
"def find(key)\n FlyError::raise_superclass_error\n end",
"def find_by_id(id)\n nil_or_object(FFI::Libvirt.virDomainLookupByID(interface, id), Domain)\n end",
"def find_by_id(id)\n resp = get(\"/#{exposed_as}/#{id}\")\n case resp.response.code.to_i\n when 200\n result = MultiJson.load resp.parsed_response\n new(result)\n when 404\n nil\n else\n raise \"#{self.class.name}#try_find with ID #{id.inspect} returned unexpected response: #{resp.inspect}\"\n end\n end",
"def find(id)\n @objects[id]\n end",
"def find(name)\n result = nil\n connect do |conn|\n begin\n conn.search2(dn(name), 0, \"objectclass=*\") do |result|\n # Convert to puppet-appropriate attributes\n return entry2provider(result)\n end\n rescue => detail\n return nil\n end\n end\n end",
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && new(results) || nil\n end",
"def find_item(purchase_or_id)\n raise NotImplementedError\n end",
"def find_one(query={}, opts={})\n return nil unless doc = self.collection.find_one(query, opts)\n self.new(doc, false)\n end",
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find_object(name); end",
"def first!\n first or raise RecordNotFound\n end",
"def find_one(params, field = :_id)\n return nil if params.nil? #to avoid mistakes \n return self.find(params).first if params.is_a? Hash\n\n find_one((field.to_s) => params)\n end",
"def find; end",
"def method_missing(method, *args)\n begin\n if method != :find_by_symbol\n if obj = find_by_symbol(method)\n redefine_method method do\n find_by_symbol(method)\n end\n return obj\n end\n end\n rescue\n # Ignore errors, and call super\n end\n super\n end",
"def find_one(id)\n response = request(:get, \"/#{resource_name}/#{id}\")\n #puts response\n construct_record_from_singular(response)\n end",
"def find(code)\n new(code)\n rescue UnknownCurrency\n nil\n end",
"def find_record(item, no_raise: false, meth: nil, **opt)\n return item if item.nil? || item.is_a?(record_class)\n meth ||= __method__\n record = error = id = sid = nil\n id_key = opt.key?(:id_key) ? opt[:id_key] : id_column\n sid_key = opt.key?(:sid_key) ? opt[:sid_key] : sid_column\n if id_key || sid_key\n opt.merge!(item) if item.is_a?(Hash)\n opt.reverse_merge!(id_term(item, **opt))\n id = id_key && (opt[id_key] || opt[alt_id_key(opt)])\n sid = sid_key && opt[sid_key]\n if valid_sid?(id)\n if sid && (id != sid)\n Log.warn { \"#{meth}: id: #{id.inspect}, but sid: #{sid.inspect}\" }\n end\n id, sid = [nil, id]\n elsif id && sid\n Log.debug do\n \"#{meth}: choosing id: #{id.inspect} over sid: #{sid.inspect}\"\n end\n end\n if id && (id_key == id_column)\n record = record_class.find(id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif id\n record = record_class.find_by(id_key => id)\n error = \"for #{id_key} #{id.inspect}\" unless record\n elsif sid\n record = record_class.find_by(sid_key => sid)\n error = \"for #{sid_key} #{sid.inspect}\" unless record\n else\n error = '%s value given' % [id_key, sid_key].compact.join(' or ')\n end\n error &&= \"No #{record_name} #{error}\"\n else\n error = \"#{record_name}: both :id_key and :sid_key set to nil\"\n end\n if record\n record\n elsif !id && !sid\n Log.info { \"#{meth}: #{error} (no record specified)\" }\n raise_failure(:file_id) unless no_raise\n elsif no_raise\n # noinspection RubyMismatchedReturnType\n Log.warn { \"#{meth}: #{error} (skipping)\" }\n else\n Log.error { \"#{meth}: #{error}\" }\n raise_failure(:find, item) unless no_raise\n end\n end",
"def method_missing(name, *args)\n obj = find(name.to_s)\n if obj\n return obj.value\n else\n return nil\n end\n end",
"def find(id, optional = {})\n find_all([id], optional).first\n end",
"def find_by_id(id, options = {})\n if item = Dynamoid::Adapter.read(self.table_name, id, options)\n obj = self.new(item)\n obj.new_record = false\n return obj\n else\n return nil\n end\n end",
"def find(key)\n document = manager.get(key)\n\n # Prevent finding a node which is a member of the superclass, but\n # not this subclass, e.g. FinalDemandNode.find('not_an_fd_node')\n if document.nil? || ! document.is_a?(self)\n fail(DocumentNotFoundError.new(key, self))\n end\n\n document\n end",
"def find_single(id, *args)\n data = get(id.to_s, *args)\n return nil unless data && !data.empty?\n instantiate(id, data)\n end",
"def find(dn = self.dn, options = {})\n # Some misguided attempts to emulate active record.\n case dn\n when :all then search({:limit => false}.merge(options))\n when :first then first(options)\n when Array then dn.map {|d| fetch(d, options)}\n else fetch(dn, options)\n end\n end",
"def find_document!(model, id)\n document = model.find_by_id(id)\n unless document\n error 404, convert(body_for(:not_found))\n end\n document\n end",
"def find(id)\n end",
"def db_find(query=nil)\n return $posts.find(query)\nend",
"def get_or_404(type, id)\n obj = type.find_by_id(id)\n if obj.nil?\n render :json => type.missing_instance(id), :status => 404\n return nil\n end\n return obj\n end",
"def find_one(spec)\n doc = collection.find(spec.is_a?(Hash) ? spec : {}.merge('_id' => spec)).first\n new(doc) if doc\n end",
"def get_entry( c, dn ) # :yields: connection_info, distinguished_name\n \n self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap\n \n entry = @ldap.search( \n base: dn, \n filter: Net::LDAP::Filter.eq( 'objectClass', '*' ),\n scope: Net::LDAP::SearchScope_BaseObject,\n attributes: [ '*' ]\n )\n \n raise \"Error while searching: #{@ldap.get_operation_result.message}\" unless @ldap.get_operation_result.message =~ /(Success|No Such Object)/\n return entry ? entry.first : entry\n end",
"def find(id)\n klass.find(id)\n end",
"def find(item, type = nil)\n find_by_id(item) || find_by_generic(item, type)\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find_existing_record\n @record = record_class.find(@locator)\n end",
"def find\n\t\tif !defined?(@collection)\n\t\t\treturn false\n\t\telse\n\t\t\treturn @collection.find\n\t\tend\n end",
"def find_record\n record_id = params[:record_id] || params[:id]\n @record = Record.where(medical_record_number: record_id).first\n raise RequestError.new(404) if @record.nil?\n end",
"def first!\n first || raise_record_not_found_exception!\n end",
"def lookup!(id_or_slug)\n lookup(id_or_slug) || (raise Mongoid::Errors::DocumentNotFound.new(self, id_or_slug))\n end",
"def find(id, ignore: [])\n hit = es_get(id, ignore: ignore)\n if hit['found']\n result = instantiate_result(hit)\n return result\n end\n false\n end",
"def find(name)\n storage.fetch(name) { not_found(name) }\n end",
"def find(id)\n # Used where so no exception will be raised if the instance\n # does not exist.\n @model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first\n end",
"def find_or_initialize(query={}, opts={})\n find_one(query, opts) || new(query, true)\n end",
"def find(id)\n map_id = proc { |object| object.respond_to?(:id) ? object.send(:id) : object }\n\n result = find_by_id_or_ids(map_id, id)\n\n fail RecordNotFound.new(\n \"Couldn't find #{name} with '#{id_property_name}'=#{id.inspect}\",\n name, id_property_name, id) if result.blank?\n result.tap { |r| find_callbacks!(r) }\n end",
"def find_record\n record_id = params[:record_id] || params[:id]\n @record = Record.where(medical_record_number: record_id).first\n not_found if @record.nil?\n end",
"def find_by_id(id)\n find(id)\n end",
"def find\n\t\tif defined?(@collection)\n\t\t\treturn @collection.find\n \tend\n\tend",
"def fetch(dn = self.dn, options = {}) #:nodoc:\n find_one(dn, options)\n end",
"def record_not_found\n raise ActiveRecord::RecordNotFound\n end",
"def find(id)\n\nend",
"def find_one(id, query = nil)\n response = request(:get, \"/#{resource_name}/#{id}\", query)\n construct_record_from_singular(response)\n end",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find_invoice_or_fail(id)\n begin\n invoice = find_invoice(id)\n rescue InvalidInvoiceError => e\n raise Reji::AccessDeniedHttpError, e.message\n end\n\n raise ActiveRecord::RecordNotFound if invoice.nil?\n\n invoice\n end",
"def resolve_object obj\n case obj\n when Shark::Object\n obj\n when String\n obj.identifier? ? @storage.find(obj) : nil\n else\n nil\n end\n end",
"def find(id)\n repository.find(self, id)\n end",
"def find_record\n if record\n self.new_session = false\n return record\n end\n \n find_with.each do |find_method|\n if send(\"valid_#{find_method}?\")\n self.new_session = false\n return record\n end\n end\n nil\n end",
"def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end",
"def find(id)\n item = raw_find(id)\n item && item.dup\n end",
"def find_object\n @object = @model_class.find_by_id(params[:id].to_i)\n end",
"def find(id)\n response = client.get(endpoint(id))\n\n if response.success?\n new(response.body)\n else\n false\n end\n end",
"def find_one(&block)\r\n copy_and_return(@records.find(&block))\r\n end",
"def find_drop(slug)\n Drop.find slug\n rescue Drop::NotFound\n not_found\n end",
"def find_drop(slug)\n Drop.find slug\n rescue Drop::NotFound\n not_found\n end",
"def find_gracefully path\n path = full_path(path)\n if blob = find_blob(path)\n new(blob, path)\n else\n nil\n end\n end",
"def find(name, container = nil, findall = false)\n if container.nil?\n if findall\n @game_objects.find_all('@generic', name)\n else\n @game_objects.find(name)\n end\n elsif container.is_a? HasInventory\n container.search_inv(name)\n elsif not container.is_a? GameObject\n container = @game_objects.find(container)\n if container.nil?\n return nil\n else\n return find(name, container)\n end\n end\n end",
"def object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length == 1 ? objs[0] : nil\n end",
"def find_by_name(name)\n nil_or_object(FFI::Libvirt.virDomainLookupByName(interface, name), Domain)\n end",
"def find_record_by(model)\n raise_must_override\n end",
"def lookup(field)\n id = BSON::ObjectId(field.to_s)\n Server.new_instance self, collection.find_one(id)\n rescue BSON::InvalidObjectId\n Server.new_instance self, collection.find_one({ :display_name=>field }) || collection.find_one({ :link=>field })\n end",
"def find(*args)\n find_all(*args).first\n end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)\n results.blank? && nil || with_details(results)\n end",
"def find item\n\tend",
"def find_by_ncbi_id_or_fetch!(ncbi_id)\n find_by_ncbi_id(ncbi_id) || fetch!(ncbi_id)\n end",
"def find_object(parent_object, id)\n raise NotImplementedError, \"#{self.class} must implement method: #{__callee__}\"\n end",
"def find(typed_name)\n nil\n end",
"def find 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.get_doc index_id, doc_id\n return Document.from_hash(JSON.parse(resp.body)) if resp.success?\n return nil if resp.status == 404\n fail ApiError.from_response(resp)\n rescue JSON::ParserError\n raise ApiError.from_response(resp)\n end",
"def find_from!(collection, identifier, find_by = :id)\n if identifier.present?\n collection.detect { |instance| instance.send(find_by) == identifier.to_i } || (raise ActiveRecord::RecordNotFound)\n else\n raise ActiveRecord::RecordNotFound\n end\n end"
] |
[
"0.74274224",
"0.6814657",
"0.6559267",
"0.6468734",
"0.6432075",
"0.63332105",
"0.62680995",
"0.6197517",
"0.6134887",
"0.6084389",
"0.6084262",
"0.60618645",
"0.60472596",
"0.6045599",
"0.6045599",
"0.6028982",
"0.60053873",
"0.5977807",
"0.5976942",
"0.5947629",
"0.5902561",
"0.5899838",
"0.5890455",
"0.5869251",
"0.5854837",
"0.584266",
"0.5842355",
"0.58274716",
"0.5825847",
"0.58253604",
"0.5815555",
"0.5785834",
"0.57662076",
"0.57656354",
"0.57640666",
"0.5757496",
"0.5734792",
"0.57201403",
"0.57190526",
"0.56773365",
"0.567594",
"0.5674953",
"0.5671002",
"0.5647556",
"0.5635199",
"0.5629184",
"0.56233215",
"0.56181943",
"0.5613232",
"0.5601302",
"0.5583227",
"0.5579207",
"0.5578866",
"0.5571995",
"0.5567901",
"0.55602515",
"0.55601853",
"0.55601853",
"0.5554362",
"0.554537",
"0.55442506",
"0.5536437",
"0.5534908",
"0.55315006",
"0.55313694",
"0.55293065",
"0.5523343",
"0.5522191",
"0.5519126",
"0.55130994",
"0.5512969",
"0.54946256",
"0.54941434",
"0.5492928",
"0.54927945",
"0.54924875",
"0.54848236",
"0.54820424",
"0.54775506",
"0.54772544",
"0.54611075",
"0.5456357",
"0.54507124",
"0.54484683",
"0.54450226",
"0.54450226",
"0.5440834",
"0.5439221",
"0.5437228",
"0.5435966",
"0.5431163",
"0.5426458",
"0.54257476",
"0.54240626",
"0.54209334",
"0.5415611",
"0.5414451",
"0.53993887",
"0.53938216",
"0.5387797"
] |
0.75704217
|
0
|
GET /resource/sign_up def new super end POST /resource
|
def create
u = User.only_deleted.where("email = ?", params[:user][:email])
if u.present?
flash[:danger] = 'User Deleted. Please Contact Admin.'
redirect_to new_user_session_path
else
# if valid_email(params[:user][:email]) == true
super
# end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sign_up(resource_name, resource)\n end",
"def create\n build_resource(sign_up_params)\n\n resource.save\n render_resource(resource)\n end",
"def sign_up(resource_name, resource)\n redirect_to users_url\n end",
"def create\n build_resource(configure_sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n render json: { error_messages: resource.errors.full_messages.join(', ') }, status: 422\n end\n end",
"def create\n build_resource(sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n # set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n render json: resource # , location: after_sign_up_path_for(resource)\n else\n # set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def create\n build_resource sign_up_params\n\n if resource.save\n Notifier.notify_superusers_of_access_request(resource).deliver\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_in(resource_name, resource)\n respond_with resource, :location => after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def create\n build_resource(sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n flash[:notice] = 'Registration Successful.'\n render json: { after_sign_in_path: after_sign_in_path_for(User) }\n else\n expire_data_after_sign_in!\n render json: { error: 'Something went wrong' }, status: 422\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n render json: { error: resource.errors.full_messages.join('<br>') }, status: 422\n end\n end",
"def create\n build_resource(sign_up_params)\n\n respond_to do |format|\n if resource.save\n format.html { redirect_to admin_root_path, notice: 'User was successfully created.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end \n\n if resource.save\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_up(resource_name, resource)\n respond_with resource, :location => after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def create\n build_resource(configure_sign_up_params)\n resource.save\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n # To avoid login comment out sign_up method\n # sign_up(resource_name, resource)\n respond_to do |format|\n format.json { \n render json: resource # , location: after_sign_up_path_for(resource)\n }\n format.html {respond_with resource, location: after_sign_up_path_for(resource)}\n end\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_to do |format|\n format.json { \n render json: resource # , location: after_inactive_sign_up_path_for(resource)\n }\n format.html {respond_with resource, location: after_inactive_sign_up_path_for(resource)}\n end\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_to do |format|\n format.json { render json: { error_messages: resource.errors.full_messages.join(', ') }, status: 422 }\n format.html {respond_with resource}\n end\n end\n end",
"def sign_up(resource_name, resource)\n # sign_in(resource_name, resource)\n end",
"def new\n @sign_up = SignUp.new\n end",
"def create\n build_resource(sign_up_params)\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n # sign_up(resource_name, resource)\n # respond_with resource, location: after_sign_up_path_for(resource)\n\n # mailer\n AccountMailer.account_email(resource).deliver\n\n # devise override\n # (サインアップしたユーザーでログインせずadminページにリダイレクト)\n redirect_to admin_path\n\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def create\n build_resource(sign_up_params)\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n redirect_to new_matcher_registration_path, notice: error_al_registrar(resource)\n end\n end",
"def signup\n end",
"def signup\n end",
"def create\n build_resource\n #build_resource(sign_up_params)\n resource.email = resource_params[:email]\n # ^^ ref https://github.com/RailsApps/rails-prelaunch-signup/commit/ec01a952b56ccf49b4dfa4d529caea22b4dbdae8\n\n if resource.save\n if resource.active_for_authentication?\n sign_in(resource_name, resource)\n (render(partial: 'thankyou', layout: false) && return) if request.xhr?\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n expire_data_after_sign_in!\n (render(partial: 'thankyou', layout: false) && return) if request.xhr?\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n render action: :new, layout: !request.xhr?\n end\n end",
"def sign_up(resource_name, resource)\n true\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n flash[:notice] = \"Sign up successfully.\"\n end",
"def sign_up(resource_name, resource)\n # DO NOT sign_in(resource_name, resource)\n end",
"def new\n super\n @title = \"Sign up\"\n logger.debug \"\\n\\t RegistrationsController#new \\n\\n\"\n end",
"def create\n build_resource\n if resource.save\n log_event(\"signed up\")\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_in(resource_name, resource)\n respond_with resource, :location => after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def create\n\t\tcheck_recaptcha\n\t\tbuild_resource(sign_up_params)\n\t\tresource.m_client = self.m_client\n\t \tresource.set_client_authentication\n\t resource.save\n\t yield resource if block_given?\n\t if resource.persisted?\n\t if resource.active_for_authentication?\n\t set_flash_message! :notice, :signed_up\n\t sign_up(resource_name, resource)\n\t respond_with resource, location: after_sign_up_path_for(resource)\n\t else\n\t set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n\t expire_data_after_sign_in!\n\t respond_with resource, location: after_inactive_sign_up_path_for(resource)\n\t end\n\t else\n\t clean_up_passwords resource\n\t set_minimum_password_length\n\t respond_with resource\n\t end\n\n\tend",
"def sign_up(resource_name, resource)\n true\n end",
"def sign_up(resource_name, resource)\n true\n end",
"def sign_up\n NexaasID::Resources::SignUp.new(api_token, config)\n end",
"def create\n user = build_resource\n\n if user.save\n set_flash_message :notice, :signed_up\n sign_in('user', user)\n respond_with user, :location => after_sign_up_path_for(user)\n else\n clean_up_passwords user\n respond_with user\n end\n end",
"def devise_create_new_rails_user\n build_resource(sign_up_params)\n\n resource.save\n\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_flashing_format?\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_flashing_format?\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def create\n \n build_resource(sign_up_params)\n\n #this is a private function to check params\n if check_some_validations\n redirect_to new_user_registration_path\n else #the next part taken form Devise on github\n resource.save\n yield resource if block_given?\n\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end\n end",
"def create\n # Modified the super class to allow for ip address on sign_up\n build_resource(sign_up_params)\n resource.sign_up_ip = request.env['REMOTE_ADDR']\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n\n if @teacher.persisted?\n @teacher.submit_signup\n end\n cookies[:is_signed_in] = teacher_signed_in?\n cookies[:signed_in_type] = 'teacher'\n if teacher_signed_in?\n cookies[:name] = current_teacher.first_name\n end\n end",
"def create\n build_resource(sign_up_params)\n\n resource_saved = resource.save\n yield resource if block_given?\n if resource_saved\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_flashing_format?\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_flashing_format?\n expire_data_after_sign_in!\n redirect_to :new_user_session, flash: {notice: \"Seu registro foi efetuado com sucesso! Por favor aguarde a aprovação do admnistrador!\"}\n end\n else\n clean_up_passwords resource\n @validatable = devise_mapping.validatable?\n if @validatable\n @minimum_password_length = resource_class.password_length.min\n end\n respond_with resource\n end\n # redirect_to :back, flash: {error: \"Oops, something went wrong. Please try again\"}\n end",
"def create\n build_resource(sign_up_params)\n resource_saved = resource.save\n yield resource if block_given?\n if resource_saved\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_flashing_format?\n #sign_up(resource_name, resource)\n sign_up(resource_name, resource) if !employee_signed_in?\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_flashing_format?\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n #set_minimum_password_length\n respond_with resource\n end\n end",
"def signup\n puts 'signup is happening here'\n permitted = params.require('signup').permit(['email', 'password', 'password_confirmation'])\n @newUser = User.new(permitted)\n if @newUser.save\n head :ok\n else\n render json:{\"reason\": \"could not create user\"}, status: 422\n end\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def create\n @user = User.new(signup_params)\n if @user.save\n sign_in @user\n respond_to do |format|\n \tformat.json { render json: @user }\n end\n else\n # render :new\n end\n end",
"def create\n build_resource(sign_up_params)\n resource_saved = resource.save\n yield resource if block_given?\n if resource_saved\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up\n sign_in(resource_name, resource)\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n end\n\n @redirect_to_path = request.referer\n \n respond_to do |format|\n format.js { render 'registrations/success_registration' }\n end\n else\n # Errors occurred while registration\n clean_up_passwords resource\n @validatable = devise_mapping.validatable?\n \n @minimum_password_length = resource_class.password_length.min if @validatable\n\n respond_to do |format|\n format.js { render 'registrations/error_registration' }\n end\n end\n end",
"def create\n build_resource(sign_up_params)\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n sign_up(resource_name, resource)\n render status: 200\n else\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n render status: 400\n end\n end",
"def sign_up(resource_name, resource)\r\n # Create an account for this user.\r\n account = Account.create(name: \"#{resource.email}'s account\")\r\n \r\n # Sign in the user (from the original Devise::RegistrationsController).\r\n sign_in(resource_name, resource)\r\n end",
"def create\n build_resource(sign_up_params)\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n # respond_with resource, location: after_sign_up_path_for(resource)\n render 'users/registrations/finish_registration'\n # redirect_to(controller: \"custom_registration\", action: \"index\") and return\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n # respond_with resource, location: after_inactive_sign_up_path_for(resource)\n render 'users/registrations/finish_registration'\n # redirect_to(controller: \"custom_registration\", action: \"index\") and return\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def create\n @sign_up = SignUp.new(params[:sign_up])\n\t@referer ||= request.env['HTTP_REFERER']\n\t@sign_up.ip_address = request.remote_ip\n @sign_up.user_agent = request.env['HTTP_USER_AGENT']\n @sign_up.referer = @referer\n\n respond_to do |format|\n if @sign_up.save\n format.html { render :action => \"thanks\", :notice => 'Sign up was successful.' }\n #redirect_to :thanks\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sign_up.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def sign_up(resource_name, resource)\r\n sign_in(resource_name, resource)\r\n end",
"def sign_up\n @user = User.new(user_params)\n if @user.save\n sign_in(@user)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def signup\n client.signup(\n params[:user],\n params[:password]\n )\n end",
"def create\n @signup = Signup.new(params[:signup])\n \n respond_to do |format|\n if @signup.save\n format.html { redirect_to(root_url, :notice => 'Signup was successfully created.') }\n format.xml { render :xml => @signup, :status => :created, :location => @signup }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @signup.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def sign_up(resource_name, resource)\n sign_in(resource_name, resource)\n end",
"def signup\n @user = User.new\n end",
"def signup\n @user = User.new\n end",
"def create\n build_resource(sign_up_params)\n resource.name = params[:user][:name] if not params[:user][:name].blank?\n resource_saved = resource.save\n yield resource if block_given?\n if resource_saved\n if resource.active_for_authentication?\n set_flash_message :alert, :signed_up if is_flashing_format?\n sign_up(resource_name, resource)\n\n if request.referer && resource\n if request.referer.to_s.include? ('courses/activate')\n redirect_to '/courses/activate'\n return\n end\n end\n\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message :alert, :\"signed_up_but_#{resource.inactive_message}\" if is_flashing_format?\n expire_data_after_sign_in!\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n else\n set_flash_message :alert, :invalid_email if is_flashing_format?\n clean_up_passwords resource\n @validatable = devise_mapping.validatable?\n if @validatable \n @minimum_password_length = resource_class.password_length.min\n set_flash_message :alert, :invalid_email if is_flashing_format?\n end\n respond_with resource\n end\n end",
"def create\n @sign_up_user = SignUpUser.new(sign_up_user_params)\n # @sign_up_user = SignUpUser.new(user_params)\n\n respond_to do |format|\n if @sign_up_user.save\n format.html { redirect_to @sign_up_user, notice: 'Sign up user was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sign_up_user }\n else\n format.html { render action: 'new' }\n format.json { render json: @sign_up_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \thashPassword= Digest::MD5.hexdigest(params[:signup][:password])\n\t\tnewParams={\"name\" => params[:signup][:name], \"email\" => params[:signup][:email], \"password\" => hashPassword, \"phone\" => params[:signup][:phone] }\n\t\t@signup = Signup.new(newParams)\n respond_to do |format|\n if @signup.save\n\t\t\t\t@first = \"first\"\n\t\t\t\tformat.html { render action: \"login\" }\n #format.html { redirect_to @signup, notice: hashPassword }\n format.json { render json: @signup, status: :created, location: @signup }\n else\n format.html { render action: \"new\" }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:user][:password].blank?\n password = SecureRandom.base64(10)\n params[:user][:password] = password\n params[:user][:password_confirmation] = password\n end\n\n # Copied from devise-4.6.1/app/controllers/devise/registrations_controller.rb\n build_resource(sign_up_params)\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n # sign_up(resource_name, resource)\n # respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n # respond_with resource, location: after_inactive_sign_up_path_for(resource)\n end\n\n resource.send_account_created_instructions\n else\n clean_up_passwords resource\n set_minimum_password_length\n # respond_with resource\n end\n @users = User.order(:last_name, :first_name)\n @user = current_user\n\n if @user.nil?\n redirect_to :root, notice: \"You have been signed up. Please check your email to set a password and complete your registration.\"\n else\n render :index\n end\n end",
"def create\n build_resource(registration_params)\n\n #Find the email entered by the guest in the User table in the database \n @userTemp = User.where(email: resource.email).first\n \n #If user doesn't exist\n if @userTemp.nil?\n\n \t#Save it in the database\n\t if resource.save\n\t set_flash_message :notice, :signed_up\n\t sign_up(resource_name, resource)\n\t respond_with resource, :location => after_sign_up_path_for(resource)\n\t else\n\t #clean_up_passwords\n\t respond_with resource\n\t end\n\telse\n\t\t#If user already exists, go to registration url and show an error message\n\t\tredirect_to new_user_registration_url, :flash => { :error => \"Email already registered! Please Sign Up using another email!\" }\n\tend\n\n end",
"def create\r\n build_resource(sign_up_params)\r\n\r\n resource.save\r\n yield resource if block_given?\r\n if resource.persisted?\r\n if resource.active_for_authentication?\r\n set_flash_message! :notice, :signed_up\r\n sign_up(resource_name, resource)\r\n\r\n user_details = Api::V1::UserSerializer.new(resource)\r\n articles = ActiveModel::Serializer::CollectionSerializer.new(Article.all.to_a, serializer: Api::V1::ArticleSerializer)\r\n\r\n render json: { user: user_details, articles: articles }, status: :created\r\n else\r\n set_flash_message! :notice, :\"signed_up_but_#{resource.inactive_message}\"\r\n expire_data_after_sign_in!\r\n respond_with resource, location: after_inactive_sign_up_path_for(resource)\r\n end\r\n else\r\n clean_up_passwords resource\r\n set_minimum_password_length\r\n respond_with resource\r\n end\r\n end",
"def create\n build_resource(sign_up_params)\n\n if resource.save\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_up(resource_name, resource)\n if SystemConfiguration.count == 0 && @user.global_role_id == GlobalRole::ADMINISTRATOR_ID\n flash[:notice] += \" Please set up your system configuration now.\"\n respond_with resource, :location => edit_system_configuration_path\n else\n respond_with resource, :location => after_sign_up_path_for(resource)\n end \n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n if SystemConfiguration.count == 0 && @user.global_role_id == GlobalRole::ADMINISTRATOR_ID\n flash[:notice] += \" Please set up your system configuration now.\"\n respond_with resource, :location => edit_system_configuration_path\n else\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end \n end\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def signup\n @user= User.new\n end",
"def create\n build_resource(sign_up_params)\n\n if resource.save\n yield resource if block_given?\n\n set_flash_message :notice, 'actioncontroller.admin.created' if is_flashing_format?\n #sign_up(resource_name, resource)\n respond_with resource, :location => after_sign_up_path_for(resource)\n\n else\n clean_up_passwords resource\n respond_with resource\n end\n end",
"def create\n @sign_up = SignUp.new(sign_up_params)\n\n respond_to do |format|\n if @sign_up.save\n # format.html { redirect_to @sign_up, notice: 'Sign up was successfully created.' }\n format.html { redirect_to panel_path(1)}\n else\n format.html { render :new }\n format.json { render json: @sign_up.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sign_up\n user = User.new(signup_params)\n if user.save\n response = {success: true, result: user.id}\n render json: response, status: :created\n else\n response = {success: false}\n render json: response, status: :internal_server_error\n end\n end",
"def sign_up\n @user = User.new\n end",
"def create\n if resource.active_invitation? && !resource.new_record?\n # The user record already existed\n if resource.update(sign_up_params)\n resource.accept_invitation\n\n # Follow the standard Devise logic to sign in\n set_flash_message! :notice, :signed_up\n sign_up(resource_name, resource)\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n # Follow the standard Devise failed registration logic\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n elsif !Rails.configuration.x.recaptcha.enabled || verify_recaptcha(action: 'register')\n\n # Devise doesn't set a flash message for some reason if its going to fail\n # so do it here\n super do |user|\n flash[:alert] = _('Unable to create your account!') unless user.valid?\n\n # Attach the Shib eppn if this is part of an SSO account creation\n hash = session.fetch('devise.shibboleth_data', {})\n if hash.present? && user.valid?\n user.attach_omniauth_credentials(scheme_name: 'shibboleth',\n omniauth_hash: hash)\n end\n end\n else\n flash[:alert] = _('Invalid security check! Please make sure your browser is up to date and then try again')\n end\n end",
"def create\n build_resource(sign_up_params)\n if resource.save\n\n save_image_attribute!(sign_up_params[:profile_image] || sign_up_params[:profile_image_name], params[:remove_profile_image])\n\n child = (auth_user && auth_user.is_a?(Child)) ? auth_user : (params[:child_id] ? User.find_by_id(params[:child_id]) : nil)\n if child.is_a?(Child)\n connect_parent_and_child!(resource, child)\n end\n if resource.active_for_authentication?\n set_flash_message :notice, :signed_up if is_navigational_format?\n sign_up(resource_name, resource)\n\n else\n set_flash_message :notice, :\"signed_up_but_#{resource.inactive_message}\" if is_navigational_format?\n expire_session_data_after_sign_in!\n end\n respond_to do |format|\n format.json { render :json => {:success => true, :user => resource.json_attributes} }\n format.html { redirect_to(user_locations_path(initial_reg: params[:initial_reg], child_id: params[:child_id] ) ) }\n end\n else\n clean_up_passwords resource\n logger.info \" Errors: #{resource.errors.full_messages}\"\n respond_to do |format|\n format.json { render :json => {:success => false, :errors => resource.errors.messages} }\n format.html { params[:initial_reg] ? redirect_to(user_locations_url) : redirect_to(edit_user_registration_path) }\n end\n end\n end",
"def create\n user = User.new(sign_up_params)\n user.save!\n\n # Check if active for authentication.\n # If it needs mail confirmation, etc.., return false.\n if resource.active_for_authentication?\n # Validate params for authorize.\n if pre_auth.authorizable?\n # TODO: Fase 2, activate below flow.\n # if skip_authorization? || matching_token?\n # auth = authorization.authorize\n # redirect_to auth.redirect_uri\n # else\n # render :new\n # end\n\n # TODO: Fase 2, remove below process.\n result = authorization.authorize\n render json: result.auth, status: 201\n else\n # TODO: Fase 2, return error view.\n render json: pre_auth.error_response.body, status: 400\n end\n else\n render json: \"mail okuttayo\", status: 201\n end\n end",
"def client_sign_up\n\n end",
"def signup\n @user = User.new(params[:user])\n return unless request.post?\n if @user.save\n flash[:notice] = \"New user added!\"\n redirect_to :action=>'show', :id=>@user\n end\n end",
"def new_user\n\t\t@resource = User.new\n\t\t@resource_name = 'user'\n\tend",
"def create\n @user = User.new(sign_up_params)\n\t\t@user.permission = 0\n respond_to do |format|\n if @user.save\n format.html { redirect_to url_for({controller: :users, action: :sign_in, id: 0}), notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n build_resource sign_up_params\n\n resource.save\n yield resource if block_given?\n if resource.persisted?\n if resource.active_for_authentication?\n set_flash_message! :notice, :signed_up\n sign_up resource_name, resource\n if invitation_param && invitation_param != ''\n invitation = Invitation.find_by(token: invitation_param)\n invitation.update! user: current_user\n end\n if participate_param && participate_param != ''\n game = Game.find_by(id: participate_param)\n Invitation.create! user: current_user, game: game if game\n end\n respond_with resource, location: after_sign_up_path_for(resource)\n else\n set_flash_message! :notice,\n :\"signed_up_but_#{resource.inactive_message}\"\n expire_data_after_sign_in!\n respond_with resource,\n location: after_inactive_sign_up_path_for(resource)\n end\n else\n clean_up_passwords resource\n set_minimum_password_length\n respond_with resource\n end\n end",
"def sign_up\n self.sign_up_link\n CreateNewAccount.new @browser\n end",
"def new\n\t@user = User.new\n\t@title = \"Sign up\"\n end",
"def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end",
"def new\n @signup = Signup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signup }\n end\n end",
"def new\n @user = User.new\n @is_signup = true\n end",
"def new\n session[:signup_params] ||= {}\n @user = User.new(session[:signup_params])\n @user.signup_current_step = session[:signup_step]\t\n# @company = @user.build_company\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 @user_signup = User.new\n @is_signup = true\n end",
"def new\n\t\tmissing unless WAYGROUND['ALLOW_SIGNUP']\n\t\t@user = User.new(params[:user])\n\t\t@user.time_zone = Time.zone.name unless params[:user]\n\t\t@user.valid? if params[:user]\n\t\t@page_title = 'New User Registration'\n\tend",
"def create\n\n @seminar = Seminar.find(params[:seminar_id])\n\n @signup = Signup.new(signup_params)\n\n respond_to do |format|\n if @signup.save\n format.html { redirect_to @seminar, notice: \"Signup was successfully created.\" }\n format.json { render :show, status: :created, location: @seminar }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @signup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user = new_user\n\n authorize! :create, user\n\n user.unflattened_attributes = flat_params\n user.signup_type = :api\n\n user.save\n\n respond_with(user)\n end",
"def create \n\t\t@user=User.new\n\t\t@user.provider=\"native\"\n\t\t@user.assign_attributes(signup_params)\n\t\t@user.save!\n\t\tflash[:success]=\"Thanks for joining SPACEF!T, #{@user.name ||\n\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@user.email.split(\"@\").first }. \"\n\t\tsign_in!(@user, true)\n\t\tredirect_to root_path\n\trescue ActiveRecord::RecordInvalid,\n\t\t\t\t\tActiveRecord::RecordNotUnique => e\n\t\tflash.now[:error]=\"We were not able to sign you up, please correct the following fields\"\n\t\t@user.wipe\n\t\trender 'new'\n\tend",
"def signup\n case request.method\n when :post\n @user = User.new(params['user'])\n \n if @user.save \n session['user'] = User.authenticate(@user.login, params['user']['password'])\n flash['notice'] = _(\"Signup successful\")\n redirect_back_or_default :action => \"welcome\" \n end\n end \n end",
"def create\n build_resource(sign_up_params)\n if resource.save\n expire_session_data_after_sign_in!\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n else\n clean_up_passwords resource\n if resource.errors[:email].include?(I18n.t(\"errors.messages.taken\"))\n user = User.where(email: resource.email).first\n if user.active_for_authentication?\n # Send mail that already registered and ready to log in\n user.already_active_user_mail\n elsif user.invitation_token.nil?\n # Is not invited yet? tell him that he is already on the\n # waiting list\n user.already_waiting_mail\n else\n # Probably didn't get the invitation mail. Resend!\n user.re_invite!(:selfrequest)\n end\n resource.errors.clear\n end\n respond_with resource, :location => after_inactive_sign_up_path_for(resource)\n end\n end",
"def create\n @form = Users::SignUpForm.from_params(params)\n\n Users::SignUp.call(@form) do\n on(:ok) { redirect_to dashboard_index_path }\n on(:invalid) { render :new}\n on(:race_non_unique_email) do\n flash.now[:alert] = t(:email_taken)\n render :new\n end\n end\n end",
"def create\n @user = User.new(filter_sign_up_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user.profile, :notice => \"Welcome #{@user.name}!\" }\n format.json { render :json => @user, :status => :created, :location => @user }\n else\n errors = @user.errors.full_messages\n format.html { redirect_to signup_path({errors: errors}), flash: {error: 'Invalid email or password.'}}\n format.json { render :json => {errors: @user.errors, type: 'register'}, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n if @user.save\n redirect_to root_url, :notice => \"Signed up!\"\n else\n render \"new\"\n end\n end"
] |
[
"0.802381",
"0.79407203",
"0.7855574",
"0.78512365",
"0.7847869",
"0.77352446",
"0.76984376",
"0.76961756",
"0.76653403",
"0.7656444",
"0.7655498",
"0.7641147",
"0.7629752",
"0.76207453",
"0.76207453",
"0.7601901",
"0.7593272",
"0.75696474",
"0.7566873",
"0.7546625",
"0.75424844",
"0.7541681",
"0.75363",
"0.75363",
"0.7533934",
"0.7483312",
"0.7451734",
"0.7426215",
"0.74190265",
"0.7402497",
"0.7375282",
"0.7372295",
"0.73649013",
"0.73622227",
"0.7356853",
"0.7347141",
"0.7342903",
"0.7325265",
"0.73083436",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7278486",
"0.7266662",
"0.72616875",
"0.722045",
"0.7210537",
"0.7156728",
"0.7114885",
"0.7114885",
"0.71092194",
"0.7094203",
"0.707831",
"0.70692325",
"0.70534056",
"0.70253944",
"0.70212984",
"0.700779",
"0.7007127",
"0.70063066",
"0.6996979",
"0.6995494",
"0.699117",
"0.6986782",
"0.698594",
"0.69541126",
"0.6950511",
"0.6945074",
"0.69410604",
"0.6932035",
"0.6920663",
"0.69206095",
"0.68834746",
"0.68834746",
"0.68783796",
"0.6867561",
"0.68337864",
"0.68330127",
"0.68063533",
"0.68062717",
"0.6788584",
"0.6777378",
"0.6775637",
"0.67634594",
"0.676185",
"0.67600185"
] |
0.0
|
-1
|
If you have extra params to permit, append them to the sanitizer. def configure_sign_up_params devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute]) end If you have extra params to permit, append them to the sanitizer. def configure_account_update_params devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) end The path used after sign up. def after_sign_up_path_for(resource) super(resource) end The path used after sign up for inactive accounts.
|
def after_update_path_for(resource)
flash[:notice] = "Profile updated successfully"
home_path
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email,:password, :password_confirmation, :first_name, :last_name, :circonscription])\n devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :email, :password, :password_confirmation, :circonscription])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(\n :sign_up, keys: authentication_params(type: :sign_up)\n )\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :password, :password_confirmation])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: custom_parameters)\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :password, :password_confirmation])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:api_key, :home_zip_code, :full_name, :found_option])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: SIGNUP_KEYS)\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[email password username name lastname\n birth_date address type avatar phone_number])\n end",
"def configure_sign_up_params\n #devise_parameter_sanitizer.for(:sign_up) << :email, :password, :password_confirmation\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:email, :password, :password_confirmation, :picture, :bio, :username ) }\n\n devise_parameter_sanitizer.for(:account_update) << :bio\n devise_parameter_sanitizer.for(:account_update) << :role\n devise_parameter_sanitizer.for(:account_update) << :type\n devise_parameter_sanitizer.for(:account_update) << :picture\n devise_parameter_sanitizer.for(:account_update) << :username\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, \\\n keys: %i[name date_of_birth username terms_of_service])\n end",
"def configure_sign_up_params\n # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n # devise_parameter_sanitizer.permit(:sign_up) do |user_params|\n # user_params.permit(:email, :password, :password_confirmation)\n # end\n params.require(:user).permit(:email, :password, :password_confirmation)\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [:attribute, :first_name, :last_name, :terms_and_conditions, :profile_image]\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute, :first_name, :last_name])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :password])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :age, :address, :pincode, :phone, :gender, :dob, :position_id])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :email, :birth_date, :password])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :company_id, :birthday, :admin])\n end",
"def configure_permitted_parameters\n added_attrs = %i[username email password password_confirmation]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :first_name, :last_name])\n devise_parameter_sanitizer.permit(:account_update, keys: [:username, :first_name, :last_name])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [\n :first_name,\n :last_name,\n :street,\n :apartment_number,\n :city,\n :state,\n :zip_code,\n :phone,\n :email,\n :password])\n devise_parameter_sanitizer.permit(:account_update, keys: [\n :first_name,\n :last_name,\n :street,\n :apartment_number,\n :city,\n :state,\n :zip_code,\n :phone,\n :email,\n :password,\n :current_password])\n end",
"def configure_perimitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys:[:fname, :lname, :username, :seller])\n devise_parameter_sanitizer.permit(:account_update, keys:[:fname, :lname, :username, :seller])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first, :last, :email, :password])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << [\n :name, :current_profession, :years_experience,\n :desired_profession, :desired_location, :work_status\n ]\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, profile_attributes: [:name, :last_name, :phone]])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :email, :password, :password_confirmation])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:role, :first_name, :last_name, :company_name, :postal_code, :city, :province, :gender, :birth_date])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:last_name, :first_name, :birthday])\n end",
"def configure_sign_up_params\n # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :current_password, :names, :surnames, :area_of_residence_id, :area_of_interest_id])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:username, :first_name, :last_name,\n :email, :postcode, :city, :rating, :password, :phone_number, :password_confirmation)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:username, :first_name, :last_name,\n :email, :postcode, :city, :rating, :password, :phone_number, :password_confirmation, :current_password)\n end\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :name])\n end",
"def configure_permitted_parameters\n added_attrs = [:username, :email, :password, :password_confirmation]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_devise_params\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:first_name, :last_name, :email, :role, :password,\n :password_confirmation)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:first_name, :last_name, :email, :role, :password,\n :password_confirmation, :current_password)\n end\n end",
"def configure_permitted_parameters\n added_attrs = %i[username email password password_confirmation remember_me]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) do |u|\n u.permit(:name, :email, :password, :password_confirmation)\n end\n devise_parameter_sanitizer.permit(:account_update) do |u|\n u.permit(:name, :email, :password, :password_confirmation, :current_password)\n end\n end",
"def configure_sign_up_params\n devise_params_sanitizer.permit(:sign_up, keys: [:name, :description, :password, :email, :password_confirmation, :avatar])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) do |u|\n u.permit(:name, :last_name,\n :email, :password, :password_confirmation)\n end\n devise_parameter_sanitizer.permit(:account_update) do |u|\n u.permit(:name, :last_name,\n :email, :password, :password_confirmation, :current_password)\n end\n end",
"def configure_permitted_params\n devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation)}\n devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }\n end",
"def configure_permitted_parameters\n added_attrs = [:email, :first_name, :last_name, :account_type]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_permitted_parameters\n\t \tattributes = [:name, :email, :password, :password_confirmation, :remember_me]\n \tdevise_parameter_sanitizer.permit(:sign_up, keys: attributes)\n \tdevise_parameter_sanitizer.permit(:account_update, keys: attributes)\n\t end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:firstname, :lastname, :username ])\n devise_parameter_sanitizer.permit(:account_update, keys: [:firstname, :lastname, :username])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:fname, :lname, :avatar, :avatar_cache, :bio, :school, :job, :nickname, :grade, :major, :hometown])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :middle_name, :last_name, \n :phone, :gender, :birthday, :graduation_date, :school, :organization])\n end",
"def configure_permitted_parameters\n added_attrs = [:username, :email, :password, :password_confirmation, :remember_me]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_permitted_parameters\n attributes = [:first_name, :last_name, :street_address, :address_id, :overall_rating, :dob, :description, :phone_number, :emergency_contact_name, :emergency_contact_number, :emergency_contact_relationship, :gender_id, :occupation_id, :profile_photo]\n devise_parameter_sanitizer.permit(:sign_up, keys: attributes)\n devise_parameter_sanitizer.permit(:account_update, keys: attributes)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :account_name, :profile_sentence, :profile_image_id, :user_status])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) { |u| u.permit(:name, :email, :password, :address, :city, :postal_code, :province, :province_id) }\n\n devise_parameter_sanitizer.permit(:account_update) { |u| u.permit(:name, :email, :password, :current_password) }\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name])\n devise_parameter_sanitizer.permit(:account_update, keys: [:name])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name])\n devise_parameter_sanitizer.permit(:account_update, keys: [:name])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name])\n devise_parameter_sanitizer.permit(:account_update, keys: [:name])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :nationality_id ])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :phone, :workgroup, :timezone])\n params.require(:user).permit(:name, :email, :password, :password_confirmation, :phone, :timezone)\n end",
"def configure_permitted_parameters\n added_attrs = [:email, :password, :password_confirmation, :remember_me, :name]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :first_name, :last_name, :contact_number, :address, :suburb, :state, :postcode])\n #params.require(:user).permit(:email, :password, :password_confirmation, :first_name, :last_name, :contact_number, :address, :suburb, :state, :postcode)\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :email, :password, :password_confirmation, :admin])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :age])\n devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :age])\n end",
"def configure_permitted_parameters\n added_attrs = [:email, :first_name, :last_name]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_permitted_parameters\n added_attrs = [:email, :first_name, :last_name]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_permitted_parameters\n added_attrs = [:email, :first_name, :last_name]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :fname, :lname, :avatar, :bio, :street, :city, :state, :country, :lat, :lng])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:firstname,:middlename,:lastname,:contact,:birthday,:gender, :bio, :username])\n end",
"def configure_permitted_parameters\n added_attrs = %i[phone email password_confirmation remember_me]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :created_at, :updated_at, :telefono, :sucursalt_id, :tipousuariot_id, :activo, :consorciot_id, :sucursalbt, :siglas, :direccion, :ciudadt_id, :provinciat_id, :zonat_id, :vendedor, :contacto, :supervisort_id, :colectort_id, :sociot_id, :gppt_id])\n end",
"def configure_account_update_params\n devise_parameter_sanitizer.permit(\n :account_update, keys: authentication_params(type: :sign_up)\n )\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:name, :email, :password, :password_confirmation)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:name, :email, :password, :password_confirmation, :current_password)\n end\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :role, :establishment, :name])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation, :role])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up,\n keys: [\n :attribute,\n profile_attributes: [\n :username,\n :name,\n :address1,\n :address2,\n :city,\n :state,\n :zip\n ]\n ])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |u|\n u.permit(:name, :username, :email, :password)\n end\n devise_parameter_sanitizer.for(:account_update) do |u|\n u.permit(:name, :email, :password, :password_confirmation, :current_password)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username]) \n devise_parameter_sanitizer.permit(:account_update, keys: [:username])\nend",
"def configure_permitted_parameters\n devise_parameter_sanitizer.for(:sign_up) do |user|\n user.permit(:name, :email, :user_avatar, :password, :password_confirmation)\n end\n devise_parameter_sanitizer.for(:account_update) do |user|\n user.permit(:name, :email, :user_avatar, :password, :password_confirmation, :current_password, :commit)\n end\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up,\n keys: [:radio_certificate,\n :aviation_document,\n :aviation_document_date,\n :pilot_license_type,\n :pilot_license_number,\n :medical_category,\n :medical_date,\n :instrument_rating_date,\n :instrument_rating_renewal_date,\n :night_rating_date,\n :FAA_PPL_Conversion_date,\n :FAA_PPL_license,\n :FAA_CPL_license,\n :FAA_CPL_conversion_date,\n :biennial_flight_review])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[type])\n end",
"def configure_permitted_parameters\n added_attrs = %i[name username email password password_confirmation remember_me photo cover_image]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :attribute\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :attribute\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.for(:sign_up) << :attribute\n end",
"def configure_permitted_marameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name])\n devise_parameter_sanitizer.permit(:account_update, keys: [:name])\n end",
"def configure_permitted_parameters\n added_attrs = [ :username, :email, :password, :password_confirmation ]\n devise_parameter_sanitizer.permit :sign_up, keys: added_attrs\n devise_parameter_sanitizer.permit :account_update, keys: added_attrs\n devise_parameter_sanitizer.permit :sign_in, keys: added_attrs\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :registration, :course])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name])\n devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name])\n end",
"def configure_sign_up_params\n # devise_parameter_sanitizer.permit(:sign_up, :keys => [:username])\n devise_parameter_sanitizer.for(:sign_up) << :username\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: %i[email password username name lastname birth_date\n address type document_number document_type_id\n avatar document_face_pic document_back_pic phone_number])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up) do |u|\n u.permit(:email, :password, :password_confirmation, :first_name, :last_name, :sex, :date_of_birth, :contact_no, :address)\n end\n devise_parameter_sanitizer.permit(:account_update) do |u|\n u.permit(:password, :password_confirmation, :first_name, :last_name, :sex, :date_of_birth, :contact_no, :address)\n end\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :membership_number, :authorized_for_app])\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :membership_number, :authorized_for_app])\n end",
"def configure_sign_up_params\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :mobile_number, :email, :country, :state,\n :city, :address, :sponsor_id, :dob])\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up)\n end",
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :phone_number, :account])\n end"
] |
[
"0.8480727",
"0.84463453",
"0.8363743",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.8343737",
"0.827618",
"0.8251671",
"0.81992054",
"0.8192859",
"0.81923246",
"0.81831354",
"0.8180352",
"0.81715137",
"0.8170309",
"0.81379896",
"0.8129881",
"0.8123368",
"0.81091714",
"0.81061375",
"0.8098743",
"0.80910885",
"0.8089233",
"0.8085987",
"0.80857426",
"0.80748874",
"0.8074259",
"0.8073501",
"0.8072173",
"0.8065667",
"0.80508596",
"0.8047848",
"0.8042443",
"0.80391055",
"0.80278975",
"0.80277365",
"0.8023139",
"0.8022941",
"0.8022434",
"0.8020039",
"0.8017729",
"0.80170316",
"0.8007386",
"0.8003182",
"0.7992543",
"0.79883194",
"0.7986449",
"0.79812044",
"0.7980941",
"0.7979716",
"0.797938",
"0.797938",
"0.797938",
"0.797896",
"0.79768336",
"0.79768336",
"0.7974266",
"0.7973728",
"0.7973181",
"0.7968092",
"0.79657423",
"0.79636383",
"0.79636383",
"0.79636383",
"0.79556835",
"0.794912",
"0.79487324",
"0.7948149",
"0.7947541",
"0.7947042",
"0.7946703",
"0.79451746",
"0.79437816",
"0.7942765",
"0.7939777",
"0.79395086",
"0.79389143",
"0.7936897",
"0.7934386",
"0.7934037",
"0.79300344",
"0.79300344",
"0.79300344",
"0.7929463",
"0.7923979",
"0.7922304",
"0.79210997",
"0.79204726",
"0.791959",
"0.7917639",
"0.7916636",
"0.79159087",
"0.79137117",
"0.79083306"
] |
0.0
|
-1
|
maneuver states: hunt approach (spiral in until at optimal distance) circle_strafing target actions: lock on target
|
def best_target
far_enough = competitors.select do |competitor|
competitor.projected_position_at(current_tick_index).distance(self.sensors.position) >= RTanque::Bot::Turret::LENGTH
end
far_enough.sort_by do |competitor|
competitor.projected_position_at(current_tick_index).distance(self.sensors.position) +
(competitor.name == NAME ? 1000 : 0)
end.first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def setup_change_target\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n case @acts[1]\n # --------------------\n when 0 # Original Target\n self.area_flag = item_in_use.area?\n @target = @ori_target\n @target_array = @ori_targets.clone\n # -------------------\n when 1 # All Battler\n self.area_flag = true\n t = $game_party.alive_members + $game_troop.alive_members\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 2 # All Battler except user\n self.area_flag = true\n t = $game_party.alive_members + $game_troop.alive_members\n t -= [self]\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 3 # All Enemies\n self.area_flag = true\n t = opponents_unit.alive_members\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 4 # All Enemies except current target\n self.area_flag = true\n t = opponents_unit.alive_members\n t -= [target]\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 5 # All Allies\n self.area_flag = true\n t = friends_unit.alive_members\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 6 # All Allies except user\n self.area_flag = true\n t = friends_unit.alive_members\n t -= [self]\n @target_array = t\n $game_temp.battler_targets += t\n # -------------------\n when 7 # Next random enemy\n self.area_flag = false\n @target = opponents_unit.random_target\n @target_array = [@target]\n $game_temp.battler_targets += [@target]\n # -------------------\n when 8 # Next random ally\n self.area_flag = false\n @target = friends_unit.random_target\n @target_array = [@target]\n $game_temp.battler_targets += [@target]\n # -------------------\n when 9 # Absolute Targets (Enemies)\n self.area_flag = true\n @target_array = opponents_unit.abs_target(@acts[2])\n @target_array -= [target] if @acts[3]\n $game_temp.battler_targets += @target_array\n # -------------------\n when 10 # Absolute Target (Allies)\n self.area_flag = true\n @target_array = friends_unit.abs_target(@acts[2])\n @target_array -= [target] if @acts[3]\n $game_temp.battler_targets += @target_array\n # -------------------\n when 11 # self\n self.area_flag = false\n @target = self\n @target_array = [@target]\n $game_temp.battler_targets += [@target]\n end\n end",
"def setup_smooth_move_target\n if area_flag\n size = target_array.size\n xpos = target_array.inject(0) {|r,battler| r + battler.x}/size\n ypos = target_array.inject(0) {|r,battler| r + battler.y}/size\n xpos += @acts[1]\n xpos *= -1 if flip && !@ignore_flip_point\n rev = @acts[3]\n rev = true if rev.nil?\n smooth_move(xpos, ypos + @acts[2], @acts[3])\n return\n end\n return unless target\n tx = @acts[1] + target.x || 0\n ty = @acts[2] + target.y || 0\n tx *= -1 if flip && !@ignore_flip_point\n dur = @acts[3] || 25\n rev = @acts[4]\n rev = true if rev.nil?\n smooth_move(tx,ty,dur,rev)\n end",
"def setup_smooth_move_target\n if area_flag\n size = target_array.size\n xpos = target_array.inject(0) {|r,battler| r + battler.x}/size\n ypos = target_array.inject(0) {|r,battler| r + battler.y}/size\n xpos += @acts[1] * (flip && !@ignore_flip_point ? -1 : 1)\n dur = @acts[3] || 25\n rev = @acts[4]\n rev = true if rev.nil?\n smooth_move(xpos, ypos + @acts[2], dur, rev)\n return\n end\n return unless target\n tx = @acts[1] + target.x || 0\n ty = @acts[2] + target.y || 0\n tx *= -1 if flip && !@ignore_flip_point\n dur = @acts[3] || 25\n rev = @acts[4]\n rev = true if rev.nil?\n smooth_move(tx,ty,dur,rev)\n end",
"def setup_move_to_target\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n stop_all_movements\n if area_flag\n size = target_array.size\n xpos = target_array.inject(0) {|r,battler| r + battler.x}/size\n ypos = target_array.inject(0) {|r,battler| r + battler.y}/size\n xpos += @acts[1] * (flip && !@ignore_flip_point ? -1 : 1)\n # Get the center coordinate of enemies\n goto(xpos, ypos + @acts[2], @acts[3], @acts[4])\n return\n end\n xpos = target.x + (flip ? -@acts[1] : @acts[1])\n ypos = target.y + @acts[2]\n goto(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def setup_move_to_target\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n stop_all_movements\n if area_flag\n size = target_array.size\n xpos = target_array.inject(0) {|r,battler| r + battler.x}/size\n ypos = target_array.inject(0) {|r,battler| r + battler.y}/size\n xpos += @acts[1]\n xpos *= -1 if flip && !@ignore_flip_point\n # Get the center coordinate of enemies\n goto(xpos, ypos + @acts[2], @acts[3], @acts[4])\n return\n end\n xpos = target.x + (flip ? -@acts[1] : @acts[1])\n ypos = target.y + @acts[2]\n goto(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def target_acquired(board)\n puts \"#{@name} has acquired a target.\\nPrepare for imminent destruction.\"\n if board.hits.length == 1\n board.pos_cross(board.hits[0]).sample\n else\n target_direction(board, board.hits.sort)\n end\n end",
"def setup_add_state\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n c = @acts[2] || 100\n c = c/100.0 if c.integer?\n if area_flag\n target_array.each do |t|\n cx = c # Chance extra\n if !@acts[3]\n cx *= target.state_rate(@acts[1]) if opposite?(self)\n cx *= target.luk_effect_rate(self) if opposite?(self)\n end\n if chance(cx)\n t.add_state(@acts[1]) \n get_scene.tsbs_redraw_status(t)\n end\n end\n return\n end\n return unless target\n if !@acts[3]\n c *= target.state_rate(@acts[1]) if opposite?(self)\n c *= target.luk_effect_rate(self) if opposite?(self)\n end\n if chance(c)\n target.add_state(@acts[1]) \n get_scene.tsbs_redraw_status(target)\n end\n end",
"def setup_smooth_move_target\n targets = current_action_targets\n size = targets.size\n xpos = targets.inject(0){|r, battler| r + battler.map_char.x} / size\n ypos = targets.inject(0){|r, battler| r + battler.map_char.y} / size\n xpos += @acts[1]\n xpos *= -1 if flip && !@ignore_flip_point\n rev = @acts[3].nil? ? true : (@acts[3] || false)\n smooth_move(xpos, ypos + @acts[2], @acts[3])\n end",
"def get_move\n #puts \"get_move for #{self}\"\n return [] if goal == nil or goal == []\n while(1)\n rv = []\n g = goal.shift\n return [] if g == nil\n puts g.join('---')\n case g[0]\n when KILL\n e = g[1] # get the ennemy\n if(not $map.exists?(e) or e.life<=0)\n puts 'this ant does not exists anymore or is dead, next goal'\n next \n end\n \n dist = distance(self,e)\n #puts \"I am #{self}\"\n #puts \"goal: kill this enneny: #{e}\"\n i = 0\n if dist > 1 # move\n # by doing this we are finding subgoals\n # TODO: add_sub_goal ?\n\n path = find_best_way(e.x,e.y)# we have to move next to it\n #puts ppath(path)\n if path==nil\n # TODO: no path, find something else to do\n puts 'no path ! , next goal'\n next\n end\n \n # we have a path to it\n # so now we have to move smartly\n # if we are at 3 cases, we can move and attack\n # more than that we have to move at 4 cases and wait the next turn\n # TODO: do not wait at a position where we can be attacked\n if(path.size-2 <= 3) # minus two because the path include our case\n i = path.size-2 # 0 based minus one, so -2 \n #puts 's1'\n elsif(path.size-2 >= 6) # we are far away\n i = 6\n #puts 's2'\n else\n i = (path.size-2)\n #puts 's3'\n end\n #puts i\n #sleep(1)\n if i <= 0\n puts \"i <= 0 (#{i}), #{ppath(path)}\"\n sleep(5)\n else\n a,b = path[i][0]\n #puts \"I am moving to (#{[a,b].join(',')})\"\n self.x,self.y = a,b\n rv << \"Cb#{object_id}~\"+[a,b].pack('cc')\n #puts x\n end\n end\n return rv if i > 3 # return if we can not attack at the same round\n #puts i\n dist = distance(self,e)\n if dist == 1\n puts 'Attack'\n rv << \"Cc#{object_id}~#{e.object_id}\"\n e.life -= 5\n end\n return rv\n else\n puts 'unknown goal, next goal'\n end # case\n end #while\n puts \"no goal ? find something else to do !\"\n rv\n end",
"def setup_rem_state\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n c = @acts[2] || 100\n c = c/100.0 if c.integer?\n if area_flag\n target_array.each do |t|\n if chance(c)\n t.remove_state(@acts[1])\n get_scene.tsbs_redraw_status(t)\n end\n end\n return\n end\n return unless target\n if chance(c)\n target.remove_state(@acts[1])\n get_scene.tsbs_redraw_status(target)\n end\n end",
"def tick events\n @outerlimit = (battlefield_width + battlefield_height) * 3\n #print \"mode=#{@mode},stage=#{@stage},dir=#{@dir},walldir=#{@walldir}\\n\"\n #print \"at (#{x},#{y}) at time #{time},res=#{@trk_res}\\n\"\n #mode nil is startup and initialize variables\n #STDOUT.flush\n # ###########\n # # Sensors\n # ###########\n @since_evade += 1\n @sincehit += 1\n @sincehit = 0 if not events['got_hit'].empty?\n events['got_hit'].each{|e| @hit_filter += e.first}\n @hit_filter *= 0.99\n if events['robot_scanned'].empty?\n @sinceblip += 1\n @closest = @outerlimit\n #print\"\\n\" \n else\n @closest = events['robot_scanned'].collect{|e| e.first}.sort.first\n @sinceblip = 0\n #print \",blip=#{@closest}\\n\"\n end\n # ###########\n # # High level logic - state machine\n # ###########\n #print \"sincehit=#{@sincehit},closest=#{@closest},range=#{@range}\\n\"\n #mode 0 is orient tank\n if @mode == 0\n @stage = 0\n @range = @outerlimit\n @mode = 1 if aimrad(@dir*90)\n #mode 1 find range of nearest target\n elsif @mode == 1\n #setup radar for a scan\n if @stage==0\n aimrad(@dir*90 + 180,60,1)\n @range = min(@range,@closest)\n @stage +=1\n #continue around for full circle\n elsif @stage == 1\n @range = min(@range,@closest)\n if aimrad(@dir*90,60,1)\n #did we see a bot?\n if @range == @outerlimit\n @stage = 0 \n else\n @mode = 2\n @stage = 0\n end\n end\n end\n #mode 2: find the nearestbot\n elsif @mode == 2\n #start next circle to re find the closest bot\n if @stage == 0\n #print \"range is #{@range}\\n\"\n aimrad(@dir*90 + 180,60,1)\n @stage +=1\n #continue scan for the closest bot\n elsif @stage == 1\n #print \"dir=#{@dir},angle=#{radar_heading}, closest=#{@closest}\\n\"\n if @closest < @range * 1.25\n @range = @closest\n @mode = 3\n @stage = 0\n @tangle = radar_heading\n #print \"found target at angle #{@tangle}\\n\"\n #if we finished the scan, and didn't find close target, recompute range\n elsif aimrad(@dir*90,60,1)\n @mode = 0\n @stage =0\n end\n end\n #mode 3 is tracking bot\n elsif @mode == 3\n #entry from previous mode, determine whether to scan ccw or cw\n if @stage == 0\n @trk_dir,@trk_res,@stage = -1,4,2\n #first scan in this direction\n elsif @stage == 1\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n else\n @stage = 2\n end\n #second scan in this direction\n elsif @stage == 2\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = -@trk_dir\n @trk_res = max(@trk_res - 1,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n else\n @trk_dir = -@trk_dir\n @trk_res = min(@trk_res + 2,4)\n @stage = 3\n end\n #the target bot has moved out of our window, expand the window\n elsif @stage == 3\n if @closest < @range * 1.25\n @range = @closest\n @trk_dir = - @trk_dir\n @trk_res = max(@trk_res - 2,0)\n @mytrack.add(x,y,@radar_heading, @range , time) if @trk_res < 3\n @stage = 1\n elsif @trk_res < 6\n @trk_dir = - @trk_dir\n @trk_res = @trk_res +1\n else\n #we lost our target, reaquire from scratch\n @mode = 0\n @stage = 0\n end\n end\n @tangle += @@ScanRes[@trk_res] * @trk_dir\n aimrad(@tangle)\n #print\"tangle=#{@tangle}, res=#{@@ScanRes[@trk_res]}, rot=#{@trk_dir}\\n\"\n elsif @mode == 4\n #determine which corner to go to from a corner\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 + 95*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 60*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @prevCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n elsif @stage == 3\n aimrad(@dir*90 -5*@walldir)\n @stage += 1\n elsif @stage == 4\n @nextCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + @walldir)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n elsif @mode == 5\n #determine which corner to go to from middle of wall\n if @stage == 0\n @stage += 1 if aimrad(@dir*90 - 5*@walldir)\n #first scan in direction of prev corner\n elsif @stage == 1\n aimrad(@dir*90 + 30*@walldir)\n @stage += 1\n #save count of robots in next corner, and swing radar to previous corner\n elsif @stage == 2\n @nextCorner = events['robot_scanned'].size\n aimrad(@dir*90 + 150*@walldir)\n @stage += 1\n elsif @stage == 3\n @stage += 1 \n aimrad(@dir*90 -150*@walldir)\n elsif @stage == 4\n aimrad(@dir*90 -185*@walldir)\n @stage += 1\n elsif @stage == 5 \n @prevCorner = events['robot_scanned'].size\n #print \"next corner=#{@nextCorner}, prev corner=#{@prevCorner}\\n\"\n if @nextCorner > @prevCorner\n @dir = (@dir + 2)%4\n @walldir *= -1\n end\n @stage = 0\n @mode = 0\n end\n end\n #compute the distances to the four walls\n walls = [battlefield_width - x,y,x,battlefield_height - y]\n #hug the wall, if we are slightly off the wall, than move back to the wall\n toleftwall,torightwall = walls[(@dir+1)%4],walls[(@dir-1)%4]\n #print \"wallroom left=#{toleftwall}, right=#{torightwall}\\n\"\n if toleftwall > 80 and toleftwall < 200\n aimtank(@dir * 90 + 20)\n elsif torightwall > 80 and torightwall < 200\n aimtank(@dir * 90 - 20)\n else\n aimtank(@dir * 90)\n end\n #If we reach a corner or wall, turn towards farthest corner on this wall\n if walls[@dir] < 100\n if toleftwall > torightwall\n @walldir = 1 #we are now going ccw\n @dir = (@dir+1)%4 # turn ccw\n #print \"turn left\\n\" \n else\n @walldir = -1 #we are now going cw\n @dir = (@dir-1)%4 #turn cw\n #print \"turn right\\n\" \n end\n #don't check corners at T junction\n if toleftwall > 100 and torightwall > 100\n @mode = 5 # determin weather it is safer ahead or behind\n @stage = 0\n else\n @mode = 4 # determin if previous corner was safer\n @stage = 0\n end\n #If we are getting hammered, turn now to evade damage\n # once we evade, avoid making another evasive manuver or we will turn in circles\n elsif @hit_filter > 400 and @since_evade > 100\n @dir = (@dir+@walldir)%4\n @hit_filter = 0\n @since_evade = 0\n end\n accelerate 1\n aim = @mytrack.predict(x,y,time) || (@dir * 90)%360\n aimgun(aim)\n fire 0.1\n doturns #we already computed our turns, now execute them\n STDOUT.flush\n end",
"def path_blocked?(target)\n x_steps = target[0].to_i - @x\n y_steps = target[1].to_i - @y\n # Diagonal movements\n if x_steps != 0 && y_steps != 0\n (y_steps.abs - 1).times do |index| \n if y_steps > 0 && x_steps > 0\n current_target = \"#{@x + (index + 1)}#{@y + (index + 1)}\"\n return true if @board[current_target] != nil\n elsif y_steps < 0 && x_steps > 0\n current_target = \"#{@x + (index + 1)}#{@y - (index + 1)}\"\n return true if @board[current_target] != nil\n elsif y_steps > 0 && x_steps < 0\n current_target = \"#{@x - (index + 1)}#{@y + (index + 1)}\"\n return true if @board[current_target] != nil\n elsif y_steps < 0 && x_steps < 0\n current_target = \"#{@x - (index + 1)}#{@y - (index + 1)}\"\n return true if @board[\"#{target[0]}#{current_target}\"] != nil\n end\n end\n # Straight line movements\n else\n (y_steps.abs - 1).times do |index| \n if y_steps > 0\n current_target = @y + (index + 1)\n return true if @board[\"#{target[0]}#{current_target}\"] != nil\n elsif y_steps < 0\n current_target = @y - (index + 1)\n return true if @board[\"#{target[0]}#{current_target}\"] != nil\n end\n end\n (x_steps.abs - 1).times do |index| \n if x_steps > 0\n current_target = @x + (index + 1)\n return true if @board[\"#{current_target}#{target[1]}\"] != nil\n elsif x_steps < 0\n current_target = @x - (index + 1)\n return true if @board[\"#{current_target}#{target[1]}\"] != nil\n end\n end\n end\n false\n end",
"def setup_target_z\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n if area_flag\n target_array.each do |target|\n target.lock_z = @acts[1]\n end\n return\n end\n target.lock_z = @acts[1]\n end",
"def setup_move_to_target\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n xpos = target.x + (flip ? -@acts[1] : @acts[1])\n ypos = target.y + @acts[2]\n goto(xpos, ypos, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def setup_target_move\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n if area_flag\n target_array.each do |target|\n target.goto(*args)\n end\n return\n end\n target.goto(*args)\n end",
"def on_player_toggle_sneak(evt)\n player = evt.player\n return unless %w[world world_nether].include?(player.location.world.name)\n\n #if player.name == 'ujm'\n # #location_around(add_loc(player.location, 0, 5, 0), 5).map(&:block).each {|b| b.type = Material::AIR if b.type != Material::AIR }\n # location_around_flat(loc_below(player.location), 5).map(&:block).each {|b| b.type = Material::GRASS if b.type != Material::AIR }\n # player.perform_command 'dynmap render'\n #end\n # Superjump\n name = player.name\n @crouching_counter ||= {}\n @crouching_counter[name] ||= 0\n @crouching_countingdown ||= false\n if evt.sneaking?\n # counting up\n @crouching_counter[name] += 1\n later sec(2.0) do\n @crouching_counter[name] -= 1\n end\n if @crouching_counter[name] == 4\n play_sound(add_loc(player.location, 0, 5, 0), Sound::BAT_TAKEOFF, 1.0, 0.0)\n # evt.player.send_message \"superjump!\"\n player.fall_distance = 0.0\n player.velocity = player.velocity.tap {|v| v.set_y jfloat(1.4) }\n end\n\n # map teleport\n if player.location.pitch == 90.0\n item = player.item_in_hand\n if item && item.type == Material::MAP\n map = Bukkit.get_map(item.data.data)\n loc = block2loc(map.world.get_highest_block_at(map.center_x, map.center_z))\n loc = add_loc(loc, 0, 3, 0)\n loc.pitch = 90.0\n loc.yaw = player.location.yaw\n loc.chunk.load\n\n animals = player.get_nearby_entities(2, 2, 2).select {|e|\n Player === e\n }\n move_livings = [player] + animals\n\n play_effect(player.location, Effect::ENDER_SIGNAL, nil)\n play_sound(player.location, Sound::ENDERMAN_TELEPORT , 1.0, 0.5)\n move_livings.each do |e|\n e.velocity = e.velocity.tap {|v| v.set_y 1.0 }\n end\n later sec(0.5) do\n move_livings.select(&:valid?).each do |e|\n e.teleport(loc)\n e.fall_distance = 0.0\n play_effect(player.location, Effect::ENDER_SIGNAL, nil)\n play_sound(loc, Sound::ENDERMAN_TELEPORT , 1.0, 0.5)\n end\n end\n end\n end\n\n ctf_sneaking(player) if @ctf_players.member?(player)\n end\n\n #player_update_speed(evt.player, snp: evt.sneaking?)\n\n #player = evt.player\n #if player.equipment.boots && HARD_BOOTS.include?(player.equipment.boots.type)\n # if !evt.player.on_ground? && evt.sneaking?\n # later 0 do\n # newloc = player.location\n # newloc.x = newloc.x.to_i.to_f - 0.5\n # newloc.z = newloc.z.to_i.to_f - 0.5\n # player.teleport newloc\n # play_effect(newloc, Effect::ENDER_SIGNAL)\n # player.velocity = Vector.new(0.0, -1.0, 0.0)\n # end\n # loc = (1..4).lazy.\n # map {|y| evt.player.location.clone.add(0, -y, 0) }.\n # find {|l| l.block.type != Material::AIR }\n # later sec(0.2) do\n # if loc && loc.block.type == Material::STONE\n # loc.block.break_naturally(ItemStack.new(Material::DIAMOND_PICKAXE))\n # end\n # end\n # end\n #end\n end",
"def class_update\n if can_drop_bomb? and closest_target\n drop_bomb if on_top_of?(closest_target)\n if facing_right_of?(closest_target)\n turn_left\n end\n if facing_left_of?(closest_target)\n turn_right\n end\n end\n go_forward\n loop_position\n end",
"def haze(source, target)\n\tsource.attack_stage = 6\n\tsource.defense_stage = 6\n\tsource.special_attack_stage = 6\n\tsource.special_defense_stage = 6\n\tsource.speed_stage = 6\n\tsource.crit_stage = 0\n\t\n\ttarget.attack_stage = 6\n\ttarget.defense_stage = 6\n\ttarget.special_attack_stage = 6\n\ttarget.special_defense_stage = 6\n\ttarget.speed_stage = 6\n\ttarget.crit_stage = 0\nend",
"def try_something(ball)\n dist = (ball.position - @position).r\n\n if ball.carrier == self\n return Action.new(self,:kick_forward) if @rand.rand(1.0)>0.9 and (Vector[50 + @play_direction[0]*50,30] - @position).r>30\n return Action.new(self,:shoot_at_goal) if @rand.rand(1.0)>0.25 and (Vector[50 + @play_direction[0]*50,30] - @position).r<30\n return nil\n elsif dist<1.5\n if ball.carrier.nil?\n return Action.new(self, :tackle)\n else\n return Action.new(self, :tackle) unless ball.carrier.team == self.team\n end\n end\n return nil\n end",
"def battle\n # Runden auf 0 setzen, continue auf true (Für die Schleife)\n round = 0\n continue = true\n victory = false\n # Bilde Arrays mit allen nötigen Werten für den Kampf\n turn_fleet = build_array(@attacker, @attacker_fleet)\n target_fleet = build_array(@defender, @defender_fleet)\n emp_phase(@attacker)\n emp_phase(@defender)\n # Angreifer beginnt\n turn_user = @attacker\n target_user = @defender\n while (round < 1000 && continue ) do\n round = round + 1\n if target_user == @defender\n @fight_shield = @defender_shield\n else\n @fight_shield = @attacker_shield\n end\n # Damit alle Gruppen in einer Runde nur auf das Schild feuern können\n shield = @fight_shield\n # Für die Ausgabe der Runden-Berichte\n turn_fleet.each do |fleet|\n # Nur Einheiten mit Anzahl > 0 und Schaden > 0 können kämpfen\n if fleet[1] > 0 && fleet[2] > 0 \n # Bestimme Ziel anhand von id.\n # -2 ist Miss\n # -1 ist Schild\n target = hit(target_fleet, turn_user)\n if(target==-1)\n mult = 1\n # Falls Ionenwaffe, wird Schaden an Schild erhöht\n if fleet[3] == 2\n mult = DamageType.find(fleet[3]).shield_mult\n end\n damage = fleet[2] * mult\n # Abzug des Schilds. Übernahme erst bei nächster Runde\n @fight_shield = @fight_shield - damage\n else\n mult = 1\n # Falls Laserwaffe, wird Schaden an Hülle erhöht\n # TABELLE DAMAGETYPE EINFÜGEN\n if (fleet[3] == 1)\n mult = DamageType.find(fleet[3]).shell_mult\n end \n if fleet[3] == 3 and !fleet[6]\n mult = DamageType.find(fleet[3]).station_mult\n end\n if fleet[3] == 4 and fleet[0] == @plattform_id\n mult = DamageType.find(fleet[3]).plattform_mult\n end \n # Bestimme welche Einheit getroffen wurde\n victim = target_fleet[target]\n # Schadensberechnung\n damage = fleet[2] * mult\n # Berechne neue HP\n hit_points = victim[-2]\n victim[-2] = hit_points-damage\n # Berechne Anzahl und Schaden neu\n update_ship_group(victim, target_user)\n end\n end \n end\n # Füge Runden-Bericht ein\n # Testet, ob Spieler noch Truppen besitzt\n if (defeat(target_fleet))\n continue = false\n if turn_user == @attacker\n victory = true \n end\n else\n # Falls Schild unter 0, wird er auf 0 gesetzt\n if @fight_shield < 0\n @fight_shield = 0\n end\n # Kampf-Schild für nächste Runde\n if target_user == @attacker\n @attacker_shield = @fight_shield\n else\n @defender_shield = @fight_shield\n end\n # Tausche Rolle des Angreifers aus\n tmp_fleet = turn_fleet\n tmp_user = turn_user\n turn_fleet = target_fleet\n turn_user = target_user\n target_fleet = tmp_fleet\n target_user = tmp_user\n end\n # Füge alle Runden-Berichte hinzu\n end\n if continue\n @report << \"Unentschieden! \"\n @report << \"Es konnte kein Sieger ermittelt werden \"\n else \n @report << \"Die Flotte von #{target_user.username} unterlag. \"\n @report << \" #{turn_user.username} war siegreich! \"\n end\n # Generiere Verlustrechnung\n attacker_fleet_ary = []\n defender_fleet_ary = []\n if turn_user == @attacker\n lost_report(turn_fleet, @attacker) \n lost_report(target_fleet, @defender) \n attacker_fleet_ary = turn_fleet\n defender_fleet_ary = target_fleet\n else\n lost_report(target_fleet, @attacker) \n lost_report(turn_fleet, @defender) \n\n attacker_fleet_ary = target_fleet\n defender_fleet_ary = turn_fleet\n end\n update_fighting_fleet(@attacker_fleet, attacker_fleet_ary)\n update_fighting_fleet(@defender_fleet, defender_fleet_ary)\n ary = [@attacker_fleet, @defender_fleet] \n return [@report, @spy_report]\n end",
"def calc_am_slow_start(user, target)\n VAL_0_5 if user.turn_count < 5\n end",
"def update_phase4_step2\n # If not a forcing action\n unless @active_battler.current_action.forcing\n # If restriction is [normal attack enemy] or [normal attack ally]\n if @active_battler.restriction == 2 or @active_battler.restriction == 3\n # Set attack as an action\n @active_battler.current_action.kind = 0\n @active_battler.current_action.basic = 0\n end\n # If restriction is [cannot perform action]\n if @active_battler.restriction == 4\n # Clear battler being forced into action\n $game_temp.forcing_battler = nil\n # Shift to step 1\n @phase4_step = 1\n return\n end\n end\n # Clear target battlers\n @target_battlers = []\n # Branch according to each action\n case @active_battler.current_action.kind\n when 0 # basic\n make_basic_action_result\n when 1 # skill\n make_skill_action_result\n when 2 # item\n make_item_action_result\n end\n # Shift to step 3\n if @phase4_step == 2\n @phase4_step = 3\n end\n end",
"def fiddle args\n args.state.gravity = -0.3\n args.state.enemy_jump_power = 10 # sets enemy values\n args.state.enemy_jump_interval = 60\n args.state.hammer_throw_interval = 40 # sets hammer values\n args.state.hammer_launch_power_default = 5\n args.state.hammer_launch_power_near = 2\n args.state.hammer_launch_power_far = 7\n args.state.hammer_upward_launch_power = 15\n args.state.max_hammers_per_volley = 10\n args.state.gap_between_hammers = 10\n args.state.player_jump_power = 10 # sets player values\n args.state.player_jump_power_duration = 10\n args.state.player_max_run_speed = 10\n args.state.player_speed_slowdown_rate = 0.9\n args.state.player_acceleration = 1\n args.state.hammer_size = 32\nend",
"def update_phase4_step2\r\n # If not a forcing action\r\n unless @active_battler.current_action.forcing\r\n # If restriction is [normal attack enemy] or [normal attack ally]\r\n if @active_battler.restriction == 2 or @active_battler.restriction == 3\r\n # Set attack as an action\r\n @active_battler.current_action.kind = 0\r\n @active_battler.current_action.basic = 0\r\n end\r\n # If restriction is [cannot perform action]\r\n if @active_battler.restriction == 4\r\n # Clear battler being forced into action\r\n $game_temp.forcing_battler = nil\r\n # Shift to step 1\r\n @phase4_step = 1\r\n return\r\n end\r\n end\r\n # Clear target battlers\r\n @target_battlers = []\r\n # Branch according to each action\r\n case @active_battler.current_action.kind\r\n when 0 # basic\r\n make_basic_action_result\r\n when 1 # skill\r\n make_skill_action_result\r\n when 2 # item\r\n make_item_action_result\r\n end\r\n # Shift to step 3\r\n if @phase4_step == 2\r\n @phase4_step = 3\r\n end\r\n end",
"def move_one_patch\n target = patch_ahead 1\n\n # faced patch desirable\n # faced patch force move\n #\n # find desirable neighboring patch\n # no desirable, about face\n\n if passable?(target)\n if patch_desirable?(target)\n walk_forward 1\n self.random_walk_suitable_count += 1\n elsif should_leave?\n walk_forward 1\n self.random_walk_unsuitable_count += 1\n else\n select_forage_patch_and_move\n end\n else\n select_forage_patch_and_move\n end\n end",
"def walk\n return false if (@captives > 0 and captives_close and warrior.feel(get_bomb_direction).captive?) or # Captives needs to be rescued, dont walk away\n count_unit_type(:Sludge) > 5\n message = nil\n walk_to = nil\n if check_for_a_bomb and @bomb_optimal_direction != false\n message = \"Walking to captive with the bomb optimal direction to direction #{@bomb_optimal_direction}\"\n walk_to = @bomb_optimal_direction\n elsif @captives > 0 and check_for_a_bomb and !warrior.feel(:forward).enemy?\n message = \"Walking to get the captive with a bomb to direction #{get_bomb_direction}\"\n walk_to = get_bomb_direction\n elsif @captives > 0 and warrior.look(:forward)[1].to_s.to_sym == :\"Thick Sludge\" and count_unit_type(:\"Thick Sludge\") > 1\n message = \"Walking to avoid sludges to direction #{@captives_direction[0]}\"\n walk_to = :right\n elsif @enemies_binded < 3 and @captives > 0 and !enemies_close\n message = \"Walking to rescue captives to direction #{@captives_direction[0]}\"\n walk_to = @captives_direction[0]\n elsif !under_attack and warrior.listen.empty?\n message = \"Walking to the stairs to direction #{warrior.direction_of_stairs}\"\n walk_to = warrior.direction_of_stairs\n elsif !under_attack and !enemies_close\n message = \"Walking to closest unit to direction #{warrior.direction_of(warrior.listen.first)}\"\n walk_to = warrior.direction_of(warrior.listen.first)\n end\n if walk_to != nil\n if message != nil\n puts message\n end\n return warrior.walk! walk_to\n end\n return false\n end",
"def tick!\n if target = acquire_target\n shoot_at(target)\n else\n scan_for_targets\n end\n end",
"def do_mill\r\n # - - - - - - - - - - - - - - - - - - \r\n max_diam = 4.95\r\n max_radius = max_diam / 2\r\n shaft_support_diam = 0.55\r\n beg_diam = shaft_support_diam\r\n shaft_diameter = 1.0 / 4.0\r\n beg_corr_width = 0.2\r\n growth_factor = 0.09 # 0.12 #0.15 #0.25\r\n degree_increment = 30\r\n wall_thick = 0.015\r\n sweep = 45.0\r\n curr_radius = beg_diam / 2\r\n curr_degree = 0.0\r\n curr_corr_width = beg_corr_width\r\n degree_inc = 4.0\r\n inner_adj_factor = 1.2 #0.8 #0.7 #0.9 #1.2 #2.7 #2.1\r\n material_thickness = 1.0\r\n outer_radius_beg = curr_radius + curr_corr_width\r\n\r\n aCircle = CNCShapeCircle.new(mill,x,y)\r\n aCircle.mill_pocket(x, y, 1.0, depth,shaft_support_diam)\r\n mill.retract() # mill whole for entrance \r\n # of gases from prior chamber but leave\r\n # shaft support area\r\n\r\n aCircle.mill_pocket(x, y, shaft_diameter, 0 - material_thickness.abs)\r\n mill.retract() # mill hole for the shaft\r\n\r\n\r\n\r\n while true\r\n end_degree = curr_degree + sweep\r\n end_corr_width = curr_corr_width + (curr_corr_width * growth_factor)\r\n\r\n outer_radius_end = curr_radius + end_corr_width\r\n\r\n inner_rad_end = curr_radius + (curr_radius * growth_factor * inner_adj_factor)\r\n\r\n inner_adj_factor = inner_adj_factor * 0.97\r\n\r\n arc_segment_pocket_adv(mill, x,y,\r\n curr_radius, \r\n outer_radius_beg,\r\n curr_degree,\r\n inner_rad_end, \r\n outer_radius_end, \r\n end_degree, \r\n 0,\r\n depth,\r\n degree_inc)\r\n\r\n curr_degree += sweep\r\n curr_corr_width = end_corr_width\r\n\r\n curr_radius = inner_rad_end\r\n\r\n outer_radius_beg = outer_radius_end\r\n\r\n if (outer_radius_end > max_radius)\r\n break\r\n end #if\r\n\r\n\r\n\r\n\r\n end #while\r\n end",
"def update_self_movement\n return if $game_system.story_mode?\n if !@pathfinding_moves.empty?\n process_pathfinding_movement\n #elsif BattleManager.valid_battler?(self) && @current_target\n # chase_target\n elsif near_the_screen? && @stop_count > stop_count_threshold\n case @move_type\n when 1; move_type_random\n when 2; move_type_toward_player\n when 3; move_type_custom\n end\n end\n end",
"def update_target_position\n return if no_target\n @target.opacity -= 20 if @flag\n @target.opacity += 20 unless @flag\n @flag = true if @target.opacity >= 250\n @flag = false if @target.opacity <= 50\n end",
"def beast_mode(derp)\n largest_radius = [self.arena.width, self.arena.height].min / 2\n desired_dfd = largest_radius * self.health_factor\n dfd_delta = (desired_dfd - derp.distance).abs\n\n command.turret_heading = derp.heading\n command.radar_heading = derp.heading\n\n if (derp.heading.delta(sensors.turret_heading)).abs < TURRET_FIRE_RANGE\n command.fire(derp.distance > 200 ? MAX_FIRE_POWER : MIN_FIRE_POWER)\n end\n\n angle_from_derp = desired_dfd > derp.distance ? sensors.radar_heading : sensors.radar_heading + 180\n\n if dfd_delta <= 20 # we are at desired distance away\n command.heading = @clockwise ? angle_from_derp + 85 : angle_from_derp - 85\n command.speed = MAX_BOT_SPEED * (1 - (derp.distance / largest_radius))\n else\n command.heading = angle_from_derp\n command.speed = MAX_BOT_SPEED\n end\n\n end",
"def sweep_stairs\n climb_stair\n pick_beeper\n climb_stair\n pick_beeper\n climb_stair\n pick_beeper\n turn_off\n end",
"def steer(target, slowdown) \n desired = PVector.sub(target,@loc) # A vector pointing from the @location to the target\n d = desired.mag # Distance from the target is the magnitude of the vector\n # If the distance is greater than 0, calc steering (otherwise return zero vector)\n if (d > 0) \n # Normalize desired\n desired.normalize\n # Two options for desired vector magnitude (1 -- based on distance, 2 -- @maxspeed)\n if ((slowdown) && (d < 100.0)) \n desired.mult(@maxspeed*(d/100.0)) # This damping is somewhat arbitrary\n else desired.mult(@maxspeed)\n # Steering = Desired minus Ve@locity\n steer = PVector.sub(desired,@vel)\n steer.limit(@maxforce) # Limit to maximum steering force\n end \n else \n steer = PVector.new(0,0)\n end\n return steer\n end",
"def make_attack_targets\n targets = []\n if battler.confusion?\n targets.push(friends_unit.random_target)\n elsif battler.berserker?\n targets.push(opponents_unit.random_target)\n else\n targets.push(opponents_unit.smooth_target(@target_index))\n end\n if battler.dual_attack # Chain attack\n targets += targets\n end\n return targets.compact\n end",
"def explore\n rover_bay.each do |r|\n if pass_path_check?(r)\n move(r)\n else\n raise \"There is a collision\\nin placement #{r.coordinate.inspect}, please revise instruction set #{r.command.inspect}\"\n end\n end\n end",
"def computeMidMovePoint()\n# dist = computeDistance(@targetPosition, @ballPosition)\n dist = (@targetPosition.getX() - @ballPosition.getX()).abs() + (@targetPosition.getY() - @ballPosition.getY()).abs()\n \n dX = (@targetPosition.getX() - @ballPosition.getX()) / dist\n dY = (@targetPosition.getY() - @ballPosition.getY()) / dist\n moveX = @ballPosition.getX() - dX * @@odLopty\n moveY = @ballPosition.getY() - dY * @@odLopty\n \n movePositionTmp = Java::sk.fiit.robocup.library.geometry.Vector3D.cartesian(moveX, moveY, 0)\n\n agentModel = Java::sk.fiit.jim.agent.models.AgentModel.getInstance()\n movePosition = agentModel.relativize(movePositionTmp)\n \n moveDist = movePositionTmp.getXYDistanceFrom(@agentPosition)\n ballDist = @ballPosition.getXYDistanceFrom(@agentPosition)\n \n# if ((@ballPosition.getPhi() - movePositionTmp.getPhi()).abs() < 0.1 && moveDist > ballDist)\n# puts \"BP: \"+@ballPosition.getX().to_s+\", \"+@ballPosition.getY().to_s\n# puts \"MID: \"+movePositionTmp.getX().to_s+\", \"+movePositionTmp.getY().to_s\n# if dX > dY\n# newMP = Java::sk.fiit.robocup.library.geometry.Vector3D.cartesian(\n# movePositionTmp.getX() + 1.5 * dY,\n# movePositionTmp.getY() - 1.5 * dX,\n# 0)\n# else\n# newMP = Java::sk.fiit.robocup.library.geometry.Vector3D.cartesian(\n# movePositionTmp.getX() - 1.5 * dY,\n# movePositionTmp.getY() + 1.5 * dX,\n# 0)\n# end\n# \n# movePosition = agentModel.relativize(newMP)\n# \n# @indirectMove = true\n# end\n \n return movePosition\n end",
"def initialize_strategy\n main_position = player.command_centers.first.position\n _, *unscouted_bases = BWTA.start_locations.to_a.map(&:position).sort do |a, b|\n main_position.getDistance(b) <=> main_position.getDistance(a)\n end.reverse\n overlord_target = nil\n\n #Basic Strategy:\n strategy_step \"Every idle worker should mine\" do\n precondition { player.workers.any? &:idle? }\n\n postcondition { false } #this step should be repeated\n\n order do\n center = player.command_centers.first\n\n minerals = state.units.values.select{|u| u.type.mineral_field? }.sort do |a, b|\n b.distance(center) <=> a.distance(center)\n end\n\n player.workers.select(&:idle?).each do |worker|\n worker.mine(minerals.pop)\n end\n end\n end\n\n #When there is less than 5 supply and a spawning pool does not exist, a drone should be spawned\n strategy_step \"Spawn a drone\" do\n precondition { player.minerals >= 50 && player.supply_used < 10 }\n\n postcondition { false } #this step should be repeated\n\n order { spawn UnitType.Zerg_Drone }\n end\n\n #When there is not enough supply an overlord should be spawned\n strategy_step \"Spawn an overlord\" do\n precondition { player.minerals >= 100 && player.supply_total <= player.supply_used && player.larva_available? } #not smart\n\n progresscondition { player.units.values.any? {|unit| unit.has_order? \"Spawn Overlord\" } }\n\n postcondition { false }#this step should be repeated\n\n order { spawn UnitType.Zerg_Overlord }\n end\n\n strategy_step \"Early overlord scout\" do\n overlord = nil\n target = nil\n\n precondition do\n overlords = player.get_all_by_unit_type(UnitType.Zerg_Overlord)\n if overlords.count == 1\n overlord = overlords.first\n target = unscouted_bases.shift\n overlord_target = target\n true\n end\n end\n\n progresscondition { overlord && target }\n\n postcondition { overlord.position == target if overlord }\n\n order { overlord.move(target) if overlord }\n end\n\n strategy_step \"Drone scout\" do\n drone_scout = nil\n target = nil\n\n precondition do\n if player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 && target = unscouted_bases.shift\n drone_scout = player.workers.first\n true\n end\n end\n\n order do\n # TODO why is if drone_scout necessary?\n drone_scout.move(target) if drone_scout\n end\n end\n\n #At 5 supply, 200 minerals a spawning pool should be made\n strategy_step \"Make a spawning pool at 5 supply\" do\n precondition { player.minerals > 200 && player.supply_total >= 10 }\n\n postcondition { player.units.values.any? {|u| u.type == UnitType.Zerg_Spawning_Pool} }\n\n progresscondition { player.units.values.any? {|u| u.has_order? \"Build SpawningPool\" } }\n\n order do\n player.workers.first.build(UnitType.Zerg_Spawning_Pool, build_location(UnitType.Zerg_Spawning_Pool))\n end\n end\n\n #When there is a spawning pool and enough minerals and supply, a zergling should be made\n strategy_step \"Make zerglings\" do\n precondition { player.minerals > 50 && player.supply_left >= 2 && player.larva_available? }\n\n precondition { player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 }\n\n postcondition { false } #this step should be repeated\n\n order do\n while (player.minerals > 50 && player.supply_left >= 2 && player.larva_available?) do\n spawn UnitType.Zerg_Zergling #spawn many zerglings in one frame\n end\n end\n end\n\n strategy_step \"Move in!\" do\n precondition { zerglings.count >= 1 && enemy.units.count == 0 }\n\n postcondition { false }\n\n order do\n target = unscouted_bases.shift || overlord_target\n\n zerglings.each do |z|\n puts \"Ordering zerglings to move\"\n z.move(target)\n end\n end\n end\n\n #When there are 5 zerglings, they should attack\n strategy_step \"Attack!\" do\n precondition { zerglings.count >= 5 && enemy.units.count > 0 }\n\n postcondition { false } #just keep on doin' it\n\n order do \n puts \"Ordering zerglings to attack\"\n zerglings.each { |z| attack_nearest_enemy(z) }\n end\n end\n end",
"def can_attack?( target )\n not @finished and targets.include?( target )\n end",
"def update\n if idle?\n if Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) < 150\n # If distance is 150 or less, behaviour changes to approaching\n change_state(GameStates::States::WALKING)\n @vect_v = 1\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n end\n elsif walking?\n # While walking, wolf tries to approach the main character\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n if @una_check_tiks <= 0\n # When next attack check counter reaches 0, wolf can attack.\n dieroll = Random.rand\n if dieroll <= ATTACK_PROBABILITY\n # If random is within attack probability, the wolf changes behaviour to attack\n change_state(GameStates::States::ATTACKING)\n @event_tiks =60\n @vect_v = 0\n else\n #If random is not within attack probability, next attack check counter is reset to 30.\n @una_check_tiks = 30\n end\n end\n check_change_dir\n elsif attacking?\n # If attacking, wolf waits for a little while, then charges in a straight line. Then waits a little while.\n if @event_tiks > 20\n check_change_dir\n elsif @event_tiks == 20\n @vect_angle = Gosu.angle(@hb.x, @hb.y, $WINDOW.player.hb.x, $WINDOW.player.hb.y)\n @vect_v = 3.5\n elsif @event_tiks == 10\n @venct_v = 0\n elsif @event_tiks <= 0\n change_state(GameStates::States::IDLE)\n @una_check_tiks = 100\n end\n end\n\n if normal? && $WINDOW.player.inv_frames <= 0 && !$WINDOW.player.recoiling? && @hb.check_brute_collision($WINDOW.player.hb)\n # If it connects with player, player is set to impacted.\n $WINDOW.player.impacted(@hb.center, @attack_dmg)\n end\n\n if !idle? && Gosu.distance(@hb.x,@hb.y,$WINDOW.player.hb.x, $WINDOW.player.hb.y) > 250\n #If distance surpasses 250, the wolf turns back to idle.\n change_state(GameStates:States::IDLE)\n end\n\n super\n @una_check_tiks -= 1 unless idle? || @una_check_tiks <= 0\n end",
"def input_target2\n old_target = state.target.clone\n unless cell_closest_to_mouse2 == state.star\n state.target = cell_closest_to_mouse2\n end\n unless old_target == state.target\n reset_search\n end\n end",
"def under_check\r\n # Define permitted moves for the king, when under check.\r\n end",
"def calculate_route(player_id, unit_ids, source, target, avoid_npc,\n speed_modifier)\n raise GameLogicError.new(\"Cannot move, source == target!\") \\\n if source == target\n raise GameLogicError.new(\n \"Cannot land in #{target}!\"\n ) if target.is_a?(SsObject) && ! target.landable?\n\n requested_count = unit_ids.size\n raise GameLogicError, \"You requested 0 units to move!\" \\\n if requested_count == 0\n\n selected_count = 0\n\n hop_times = {\n :solar_system => 0,\n :galaxy => 0\n }\n\n decreases = player_id.nil? \\\n ? {} \\\n : TechModApplier.apply(\n without_locking {\n TechTracker.query_active(player_id, TechTracker::SPEED).all\n },\n TechTracker::SPEED\n )\n\n units = Unit.units_for_moving(unit_ids, player_id, source)\n units.each do |type, count|\n kind = CONFIG[\"units.#{type.underscore}.kind\"]\n raise GameLogicError.new(\n \"Unit type #{type} should be space unit but was #{kind.inspect}\"\n ) unless kind == :space\n\n find_max_hop_times!(\n hop_times, type, 1 + (decreases[\"Unit::#{type}\"] || 0)\n )\n selected_count += count\n end\n\n raise GameLogicError.new(\n \"#{requested_count} units requested to move but only #{\n selected_count} was found for player id #{player_id} in #{\n source}\"\n ) unless requested_count == selected_count\n\n route = Route.new\n route.source = source.client_location\n route.current = source.client_location\n route.target = target.client_location\n route.player_id = player_id\n route.cached_units = units\n\n path = SpaceMule.instance.find_path(source, target, avoid_npc)\n first_hop = nil\n last_hop = nil\n index = 0\n hops = path.map do |server_location|\n hop = RouteHop.new\n x, y = server_location.coords.empty? \\\n ? [nil, nil] \\\n : [server_location.coords.get.x, server_location.coords.get.y]\n hop.location = LocationPoint.new(\n server_location.id.to_i,\n server_location.kind.id,\n x,\n y\n )\n hop.index = index\n\n hop.arrives_at = (last_hop.try(:arrives_at) || Time.now) +\n (hop_times[hop.hop_type] * server_location.time_multiplier *\n speed_modifier).round\n\n # Set Route#jumps_at if we switched zones.\n if route.jumps_at.nil? && route.source.type != hop.location.type\n route.jumps_at = hop.arrives_at\n end\n\n index += 1\n first_hop ||= hop\n last_hop = hop\n\n hop\n end\n\n route.arrives_at = last_hop.arrives_at\n\n first_hop.next = true\n\n [units, route, hops]\n end",
"def greedy_make_change(target, coins=[25,10,5,1])\nend",
"def decide_action(char)\n # temporary variables\n dir, x, y, ai = char.direction, char.x, char.y, char.ai\n pix = $BlizzABS.pixel\n # get alignment setup\n negative, positive = ai.negative, ai.positive\n # invert setup if confused\n negative, positive = positive, negative if char.restriction == 3\n # get all enemies in sight\n in_sight_e = ai.sight.find_all {|b| negative.include?(b.ai.group)}\n # if no enemies are available\n if in_sight_e.size == 0\n # initialize\n in_sight_a, in_range = [], ai.memory.keys\n # get all allies and enemies in range\n in_range.each {|b|\n in_sight_a.push(b) if positive.include?(b.ai.group)\n in_sight_e.push(b) if negative.include?(b.ai.group)}\n # if still no enemies are available\n if in_sight_e.size == 0\n # initialize again\n in_sight_a = []\n # get all allies and enemies from memory\n ai.memory.each_key {|b|\n in_sight_a.push(b) if positive.include?(b.ai.group)\n in_sight_e.push(b) if negative.include?(b.ai.group)}\n end\n else\n # get all allies in sight\n in_sight_a = ai.sight.find_all {|b| positive.include?(b.ai.group)}\n end\n # exit if no enemies are in sight\n return if in_sight_e.size == 0\n # if actor\n if char.is_a?(Map_Actor)\n # exit if \"no enemies\" are in sight\n return if in_sight_e.size == 0\n # get radius reach of player\n rad = $BlizzABS.util.get_player_radius\n # find all enemies within radius according to aggressiveness\n in_radius = in_sight_e.find_all {|e|\n Math.hypot(char.x / pix - e.x / pix, char.y / pix - e.y / pix) <=\n rad * char.ai.aggressive / 15}\n # check next trigger if action can't be executed\n return if in_radius.size == 0\n # add self as ally\n in_sight_a.push(char)\n # if confused or no trigger action was set up\n if char.restriction == 3 ||\n !trigger_actor_action(char, in_sight_a, in_sight_e)\n # set up advanced action based on Blizz-ABS AI\n advanced_actor_action(char)\n end\n # if enemy\n elsif char.is_a?(Map_Enemy)\n # if action attribute is not active\n if !ai.actions\n # decide normal action\n char.battler.make_action\n # temporary variable\n act = char.battler.current_action\n # set up the action in Blizz-ABS as normal action\n normal_action(char, in_sight_a, in_sight_e, (act.kind == 0),\n act.basic, rand(31) + 70, 80, act.skill_id)\n else\n # set up advanced action based on Blizz-ABS AI\n advanced_enemy_action(char)\n end\n end\n # if target doesn't exist or forced moving\n if ai.target == nil || !ai.target.valid?\n # reset action\n char.reset_action\n # if not being force moved\n elsif char.is_a?(Map_Enemy) && char.move_type != 3\n # set path request state\n ai.state = Request\n # turn toward the target not to lose it out of sight\n char.turn_toward(ai.target)\n # request a path\n request_path(char, ai.target)\n end\n end",
"def command_use_point\r\r\n if $game_actors[@actor.id].skill_tree[0] == 0 || confirm_skill_add\r\r\n Sound.play_buzzer\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n else\r\r\n @skills_icons[@skill_selected].opacity = 255\r\r\n $game_actors[@actor.id].skill_tree[0] -= 1\r\r\n $game_actors[@actor.id].lose_jp(Actor[@actor.id][@skill_selected]['JP'])\r\r\n $game_actors[@actor.id].skill_mult[Actor[@actor.id][@skill_selected]['Skill_id']] += Actor[@actor.id][@skill_selected]['Multiply']\r\r\n $game_actors[@actor.id].skill_tree[Actor[@actor.id][@skill_selected]['Skill_id']] += 1\r\r\n $game_actors[@actor.id].learn_skill(Actor[@actor.id][@skill_selected]['Skill_id'])\r\r\n @info_window.refresh(@actor, @tree)\r\r\n Audio.se_play(\"Audio/SE/Skill3\",75,100)\r\r\n @confirm.close\r\r\n @confirm.active = false\r\r\n if $game_switches[19] # achievement available?\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Markspony\r\r\n #-------------------------------------------------------------------------------\r\r\n earn_trophic = true\r\r\n for i in 546..561\r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_markspony\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_markspony\r\r\n $ACH_markspony = true\r\r\n GameJolt.award_trophy(\"53491\")\r\r\n p sprintf(\"Achievement unlock - markspony\")\r\r\n $game_system.earn_achievement(:markspony)\r\r\n end\r\r\n #------------------------------------------------------------------------------- \r\r\n # Trophic: Elementalist\r\r\n #------------------------------------------------------------------------------- \r\r\n earn_trophic = true\r\r\n for i in 563..582\r\r\n next if i == 567 || i == 571 || i == 577 || i == 581 \r\r\n if !$game_actors[@actor.id].skill_learned?(i) && !$ACH_elementalist\r\r\n earn_trophic = false\r\r\n break\r\r\n end\r\r\n end\r\r\n \r\r\n if earn_trophic && !$ACH_elementalist\r\r\n $ACH_elementalist = true\r\r\n GameJolt.award_trophy(\"53485\") \r\r\n p sprintf(\"Achievement unlock - elementalist\")\r\r\n $game_system.earn_achievement(:elementalist)\r\r\n end\r\r\n #---------------------------------------------------\r\r\n end\r\r\n end\r\r\n end",
"def calc_def_mod_metal_powder(user, target)\n return 1 unless target.db_symbol == :ditto\n target.moveset.each do |move|\n return 1 if move.db_symbol == :transform && move.used\n end\n return 1.5\n end",
"def give_target\n if @hunting\n target = @priority_targets.first\n if target.nil?\n @hunting = false\n target = @all_targets.first\n end\n else\n target = @all_targets.first\n end\n\n target\n end",
"def all_moves harmless\n\t\t# NOTE: harmless test disabled\n\t\tharmless = false\n\n\t\tmoves = {} \n\n\t\tif moved? or next_to_enemy?\n\t\t\tmoves[ :STAY ] = pos\n\t\t\treturn moves\n\t\tend\n\n\t\tlam = lambda do |dir| \n\t\t\t# Test movement of collective\n\t\t\tif can_pass? dir, false\n\t\t\t\tmoves[ dir ] = square.neighbor dir\n\t\t\tend\n\t\tend\n\n\t\t# Note that we don't bother with orientation so close to conflict\t\n\n\t\tif harmless\n\t\t\t$logger.info { \"#{ self } attackers harmless; staying is not an option\" }\n\t\telse\n\t\t\tmoves[ :STAY ] = square\n\t\tend\n\t\tlam.call :N\n\t\tlam.call :E\n\t\tlam.call :S\n\t\tlam.call :W\n\n\t\tif moves.empty?\n\t\t\t$logger.info \"We are stuck, apparently; staying anyway.\"\n\t\t\tmoves[ :STAY ] = square\n\t\tend\n\n\t\t$logger.info { \"possible moves: #{ moves }\" }\n\n\t\tmoves\n\tend",
"def take_turn(source, target)\n\t\n\tskip_turn = false\n\t\n\tif (source.status_effect == \"s_sleeping\")\n\t\t#puts \"SLEEP: #{source.name}\"\n\t\tif source.status_effect_duration > 0\n\t\t\t#puts \"#{source.name} is still sleeping for #{source.status_effect_duration} more turns\\n\\n\"\n\t\t\tskip_turn = true\n\t\telse\n\t\t\t#puts \"#{source.name} woke up!\"\n\t\t\tsource.has_status_effect = false\n\t\t\tsource.status_effect = nil\n\t\tend\n\t\tsource.status_effect_duration = source.status_effect_duration - 1\n\tend\n\t\n\tif (source.confused)\n\t\t#puts \"CONFUSION: #{source.name}\"\n\t\tif source.confused_duration > 0\n\t\t\t#puts \"#{source.name} is still confused for #{source.confused_duration} more turns\"\n\t\t\t# Calculate chance to hit self and end turn\n\t\t\trolled = Random.rand(0..100)\n\t\t\t#puts \"Rolled: #{rolled}, >= 50 means hurt self\"\n\t\t\tif (rolled >= 50 && source.status_effect != \"s_sleeping\")\n\t\t\t\tdamage = confusion_damage(source)\n\t\t\t\t#puts \"#{source.name} did #{damage} damage to itself in confusion\\n\\n\"\n\t\t\t\tsource.current_hp = source.current_hp - damage\n\t\t\tend\n\t\telse\n\t\t\t#puts \"#{source.name} snapped out of confusion!\"\n\t\t\tsource.confused = false\n\t\tend\n\t\tsource.confused_duration = source.confused_duration - 1\n\tend\n\t\n\tif (source.status_effect == \"s_frozen\")\n\t\t#puts \"FROZEN: #{source.name}\"\n\t\trolled = Random.rand(0..100)\n\t\t#puts \"Rolled: #{rolled}, > 20 means still frozen\"\n\t\tif (rolled > 20)\n\t\t\t#puts \"#{source.name} is still frozen!\\n\\n\"\n\t\t\tskip_turn = true\n\t\telse\n\t\t\t#puts \"#{source.name} unfroze!\"\n\t\t\tsource.has_status_effect = false\n\t\t\tsource.status_effect = nil\n\t\tend\n\tend\n\t\n\tif (source.status_effect == \"s_paralyzed\")\n\t\t#puts \"PARALYSIS: #{source.name}\"\n\t\trolled = Random.rand(0..100)\n\t\t#puts \"Rolled: #{rolled}, > 25 means paralyzed for this turn (cannot use move)\"\n\t\tif (rolled > 25)\n\t\t\t#puts \"#{source.name} is paralyzed, it cannot move!\\n\\n\"\n\t\t\tskip_turn = true\n\t\telse\n\t\t\t#puts \"#{source.name} is paralyzed, but is able to attack!\"\n\t\tend\n\tend\n\t\n\tif source.flinched\n\t\t#puts \"#{source.name} flinched!\\n\\n\"\n\t\tsource.flinched = false\n\t\tskip_turn = true\n\tend\n\t\n\tif source.recharge > 0\n\t\tsource.recharge = source.recharge - 1\n\t\tsource.using_move = nil\n\t\t#puts \"#{source.name} is recharging for #{source.recharge} more turns\\n\\n\"\n\t\tapply_status_effect_damage(source)\n\t\tskip_turn = true\n\telse\n\t\tif source.using_move\n\t\t\tmove = source.using_move\n\t\telse\n\t\t\treturn if skip_turn\n\t\t\t# Get a random move\n\t\t\t#move = source.moves.sample\n\t\t\tmove = choose_move(source, target)\n\t\t\t\n\t\t\t#puts \"#{source.name} chose to use #{move.name}\"\n\t\t\t\n\t\t\tif [\"Dig\", \"Fly\", \"Razor Wind\", \"Skull Bash\", \"Sky Attack\", \"Solar Beam\"].include? move.name\n\t\t\t\t#puts \"Charge move: #{move.name}\"\n\t\t\t\tsource.using_move = move\n\t\t\t\tsource.charge = 1\n\t\t\tend\n\t\tend\n\tend\n\t\n\tif (source.charge > 0)\n\t\tsource.charge = source.charge - 1\n\t\t#puts \"#{source.name} is charging for #{source.charge} more turns\\n\\n\"\n\t\tapply_status_effect_damage(source)\n\t\tskip_turn = true\n\telse\n\t\tsource.using_move = nil\n\tend\n\t\n\treturn if skip_turn\n\t\n\t# A move will miss if the accuracy check failed or the enemy Pokemon is using Fly/Dig\n\t# and the source pokemon did not use a move that could hit a Fly/Dig Pokemon\n\tdig_miss = (target.using_move && target.using_move.name == \"Dig\" && move.name != \"Earthquake\")\n\tfly_miss = (target.using_move && target.using_move.name == \"Fly\" && (move.name != \"Thunder\" && move.name != \"Gust\"))\n\tif (!move_hit?(move) || fly_miss || dig_miss)\n\t\t#puts \"Attack missed!\\n\\n\"\n\t\tif [\"High Jump Kick\", \"Jump Kick\"].include? move.name\n\t\t\tsource.current_hp = source.current_hp - (source.hp / 2.0).round\n\t\tend\n\t\treturn\n\tend\n\t\n\tif move.name == \"Dream Eater\"\n\t\tif !(target.has_status_effect && target.s_sleeping?)\n\t\t\t#puts \"#{target.name} is not asleep. Attack missed!\"\n\t\tend\n\tend\n\t\n\tif [\"Recover\", \"SoftBoiled\"].include? move.name\n\t\thealed = (source.hp / 2.0).round\n\t\tsource.current_hp = source.current_hp + healed\n\t\t#puts \"#{source.name} healed #{healed} hp\"\n\t\treturn\n\tend\n\t\n\tif move.name == \"Super Fang\"\n\t\tdamage = (target.current_hp / 2.0).round\n\t\ttarget.current_hp = target.current_hp - damage\n\t\t#puts \"#{source.name} did #{damage} damage to #{target.name}\\n\\n\"\n\t\treturn\n\tend\n\t\n\tif move.name == \"Haze\"\n\t\t#puts \"Haze used, resetting all stat stages\\n\\n\"\n\t\thaze(source, target)\n\t\treturn\n\tend\n\t\n\tdamage = 0\n\t\n\t# These moves all hit 2-5 times, so calculate the damage that many times.\n\tif [\"Barrage\", \"Comet Punch\", \"Double Slap\", \"Fury Attack\", \"Fury Swipes\", \"Pin Missle\", \"Spike Cannon\"].include? move.name\n\t\thits = Random.rand(2..5)\n\t\t#puts \"Hitting #{hits} times\"\n\t\thits.times do |i|\n\t\t\thit_damage = calculate_damage(source, target, move)\n\t\t\tdamage = damage + hit_damage\n\t\tend\n\t# These moves all hit exactly twice\n\telsif [\"Bonemerang\", \"Double Kick\", \"Twineedle\"].include? move.name\n\t\t2.times do |i|\n\t\t\thit_damage = calculate_damage(source, target, move)\n\t\t\tdamage = damage + hit_damage\n\t\tend\n\t# The rest of the moves only hit once\n\telse\n\t\tdamage = calculate_damage(source, target, move)\n\tend\n\t\n\t# If the move can affect a Pokemon's stats, do the calculation now\n\tif move.stat_type?\n\t\t\n\t\t# If the stage_change is positive, it affects the source Pokemon. Negative affects the target Pokemon\n\t\t#puts \"Stage Change: #{move.stage_change}\"\n\t\tif move.stage_change > 0\n\t\t\tchanged = true\n\t\t\tstat_target = source\n\t\t\t#puts \"STAT CHANGE: (CHANGED) #{changed}\"\n\t\telse\n\t\t\tstat_change_max = 100\n\t\t\trolled = Random.rand(stat_change_max)\n\t\t\tchanged = (rolled >= (stat_change_max - move.stat_change_chance))\n\t\t\tstat_target = target\n\t\t\t#puts \"STAT CHANGE: (NEED) #{stat_change_max - move.stat_change_chance} || (ROLL) #{rolled} || (CHANGED) #{changed}\"\n\t\tend\n\t\t\n\t\t#puts \"Stages (BEFORE): #{stat_target.attack_stage} || #{stat_target.defense_stage} || #{stat_target.special_attack_stage} || #{stat_target.special_defense_stage} || #{stat_target.speed_stage}\"\n\t\t\n\t\tif changed\n\t\t\tcase move.stat_type\n\t\t\t\twhen \"attack\"\n\t\t\t\t\tstat_target.attack_stage = stat_target.attack_stage + move.stage_change\n\t\t\t\twhen \"defense\"\n\t\t\t\t\tstat_target.defense_stage = stat_target.defense_stage + move.stage_change\n\t\t\t\twhen \"special_attack\"\n\t\t\t\t\tstat_target.special_attack_stage = stat_target.special_attack_stage + move.stage_change\n\t\t\t\twhen \"special_defense\"\n\t\t\t\t\tstat_target.special_defense_stage = stat_target.special_defense_stage + move.stage_change\n\t\t\t\twhen \"speed\"\n\t\t\t\t\tstat_target.speed_stage = stat_target.speed_stage + move.stage_change\n\t\t\tend\n\t\tend\n\t\t\n\t\t#puts \"Stages (AFTER): #{stat_target.attack_stage} || #{stat_target.defense_stage} || #{stat_target.special_attack_stage} || #{stat_target.special_defense_stage} || #{stat_target.speed_stage}\"\n\t\t\n\t\t#puts \"#{stat_target.name} #{move.stat_type.upcase} #{(move.stage_change > 0) ? 'rose' : 'fell'} by #{move.stage_change.abs} stage(s)\" if changed\n\tend\n\t\n\tapply_status_effect = apply_status_effect?(source, target, move)\n\t#puts \"Apply status effect? #{apply_status_effect} --> #{move.status_effect}\"\n\t\n\tif !target.has_status_effect && apply_status_effect && move.status_effect != \"s_confused\"\n\t\ttarget.has_status_effect = true\n\t\ttarget.status_effect = move.status_effect\n\t\t#puts \"#{target.name} now has status effect: #{target.status_effect}\" if target.has_status_effect\n\t\t\n\t\tif (target.status_effect == \"s_sleeping\")\n\t\t\tfor_turns = Random.rand(1..3)\n\t\t\t#puts \"#{target.name} sleeping for #{for_turns} turns\"\n\t\t\ttarget.status_effect_duration = for_turns\n\t\tend\n\tend\n\t\n\tif !target.confused && move.status_effect == \"s_confused\"\n\t\ttarget.confused = true\n\t\tfor_turns = Random.rand(1..4)\n\t\t#puts \"#{target.name} confused for #{for_turns} turns\"\n\t\ttarget.confused_duration = for_turns\n\tend\n\t\n\tif $turn_count % 2 == 0\n\t\t$battle_stats[:source_damage_done] = $battle_stats[:source_damage_done] + damage\n\telse\n\t\t$battle_stats[:target_damage_done] = $battle_stats[:target_damage_done] + damage\n\tend\n\t\n\ttarget.current_hp = target.current_hp - damage\n\t#puts \"#{source.name} did #{damage} damage to #{target.name}\\n\\n\"\n\t\n\t# If the Pokemon just used Hyper Beam, give them a 1-turn cooldown, but we don't care about keeping track of the move\n\tif move.name == \"Hyper Beam\"\n\t\tsource.using_move = move\n\t\tsource.recharge = 1\n\tend\n\t\n\tif move_caused_flinch?(source, move)\n\t\ttarget.flinched = true\n\tend\n\t\n\t# Healing self\n\tif [\"Absorb\", \"Dream Eater\", \"Leech Life\", \"Mega Drain\"].include? move.name\n\t\thealed = (damage / 2.0).round\n\t\tsource.current_hp = source.current_hp + healed\n\t\t#puts \"#{source.name} healed #{healed} hp\"\n\tend\n\t\n\t# Recoil self damage (1/4)\n\tif [\"Submission\", \"Take Down\"].include? move.name\n\t\trecoil = (damage / 4).round\n\t\tsource.current_hp = source.current_hp - recoil\n\t\t#puts \"#{source.name} took #{recoil} recoil damage\"\n\tend\n\t\n\t# Recoil self damage (1/3)\n\tif move.name == \"Double-Edge\"\n\t\trecoil = (damage / 3).round\n\t\tsource.current_hp = source.current_hp - recoil\n\t\t#puts \"#{source.name} took #{recoil} recoil damage\"\n\tend\n\t\n\t# Burn or poison damage taken\n\tapply_status_effect_damage(source)\nend",
"def setup_target_reset\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n if area_flag\n target_array.each do |target|\n target.reset_pos(@acts[1],@acts[2])\n end\n return\n end\n target.reset_pos(@acts[1],@acts[2])\n end",
"def get_target(map, loc)\n owned = nil\n owned_min = 1000\n GameMap::CARDINALS.each do |l|\n new_loc = map.find_location(loc, l)\n site = map.site(new_loc)\n if site.owner != $tag && site.strength < owned_min\n owned_min = site.strength\n owned = l\n end\n end\n owned\nend",
"def is_target_blocked?(deadends, target, moves_limit)\n queue = Queue.new\n checked = Set.new\n start = Combination.new(target)\n queue << start\n moves = 0\n\n until queue.empty? || moves > moves_limit do\n current_combination = queue.pop\n moves = current_combination.moves\n if checked.include? current_combination.code\n # puts \"Already checked #{current_combination.code}\"\n\n elsif deadends.include? current_combination.code\n # puts \"Hit a deadend at #{current_combination.code}\"\n\n elsif current_combination.is? \"0000\"\n return false\n\n else\n checked.add current_combination.code\n current_combination.get_next_moves.each {|combo| queue << combo}\n end\n end\n queue.empty?\nend",
"def move dir, target = nil, always_move = true\n\n\t\tstrf = \"#{ self } to #{ dir } => #{ target } - %s\"\n\t\t$logger.info { strf % [ 'entered' ] }\n\n\t\tnext_sq = square.neighbor(dir)\n\n\t\t$logger.info {\n\t\t\t\"dir #{ dir }, next_sq: #{ next_sq }, \" +\n\t\t\t\"can_pass: #{ can_pass? dir }; hole: #{ next_sq.hole?}\"\n\t\t}\n\n\t\tif dir == :STAY\n\t\t\tstay\n\t\t\t$logger.info { strf % [ 'staying' ] }\n\t\t\treturn true\n\t\t# If next square is a hole and not our target, we dont want to go there\n\t\telsif can_pass? dir and ( ( not target.nil? and next_sq == target ) or not next_sq.hole? )\n\t\t\t$logger.info { strf % [ 'passable' ] }\n\t\t\torder dir\n\t\t\treturn true\n\t\tend\n\n\t\tunless always_move\n\t\t\t$logger.info { strf % [ 'move failed' ] }\n\t\t\treturn false\n\t\telse\n\t\t\t$logger.info { strf % [ 'trying evasion' ] }\n\t\tend\n\n\n\t\tstr = \"\"\n\n\t\tif ( next_sq.ant? and not next_sq.ant.moved? ) or next_sq.moved_here?\n\n\t\t\t# if you got here, you know where you are going.\n\t\t\t# Don't initiate an evasion, either move to empty square or sit it out.\n\t\t\ttmp = square.passable_directions\n\n\t\t\t# Don't go back if you can help it\n\t\t\ttmp -= [ reverse( dir ) ]\n\t\t\tif tmp.empty?\n\t\t\t\tstay\n\t\t\telse\n\t\t\t\torder tmp[0]\n\t\t\tend\n\t\telse\n\n\t\t\t# Only use pathfinder on water squares\n\t\t\tunless next_sq.water?\n\t\t\t\t# Do regular evasion\n\t\t\t\tevade dir\n\t\t\t\t#stay\t- bad idea\n\t\t\t\treturn false\n\t\t\tend\n\n\t\t\tpath_finder = EvadePathFinder.new square, dir, @left\n\n\t\t\tdo_it = true\n\t\t\tunless target.nil?\n\t\t\t\tbest = path_finder.best_direction target\n\t\t\t\tif best.nil?\n\t\t\t\t\tstr = \"Have no path\"\n\t\t\t\t\tdo_it = false\n\t\t\t\telse\n\t\t\t\t\t@left = best\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif do_it\n\t\t\t\tevade_target = path_finder.move.straight_path\n\t\n\t\t\t\tif evade_target.nil?\n\t\t\t\t\t# Follow the regular evasion\n\t\t\t\t\tevade dir\n\t\t\t\telse\n\t\n\t\t\t\t\t# Take a shortcut to a point on the evasion path\n\t\t\t\t\tif set_order evade_target, :EVADE_GOTO, nil, true\n\t\n\t\t\t\t\t\t# Take the first step, since we are already committed\n\t\t\t\t\t\t# to moving.\n\t\t\t\t\t\tdir = path_finder.first_dir\n\t\t\t\t\t\tif not dir.nil? and square.neighbor(dir).passable?\n\t\t\t\t\t\t\torder dir\n\t\t\t\t\t\tend\n\t\t\t\t\t\tstr = \"taking shortcut through #{ dir }\"\n\t\t\t\t\telse\n\t\t\t\t\t\t# Fall back to regular evasion\n\t\t\t\t\t\tevade dir\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t$logger.info { strf % [ str ] }\n\t\treturn false\n\tend",
"def open_lock(deadends, target)\n queue = Queue.new\n checked = Set.new\n deadends = deadends.to_s\n start = Combination.new(\"0000\")\n queue << start\n\n unless is_target_blocked?(deadends, target, 1)\n # puts \"Target: #{target}\"\n # puts \"Deadends: #{deadends.inspect}\"\n # puts\n until queue.empty? do\n current_combination = queue.pop\n # puts \"Checking code: #{current_combination.code}\"\n\n if checked.include? current_combination.code\n # puts \"Already checked #{current_combination.code}\"\n\n elsif deadends.include? current_combination.code\n # puts \"Hit a deadend at #{current_combination.code}\"\n\n elsif current_combination.is? target\n # playback = current_combination.get_playback.reverse\n # puts \"Found combination in #{current_combination.moves} moves.\"\n # puts \"\\tPlayback: #{(playback.map {|c| c.code}).join(' -> ')}\"\n # puts\n return current_combination.moves\n\n else\n checked.add current_combination.code\n current_combination.get_next_moves.each {|combo| queue << combo}\n end\n end\n end\n # puts \"Can't crack the code!\"\n # puts\n -1\nend",
"def update_target\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Erase target window\r\n @skill_window.active = true\r\n @target_window.visible = false\r\n @target_window.active = false\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # If unable to use because SP ran out\r\n unless @actor.skill_can_use?(@skill.id)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # If target is all\r\n if @target_window.index == -1\r\n # Apply skill use effects to entire party\r\n used = false\r\n for i in $game_party.actors\r\n used |= i.skill_effect(@actor, @skill)\r\n end\r\n end\r\n # If target is user\r\n if @target_window.index <= -2\r\n # Apply skill use effects to target actor\r\n target = $game_party.actors[@target_window.index + 10]\r\n used = target.skill_effect(@actor, @skill)\r\n end\r\n # If single target\r\n if @target_window.index >= 0\r\n # Apply skill use effects to target actor\r\n target = $game_party.actors[@target_window.index]\r\n used = target.skill_effect(@actor, @skill)\r\n end\r\n # If skill was used\r\n if used\r\n # Play skill use SE\r\n $game_system.se_play(@skill.menu_se)\r\n # Use up SP\r\n @actor.sp -= @skill.sp_cost\r\n # Remake each window content\r\n @status_window.refresh\r\n @skill_window.refresh\r\n @target_window.refresh\r\n # If entire party is dead\r\n if $game_party.all_dead?\r\n # Switch to game over screen\r\n $scene = Scene_Gameover.new\r\n return\r\n end\r\n # If command event ID is valid\r\n if @skill.common_event_id > 0\r\n # Command event call reservation\r\n $game_temp.common_event_id = @skill.common_event_id\r\n # Switch to map screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end\r\n # If skill wasn't used\r\n unless used\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n end\r\n return\r\n end\r\n end",
"def chase_preceding_character\r\r\n return if self.command_holding?\r\r\n unless moving? && !@force_chase\r\r\n dist = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE / 32.0\r\r\n mrgn = CXJ::FREE_MOVEMENT::FOLLOWERS_DISTANCE_MARGIN / 32.0\r\r\n \r\r\n far_dist = distance_preceding_character\r\r\n \r\r\n if far_dist > 3\r\r\n type = 1\r\r\n prevent_bug_cnt = 0\r\r\n else\r\r\n type = 2\r\r\n end\r\r\n \r\r\n if !move_poll.empty? && distance_preceding_leader < 0.8\r\r\n move_poll.clear\r\r\n end\r\r\n \r\r\n \r\r\n if type == 1 && move_poll.empty?\r\r\n reachable = false\r\r\n \r\r\n $game_player.followers.each do |follower|\r\r\n follower.move_poll.clear\r\r\n if follower.move_poll.empty? && follower.distance_preceding_leader > 3\r\r\n reachable = follower.move_to_position($game_player.x,$game_player.y)\r\r\n if move_poll.empty? || !reachable\r\r\n follower.moveto($game_player.x,$game_player.y) \r\r\n end\r\r\n \r\r\n end\r\r\n end\r\r\n elsif type == 2\r\r\n \r\r\n goal = @preceding_character\r\r\n sx = distance_x_from(goal.x)\r\r\n sy = distance_y_from(goal.y)\r\r\n sd = Math.hypot(sx, sy)\r\r\n if @board\r\r\n @x = goal.x\r\r\n @y = goal.y\r\r\n @board = false\r\r\n elsif(sd > dist && sx.abs > mrgn && sy.abs > mrgn)\r\r\n @move_poll += [[(sx > 0 ? -1 : 1) + (sy > 0 ? 8 : 2), true]]\r\r\n elsif sx.abs > dist && sx.abs > sy.abs\r\r\n @move_poll+=[[sx > 0 ? 4 : 6, true]]\r\r\n elsif sy.abs > dist && sx.abs < sy.abs\r\r\n @move_poll+=[[sy > 0 ? 8 : 2, true]]\r\r\n end\r\r\n end\r\r\n \r\r\n end\r\r\n end",
"def fast_dance(direction, tiles)\n\nend",
"def left_hand_solve\n until @buckets[0] == @target\n fill_left\n until @buckets[0].zero?\n left_to_right\n break if @buckets.include?(@target)\n empty_right\n break if @buckets.include?(@target)\n left_to_right\n break if @buckets.include?(@target)\n end\n end\n end",
"def knight_moves start, target\n raise StandardError.new(\"Invalid ending space\") if validate_space(target)\n root = Node.new(start, nil)\n target_acquired = nil\n queue = [root]\n return queue if root.position == target\n \n #build the structure to be searched\n puts \"I am right before the while loop\"\n while(!queue.empty? && !target_acquired)\n current = queue[0]\n potential_moves = get_possible_moves(current.position)\n potential_moves.each do |move|\n new_node = Node.new(move, current)\n current.children.push(new_node)\n queue.push(new_node)\n target_acquired = new_node if new_node.position == target\n puts \"FOUND IT MOFO\" if new_node.position == target\n end\n queue.shift\n end\n\n #search the structure, start with target node and go up parent\n current = target_acquired\n path = [current]\n while current.parent\n path.push(current.parent)\n current = current.parent\n end\n return path.reverse!\n end",
"def input_target\n old_target = state.target.clone\n unless cell_closest_to_mouse == state.star\n state.target = cell_closest_to_mouse\n end\n unless old_target == state.target\n reset_search\n end\n end",
"def handle_ko(target)\n sprite = scene.visual.battler_sprite(target.bank, target.position)\n scene.visual.lock do\n sprite.start_animation_KO\n scene.display_message(parse_text_with_pokemon(19, 0, target))\n while sprite.animated?\n scene.update\n Graphics.update\n end\n end\n end",
"def sweep_stairs\n turn_off\n end",
"def decide_random_target_for_actor\n # Diverge with effect scope\n if for_one_friend_hp0?\n battler = $game_party.random_target_actor_hp0\n elsif for_one_friend?\n battler = $game_party.random_target_actor\n else\n battler = $game_troop.random_target_enemy\n end\n # If a target exists, get an index, and if a target doesn't exist,\n # clear the action\n if battler != nil\n @target_index = battler.index\n else\n clear\n end\n end",
"def living_move\n simulate_move(opponent)\n end",
"def exploit\n # Is the selected target a brute force target?\n if (target.bruteforce?)\n # The step direction is automatically calculated\n direction = {}\n\n bf = target.bruteforce\n\n # Get the start and stop address hashes\n start = bf.start_addresses ? bf.start_addresses.dup : {}\n stop = bf.stop_addresses ? bf.stop_addresses.dup : {}\n step = bf.step_size\n delay = bf.delay\n\n # Enumerate each start address and try to figure out the direction\n start.each_pair { |name, addr|\n # If there's a stop address, figure out if it's above or below\n # the start address\n if (stop[name])\n if (stop[name] < addr)\n direction[name] = -1\n else\n direction[name] = 1\n end\n # If there's no stop address, infer the direction based on\n # the default\n else\n direction[name] = bf.default_direction\n end\n }\n\n # Import start/stop address overrides from the datastore\n import_from_datastore(start, 'Start')\n import_from_datastore(stop, 'Stop')\n\n # User-defined brute wait?\n if self.datastore['BruteWait'] and self.datastore['BruteWait'] > 0\n delay = self.datastore['BruteWait'].to_i\n end\n\n # User-defined brute step?\n if self.datastore['BruteStep'] and self.datastore['BruteStep'] > 0\n step = self.datastore['BruteStep'].to_i\n end\n\n # Sane defaults\n delay = 1 if delay.nil? or delay == 0\n\n # Okay, we've got all this crap out of the way, let's actually brute\n # force\n stopped = []\n curr = start.dup\n\n # Automatically determine the step size based off the nop sled length\n if step == 0\n step = payload.nop_sled_size\n\n if step == 0\n raise OptionValidateError.new(['BruteStep - The step size for this exploit is invalid'])\n end\n end\n\n # Keep going until we run out of options\n while (curr.length != stopped.length)\n\n # Stop brute forcing once a session is found\n break if session_created?\n\n # Fire off an exploit attempt with the supplied addresses\n brute_exploit(curr)\n\n # Give it time before we try again\n brute_wait(delay)\n\n # Scan each current key, increasing it or decreasing it by the\n # step size according to its direction\n curr.each_key { |k|\n\n # Has movement been stopped on this address? If so, skip it.\n next if (stopped.include?(k))\n\n # Calculate the next address before we move it to see if\n # we're going to go over\n next_addr = step * direction[k]\n\n # If this item has hit a stop address, add it to the stopped\n # hash and move it no further\n if (stop[k])\n if ((direction[k] == 1 and curr[k] + next_addr >= stop[k]) or\n (direction[k] == -1 and curr[k] + next_addr < stop[k]))\n stopped << k\n next\n end\n end\n\n # If it's not time to stop, move it\n curr[k] += next_addr\n }\n end\n else\n single_exploit\n end\n end",
"def play\n\n # TODO: for all loops below, precalculate all the sums, instead of looping them\n\n # if deploying, do nothing else\n @tentacles.each { |t| return if t.state==:deploying }\n\n ots = occupied_tentacles.size\n ets = ennemies_tentacles.size\n ats = active_tentacles.size\n\n # remove useless tentacles: to same team not attacked with more life (attention to rule below when connecting friends with less life)\n occupied_tentacles.each { |t|\n next if t.state == :retracting\n t.retract if t.to.team == @team and t.to.life+t.to.tentacles_life > @life+tentacles_life+deploy_cost(t.to) and t.to.ennemies_tentacles.size == 0\n }\n\n # remove useless tentacles: from neutral or not dueling when attacked\n if ennemies_tentacles.size > 0 and occupied_tentacles.size >= 0\n occupied_tentacles.each { |t|\n return if (remove_neutral or remove_not_dueling)\n }\n end\n\n # attack if attacked\n if ets > 0 and ots < @nb_t and ots == ats\n ennemies_tentacles.each { |t|\n return if enough_life?(t.from, :half) and add_tentacle(t.from)\n }\n end\n\n # attack neutral\n if ots < @nb_t\n n = nearest { |v| v.team == :neutral and enough_life?(v)}\n return if n and enough_life?(n) and add_tentacle(n)\n end\n\n # attack nearest ennemy\n if ots < @nb_t\n e = nearest { |v| v.team != @team and v.team != :neutral and enough_life?(v) }\n return if e and add_tentacle(e)\n end\n\n # recharge friends\n if ots < @nb_t\n e = nearest { |v| v.team == @team and v != self and not find_all(v) and v.life < (@life-deploy_cost(v))-1 }\n return if e and add_tentacle(e)\n end\n\n end",
"def make_circles\n command.speed = -2 # takes a value between -5 to 5\n command.heading = sensors.heading + 0.01\n end",
"def attack(target)\n if @attacked_this_turn == false\n target.health = target.health - @attack\n @health = @health - target.attack\n @attacked_this_turn = true\n else\n raise 'hero already attacked'\n end\n end",
"def move(all_units)\n all_units.each do |char|\n next unless char.alive\n\n targets = []\n\n queue = []\n queue.push([1, char.pos])\n\n distances = Hash.new\n previous = Hash.new\n\n while queue.length > 0\n curr = queue.shift\n # puts \"Q: #{curr[0]} POS: #{curr[1]}\"\n new_round = curr[0] + 1\n next if targets.length > 0 # Skip branches if we've found targets.\n\n DIRS.each do |dir| # For each potential neighbor...\n f_pos = curr[1] + dir\n # puts \"\\tCHECKING: #{f_pos} LINE: #{LINES[f_pos[0]][f_pos[1]]}\"\n if LINES[f_pos[0]][f_pos[1]] == '.' # Check map for wall\n skip_add = false\n all_units.each do |check|\n next if check == char || !check.alive\n if check.pos == f_pos\n if char.type != check.type # If enemy...\n # targets.push([check, curr[2]]) # Using state path\n targets.push([check, curr[0], curr[1]]) # Using previous hash\n end\n skip_add = true # Can't walk through units.\n end\n end\n # puts \"\\tSKIP CHECK: #{skip_add} PAST: #{curr[2]} EXISTS: #{curr[2].include?(f_pos)}\"\n # if !skip_add && !curr[2].include?(f_pos)\n # # puts \"\\tADDING: #{f_pos}\"\n # new_path = Marshal.load(Marshal.dump(curr[2]))\n # not_queued = queue.index {|q| q[1] == f_pos}.nil?\n # queue.push([new_round, f_pos, new_path.push(f_pos)]) if not_queued\n # end\n if (!skip_add && (distances[f_pos].nil? || new_round < distances[f_pos]))\n distances[f_pos] = new_round\n previous[f_pos] = curr[1]\n queue.push([new_round, f_pos])\n end\n end\n end\n end\n\n targets.each_with_index do |target, i|\n # puts \"#{char} #{i}: #{target[0]} PATH:#{target[1]}\"\n # puts \"#{char} #{i}: #{target[0]} NUM_STEPS:#{target[1]}\"\n end\n if targets.length > 0\n # Move\n nearest_target = targets[0] # Only interested in nearest enemy.\n # if nearest_target[1].length > 1 # More than 1 step away?\n # char.pos = nearest_target[1][1] # Step towards nearest enemy.\n # end\n if nearest_target[1] > 1 # More than 1 step away?\n next_pos = nearest_target[2]\n next_pos = previous[next_pos] while previous[next_pos] != char.pos\n # char.pos = nearest_target[1][1] # Step towards nearest enemy.\n # puts \"#{char} GOES TO #{next_pos}\"\n char.pos = next_pos # Step towards nearest enemy.\n end\n\n d_to_closest = (nearest_target[0].pos - char.pos).to_a.collect!{|v| v.abs}.sum\n # puts \"\\tC:#{char} T:#{nearest_target[0]} D_TO_T: #{d_to_closest}\"\n if d_to_closest == 1 # In melee range!\n targets_by_hp = targets.select {|t| (t[0].pos - char.pos).to_a.collect!{|t| t.abs}.sum == 1}.sort_by {|t| t[0].hp}\n target = targets_by_hp[0] # Lowest hp in melee range.\n target[0].hp -= char.attack\n # puts \"#{char} HITS #{target[0]}\"\n\n if target[0].hp <= 0\n puts \"#{char} KILLS #{target[0]}\"\n target[0].hp = 0\n target[0].alive = false\n end\n end\n else\n all_alive = all_units.select {|unit| unit.alive }\n all_elves = all_alive.select {|unit| unit.type == 'E'}\n return false if all_elves.length == 0 || all_elves.length == all_alive.length\n end\n end\n\n return true\nend",
"def impacted(away_from, attack_dmg)\n @current_hp -= attack_dmg\n @vect_angle = Gosu.angle(away_from[0], away_from[1], @hb.x, @hb.y)\n @vect_v = @recoil_magnitude\n change_state(GameStates::States::RECOILING)\n @event_tiks = @current_hp > 0 ? @recoil_frames : 18\n end",
"def midpoint_scheduling(method=:midpoint)\n next_greens = inroads.select {|r| r.has_headroad? }\n\n blurs = next_greens.map do |r|\n r.blurs[0]\n end.compact\n\n blurs = blurs.select {|b| b.start <= Intersection::YELLOW +\n Turtle::FOLLOWING }\n\n # preemptive switching\n # don't look at the first blur if it's almost done, but rather look\n # at the next one behind it\n preemptive = false\n cur_blurs = @current.blurs\n if next_greens.include?(@current) &&\n @current.in_blur? &&\n cur_blurs[0].traffic[-1].left_on_road <= Intersection::YELLOW\n\n preemptive = true\n blurs.delete cur_blurs[0]\n blurs << cur_blurs[1] if cur_blurs[1]\n end\n\n soonest_blurs = case method\n when :midpoint\n blurs_by_midpoint blurs\n when :delay\n blurs_by_delay blurs\n else\n []\n end\n\n soonest_roads = soonest_blurs.map {|blur| blur.road }\n \n # don't shift if there's a \"big\" blur\n # judge actual speed, not speed_limit\n big_blur = @current.blurs[0] &&\n @current.blurs[0].traffic[-1].left_on_road > Intersection::YELLOW\n\n if soonest_roads.include? @current\n next_green = nil\n elsif next_greens.include?(@current) &&\n @current.in_blur? &&\n big_blur\n\n remaining = @current.blurs[0].traffic[-1].left_on_road\n info \"#{@current.label}: finishing up a blur, not ready to \" +\n \"change yet (#{remaining} sec left)\"\n\n next_green = nil\n else\n next_green = soonest_roads[0]\n end\n\n # info logging\n info = []\n if next_green\n p = @current.blurs[0]\n s = p ? p.midpoint : @current.ehr\n n = next_green.blurs[0]\n\n if preemptive\n info << \"\\t\\tpreemptive switching\"\n info << \"\\t\\t\\t#{p.traffic[-1].left_on_road} remaining here\"\n info << \"\\t\\t\\t#{n.start} to blur on next road (@ speed limit)\"\n end\n\n if method == :midpoint\n info << (\"\\t\\tmidpoint (#{n.midpoint}|#{n.size}\" +\n \" vs #{s}|#{p && p.size or 0})\")\n info << (\"\\t\\t\\t\" + blurs.inspect)\n info << \"\\t\\t\\tsoonest: #{soonest_blurs.inspect}\"\n elsif method == :delay\n info << \"\\t\\tmin delay: #{blurs.map {|b| b.delay_for_holding blurs }.min}\"\n info << \"\\t\\t\\tblurs: #{blurs.inspect}\"\n info << \"\\t\\t\\ttotal: #{\n blurs.map {|b| b.delay_for_holding blurs }.inspect}\"\n end\n end\n\n {:next_green => next_green, :reason => :midpoint, :info => info.join(\"\\n\")}\n end",
"def sniper_targets\n potential_sniper_targets.select do |planet|\n # Predict future accounting for all current fleets\n max_travel_time = @pw.fleets_underway_to(planet).map{|fleet| fleet.turns_remaining}.max || 0\n predictions = predict_future_population(planet, max_travel_time + 1)\n\n # Only go for planets that the enemy will eventually win\n next unless predictions.last.enemy?\n\n next if planet.enemy?\n if planet.mine?\n # Recapture\n elsif planet.enemy?\n # Don't go for planets that are getting reinforced. Don't fight the enemy head-on.\n next\n else # neutral\n # Snipe\n end\n true\n end\n end",
"def plan_next_step(used_strategy)\n options = {}\n case used_strategy\n when :agressive\n\n # attack a company if success rate is high enough\n attackable_companies = Company.all.delete_if { |c| chance_of_success_against(c, :hack) < 50.0 }\n if attackable_companies.present?\n company_with_highest_success_rate = attackable_companies.sort_by! { |c| chance_of_success_against(c, :hack) }.first\n options = {\n user_id: id,\n target_id: company_with_highest_success_rate.id,\n target_type: \"Company\",\n type_id: Action::TYPE_ATTACK_COMPANY,\n completed_at: time_to_attack(company_with_highest_success_rate, :hack)\n }\n\n # counter-attack last attacker (if his attack is still unavenged)\n elsif successful_attacks_in_last_24_hours > 0 && !counterattack_successful?\n last_attacker = Action.where([\"type_id = ? OR type_id = ?\", Action::TYPE_ATTACK_USER, Action::TYPE_ATTACK_USER_DDOS]).where(target_id: id, target_type: \"User\", completed: true, success: true).where(\"completed_at >= ?\", DateTime.now-24.hours).order(\"completed_at DESC\").first.try(:user)\n if last_attacker.present? && \n (can_attack?(last_attacker, :hack) || can_attack?(last_attacker, :ddos)) && \n (chance_of_success_against(last_attacker, :hack) >= 50.0 || chance_of_success_against(last_attacker, :ddos) >= 50.0)\n\n # determine attack type based on success rate and possible reward\n options = {\n user_id: id,\n target_id: last_attacker.id,\n target_type: \"User\"\n }\n\n # assume that last attacker is rich if he controls a company\n if last_attacker.companies.present?\n options[:type_id] = Action::TYPE_ATTACK_USER\n options[:completed_at] = DateTime.now + time_to_attack(last_attacker, :hack).seconds\n\n elsif chance_of_success_against(last_attacker, :hack) > chance_of_success_against(last_attacker, :ddos)\n options[:type_id] = Action::TYPE_ATTACK_USER\n options[:completed_at] = DateTime.now + time_to_attack(last_attacker, :hack).seconds\n\n elsif chance_of_success_against(last_attacker, :hack) <= chance_of_success_against(last_attacker, :ddos)\n options[:type_id] = Action::TYPE_ATTACK_USER_DDOS\n options[:completed_at] = DateTime.now + time_to_attack(last_attacker, :ddos).seconds\n end\n\n # buy or evolve attack skills\n else\n options = buy_or_evolve_attack\n end\n else\n options = buy_or_evolve_attack\n end\n when :defensive\n options = buy_or_evolve_defense\n\n when :moderate\n options = if (hacking_ratio <= botnet_ratio && hacking_ratio <= defense_ratio) ||\n (botnet_ratio <= hacking_ratio && botnet_ratio <= defense_ratio)\n buy_or_evolve_attack\n elsif defense_ratio <= botnet_ratio && defense_ratio <= hacking_ratio\n buy_or_evolve_defense\n end\n end\n\n if options.present?\n if options[:accept_job_id].present? && Job.acceptable.where(id: options[:accept_job_id]).first.present?\nRails.logger.info(\"---> AI: i accept job# #{options[:accept_job_id]}\")\n Job.acceptable.where(id: options[:accept_job_id]).first.accept_by(self)\n else\n result = Action.create(options)\nRails.logger.info(\"---> AI: i perform #{result.readable_type}\")\n result\n end\n end\n end",
"def right_hand_solve\n until @buckets[1] == @target\n fill_right\n until @buckets[1].zero?\n right_to_left\n break if @buckets.include?(@target)\n empty_left\n break if @buckets.include?(@target)\n right_to_left\n break if @buckets.include?(@target)\n end\n end\n end",
"def fast_dance(target, tiles_hash)\n tiles_hash[target]\nend",
"def determine_moves(loc)\n\n piece = @spaces[loc]\n\n moveset = []\n attackset = []\n new_moves = []\n\n x = loc[0]\n y = loc[1]\n\n enemy_king_checked = false\n\n\n case piece.type\n\n when \"pawn\"\n\n if piece.color == \"white\"\n\n new_moves << [x, y+1]\n new_moves << [x,y+2] if y == 1\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if y == 1\n\n end\n\n atk_moves = [[x+1, y+1], [x-1, y+1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"black\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"black\" and @spaces[move].type == \"king\"\n end\n end\n \n\n elsif piece.color == \"black\"\n\n new_moves = [[x, y-1]]\n new_moves << [x,y-2] if y == 6\n\n if @spaces[new_moves[0]].nil?\n\n moveset << new_moves[0]\n moveset << new_moves[1] if loc[1] == 6\n\n end\n\n atk_moves = [[x+1, y-1], [x-1, y-1]]\n atk_moves.each do |move|\n attackset << move if @spaces[move].nil?.! and @spaces[move].color == \"white\"\n if @spaces[move].nil?.!\n enemy_king_checked = true if @spaces[move].color == \"white\" and @spaces[move].type == \"king\"\n end\n end\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n \n\n when \"rook\"\n\n runner(loc, :north)\n runner(loc, :east)\n runner(loc, :south)\n runner(loc, :west)\n\n when \"knight\"\n\n possible_directions =\n [ [x+1, y+2],\n [x+1, y-2],\n [x-1, y+2],\n [x-1, y-2],\n [x+2, y+1],\n [x+2, y-1],\n [x-2, y+1],\n [x-2, y-1] ]\n\n moveset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and @spaces[d].nil?\n end\n\n attackset = possible_directions.select do |d|\n (d[0].between?(0,7) & d[1].between?(0,7)) and (@spaces[d].nil?.! and @spaces[d].color != @spaces[loc].color)\n end\n\n @spaces[loc].moveset = moveset\n @spaces[loc].attackset = attackset\n\n\n when \"bishop\"\n\n runner(loc, :northeast)\n runner(loc, :southeast)\n runner(loc, :northwest)\n runner(loc, :southwest)\n\n\n when \"queen\"\n\n runner(loc, :north)\n runner(loc, :northeast)\n runner(loc, :east)\n runner(loc, :southeast)\n runner(loc, :south)\n runner(loc, :southwest)\n runner(loc, :west)\n runner(loc, :northwest)\n\n\n when \"king\"\n\n runner(loc, :north, 1)\n runner(loc, :northeast, 1)\n runner(loc, :east, 1)\n runner(loc, :southeast, 1)\n runner(loc, :south, 1)\n runner(loc, :southwest, 1)\n runner(loc, :west, 1)\n runner(loc, :northwest, 1)\n\n end\n\n\n end",
"def legal_moves\n # Fill this in\n end",
"def Knight_long_path(position, target)\n possible_moves = []\n moves = ['move_down', 'move_up', 'move_right', 'move_left']\n chessercise = Chessercise.new\n for i in moves do\n for j in moves do\n now = getposition(position)\n if i != j\n if @directions_flag[i.to_sym] != @directions_flag[j.to_sym]\n if chessercise.send(i.to_sym, now) != nil\n mv_now = chessercise.send(i.to_sym, now)\n now = getposition(mv_now)\n if chessercise.send(j.to_sym, now) != nil\n mv_now = chessercise.send(j.to_sym, now)\n now = getposition(mv_now)\n if chessercise.send(j.to_sym, now) != nil\n mv_now = chessercise.send(j.to_sym, now)\n possible_moves.push(mv_now)\n end\n end\n end\n end\n end\n end\n end\n return possible_moves\n # print Knight_long_path('d2')\n end",
"def times_walked_to(state); end",
"def repel\n temp = subject\n if random_reflect? # Random target reflect if skill/item allow to do so\n temp = temp.friends_unit.alive_members.shuffle[0]\n end\n self.subject = target\n self.target = temp\n # Invert setup as well ~\n start = @setup[PROJ_START]\n start_p = @setup[PROJ_STARTPOS]\n @setup[PROJ_START] = @setup[PROJ_END]\n @setup[PROJ_STARTPOS] = @setup[PROJ_ENDPOS]\n @setup[PROJ_END] = start\n @setup[PROJ_ENDPOS] = start_p\n self.mirror = !self.mirror\n # Re-start projectile\n start_projectile\n start_animation(@animation, !@mirror)\n end",
"def setup_rem_state\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n state_id = @acts[1]\n chance = @acts[2] || 100\n chance = chance / 100.0 if c.integer?\n target.remove_state(state_id) if rand < chance\n end\n end",
"def tsbs_action_main(targets, item, subj)\n # Determine if item is not AoE ~\n if !item.area?\n subj.area_flag = false\n # Repeat item sequence for target number times\n targets.each do |target|\n # Change target if the target is currently dead\n if target.dead? && !item.for_dead_friend? \n target = subj.opponents_unit.random_target\n break if target.nil?\n # Break if there is no target avalaible or force break action\n end\n target = @cover_battlers[target] if @cover_battlers[target]\n # Do sequence\n subj.target = target\n subj.battle_phase = :skill\n wait_for_skill_sequence\n break if [:forced, :idle].include?(subj.battle_phase) || \n subj.break_action\n end\n # If item is area of effect damage. Do sequence skill only once\n else\n subj.area_flag = true\n subj.battle_phase = :skill\n wait_for_skill_sequence\n subj.area_flag = false\n end\n end",
"def select_moves(source, target)\n \n source.moves = source.moves.reject {|m| m.category == \"god\" }\n \n # puts \"Selecting moves for #{source.name} vs #{target.name}\"\n \n selected_moves = Array.new\n \n # Select 2 STAB damaging moves as they will do the most damage\n same_type_damage_moves = source.moves.select { |m| ((source.type_1 == m.type_1 || source.type_2 == m.type_1) && m.power) }\n \n if same_type_damage_moves.any?\n \n same_type_damage_moves.each do |m|\n total_damage = 0\n 100.times do |i|\n total_damage = total_damage + calculate_damage(source, target, m)\n end\n m.average_damage = ((total_damage / 100.0) * (m.accuracy / 100.0)).round\n #puts \"#{source.name} used #{m.name} for an average of #{m.average_damage} damage\"\n end\n \n same_type_damage_moves.sort! { |x, y| x.average_damage <=> y.average_damage }\n same_type_damage_moves.reverse!\n \n # same_type_damage_moves.each do |m|\n # puts \"#{m.name} --> avg damage = #{m.average_damage}\"\n # end\n \n selected_moves.push(same_type_damage_moves[0]) unless same_type_damage_moves[0].nil?\n selected_moves.push(same_type_damage_moves[1]) unless same_type_damage_moves[1].nil?\n end\n \n # Select 1 stat change move: use the highest stage change value move because\n # it will be the most effective\n stat_change_moves = source.moves.select { |m| m.stage_change && m.stat_type != \"speed\" }\n \n if stat_change_moves.any?\n stat_change_moves.sort! { |x, y| x.stage_change <=> y.stage_change }\n stat_change_moves.reverse!\n end\n \n # stat_change_moves.each do |m|\n # puts \"#{m.name} --> #{m.stage_change}\"\n # end\n \n already_selected = selected_moves.include? stat_change_moves[0]\n selected_moves.push(stat_change_moves[0]) unless stat_change_moves[0].nil? || already_selected\n \n status_effect_moves = source.moves.select { |m| m.status_effect }\n \n if status_effect_moves.any?\n \n status_effect_moves.each do |m|\n true_status_effect_chance = (m.accuracy / 100.0) * (m.status_effect_chance / 100.0)\n m.true_status_effect_chance = true_status_effect_chance\n end\n status_effect_moves.sort! { |x, y| x.true_status_effect_chance <=> y.true_status_effect_chance }\n status_effect_moves.reverse!\n end\n \n # status_effect_moves.each do |m|\n # puts \"#{m.name} --> #{m.status_effect} || #{m.true_status_effect_chance}\"\n # end\n \n already_selected = selected_moves.include? status_effect_moves[0]\n selected_moves.push(status_effect_moves[0]) unless status_effect_moves[0].nil? || already_selected\n \n # puts \"SELECTED MOVES: #{selected_moves.length}\"\n \n while selected_moves.length < 4\n random_move = source.moves.sample\n selected_moves.push(random_move) unless selected_moves.include? random_move\n end\n \n # puts \"SELECTED MOVES AFTER RANDOM: #{selected_moves.length}\"\n \n # selected_moves.each do |m|\n # puts \"#{source.name} selected: #{m.name}\"\n # end\n \n return selected_moves\nend",
"def fiddle args\n args.state.gravity = -0.5\n args.state.player_jump_power = 10 # sets player values\n args.state.player_jump_power_duration = 5\n args.state.player_max_run_speed = 20\n args.state.player_speed_slowdown_rate = 0.9\n args.state.player_acceleration = 0.9\nend",
"def sorrounded?\n enemies_around > 2\n end",
"def perform_action!(warrior)\n # available methods for a Space (returned by warrior.feel)\n # TESTERS\n # stairs?\n # empty?\n # enemy?\n # captive?\n # wall?\n # ticking? (OMINOUS!)\n # TYPE GETTERS\n # unit (e.g. \"Thick Sludge\", may be nil)\n # location - An [X-coord, Y-coord] pair\n # - A coordinate may be < 0, e.g. if you're at [0, 0],\n # then warrior.feel(:backward).location = [-1, 0]\n # character (e.g. \"S\" for a thick sludge, may be nil)\n # Note that the stairs space is empty (unless a unit is on it), i.e.\n # space.empty? returns true for the stairs space, so explicitly check\n # for stairs.\n\n # We can get away with only feeling in one direction, for now.\n space = warrior.feel(direction)\n\n # The stairs space may not be empty, e.g. if an enemy or captive is on\n # it\n if space.stairs? and space.empty?\n warrior.walk!(direction)\n elsif current_location == [1, 0] and warrior.feel(:backward).empty?\n # Nothing more to do here\n @direction = :forward\n warrior.walk!(direction)\n elsif @map.just_killed_an_enemy\n if @map.is_safe_location?(current_location)\n puts \"current location is safe\"\n if warrior.health < MAX_HEALTH\n warrior.rest!\n else\n # OK, forget about that enemy we just killed.\n # WE'RE AT MAX HEALTH AND READY TO ROCK!\n @map.just_killed_an_enemy = false\n @direction = @map.towards_current_enemy\n warrior.walk!(direction)\n end\n else\n puts \"current location is NOT safe\"\n reverse_direction!\n @direction = @map.towards_safe_space\n warrior.walk!(direction)\n end\n elsif space.captive?\n warrior.rescue!(direction)\n elsif space.enemy?\n @map.register_enemy_at!(space.location, space.character)\n @map.decrement_enemys_health_at(space.location)\n warrior.attack!(direction)\n elsif space.empty?\n warrior.walk!(direction)\n elsif space.wall?\n # Hit a wall, switch direction and retry\n reverse_direction!\n perform_action!(warrior)\n else\n puts \"!!! Weird space: #{space.inspect}\"\n warrior.walk!(direction)\n end\n end",
"def block\n winning_move(@opponent_mark) \n end",
"def setup_target_slide\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n if area_flag\n target_array.each do |target|\n target.slide(*args)\n end\n return\n end\n target.slide(*args)\n end",
"def move\n # Choose a random cell\n # JAVI: Extend this part of the method to choose cell with lower number of surveys (on average)\n cell = cells_around(@loc).rand\n \n # possibly a good location\n # first look ahead \n if !touches_path? cell, @path, @loc \n \n # do 1 more look ahead for each further possible step to avoid this:\n #\n # . . . . .\n # v < < . .\n # v . ^ . .\n # v . ^ < .\n # v . x o .\n # v x ? x .\n # > > ^ . .\n # . . . . . \n #\n # ^v<> = path\n # o = start\n # ? = possible good looking next move\n # x = shows that this is a dead end. All further steps are not allowed.\n #\n # Therefore, if any further step from cell is possible, then we're good to go\n \n # Configure future\n future_path = @path.dup\n future_path << cell\n second_steps = cells_around(cell)\n \n # If at least one of the future steps is valid, go for it\n second_steps.each do |ss|\n if !touches_path? ss, future_path, cell\n @path << cell\n @loc = cell\n @distance -= 1 \n return true\n end\n end \n end \n \n Rails.logger.debug \"*****************\"\n Rails.logger.debug \"Location: #{@loc.to_s}, New move: #{cell.to_s}.\"\n Rails.logger.debug \"Path: #{@path.to_s}\" \n \n false \n #cells = Cell.all :conditions => \"(x = #{@x-1} AND y = #{@y}) OR (x = #{@x+1} AND y = #{@y}) OR (x = #{@x} AND y = #{@y-1}) OR (x = #{@x} AND y = #{@y+1})\",\n # :order => \"positive_count + negative_count ASC\"\n \n # if all the cells have already been surveyed, weight index to those with few surveys \n #if cells.size == 4\n # i = rand(3)\n # i = (i - (i * 0.1)).floor \n # @x = cells[i].x\n # @y = cells[i].y\n # return\n #end\n \n # if there are empty cells, make a new cell where there's a gap and use that \n #[@x, @y-1] *<-- ALWAYS GOING DOWN\n #existing_cells = cells.map {|c| [c.x, c.y]}\n #survey_cell = (possible_cells - existing_cells).rand\n end",
"def update_potential(spot=nil)\n x = @spot.spot[0]\n y = @spot.spot[1]\n team_in_path = []\n rooks = []\n potential = [\n [x+1,y+1],\n [x+1,y-1],\n [x-1,y+1],\n [x-1,y-1],\n [x+1,y],\n [x-1,y],\n [x,y+1],\n [x,y-1]]\n potential.each do |a|\n a.reject! { a.any? { |b| b < 1 || b > 8 } }\n end\n potential.delete([])\n potential.each do |x|\n team_in_path << x.dup if Game.whos_here(x) == self.color\n x.reject! { Game.whos_here(x) == self.color }\n end\n potential.delete([])\n # => below is castle move\n if @moved == false\n Game.pieces.each do |rook|\n if rook.is_a?(Rook) && rook.color == @color\n rooks << rook\n if rook.moved == false && rook.team_in_path.include?(self.spot.spot)\n potential << [x-2,y] if rook.spot.spot[0] < x\n potential << [x+2,y] if rook.spot.spot[0] > x\n end\n end\n end\n end\n # => above is castle move\n potential.each do |king|\n Game.pieces.each do |piece|\n if piece.color == @opposite\n piece.potential.each do |path|\n king.reject! { path == king }\n end\n piece.team_in_path.each do |check|\n king.reject! { check == king }\n end\n end\n end\n end\n potential.delete([])\n potential.delete([x+2,y]) unless potential.include?([x+1,y])\n potential.delete([x-2,y]) unless potential.include?([x-1,y])\n @potential = potential\n @team_in_path = team_in_path\n @rooks = rooks\n end",
"def move(params)\n # day:,\n # nutrients:,\n # sun:,\n # score:,\n # opp_sun:,\n # opp_score:,\n # opp_waiting:,\n # trees:,\n # actions:\n params.each_pair do |k, v|\n debug(\"#{ k }: #{ v },\")\n end\n timeline << params\n\n if begin_harvest?\n actions.\n select { |action| action.start_with?(\"COMPLETE\") }.\n min_by { |action| action.split(\" \").last.to_i } ||\n \"WAIT hump, nothing to harvest\"\n elsif grow?\n grow = nil\n\n if can_afford?(:two_to3) && my_harvestable_trees.size < 2\n inter = my_size2_trees.keys.sort.map { |i| \"GROW #{ i }\" }.to_set & actions\n\n grow = inter.sort_by { |a| a.split(\" \").last.to_i }.first\n end\n\n if can_afford?(:one_to2) && my_size2_trees.size < 2\n inter = my_size1_trees.keys.sort.map { |i| \"GROW #{ i }\" }.to_set & actions\n\n grow = inter.sort_by { |a| a.split(\" \").last.to_i }.first\n end\n\n grow || \"WAIT\"\n else\n \"WAIT\"\n end\n end",
"def make_basic_action_result\r\n # If attack\r\n if @active_battler.current_action.basic == 0\r\n # Set anaimation ID\r\n @animation1_id = @active_battler.animation1_id\r\n @animation2_id = @active_battler.animation2_id\r\n # If action battler is enemy\r\n if @active_battler.is_a?(Game_Enemy)\r\n if @active_battler.restriction == 3\r\n target = $game_troop.random_target_enemy\r\n elsif @active_battler.restriction == 2\r\n target = $game_party.random_target_actor\r\n else\r\n index = @active_battler.current_action.target_index\r\n target = $game_party.smooth_target_actor(index)\r\n end\r\n end\r\n # If action battler is actor\r\n if @active_battler.is_a?(Game_Actor)\r\n if @active_battler.restriction == 3\r\n target = $game_party.random_target_actor\r\n elsif @active_battler.restriction == 2\r\n target = $game_troop.random_target_enemy\r\n else\r\n index = @active_battler.current_action.target_index\r\n target = $game_troop.smooth_target_enemy(index)\r\n end\r\n end\r\n # Set array of targeted battlers\r\n @target_battlers = [target]\r\n # Apply normal attack results\r\n for target in @target_battlers\r\n target.attack_effect(@active_battler)\r\n end\r\n return\r\n end\r\n # If guard\r\n if @active_battler.current_action.basic == 1\r\n # Display \"Guard\" in help window\r\n @help_window.set_text($data_system.words.guard, 1)\r\n return\r\n end\r\n # If escape\r\n if @active_battler.is_a?(Game_Enemy) and\r\n @active_battler.current_action.basic == 2\r\n # Display \"Escape\" in help window\r\n @help_window.set_text(\"Escape\", 1)\r\n # Escape\r\n @active_battler.escape\r\n return\r\n end\r\n # If doing nothing\r\n if @active_battler.current_action.basic == 3\r\n # Clear battler being forced into action\r\n $game_temp.forcing_battler = nil\r\n # Shift to step 1\r\n @phase4_step = 1\r\n return\r\n end\r\n end",
"def update_target(battler, force = false) \n if need_target_update?\n if force or in_range?\n positions = determine_cursor_area(battler)\n else\n positions = []\n end\n self.target_positions = positions\n end\n end",
"def turn!(x, y)\n\n # Policy pesimistis lock... but simple to implement. The best option to solve this problem \n # is force the thread wait only in the locks that represents de selected adjacent tile.\n @mutex.synchronize do\n\n tile = @tiles[x][y]\n location = Location.new(@n, @m, x, y)\n\n return if(tile.is_a?(Water) || tile.is_a_plant?())\n\n if tile.is_a_vegetarian?()\n\n if Utils.generate_random_percentage() <= Configurator[:vegetarian_move_probability]\n \n @tiles = VegetarianBehaviour.move(@tiles, location)\n end\n elsif tile.is_a_predator?()\n \n if Utils.generate_random_percentage() <= Configurator[:predator_move_probability]\n\n @tiles = PredatorBehaviour.move(@tiles, location)\n end\n else\n\n @tiles = GroundBehaviour.grow(@tiles, location)\n end\n end\n end",
"def test_should_kill_with_just_one_neighbour\n @game.state = [[0,0,0],[1,0,0],[1,0,0]]\n after = @game.evolve\n assert_equal 0,after[1][0]\n assert_equal 0,after[2][0]\n end",
"def mill_pump_wheel_lid(pCent_x, pCent_y)\r\n # # # # # # # # # # # # # #\r\n print \"(mill_pump_wheel_lid)\\n\" \r\n mill.retract()\r\n \r\n print \"(L995 - shaft_diam = \", shaft_diam, \")\\n\"\r\n \r\n mill_impeller_axel(pCent_x, pCent_y, mirrored=false, pBegZ=0, pEndZ=nil)\r\n \r\n \r\n # Coutout job with the last \r\n mill.retract()\r\n \r\n # TODO: change this over to cutout that leaves tabs\r\n spiral_down_circle(mill = mill, \r\n x = pCent_x,\r\n y = pCent_y, \r\n diam = cutout_diam, \r\n beg_z=0, \r\n end_z=drill_through_depth * 0.97, \r\n adjust_for_bit_radius=false, \r\n outside=true, \r\n auto_speed_adjust=false)\r\n \r\n mill.retract()\r\n mill.home() \r\n \r\n \r\n end",
"def make_basic_action_result\n # If attack\n if @active_battler.current_action.basic == 0\n # Set anaimation ID\n @animation1_id = @active_battler.animation1_id\n @animation2_id = @active_battler.animation2_id\n # If action battler is enemy\n if @active_battler.is_a?(Game_Enemy)\n if @active_battler.restriction == 3\n target = $game_troop.random_target_enemy\n elsif @active_battler.restriction == 2\n target = $game_party.random_target_actor\n else\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n end\n end\n # If action battler is actor\n if @active_battler.is_a?(Game_Actor)\n if @active_battler.restriction == 3\n target = $game_party.random_target_actor\n elsif @active_battler.restriction == 2\n target = $game_troop.random_target_enemy\n else\n index = @active_battler.current_action.target_index\n target = $game_troop.smooth_target_enemy(index)\n end\n end\n # Set array of targeted battlers\n @target_battlers = [target]\n # Apply normal attack results\n for target in @target_battlers\n target.attack_effect(@active_battler)\n end\n return\n end\n # If guard\n if @active_battler.current_action.basic == 1\n # Display \"Guard\" in help window\n @help_window.set_text($data_system.words.guard, 1)\n return\n end\n # If escape\n if @active_battler.is_a?(Game_Enemy) and\n @active_battler.current_action.basic == 2\n # Display \"Escape\" in help window\n @help_window.set_text(\"Escape\", 1)\n # Escape\n @active_battler.escape\n return\n end\n # If doing nothing\n if @active_battler.current_action.basic == 3\n # Clear battler being forced into action\n $game_temp.forcing_battler = nil\n # Shift to step 1\n @phase4_step = 1\n return\n end\n end",
"def setup_add_state\n return unless PONY::ERRNO::check_sequence(current_act)\n \n current_action_targets.each do |target|\n state_id = @acts[1]\n chance = @acts[2] || 100\n chance = chance / 100.0 if c.integer?\n chance *= target.state_rate(state_id) unless @acts[3]\n target.add_state(state_id, self) if rand < chance\n end\n end",
"def setup_targets_flip\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n if area_flag\n target_array.each do |target|\n target.flip = @acts[1]\n end\n return\n end\n target.flip = @acts[1]\n end",
"def test_guarded_simple_dsl\n \t\tsmc = StateModelCreator.new\n smc.define_action :action1 do\n @done_action1 = true\n end # end action\n \n smc.define_action :action2 do\n @done_action2 = true\n end # end action\n \n smc.define_guard_on :action2 do\n if @done_action1 && !@done_action2\n guard=true\n else\n guard=false\n end # end if \n guard\n end # end guard\n \n \tsmc.attach_transition(:STATEA,:action1,:STATEB)\n \tsmc.attach_transition(:STATEB,:action2,:STATEA)\n \n sm = smc.state_machine \n\n assert(sm.guarded_actions.include?(:action2) , \"Check action2 is identified as being guarded\")\n assert(!sm.guarded_actions.include?(:action1) , \"Check action1 is identified as not being guarded\")\n \n assert_equal(false , sm._guard_on_action2, \"check guard returns false as default\")\n \n # Create the Graphiz graph object, see if it fails...\n \tsm_graph = sm.create_dot_graph\t\n \tsm_graph.output(\"../test/test_guard_dsl_1.dot\")\n \t\n \t\t# Check standard length walk\n \t\t#the_walk = sm.random_walk(:STATEA)\n \t\tsm.state=:STATEA\n \t\tassert_equal(:STATEB , sm.action1 , \"Check at StateB\")\n \t\tassert_equal(true , sm._guard_on_action2 , \"Check Guard returns correct value\")\n \n\tend",
"def setup_immortaling\n target_array.each do |targ|\n targ.immortal = true\n end\n end"
] |
[
"0.62659484",
"0.6260761",
"0.6184533",
"0.6147916",
"0.6134955",
"0.5949397",
"0.594767",
"0.5802363",
"0.58006734",
"0.5793714",
"0.5793639",
"0.5686621",
"0.56531674",
"0.55997545",
"0.5597484",
"0.55813307",
"0.5577667",
"0.5522517",
"0.5430506",
"0.5430269",
"0.54198015",
"0.54125416",
"0.53899413",
"0.538843",
"0.5387821",
"0.5382336",
"0.53416115",
"0.53389233",
"0.5327022",
"0.53256744",
"0.5317596",
"0.53108525",
"0.5303186",
"0.52980936",
"0.5297777",
"0.52925485",
"0.5290377",
"0.5287863",
"0.5281392",
"0.5280013",
"0.527195",
"0.5265422",
"0.52623755",
"0.52591443",
"0.5257834",
"0.52494156",
"0.52430296",
"0.5241166",
"0.5239979",
"0.52338374",
"0.52276444",
"0.522234",
"0.5218654",
"0.5216665",
"0.5196962",
"0.5183811",
"0.51820964",
"0.5179442",
"0.5178492",
"0.51605874",
"0.5156681",
"0.51551056",
"0.514943",
"0.51311755",
"0.5118483",
"0.5113469",
"0.51116747",
"0.5106397",
"0.5106243",
"0.5105609",
"0.51012725",
"0.50981253",
"0.5096794",
"0.5091953",
"0.5087115",
"0.50843257",
"0.5080978",
"0.50718737",
"0.5070371",
"0.50694734",
"0.5051578",
"0.50483906",
"0.50477093",
"0.5044234",
"0.5038615",
"0.50305873",
"0.5021012",
"0.50121826",
"0.5009225",
"0.50074774",
"0.49960372",
"0.49912155",
"0.4983751",
"0.49817106",
"0.4977074",
"0.49733374",
"0.49721718",
"0.4971613",
"0.496587",
"0.49653372",
"0.49653187"
] |
0.0
|
-1
|
======================= PURCHASE STUFF ===============================
|
def num_already_purchased(deal)
active_purchases.map { |x| x.deal_id == deal.id ? x.num_bought : 0}.reduce(&:+) || 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def purging\n @purging = true\n end",
"def purge\n end",
"def purge\n\n\t\tend",
"def after_destroy(purchase)\n if purchase.store_id\n shopping = Shopping.add(\n purchase.user_id,\n purchase.store_id,\n ShoppingSource::Purchase)\n shopping.decrement_purchases_count\n end\n\n if purchase.fb_action_id && \n purchase.fb_action_id != FBSharing::Underway\n\n ProcessingQueue.push(\n DistributionManager,\n :delete_story,\n purchase.fb_action_id,\n purchase.user.access_token)\n end\n\n if purchase.tweet_id && \n purchase.tweet_id != TWSharing::Underway\n\n ProcessingQueue.push(\n DistributionManager,\n :delete_tweet,\n purchase.tweet_id,\n purchase.user)\n end\n\n if purchase.tumblr_post_id && \n purchase.tumblr_post_id != TumblrSharing::Underway\n\n ProcessingQueue.push(\n DistributionManager,\n :delete_tumblr_post,\n purchase.tumblr_post_id,\n purchase.user)\n end\n end",
"def shopping_cart_cleanup\n\n end",
"def test_purge\n religion_cat_original_id = @religion_cat.id\n assert_equal 1, @religion_cat.quotations.size\n assert @importance_of_religion.destroy\n # check the religion category has purged properly\n assert_raise(ActiveRecord::RecordNotFound) { Category.find(religion_cat_original_id) }\n end",
"def purge()\n time = Time.now\n @data.each do |key, item|\n if item.expiration < time\n @data.delete(key)\n puts \"DELETE #{item.value}\"\n end\n end\n end",
"def purchase\n \t@stock -= 1\n end",
"def zap_catalogue!()\n catalogue.clear\n save_catalogue\n zap_rentals!\n end",
"def purge_all\n initialize\n end",
"def purge_items\n purge(@nodename)\n end",
"def purge\n ModelHelper::destroy_backup self\n end",
"def purge!\n\n fetch_all({}).each { |hwi| @context.storage.delete(hwi) }\n end",
"def purchase\n @order = current_order\n @order_items = @order.order_items\n @order_items.each do |item|\n new_inventory = Product.find(item.product_id).inventory_count - item.quantity\n Product.update(item.product_id, inventory_count: new_inventory)\n end\n @order_items.destroy_all\n end",
"def after_redeem() end",
"def active_archive class_name, symbol, record\n class_name.where(symbol => record.id).destroy_all unless record.carts.empty?\n record.orders.empty? ? record.destroy : Store.inactivate!(record)\n end",
"def delete_pending(purchase)\r\n self.pending_purchases.delete(purchase)\r\n end",
"def purge_db\n\tUser.delete_all\n\tSubscription.delete_all\n\tDorkus.delete_all\nend",
"def purge(id)\n uri = URI.parse(PURGE_URL)\n uri.user = @api_key\n\n post(uri, \"url\" => url(id))\n end",
"def reclaim!(distribution)\n ActiveRecord::Base.transaction do\n distribution.line_items.each do |line_item|\n inventory_item = self.inventory_items.find_by(item: line_item.item)\n inventory_item.update_attribute(:quantity, inventory_item.quantity + line_item.quantity)\n end\n end\n distribution.destroy\n end",
"def purge\n # Get the identifiers of the EMS from the database and from the registry, and calculate the difference:\n database_ids = ManageIQ::Providers::Ovirt::InfraManager.pluck(:id)\n registry_ids = @registry.keys\n purged_ids = registry_ids - database_ids\n\n # Close the connections:\n purged_ids.each do |id|\n $rhevm_log.info(\n \"The EMS with identifier '#{id}' no longer exists in the database, the connection will be closed.\"\n )\n close(id)\n end\n\n # Update the purge time:\n @purge_time = Time.current\n end",
"def purge\n @db.execute( \"DELETE FROM #{TABLE_NAME};\" )\n end",
"def confirm_purchase(purchase)\r\n purchase.confirm\r\n end",
"def cleanup\n cleanup_accounts\n end",
"def alias_purge(al)\n obj_purge(al,Alias)\n end",
"def purchase_stock!\n nil\n end",
"def remove!(donation_or_purchase)\n log = {}\n donation_or_purchase.line_items.each do |line_item|\n inventory_item = InventoryItem.find_by(storage_location: id, item_id: line_item.item_id)\n if (inventory_item.quantity - line_item.quantity) <= 0\n inventory_item.destroy\n else\n inventory_item.update(quantity: inventory_item.quantity - line_item.quantity)\n end\n log[line_item.item_id] = \"-#{line_item.quantity}\"\n end\n log\n end",
"def purge!\n @data = nil\n end",
"def purge!\n @data = nil\n end",
"def recover_usage(quantity_to_be_recovered)\n self.used_quantity -= quantity_to_be_recovered \n self.save \n \n self.unmark_as_finished\n \n \n \n item = self.item \n item.add_ready_quantity( quantity_to_be_recovered ) \n \n return self \n end",
"def delete_purchase_order_items\n purchase_order_items.destroy_all\n end",
"def orchio_purge\n response = client.send_request :delete, inst_args(path: \"?purge=true\")\n orchio_status response, 204\n end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def mark_as_purchased!(current_user: nil)\n purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true, current_user: current_user)\n end",
"def purge!\n response = perform(:purge, ref)\n @ref = nil\n @last_request_time = response.request_time\n true\n end",
"def purge!\n response = perform(:purge, ref)\n @ref = nil\n @last_request_time = response.request_time\n true\n end",
"def return_item\n items = self.see_purchases.map do |merchandise|\n {name: merchandise.name, merch_id: merchandise.id}\n end\n merch = TTY::Prompt.new.select(\"Here is a list of your purchases. What would you like to return?\",items)\n purchase = self.specific_purchase(merch)\n purchase.destroy \n puts \"your item has been refunded!\"\n restock = self.select_merchandise(merch)\n restock.update(inventory: restock.inventory + 1)\n end",
"def update_junk\n\n #\n ##people = { 1 => { \"first_name\" => \"David\" }, 2 => { \"first_name\" => \"Jeremy\" } }\n ##PurchasesEntries.update(people.keys, people.values)\n #\n #\n #params[:purchase].each do |attributes|\n # logger.warn \"####################################### attributes: \" + attributes.inspect\n # g = \"g\"\n # #purchases_entry = @purchase.purchases_entries.detect {|pe| pe.id == attributes[1][0][:id] }\n # #\n # #@purchase.purchases_entries.each do |pe|\n # # if pe.id == attributes[1][0][:id]\n # #end\n #\n #\n # people = { 1 => { \"first_name\" => \"David\" }, 2 => { \"first_name\" => \"Jeremy\" } }\n # PurchasesEntries.update(people.keys, people.values)\n #\n #\n #\n # logger.warn \"####################################### purchases_entry.id \" + purchases_entry.id.to_s\n # purchases_entry_opposite_entry = purchases_entry.opposite_entry if purchases_entry.opposite_entry != false\n # purchases_entry.attributes = attributes\n # purchases_entry_opposite_entry.attributes = attributes if purchases_entry_opposite_entry\n # purchases_entry.save!(:validate=> false)\n # purchases_entry_opposite_entry.save(:validate=> false) if purchases_entry_opposite_entry\n #\n # purchases_entry.destroy if purchases_entry.QuantityOnOrder <= 0.0\n # if purchases_entry_opposite_entry\n # purchases_entry_opposite_entry.destroy if purchases_entry_opposite_entry.QuantityOnOrder <= 0.0\n # end\n # end\n #\n #\n #\n # delete_purchase_cache\n #\n\n\nend",
"def test_ebook_purchases_send_to_bookshelf\n puts \"test_ebook_purchases_send_to_bookshelf\"\n\n # Verify target bookshelf installation is in nibley mode\n\n # Log test user in to bookshelf\n bookshelf_token = login_bookshelf_user(\n 'tests@deseretbook.com',\n 'test123'\n )\n \n # Ensure the book isn't already in the test user's bookshelf account.\n remove_book_from_bookshelf_account(bookshelf_token, digital_product_book_id)\n\n # do the purchase\n clear_cookies\n login\n\n add_items_to_cart([:digital])\n\n begin_checkout\n\n select_addresses(allow_skip: true)\n\n select_payment(payment_type: :credit_card)\n\n confirm_order\n verify_successful_order\n verify_order_state([:digital])\n\n # Verify the book is now in the test user's bookshelf account.\n # It may take a while to get through the queue so do a timed retry here.\n # This loop will wait a total of 30 seconds.\n retries = 10\n until present = bookshelf_account_contains_book?(bookshelf_token, digital_product_book_id)\n puts \"Book #{digital_product_book_id} present yet? #{present.inspect}\"\n unless present\n retries -= 1\n puts \"#{retries} retries left. Trying again in 3 seconds.\"\n sleep(3)\n end\n end\n assert(present, \"Book #{digital_product_book_id} not in bookshelf account\")\n end",
"def purge(key_name)\n perform(:purge, key_name)\n true\n end",
"def purge\n @items.delete_if(&:is_done) \n end",
"def confirm_all_pending_purchases\r\n self.pending_purchases.each{|purchase| purchase.confirm}\r\n end",
"def recover_usage(quantity_to_be_recovered)\n self.used_quantity -= quantity_to_be_recovered \n self.save \n \n self.unmark_as_finished\n \n item = self.item \n item.update_ready_quantity\n \n return self \n end",
"def mark_for_cleanup\n add_accounts_from_activities\n end",
"def cleanup!; end",
"def cleanup!; end",
"def purchase\n begin\n ActiveRecord::Base.transaction do\n @user.coin_credit -= @product.price\n requested_detail = @product.details.available.first\n requested_detail.available = false # makes the detail unavailable\n requested_detail.save!\n @user.save!\n @user.purchased_details << requested_detail # adds the detail to purchased_details of the user\n @purchased_detail = requested_detail\n end\n true\n rescue => e\n Rails.logger.error e\n @user.reload\n @user.errors.add(:base, :purchase_problem)\n false\n end\n end",
"def purge(path)\n Result.new(call(CMD_PURGE % path))\n end",
"def buy_postage_if_necessary(options = {:current_balance => 9999, :control_total => 0})\n min_postage_balance = 25 # buy postage if balance is under this amount\n postage_purchase_amount = 75 # amount to purchase at a time\n max_control_total = 1000 # max amount to spend per month?\n if Rails.env.production?\n if options[:current_balance] < min_postage_balance && options[:control_total] < max_control_total\n Rails.logger.info(\"STAMPS: Postage below #{min_postage_balance}, attempting to purchase #{postage_purchase_amount} in postage\")\n begin \n response = Stamps.purchase_postage(:amount => postage_purchase_amount,\n :control_total => options[:control_total])\n if response[:purchase_status] == \"Rejected\"\n Rails.logger.info(\"STAMPS: Postage purchase FAILED!, Rejection reason: #{response[:rejection_reason]}\")\n else\n Rails.logger.info(\"STAMPS: Postage purchase SUCCESS!\") \n Rails.cache.write \"stamps_last_purchased_postage_at\", Time.zone.now rescue nil\n Rails.cache.write \"stamps_current_balance\", response[:postage_balance][:available_postage] rescue nil\n end \n rescue Exception => message\n Rails.logger.info(\"STAMPS PURCHASE POSTAGE ERROR MESSAGE: #{message}\")\n end \n else\n Rails.logger.info(\"STAMPS: Checking Postage Balance: #{options[:current_balance]}\") \n end\n else\n Rails.logger.info(\"STAMPS: We don't buy postage in test mode\") \n end\n end",
"def purchase\n #@cart = Cart.find(self.cart_id)\n #cart.update_attribute(:purchased_at, Time.now)\n if cart.tip && cart.tip > 0\n @amount = price_in_cents + tax_in_cents + tip_in_cents\n else\n @amount = price_in_cents + tax_in_cents\n end\n @transaction = transactions.first\n #response = GATEWAY.purchase((price_in_cents + tax_in_cents), credit_card,\n # purchase_options)\n\n response = GATEWAY.capture((@amount), @transaction.authorization)\n @transaction.update_attributes(:action => \"capture\",\n :amount => (@amount), :response => response)\n\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n # SWITCH TO ABOVE WHEN LIVE.\n ######## remove when live. ########\n #GATEWAY.void(response.authorization, purchase_options)\n ## uncomment when live\n response.success?\n end",
"def delete_from(grocery, item)\n grocery.delete(item)\n grocery\nend",
"def purchases(options = {})\n\t\t\twarn \"[DEPRECATED] Gateway#purchases is deprecated, please use Purchase.find instead\" unless options[:silence]\n\t\t\tModels::Purchase.find(options)\n\t\tend",
"def test_successful_purchase_without_address_check2\n @solo.number = '633499110000000003'\n\n response = @gateway.purchase(@amount, @solo, @params)\n assert_success response\n end",
"def postEntityPurge( entity_id, purge_masheryid, purge_supplier_id, purge_user_id, exclude, destructive)\n params = Hash.new\n params['entity_id'] = entity_id\n params['purge_masheryid'] = purge_masheryid\n params['purge_supplier_id'] = purge_supplier_id\n params['purge_user_id'] = purge_user_id\n params['exclude'] = exclude\n params['destructive'] = destructive\n return doCurl(\"post\",\"/entity/purge\",params)\n end",
"def test_purchase_and_void_for_check\n assert purchase = @gateway.purchase(1000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.void(purchase.authorization, @options)\n assert_success void\n assert_approved void\n end",
"def test_cleanup_successful\n setup_new_order()\n @o.order_line_items << @li\n @o.order_status_code = order_status_codes(:cart)\n @o.notes = \"test test\"\n assert @o.save\n\n # Make sure inventory control is enabled.\n assert Preference.find_by_name('store_use_inventory_control').is_true?\n # Make sure cc number obfuscation is enabled.\n assert Preference.find_by_name('cc_clear_after_order').is_true?\n \n initial_quantity = @li.item.quantity\n notes_before = @o.notes.clone\n \n @o.cleanup_successful\n @li.item.reload\n \n # Quantity should be updated.\n assert_equal @li.item.quantity, (initial_quantity - @li.quantity)\n # Status code should be updated.\n @o.reload\n assert_equal @o.order_status_code, order_status_codes(:ordered_paid_to_ship)\n \n # CC number should be obfuscated.\n number_len = @o.account.cc_number.length\n new_cc_number = @o.account.cc_number[number_len - 4, number_len].rjust(number_len, 'X')\n assert_equal @o.account.cc_number, new_cc_number\n \n # A new note should be added.\n notes_after = @o.notes\n assert_not_equal notes_before, notes_after\n end",
"def cleanup_abandoned\n Reservation.all(:conditions => [ \"CONFIRM = ? and updated_at < ? and archived = ?\", false, 30.minutes.ago, false]).each do |r|\n debug \"cleanup_abandoned: deleting #{r.id}\"\n Reason.close_reason_is \"abandoned\"\n begin\n\tr.archive\n rescue RuntimeError => err\n\terror 'Cleanup: ' + err.to_s\n rescue ActiveRecord::StaleObjectError => err\n\terror 'Cleanup: ' + err.to_s\n\tlocking_error(r)\n end\n end\n end",
"def purge\n purge_file\n cdb_destroy\n end",
"def finalize!\n Street.connection.execute \"DELETE FROM streets WHERE zip_code = '9999'\"\n Street.connection.execute \"DELETE FROM streets WHERE zip_code IS NULL OR city_name IS NULL OR street_name IS NULL\"\n streets = Street.find_by_sql \"SELECT MIN(id) AS id, street_name, zip_code FROM streets GROUP BY street_name, zip_code HAVING COUNT(*) > 1\"\n streets.each do |street|\n sql = sprintf(\n \"DELETE FROM streets WHERE street_name = '%s' AND zip_code = '%s' AND id != %d\",\n Street.connection.quote_string(street.street_name),\n Street.connection.quote_string(street.zip_code),\n street.id)\n Street.connection.execute sql\n end\n end",
"def delete_db_post\n # Tell the user\n puts \"> Tar bort aliaset från databasen\".green\n\n # Connect to the database\n conn = PG.connect( dbname: DB_DATABASE_NAME, user: DB_USER, password: DB_PASSWORD )\n\n # Delete the account\n res = conn.exec \"DELETE FROM #{DB_ALIAS_TABLE} WHERE address = '#{$alias}' AND userid = '#{$email}'\" unless $simulate\n\n # Close the connection\n conn.close\nend",
"def cleaning(&block)\n Sidekiq::TransactionGuard.testing { super(&block) }\n end",
"def terminate\n result = Cybersource.unstore(\";#{subscription_id}\",:order_id => \"#{order_id}\")\n if result.success == true\n self.update_attributes({:state => \"delete\", :note => \"User Requested Deletion\"})\n end\n end",
"def process_with_payu\n process_purchase\n end",
"def finalize_transaction(type='purchase')\n self.save\n self.user.make_paid! if (!user.nil? && user.persisted?)\n self.transactions.create(action:type, amount: self.price_in_cents, response: self.purchase_response)\n end",
"def release(account, merchant, transaction_id)\n delete \"/#{CGI::escape(account)}/transactions/#{transaction_id}\" + \"?merchant=#{merchant}\"\n expect_status! 'CANCELLED'\n end",
"def cleanup_successful\n\t\tself.order_status_code_id = 5\n self.new_notes=\"Order completed.\"\n self.product_cost = self.line_items_total\n self.account.clear_personal_information\n self.save\n\tend",
"def before_confirm\n return if defined?(SpreeProductAssembly)\n return unless @order.checkout_steps.include? 'delivery'\n\n packages = @order.shipments.map(&:to_package)\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\n @differentiator.missing.each do |variant, quantity|\n @order.contents.remove(variant, quantity)\n end\n end",
"def remove(purchase)\n entry = find_item(purchase)\n destroy(entry) if entry\n end",
"def replace!\n self.class.transaction do\n person.update_attribute :shopping_cart_id, nil\n person.shopping_cart # autocreates shopping cart\n end\n end",
"def test_successful_purchase_without_address_check2\n @solo.number = '633499110000000003'\n\n response = @gateway.purchase(@amount, @solo, @params)\n assert_success response\n assert response.test?\n end",
"def purchase\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #UserMailer.ordered(\"google.com\", response.params.to_s, User.find(cart.user_id), cart).deliver\n cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end",
"def reserve_inventory!(order_quantity)\n self.quantity -= order_quantity\n save!\n end",
"def checkout\n self.product.in_cart_count -= self.count\n self.product.purchase(count)\n self.purchased!\n\n self.save!\n end",
"def clean\n transaction do\n connection.delete \"DELETE FROM line_items WHERE event_id IN (SELECT id FROM events WHERE subscription_id = #{id})\"\n connection.delete \"DELETE FROM account_items WHERE event_id IN (SELECT id FROM events WHERE subscription_id = #{id})\"\n connection.delete \"DELETE FROM tagged_items WHERE event_id IN (SELECT id FROM events WHERE subscription_id = #{id})\"\n\n connection.delete \"DELETE FROM buckets WHERE account_id IN (SELECT id FROM accounts WHERE subscription_id = #{id})\"\n connection.delete \"DELETE FROM statements WHERE account_id IN (SELECT id FROM accounts WHERE subscription_id = #{id})\"\n\n connection.delete \"DELETE FROM actors WHERE subscription_id = #{id}\"\n connection.delete \"DELETE FROM events WHERE subscription_id = #{id}\"\n connection.delete \"DELETE FROM accounts WHERE subscription_id = #{id}\"\n connection.delete \"DELETE FROM tags WHERE subscription_id = #{id}\"\n end\n end",
"def add_purchaser!(actor)\n c = contact_to!(actor)\n c.relation_ids |= [ Relation::Purchaser.instance.id ]\n end",
"def void_last_transaction\n transaction = @transactions.pop\n self.total -= (transaction.price * transaction.quantity)\n transaction.quantity.times{self.items.delete(transaction.item_name)}\n end",
"def obj_purge(obj,klass)\n obj_manipulate obj,klass do |man|\n man.in_session do \n parents = find_by_member(obj.name, :find_mode => :exact, :transaction => true)\n transaction do\n parents.each do |par|\n obj_remove par, par.class, obj\n end\n obj_delete obj, obj.class\n end\n end\n end\n end",
"def delete_db_post domain\n # Tell the user\n puts \"> Tar bort domänen från databasen\".green\n\n # Connect to the database\n conn = PG.connect( dbname: DB_DATABASE_NAME, user: DB_USER, password: DB_PASSWORD )\n\n # Delete the domain\n conn.exec \"DELETE FROM #{DB_DOMAINS_TABLE} WHERE domain = '#{domain['domain']}'\" unless $simulate\n\n # Should we also delete the accounts for the domain?\n if $delete_accounts\n # Tell the user\n puts \"> Tar bort tillhörande e-postkonton från databasen\".green\n # Delete the accounts\n conn.exec \"DELETE FROM #{DB_ACCOUNTS_TABLE} WHERE userid LIKE '%@#{domain['domain']}'\" unless $simulate\n end\n\n # Close the connection\n conn.close\nend",
"def successful_purchase_response\n end",
"def ship(id, ship_number)\n @conn.exec(\"DELETE FROM products WHERE id = '#{id}';\")\n puts \"SUBSTRACTION\"\nend",
"def destroy_along_with_units\n self.quantity = 0\n OrderInventoryAssembly.new(self).verify\n self.destroy\n end",
"def destroy_along_with_units\n self.quantity = 0\n OrderInventoryAssembly.new(self).verify\n self.destroy\n end",
"def delete_db_post account\n # Tell the user\n puts \"> Tar bort kontot från databasen\".green\n\n # Connect to the database\n conn = PG.connect( dbname: DB_DATABASE_NAME, user: DB_USER, password: DB_PASSWORD )\n\n # Delete the account\n res = conn.exec \"DELETE FROM #{DB_ACCOUNTS_TABLE} WHERE userid = '#{account['userid']}'\" unless $simulate\n\n # Close the connection\n conn.close\nend",
"def purge!\n unless self.ordered?\n self.line_items.each do |line_item|\n remove_line_item(line_item) if line_item.invalid?\n end\n end\n end",
"def track_purchase\n return true if tracked?\n return true if chargeback?\n return true unless completed?\n return true if sandbox?\n \n\n tracker = FiveD::EventTracker.new\n\n tracker.track('purchase', 'revenue', {\n user_id: self.partner_user_id || nil,\n pur_provider: self.carrier,\n pur_gross: self.gross,\n pur_currency: self.gross_currency,\n pur_country_code: self.country,\n pur_earnings: self.earnings,\n pur_product_sku: self.offer_id,\n pur_product_category: self.offer_category,\n invoice_id: self.invoice_id,\n pur_receipt_identifier: self.payment_transaction_uid,\n timestamp: self.tstamp || DateTime.now\n });\n\n self.tracked = true\n\n true\n end",
"def postEntityPurgeBy_object( entity_id, object, gen_id, purge_masheryid, purge_supplier_id, purge_user_id, destructive)\n params = Hash.new\n params['entity_id'] = entity_id\n params['object'] = object\n params['gen_id'] = gen_id\n params['purge_masheryid'] = purge_masheryid\n params['purge_supplier_id'] = purge_supplier_id\n params['purge_user_id'] = purge_user_id\n params['destructive'] = destructive\n return doCurl(\"post\",\"/entity/purge/by_object\",params)\n end",
"def purchase\n if express_token.include?(\"paykey=AP\")\n\n else\n\n #processes payment for express payment and on site with credit card.\n response = process_purchase\n #creates a transaction to store info from express payment and paywith Credit card\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end\n end",
"def instance_unreserve\n if reserve? && instance\n n = reader.update( <<-SQL )\n UPDATE urls\n SET reserved = NULL\n WHERE reserved IS NOT NULL AND\n instance = '#{instance}'\n SQL\n @log.info { \"Unreserved #{n} orders for instance #{instance}\" }\n n\n end\n rescue SQLException => x\n @log.error( \"On instance_unreserve: \", x )\n end",
"def purge_request(params, *titles)\n params[:action] = 'purge'\n params[:titles] = titles.join('|')\n\n post(params)['purge'].inject({}) do |result, hash|\n title = hash['title']\n result[title] = hash.key?('purged') && !hash.key?('missing')\n warn \"Invalid purge (#{title}) #{hash['invalidreason']}\" if hash.key?('invalid')\n result\n end\n end",
"def purchase(amount, options={})\n adjust_and_save(amount.abs * -1, :purchase, options)\n end",
"def release_unequippable_items(item_gain = true)\n loop do\n last_equips = equips.dup\n @equips.each_with_index do |item, i|\n if !equippable?(item.object) || !etype_can_equip?(i, item.object)\n trade_item_with_party(nil, item.object) if item_gain\n item.object = nil\n end\n end\n return if equips == last_equips\n end\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n delete!\n return true\n rescue PoolNode::Conflict\n # still in use\n return false\n end",
"def autorestore; end",
"def deletedaysedit\n end",
"def purge?\n Time.current - @purge_time > @purge_interval\n end"
] |
[
"0.6630897",
"0.6578031",
"0.64721733",
"0.63215905",
"0.6205686",
"0.5902519",
"0.5775348",
"0.5658996",
"0.565274",
"0.5625425",
"0.5623658",
"0.55969596",
"0.55768245",
"0.55275357",
"0.55226743",
"0.5505554",
"0.54732543",
"0.547143",
"0.5424674",
"0.5411068",
"0.53894645",
"0.5348601",
"0.53463745",
"0.5340693",
"0.5339991",
"0.5323715",
"0.5317779",
"0.53071845",
"0.53071845",
"0.53067404",
"0.53030515",
"0.5302289",
"0.53019464",
"0.53019464",
"0.53019464",
"0.53019464",
"0.52850914",
"0.52809256",
"0.52809256",
"0.5263751",
"0.5262666",
"0.52519655",
"0.52427375",
"0.5238843",
"0.52347183",
"0.5222776",
"0.52222955",
"0.5221917",
"0.5221917",
"0.52213395",
"0.5210555",
"0.52091414",
"0.5205271",
"0.51990426",
"0.5197888",
"0.51957184",
"0.5191208",
"0.5190097",
"0.51719046",
"0.51687455",
"0.5164541",
"0.5154703",
"0.5153825",
"0.51420885",
"0.5138062",
"0.5131517",
"0.5126462",
"0.5125761",
"0.5115758",
"0.5111355",
"0.5110091",
"0.5107188",
"0.51068324",
"0.5103987",
"0.5101382",
"0.50925803",
"0.5080687",
"0.5080396",
"0.5073237",
"0.5067411",
"0.5062934",
"0.5057352",
"0.50532794",
"0.504854",
"0.504854",
"0.50468296",
"0.5046141",
"0.5045928",
"0.504339",
"0.5042252",
"0.504076",
"0.50402373",
"0.50401914",
"0.50381356",
"0.5030396",
"0.5030396",
"0.5030396",
"0.50301623",
"0.5027597",
"0.5027049",
"0.502568"
] |
0.0
|
-1
|
======================= COUPON STUFF ===============================
|
def active_coupons
coupons.keep_if{|coupon| coupon.active?}.reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def probers; end",
"def cop_config; end",
"def cp_c\n end",
"def cop; end",
"def cop; end",
"def cop_name; end",
"def cop_name; end",
"def cop_names; end",
"def all_cops?; end",
"def cp_b\n end",
"def cobasysprog\n end",
"def suivre; end",
"def conj\n pos 'CONJ'\n end",
"def current_clown; end",
"def current_clown; end",
"def refutal()\n end",
"def private; end",
"def celebration; end",
"def villian; end",
"def cop_registry; end",
"def cp_e\n end",
"def cop_rule?; end",
"def thorins_company; end",
"def ca; end",
"def intensifier; end",
"def production_curtailment; end",
"def cpl\n end",
"def aon; end",
"def compilereturn\n\n end",
"def c\n end",
"def upc_e; end",
"def forkless(interspinous_interdevour, cladodontid_michel)\n end",
"def getc() end",
"def getc() end",
"def getc() end",
"def autorun; end",
"def cp_l\n end",
"def conj\n self\n end",
"def connection_prelude; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def operations; end",
"def operations; end",
"def code_of_conduct; end",
"def cp_d\n end",
"def common\n \n end",
"def custom; end",
"def custom; end",
"def bridge; end",
"def bridge; end",
"def bridge; end",
"def pcc(*args)\n return\n end",
"def consolidation\n end",
"def cop=(_); end",
"def cop=(_); end",
"def masteries; end",
"def ccf\n end",
"def upc_e_with_composite_symbology; end",
"def cable; end",
"def company; end",
"def company; end",
"def romeo_and_juliet; end",
"def isolated; end",
"def isolated; end",
"def rossini; end",
"def is_consumable?\n true\n end",
"def mi_carrera\n\n\tend",
"def gounod; end",
"def schubert; end",
"def terpene; end",
"def enable_pending_cops; end",
"def co\n field_fetch('CO')\n end",
"def constructeurCopie(jauge)\n\t\t@niveauIdeal = jauge.niveauIdeal\n\t\t@niveau = jauge.niveauIdeal\n\t\t@coeffAugmentation = jauge.coeffAugmentation\n\t\t@coeffDiminution = jauge.coeffDiminution\n\tend",
"def invention; end",
"def cp_h\n end",
"def to_citrus # :nodoc:\n 'super'\n end",
"def cp_a\n end",
"def guct\n end",
"def master; end",
"def mascot; end",
"def ibu; end",
"def initialize\n \n end",
"def moon; end",
"def nebula; end",
"def curatorCoef _obj, _args\n \"_obj curatorCoef _args;\" \n end",
"def nn\n end",
"def bellini; end",
"def appraisals; end",
"def appraisals; end",
"def transitive_closure\n end",
"def munge_list_coids\n @colist.items.each do |item|\n coids = item.attr 'coids'\n next unless coids\n\n newcoids = []\n coids.split(' ').each do |coid|\n newcoids << munge_coid(coid)\n end\n item.attributes['coids'] = newcoids.join ' '\n end\n end",
"def berlioz; end",
"def doors; end",
"def upc_a_with_composite_symbology; end",
"def operation; end",
"def mob; end",
"def coolingtower\n\n end",
"def run; end",
"def run; end",
"def run; end"
] |
[
"0.6257542",
"0.6135828",
"0.613582",
"0.6103471",
"0.6103471",
"0.5938668",
"0.5938668",
"0.5913406",
"0.58448386",
"0.5795129",
"0.5759166",
"0.5713208",
"0.55861413",
"0.55729556",
"0.55729556",
"0.5542786",
"0.5537785",
"0.55359435",
"0.55229557",
"0.55112934",
"0.550786",
"0.5495798",
"0.5480397",
"0.54770356",
"0.5469639",
"0.5468776",
"0.54665023",
"0.5458686",
"0.54555404",
"0.544962",
"0.5433951",
"0.54162586",
"0.5412216",
"0.5412216",
"0.5412216",
"0.53781116",
"0.5376042",
"0.537325",
"0.5363117",
"0.53480107",
"0.53480107",
"0.53480107",
"0.53414345",
"0.53414345",
"0.5331859",
"0.5308201",
"0.5305601",
"0.5283932",
"0.5283932",
"0.5274803",
"0.5274803",
"0.5274803",
"0.5272967",
"0.52540535",
"0.52515745",
"0.52515745",
"0.5246476",
"0.52412564",
"0.5205454",
"0.51912814",
"0.51809937",
"0.51809937",
"0.51735",
"0.5155821",
"0.5155821",
"0.515503",
"0.514486",
"0.514388",
"0.5128316",
"0.5113855",
"0.51116484",
"0.5110596",
"0.5104618",
"0.5098682",
"0.5092446",
"0.5086239",
"0.50766283",
"0.5073341",
"0.5071643",
"0.50500095",
"0.5042732",
"0.5027137",
"0.50254023",
"0.50245655",
"0.50206625",
"0.50106895",
"0.50101423",
"0.49987733",
"0.49981302",
"0.49981302",
"0.49927145",
"0.49920484",
"0.4991305",
"0.49912122",
"0.4983491",
"0.49724963",
"0.49698967",
"0.49549448",
"0.49529105",
"0.49529105",
"0.49529105"
] |
0.0
|
-1
|
======================= SUBSCRIPTION STUFF ===============================
|
def active_subscriptions
subscriptions.select { |s| s.active? }.sort{|x,y| y.created_at <=> x.created_at} || []
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def subscriptions; end",
"def subscriptions; end",
"def subscriptions; end",
"def subscribed; end",
"def subscribe\n \nend",
"def subscribe!\n # TODO: Implement\n end",
"def on_subscription_success\n end",
"def pubsub_adapter; end",
"def service_subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscriptions')\n )\n )\n send_iq_stanza_fibered iq\n end",
"def prepare_subscription\n @subscriptions = Subscription.all\n @my_subscription = current_user.user_subscriptions.includes(:subscription).where(\"user_subscriptions.id = ? and user_subscriptions.status = ?\", params[:id], \"active\").first\n\n if @my_subscription.blank?\n flash[:error] = \"Sorry, You are not authorized for this subscription.\"\n redirect_to main_app.profile_users_path and return\n else\n #@order = @my_subscription.orders.where(state: :confirm).first\n @order= @my_subscription.orders.where('state = ? and delivery_date > ?',\n 'confirm', (ORDER_UPDATE_LIMIT+1).days.from_now.to_date).first\n\n @cart = Cart.get_cart(current_user.id)\n @cart.prepare_cart(current_user.id, @order.subscription_id)\n order_subscription_token = @cart.copy_order_to_cart(@order.id)\n\n @current_cart_items = @cart.get_cart_items\n @subscription_offers = Subscription.get_subscription_list\n @total_space = @cart.max_cart_items\n @snacks = Spree::Product.select('id, name')\n @my_subscription_id = @my_subscription.subscription.id\n @my_subscription_type = @my_subscription.subscription.subscription_type\n end\n end",
"def create / update_subscriptions\n end",
"def pubsub; end",
"def subscribe\n self.subscribed = true\n end",
"def subscriptions\n @subscriptions ||= {}\n end",
"def build_user_subscriptions\n Subject.all.each do |s| \n s.id\n s.name \n s.subsection \n s.language \n Subscription.create(user_id: User.last.id, subject_id: s.id, active: false)\n end\n end",
"def subscription\n @result = ChargeBee::Subscription.retrieve(@subscription_id)\n @billing_address = @result.customer.billing_address\n @country_codes = get_country_codes\n \n @shipping_address = retrieve_shipping_address(@subscription_id)\n @invoice_estimate = nil\n if @result.subscription.status != \"cancelled\" && @result.subscription.status != \"non_renewing\"\n @invoice_estimate = ChargeBee::Estimate.renewal_estimate(@subscription_id, {\"use_existing_balances\" => \"true\"}).estimate.invoice_estimate\n end\n \n @subscription_status = subscription_status()[@result.subscription.status]\n end",
"def fetch_subscription(_params) \n subscription_id = _params['subscription_id']\n if subscription_id.blank? == true \n return false\n end \n begin\n result = ChargeBee::Subscription.retrieve(subscription_id)\n session[:subscription_id] = result.subscription.id\n session[:customer_id] = result.customer.id\n return true\n rescue ChargeBee::APIError => e\n if e.api_error_code == \"resource_not_found\"\n return false\n end\n throw e\n end\n end",
"def create_new_subscription\n @subscription_offers = Subscription.get_subscription_list\n end",
"def subscription_term; end",
"def create_account_and_subscribe_single_call account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n #get the rate plans for the product\n product_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan'\n myDate = DateTime.now + 10.days;\n #create an account and subscribe to a rate plan at the same time\n subscribe(\n account_name,\n contact,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n myDate.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\nend",
"def current_subscription\n self.subscriptions.current.first\n end",
"def subid\n subscription_node[:subid]\n end",
"def subscribe( publication )\n subscriptions.create(publication: publication) unless has_subscribed?(publication)\n rescue ActiveRecord::RecordNotUnique\n end",
"def subscription\n Zapi::Models::Subscription.new\n end",
"def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end",
"def list_subs\n \t@subs = instagram_client.subscriptions\n end",
"def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end",
"def subscribe_to_channel; end",
"def create_subscription\n session[:merchant_subscription_id] = 'User' + sprintf('%03d', rand(1000)) + 'Subscription' + sprintf('%04d', rand(10000))\n\n # prepare payload\n data = {\n :Amount => params[:product] == '1' ? 1.99 : 3.99,\n :Category => 1,\n :Channel => 'MOBILE_WEB',\n :Description => 'Word game 1',\n :MerchantTransactionId => session[:merchant_subscription_id],\n :MerchantProductId => 'wordGame1',\n :MerchantPaymentRedirectUrl => settings.subscription_redirect_url,\n :MerchantSubscriptionIdList => 'sampleSubscription1',\n :IsPurchaseOnNoActiveSubscription => 'false',\n :SubscriptionRecurringNumber => '99999',\n :SubscriptionRecurringPeriod => 'MONTHLY',\n :SubscriptionRecurringPeriodAmount => 1\n }\n\n response = RestClient.post settings.notary_app_sign_url, :payload => data.to_json\n from_json = JSON.parse response\n\n redirect settings.FQDN + \"/Commerce/Payment/Rest/2/Subscriptions?clientid=#{settings.api_key}&SignedPaymentDetail=#{from_json['signed_payload']}&Signature=#{from_json['signature']}\"\nend",
"def subscription\n subscriptions.last\n end",
"def subscribes\n @subscribes ||= user_data_as_array('subscribe')\n @subscribes\n end",
"def subscribe_author\n self.subscriptions.create user_id: self.user.id\n end",
"def subscribe\n CampaignMonitorWrapper.subscribe(id: user.id, email: user.email, name: user.name, beta: user.beta?.to_s, billable: user.billable?.to_s)\n end",
"def subid\n unsubscribe[:subid]\n end",
"def subscribed\n @course_queue = CourseQueue.find(params[:id])\n stream_for @course_queue\n end",
"def subscribed # :doc:\n # Override in subclasses\n end",
"def use_subscribed(survey)\r\n # find subscription to increment, must be same as is journal_entry\r\n subscription = self.subscriptions.by_survey(survey) \r\n return false unless Subscription\r\n subscription.copy_used! # if sub.nil? => no abbo\r\n end",
"def use_subscribed(survey)\r\n # find subscription to increment, must be same as is journal_entry\r\n subscription = self.subscriptions.by_survey(survey) \r\n return false unless Subscription\r\n subscription.copy_used! # if sub.nil? => no abbo\r\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\nend",
"def set_subscription\n @subscription = Subscription.find(params[:id])\nend",
"def subscription\n ret = nil\n if type == 'S'\n ret = @mc2p.subscription('id' => @json_body['id'])\n ret.retrieve\n end\n ret\n end",
"def create\n @subscription = Subscription.create(params[:subscription])\n gb = Gibbon::API.new(\"6f8672a5c2393d1441c54d3be3fb79a1-us1\")\n gb.lists.subscribe({:id => \"c0ca5b3d41\", :email => {:email => params[:subscription][:email]}, :merge_vars => {:FNAME => '', :LNAME => ''}, :double_optin => false})\n end",
"def subscription\n s = subscription_node[:subscription]\n s.to_sym if s\n end",
"def subscriptions\n iq = connection.iq_stanza({'to'=>jid.bare},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSubOwner},\n x('subscriptions',:node => node_id)\n )\n )\n send_iq_stanza_fibered iq\n end",
"def subscribe(connection)\n channel = connection.create_channel\n q = channel.queue DESTINATION_QUEUE, durable: true\n q.subscribe do |delivery, headers, body|\n puts \"#{Time.now}: Got the message\"\n end\nend",
"def subscription\n @current\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def step3\n user = session[:user]\n #for v1, always this will be the subscription basic 18$, for v2 this will change\n user.subscription_id = 1\n end",
"def subscription_id\n customer.subscriptions.first.id\n end",
"def do_subscribe\n subscribe_to(@nodename)\n get_subscriptions\n end",
"def create_subscriptions\n Subscription.create_subscriptions(self.id, self.hashtag)\n end",
"def stripe_subscription\n if stripe_subscription_id\n Stripe::Subscription.retrieve(stripe_subscription_id)\n end\n end",
"def subscription\n case attributes['subscription']\n when 'both' then :both\n when 'from' then :from\n when 'none' then :none\n when 'remove' then :remove\n when 'to' then :to\n else nil\n end\n end",
"def subscription_for(topic)\n subscriptions.where(:topic_id => topic.id).first\n end",
"def subscriber_details(customer, subscription_id=nil)\n last_sub_order = last_shopify_subscription(customer)\n return { inactive_subscription: true } if last_sub_order.nil?\n\n is_first_sub = last_sub_order['tags'].include?('Subscription First Order')\n\n order_titles = last_sub_order['line_items'].map{ |li| li['title']}\n is_8pack = order_titles.any? { |ot| ot.include?('8 Pack')}\n\n # query recharge api for next charge date\n recharge_data = get_recharge_data(customer['id'])\n\n if subscription_id == nil\n desired_subscription = recharge_data[0]\n else\n desired_subscription = recharge_data.select{ |sub| sub['id'] == subscription_id }[0]\n end\n\n frequency = \"#{desired_subscription['order_interval_frequency']} #{desired_subscription['order_interval_unit']}s\"\n subscription_id = desired_subscription['id']\n active_subscriptions = recharge_data.map { |rd| rd['id'] }\n\n if desired_subscription['status'] == 'ACTIVE'\n next_scheduled_date = Date.strptime(desired_subscription['next_charge_scheduled_at'])\n skipped_interval_dates = potential_skip_intervals(desired_subscription)\n calendar_date = 5.business_days.after(next_scheduled_date).to_time.to_i * 1000\n else\n calendar_date = nil\n skipped_interval_dates = nil\n end\n\n return { subscription_id: subscription_id, address_id: desired_subscription['address_id'], frequency: frequency, skipped_interval_dates: skipped_interval_dates, calendar_date: calendar_date, subscription_type: desired_subscription['product_title'], inactive_subscription: false, active_subscriptions: active_subscriptions }\nend",
"def resume_subscription(card_id)\n delivery_date = FIRST_DELIVERY_DAYS.days.from_now\n subscription_id = self.subscription_id\n token = Spree::Order.get_unique_subscription_token\n coupon_code = self.check_for_coupon\n\n if coupon_code.blank?\n result = Subscription.place_subscription_without_coupon(delivery_date, subscription_id, card_id, token)\n else\n plan_price = self.subscription.plan_price.to_f\n coupon = Coupon.get_briantree_discount_id_and_calculate_final_amount(plan_price, coupon_code)\n result = Subscription.place_subscription_with_coupon(delivery_date, subscription_id, card_id, token, coupon)\n end\n\n if result.success?\n token = result.subscription.id\n activate_subscription(token, coupon)\n activate_orders(token, coupon, card_id)\n end #end of the result.success?\n\n type = self.subscription.subscription_type.to_s\n date = self.orders.where(state: 'confirm').first.delivery_date.strftime(\"%B %d, %Y\").to_s\n type + \" \" + date #\"BasicPack 20thjuly\"\n\n end",
"def add_subscription(entity)\r\n subscriptions << entity\r\n end",
"def subscribe(magazine, price)\n Subscription.create(price: price, magazine_id: magazine.id, reader_id: self.id)\n end",
"def subscribe\n subscribee = connection.jid.bare\n\n iq = connection.iq_stanza({'to'=>jid.bare,'type'=>'set'},\n x('pubsub',{:xmlns => EM::Xmpp::Namespaces::PubSub},\n x('subscribe','node' => node_id, 'jid'=>subscribee)\n )\n )\n\n send_iq_stanza_fibered iq\n end",
"def subscriptions\n @page_title = _('Subscriptions')\n @page_icon = 'layers.png'\n\n change_date\n\n @search_device = -1\n @search_user = ''\n @search_user_id = params[:s_user_id] if params[:s_user_id]\n @search_service = -1\n @search_date_from = -1\n @search_date_till = -1\n @search_memo = params[:s_memo] || ''\n @search_user = params[:s_user] if params[:s_user]\n @search_service = params[:s_service] if params[:s_service]\n @search_device = params[:device_id] if params[:device_id]\n @until_canceled = params['until_canceled'].to_i\n if params[:clear].to_s == 'true'\n session[:year_from] = Date.today.year\n session[:month_from] = Date.today.month\n session[:day_from] = Date.today.day\n session[:year_till] = Date.today.year\n session[:month_till] = Date.today.month\n session[:day_till] = Date.today.day\n end\n\n session[:hour_from] = '00'\n session[:minute_from] = '00'\n session[:hour_till] = '23'\n session[:minute_till] = '59'\n\n cond = ''\n\n if (@search_user_id.to_i != -2 && @search_user_id.present?) || (@search_user_id.to_i == -2 && @search_user.present?)\n cond = \" AND subscriptions.user_id = '#{@search_user_id}' \"\n if @search_device.to_i != -1\n cond += \" AND subscriptions.device_id = '#{@search_device}' \"\n end\n end\n\n if @search_service.to_i != -1\n cond += \" AND subscriptions.service_id = '#{@search_service}' \"\n end\n period_start = \"'#{session_from_datetime}'\"\n period_end = \"'#{session_till_datetime}'\"\n until_canceled = 'subscriptions.activation_end IS NULL OR ' if @until_canceled == 1\n cond << \" AND (subscriptions.activation_start >= #{period_start} AND (#{until_canceled}subscriptions.activation_end <= #{period_end})) \"\n\n cond += \" AND subscriptions.memo = '#{@search_memo}' \" if @search_memo.length > 0\n\n sql = \"SELECT services.name as serv_name , users.first_name, users.last_name, users.username, subscriptions.*, devices.device_type, devices.name, devices.extension, devices.istrunk, devices.ani, providers.device_id AS provider\n FROM subscriptions\n LEFT JOIN users ON(users.id = subscriptions.user_id)\n LEFT JOIN devices ON(devices.id = subscriptions.device_id)\n LEFT JOIN providers ON(providers.device_id = devices.id)\n LEFT JOIN services ON(services.id = subscriptions.service_id)\n WHERE subscriptions.id > '0' AND users.owner_id = #{correct_owner_id} #{cond}\"\n # MorLog.my_debug sql\n @search = 0\n @search = 1 if cond.length > 93\n @subs = Subscription.find_by_sql(sql)\n\n @page = 1\n @page = params[:page].to_i if params[:page]\n items_per_page = session[:items_per_page]\n @total_pages = (@subs.size.to_d / items_per_page.to_d).ceil\n @all_subs = @subs\n @subs = []\n items_per_page = session[:items_per_page]\n iend = ((items_per_page * @page) - 1)\n iend = @all_subs.size - 1 if iend > (@all_subs.size - 1)\n for index in ((@page - 1) * items_per_page)..iend\n @subs << @all_subs[index]\n end\n\n @min_end, @min_start, @max_end, @max_start = Subscription.get_activation_year\n end",
"def list_my_subscriptions() path = \"/api/v2/utilities/subscriptions\"\n get(path, {}, AvaTax::VERSION) end",
"def IsSubscribed=(arg0)",
"def IsSubscribed=(arg0)",
"def snack_queue\n #This will fetch the undelivered orders by filtering them through state: :confirm ONLY.\n @sub_items = Spree::Order.get_line_items(current_user.id)\n params_subscription_id = params[:subscription_id]\n user_id = current_user.id\n\n\n @my_subscriptions =current_user.all_subscriptions\n\n #@my_subscriptions.all\n\n if @my_subscriptions.present?\n all_subscriptions = Subscription.all\n\n if params_subscription_id.present?\n @first_subscription = UserSubscription.where(id: params_subscription_id, user_id: user_id).first\n redirect_to spree.snack_queue_orders_path and return if @first_subscription.blank?\n else\n @first_subscription = @my_subscriptions.first\n end\n\n @subscription_list = {}\n\n all_subscriptions.each do |a|\n i = 0\n @my_subscriptions.each do |s|\n if a.id == s.subscription_id\n i = i + 1\n @current_counter = i if @first_subscription.id == s.id\n sub_row = s.subscription.try(:subscription_type)+ ' ' + i.to_s\n @subscription_list.merge!(sub_row => s.id)\n end\n end\n end\n\n @first_sub_carts = Cart.create_carts_for_orders(@first_subscription)\n @first_sub_cart_ids = Cart.collect_cart_ids(@first_sub_carts)\n @undelivered_order_ids = @first_subscription.get_undelivered_order_ids\n @snacks = Spree::Product.select('id, name')\n @subscription_name = Subscription.where(id: @first_subscription.subscription_id).first.subscription_type\n else\n\n end\n end",
"def show_subscriptions\n puts \"\\nYour current subscriptions are:\"\n @user.subscriptions.reload.each do |sub|\n puts sub.name\n end\n end",
"def subscribed\n super\n increase_current_users\n stream_from channel\n end",
"def subscribe\n # PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", \"http://li182-172.members.linode.com/feeds/#{self.id}\", \"async\")\n PSHB.subscribe(\"/api/superfeedr/receive_feeds/\", self.url, \"async\")\n end",
"def subscribe(user, device_id, subscription)\n if @subscriptionLists.hasKey device_id\n device = @subscriptionLists.getRepositoryObject(device_id).getObject\n subscriptions = Hash.new\n subscriptions = @subscriptionLists.getRepositoryObject(\"subscriptions\").getObject if @subscriptionLists.hasKey(\"subscriptions\")\n\n #puts \"\\n\\n_____________________Sub Queues_______________________\\n#{subscriptions}\\n\\nLooking for #{subscription}\\n__________________________________\"\n\n if subscriptions.key? subscription\n sub = subscriptions[subscription]\n #sub.addDevice(device_id)\n if(sub != nil && sub.hasDevice?(device_id)) # Device Already subscribed so let the user know\n return \"{\\\"subscribe\\\": \\\"Device already subscribed to #{subscription}\\\"}\"\n else #Lets subscribe the user(only implemented locally, not on the firebase server)\n device.addSubscription(sub)\n sub.addDevice(device)\n @subscriptionLists.commitObject(\"subscriptions\", subscriptions, false) #List of all subscription lists with device ids\n @subscriptionLists.commitObject(device_id, device, false) #We also keep a list of subscriptions with the particular device id... do we need this??\n\n return \"{\\\"subscribe\\\": \\\"Device subscribed to #{subscription}\\\"}\"\n end\n else\n return '{\"subscribe\": \"Subscription queue('+subscription+') does not exist.\"}'\n end\n else\n return '{\"subscribe\": \"Device not registered\"}'\n end\n end",
"def create_subscription(sender)\n PsegRecurring::Subscription.new(@credentials).send_subscription(sender)\n end",
"def create\n @subscription = Subscription.create(params[:subscription])\n groups = params[:subscription][:group_name].split(\",\").collect(&:strip)\n email = params[:subscription][:email]\n begin\n gb = Gibbon::API.new(\"f24fdd53217fab0b0698fdaba15c0c6f-us7\")\n subscribe = gb.lists.subscribe({\n :id => \"caa152eac4\",\n :email => {:email => email},\n :merge_vars => {\n :FNAME => \"\",\n :LNAME => \"\",\n :groupings => {\n 0 => {\n :id => 4457,\n :groups => groups\n }\n }\n },\n :update_existing => true,\n :double_optin => false\n })\n #logger.debug subscribe\n rescue Gibbon::MailChimpError\n \n end\n redirect_to \"/contact\"\n end",
"def push_subscription\n\t\trender :nothing => true\n\tend",
"def subscribeCollection\n if !session[:user_id]\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n end\n\n roomname = params[:subscribecollection][\"roomname\"]\n collectionnodename = params[:subscribecollection][\"collectionnodename\"]\n\n begin\n am = session[:am]\n acc = Account.find_by_username(session[:user_id])\n if(acc.nil?)\n flash[:notice] = \"Need to login first\"\n redirect_to :action=> 'login'\n return\n end\n am.keepalive(acc.username, acc.password)\n\n result = am.subscribeCollection(roomname, collectionnodename)\n flash[:result] = \"subscribeCollection result success: \" + result\n redirect_to :action => 'accountManager'\n rescue Exception => msg\n flash[:notice] = msg\n end\n\n end",
"def create_initial_subscription\n return unless self.subscription_plan_id.to_i > 0\n\n @subscription_plan = SubscriptionPlan.find(self.subscription_plan_id)\n if @subscription_plan.user?\n self.subscribe_to_plan(@subscription_plan)\n else\n create_organization_and_subscription_plan\n end\n end",
"def testSubscribe2()\n topic = \"_Subscribe2\"\n conn = Scalaris::PubSub.new()\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n conn.subscribe(@testTime.to_s + topic, $_TEST_DATA[i])\n end\n \n # check if the subscribers were successfully saved:\n subscribers = conn.get_subscribers(@testTime.to_s + topic)\n (0..($_TEST_DATA.length - 1)).each do |i|\n assert(subscribers.include?($_TEST_DATA[i]),\n \"Subscriber \\\"\" + $_TEST_DATA[i] + \"\\\" does not exist for topic \\\"\" + topic + \"\\\"\")\n end\n assert_equal(nil, self.class._getDiffElement(subscribers, $_TEST_DATA),\n \"unexpected subscriber of topic \\\"\" + topic + \"\\\"\")\n \n conn.close_connection()\n end",
"def subscribe_plan\n call(:subscribe_plan, connection_space.plan.remote_id)\n synchro_point\n end",
"def push_subscription(object)\n local_server.subscribe(object)\n synchro_point\n end",
"def subscribe_frame d, h\n h[:ack] = 'auto' unless ['client', 'client-individual'].include?(h[:ack])\n create_frame 'SUBSCRIBE', [{:id => OnStomp.next_serial}, h, {:destination => d}]\n end",
"def set_subscription\n @subscription = ::Pushar::Core::Subscription.unscoped.find(params[:id])\n end",
"def subscriptions\n # subscriber entries are embedded in subscriptions inside of an\n # org. We'll flip this, so that we only return subscriber entries\n # for the account\n orgs = Org.all(:conditions=>{ \"subscriptions.subscribers.account_id\"=> self.id})\n subscribers = []\n orgs.each do |org|\n org.subscriptions.each do |subscription|\n subscribers += subscription.subscribers.select { |subscriber| subscriber.account_id.to_s == self.id.to_s }\n end\n end\n subscribers.flatten!\n subs = []\n subscribers.each do |subscriber|\n subscript = subscriber.subscription\n org = subscript.org\n subs << AccountSubscription.new(org.id.to_s, org.name, subscript.product, subscript.billing_level, subscriber.role)\n end\n subs\n end",
"def subscription_node\n unless subscription = pubsub.find_first('ns:subscription', :ns => self.class.registered_ns)\n self.pubsub << (subscription = XMPPNode.new('subscription', self.document))\n subscription.namespace = self.pubsub.namespace\n end\n subscription\n end",
"def subscriptions\n\t\t@subscriptions = current_user.customer.subjects\n\tend",
"def subscription\n ensure_connection\n @consumers.find(&:subscription)\n end",
"def subscribe(&blk)\n pres = connection.presence_stanza('to'=>jid.bare, 'type' => 'subscribe')\n connection.send_stanza pres, &blk\n end",
"def create\n\t\t@subscription = Subscription.new(params[:subscription])\n\t\trespond_to do |format|\n\t\t\tif fonct_new_dup?\n\t\t\t\tobject_orig=Subscription.find(params[:object_orig_id])\n\t\t\tst = @subscription.create_duplicate(object_orig)\n\t\t\telse\n\t\t\tst = @subscription.save\n\t\t\tend\n\t\t\tif st\n\t\t\t\t#format.html { redirect_to(@subscription, :notice => 'Subscription was successfully created.') }\n\t\t\t\tflash[:notice] = 'Subscription was successfully created.'\n\t\t\t\tparams[:id]= @subscription.id\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { render :xml => @subscription, :status => :created, :location => @subscription }\n\t\t\telse\n\t\t\t\t@ingroups = Group.all\n\t\t\t\t@inprojects = Project.all\n\t\t\t\t@fortypesobjects=Typesobject.get_from_observer\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def set_subscription\n @subscription = Subscription.find(params[:id])\n end",
"def publisher\n end"
] |
[
"0.74308246",
"0.74308246",
"0.74308246",
"0.713746",
"0.71003705",
"0.69718933",
"0.69538194",
"0.693153",
"0.67855155",
"0.6765999",
"0.6667669",
"0.6666002",
"0.6617362",
"0.65890414",
"0.65773284",
"0.655929",
"0.6528993",
"0.6445843",
"0.64414495",
"0.64260167",
"0.63945293",
"0.6387362",
"0.637485",
"0.63709486",
"0.63669145",
"0.635891",
"0.6343076",
"0.6332671",
"0.6319068",
"0.63040495",
"0.63022876",
"0.62976027",
"0.62862223",
"0.6285395",
"0.6280279",
"0.6279714",
"0.6275",
"0.6275",
"0.6267289",
"0.6267289",
"0.6257648",
"0.6250528",
"0.62367994",
"0.6234221",
"0.62263733",
"0.6224507",
"0.622409",
"0.622409",
"0.622409",
"0.6216969",
"0.61988896",
"0.6186869",
"0.6184203",
"0.61754143",
"0.6172585",
"0.61711025",
"0.61579627",
"0.61516225",
"0.6147519",
"0.6142653",
"0.61404186",
"0.61373985",
"0.6134506",
"0.6132134",
"0.6132134",
"0.61266345",
"0.61256015",
"0.6113121",
"0.611187",
"0.61113155",
"0.61081344",
"0.61062694",
"0.60970265",
"0.608112",
"0.6070607",
"0.60682875",
"0.60656995",
"0.606547",
"0.6057147",
"0.60549694",
"0.6052994",
"0.6049731",
"0.6048598",
"0.60440004",
"0.60424995",
"0.6041321",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.60403496",
"0.6034586"
] |
0.0
|
-1
|
======================= CARD LINKS STUFF ===============================
|
def fulfilled_deal?(deal)
if deal.card_linked?
card_link_for(deal.id).try(:fulfilled?)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def card_homelink options={}\n homelink decorator, options\n end",
"def get_cards\n @doc = Nokogiri::HTML(open(@url))\n card_links = @doc.css(\"div.snap-feat\")\n id = 0\n\n card_links.collect do |card|\n id += 1\n c = Cards::CreditCard.new(card.css(\"h3 a.detail-tog\").text)\n c.id = id\n c.offer = card.css(\"div.wrap div.col p\").first.text\n c.fees = card.css(\".hide .col p\").first.text\n c.credit_needed = card.css(\"a.card-snapshot-credit-tip\").text.strip\n c.href = card.css(\".bot-links a.lrn-more\").attr(\"href\").value\n c.apply_link = card.css(\"div.last div.wrap a\").attr(\"href\").value\n c\n end\n end",
"def links; end",
"def links; end",
"def buy_gift_card_link_button\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(a.className(\"ats-buyagiftcardlnk\"), __method__, self)\n end",
"def handle_link(ps, line, types)\n\n content = line.to_s.strip\n connector = nil\n card_from, card_to, label = '', '', ''\n\n # Get cardinality\n # [card]--???--[card]\n if /.*?\\[(.*?)\\][-]{2,}.*?\\[(.*?)\\].*/ =~ content\n card_from = $1.strip\n card_to = $2.strip\n content.gsub!(/\\[.*?\\]/, '')\n\n # --???--[card]\n elsif /.*?[-]{2,}.*?\\[(.*?)\\].*/ =~ content\n card_from = ''\n card_to = $1.strip\n content.gsub!(/\\[.*?\\]/, '')\n\n # [card]--???--\n elsif /.*?\\[(.*?)\\][-]{2,}.*?.*/ =~ content\n card_from = $1.strip\n card_to = ''\n content.gsub!(/\\[.*?\\]/, '')\n end\n\n # Get label\n # ???--<<label>>--???\n if /.*?[-]{2,}<<(.*?)>>[-]{2,}.*?/ =~ content\n label = \"«#{$1.strip}»\"\n content.gsub!(/<<.*?>>/, '')\n\n # ???--<<label>>--???\n elsif /.*?[-]{2,}<(.*?)>[-]{2,}.*?/ =~ content\n label = $1.strip\n content.gsub!(/<.*?>/, '')\n end\n\n ## Get arrow type\n # -!>\n if /(.*?)[-]{2,}!>(.*)/ =~ content\n from = type($1, types, ps)\n to = type($2, types, ps)\n\n if from.instance_of?(Domain::Clazz) && to.instance_of?(Domain::Interface)\n connector = Domain::Implementation.new(from, to)\n else\n connector = Domain::Inheritance.new(from, to)\n end\n\n # -<>\n elsif /(.*?)[-]{2,}<>(.*)/ =~ content\n connector = Domain::Aggregation.new(type($1, types, ps), type($2, types, ps),\n label, card_from, card_to)\n\n # -<#>\n elsif /(.*?)[-]{2,}<#>(.*)/ =~ content\n connector = Domain::Composition.new(type($1, types, ps), type($2, types, ps),\n label, card_from, card_to)\n\n # -.>\n elsif /(.*?)[-]{2,}\\.>(.*)/ =~ content\n connector = Domain::Relation.new(type($1, types, ps), type($2, types, ps),\n label, card_from, card_to)\n\n # ->\n elsif /(.*?)[-]{2,}>(.*)/ =~ content\n connector = Domain::DirectedAssociation.new(type($1, types, ps), type($2, types, ps),\n label, card_from, card_to)\n\n # --\n elsif /(.*?)[-]{2,}(.*)/ =~ content\n connector = Domain::Association.new(type($1, types, ps), type($2, types, ps),\n label, card_from, card_to)\n end\n\n ps.diagram << connector\n end",
"def link_4menu(item) #:nodoc:\n html = ''\n link = item.link\n link = \"/#{@site.route_name}/#{item.page_id}\" #if link.blank?\n# \n html << @parent.link_to(item.picture, link) unless item.picture.blank?\n html << if !item.caption.blank?\n # TODO Translation\n @parent.link_to(item.caption, link)\n end\nend",
"def links_feed\n end",
"def credit_details\n wrap_with :div, class: \"d-flex\" do\n [\n nest(card.value_card, view: :credit),\n link_to_card(card, menu_icon, path: { view: :edit }, class: \"text-dark ml-auto\")\n ]\n end\n end",
"def link() url; end",
"def link() url; end",
"def url(card)\n project = card.class.site.path.split('/').last\n \"#{Mingle.base_url}/projects/#{project}/cards/#{card.number}\"\n end",
"def maybe_item_thumb_links\n maybe_column.links(:class => \"img\", :href => /.*/) # ---------------------------------- EVERYTHING USING THIS NEEDS REPLACING!!!!!!!!\n end",
"def story_card_comments_link(story, story_locale = nil)\n if can? :edit, story\n story_comments_path(story)\n else\n story_path(story, anchor: 'comments-anchor', story_locale: story_locale)\n end\n end",
"def create_card(project, attrs)\n super(project, attrs).url\n end",
"def create_links\n end",
"def create_links\n end",
"def my_links\n end",
"def parse_link; end",
"def get_items_links(uri_arr)\n\t\tlinks = []\n\t\t(1..get_max_page(uri_arr) ).each do |x|\n\t\t links.concat P.get_css_list P.build_uri(uri_arr), '.isolux-thumbnail-name a' \n\t\tend\n\t\t\n\t\tlinks\n\tend",
"def add_link\n @bib.link.each do |l|\n case l.type&.downcase\n when \"doi\" then @item.doi = l.content\n when \"file\" then @item.file2 = l.content\n when \"src\" then @item.url = l.content\n end\n end\n end",
"def license_link(book)\n case book.license\n when nil\n return 'None<a class=\"btn btn-mini\" href=\"/books/' + book.id.to_s + '#license\">Choose a License</a>'\n when \"cc-by\"\n return '<a href=\"' + book.license_url + '\" class=\"linked-icon\" title=\"' + book.license_name + '\"><span class=\"icon-cc\"></span><span class=\"icon-cc-by\"></span><span class=\"cc-title\">' + book.license_name + '</span></a>'\n when \"cc-by-nd\"\n return '<a href=\"' + book.license_url + '\" class=\"linked-icon\" title=\"' + book.license_name + '\"><span class=\"icon-cc\"></span><span class=\"icon-cc-by\"></span><span class=\"icon-cc-nd\"></span><span class=\"cc-title\">' + book.license_name + '</span></a>'\n when \"cc-by-sa\"\n return '<a href=\"' + book.license_url + '\" class=\"linked-icon\" title=\"' + book.license_name + '\"><span class=\"icon-cc\"></span><span class=\"icon-cc-by\"></span><span class=\"icon-cc-sa\"></span><span class=\"cc-title\">' + book.license_name + '</span></a>'\n when \"cc-by-nc\"\n return '<a href=\"' + book.license_url + '\" class=\"linked-icon\" title=\"' + book.license_name + '\"><span class=\"icon-cc\"></span><span class=\"icon-cc-by\"></span><span class=\"icon-cc-nc\"></span><span class=\"cc-title\">' + book.license_name + '</span></a>'\n when \"cc-by-nc-sa\"\n return '<a href=\"' + book.license_url + '\" class=\"linked-icon\" title=\"' + book.license_name + '\"><span class=\"icon-cc\"></span><span class=\"icon-cc-by\"></span><span class=\"icon-cc-nc\"></span><span class=\"icon-cc-sa\"></span><span class=\"cc-title\">' + book.license_name + '</span></a>'\n when \"cc-by-nc-nd\"\n return '<a href=\"' + book.license_url + '\" class=\"linked-icon\" title=\"' + book.license_name + '\"><span class=\"icon-cc\"></span><span class=\"icon-cc-by\"></span><span class=\"icon-cc-nc\"></span><span class=\"icon-cc-nd\"></span><span class=\"cc-title\">' + book.license_name + '</span></a>'\n else\n # This is an \"Other\" license.\n # @todo, I could simplify the schema a bit by getting rid of the \"Other license\" field and just\n # allowing their custom license to be placed in the \"license\" field.\n return '<a href=\"' + Rack::Utils.escape_html(book.license_url) + '\" title=\"' + book.license_name + '\">' + Rack::Utils.escape_html(book.license_name) + '</a>'\n end\n end",
"def link\n h.content_tag :li do\n h.link_to h.content_tag(:i, '' , class: object.icon ) , object.url , target: \"_blank\" , title: object.name\n end\n end",
"def uri\n 'cards'\n end",
"def link\n if @link.nil?\n max_score = 0\n for link_object in self.links.reverse\n score = 0\n next if link_object.href.nil?\n if @href != nil && link_object.href == @href\n score = score - 2\n end\n if link_object.type != nil\n if (link_object.type =~ /image/ || link_object.type =~ /video/)\n score = score - 2\n end\n if FeedTools::HtmlHelper.xml_type?(link_object.type)\n score = score + 1\n end\n if FeedTools::HtmlHelper.html_type?(link_object.type)\n score = score + 2\n elsif link_object.type != nil\n score = score - 1\n end\n end\n if link_object.rel == \"enclosure\"\n score = score - 2\n end\n if link_object.rel == \"alternate\"\n score = score + 1\n end\n if link_object.rel == \"self\"\n score = score - 1\n if (link_object.href =~ /xml/ ||\n link_object.href =~ /atom/ ||\n link_object.href =~ /feed/)\n score = score - 1\n end\n end\n if score >= max_score\n max_score = score\n @link = link_object.href\n end\n end\n if @link.blank?\n @link = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"@href\",\n \"@rdf:about\",\n \"@about\"\n ], :select_result_value => true)\n end\n if @link.blank?\n if FeedTools::UriHelper.is_uri?(self.id) &&\n (self.id =~ /^http/)\n @link = self.id\n end\n end\n if !@link.blank?\n @link = FeedTools::HtmlHelper.unescape_entities(@link)\n end\n @link = nil if @link.blank?\n begin\n if !(@link =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(@link)\n channel_base_uri = nil\n unless self.channel_node.nil?\n channel_base_uri = self.channel_node.base_uri\n end\n @link = FeedTools::UriHelper.resolve_relative_uri(\n @link, [channel_base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n @link = FeedTools::UriHelper.normalize_url(@link)\n end\n unless self.cache_object.nil?\n self.cache_object.link = @link\n end\n end\n return @link\n end",
"def link\n '-'\n end",
"def update_card(project, card_num, attrs)\n super(project, card_num, attrs).url\n end",
"def card_activity_link\n\t\t# unit_test_no_generate: card_activity_link, a.className(create_ats_regex_string(\"ats-cardactivitylnk\"))\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(a.className(create_ats_regex_string(\"ats-cardactivitylnk\")), __method__)\n\tend",
"def click(link); end",
"def clothing_item_result_links\n if @country != DE\n @browser.div(:id => \"ctl00_contentBody_productListingSection\").links(:class => \"img\")\n else\n @browser.div(:id => \"ctl00_contentBody_productListingSection\").links(:class => \"img\")\n end\n end",
"def card(address_book_id, card_uri)\n end",
"def link(link, title, content)\n if no_links\n content\n else\n # \"<a href=\\\"#{DashboardRouter.normalize(link)}\\\" target=\\\"_top\\\">#{content}</a>\"\n \"<a href=\\\"#{link}\\\">#{content}</a>\"\n end\n end",
"def linked_cards\n Cache.hash_get_all(\"#{@batch_id}_linked_cards\").presence || {}\n end",
"def prepare_links!\n links_def = find_links_definition or return\n \n links_def.rel2block.each do |link|\n links.update_link(Feature::Hypermedia::Hyperlink.new.tap do |hyperlink| # create Hyperlink representer.\n hyperlink.rel = link[:rel]\n hyperlink.href = run_link_block(link[:block])\n end)\n end\n end",
"def no_item_thumb_links\n no_column.links(:class => \"img\", :href => /.*/) # ---------------------------------- EVERYTHING USING THIS NEEDS REPLACING!!!!!!!!\n end",
"def url_for_mnhn(barcode)\r\n #\"https://science.mnhn.fr/institution/mnhn/collection/p/item/\" + barcode #herbarium sheets\r\n \"https://science.mnhn.fr/institution/mnhn/collection/f/item/\" + barcode #fossil slides\r\nend",
"def click_through_link\n\t\treturn '/items/' + self.items.first.slug if !self.items.first.blank?\n\t\treturn '/blog/' + self.blogs.first.slug if !self.blogs.first.blank?\n\t\treturn \"#\"\n\tend",
"def href; end",
"def link\n @link\n end",
"def image_links(chapter_url)\n\n {}\n end",
"def gift_card_for_business_button\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(a.id(\"/blueLinkUnderline/\"), __method__, self)\n end",
"def social_media_links(*networks)\n options = networks.last.is_a?(Hash) ? networks.pop : { size: \"21x20\"}\n html = ''\n networks.to_a.each do |n|\n if n == 'rss'\n if options[:style] && File.exist?(Rails.root.join(\"app/assets/images/icons/#{options[:style]}/#{options[:size]}\", \"#{n}.png\"))\n q = []\n q << \"[#{image_path(\"icons/#{options[:style]}/#{options[:size]}/#{n}.png\")}, (default)]\"\n q << \"[#{image_path(\"icons/#{options[:style]}/#{options[:size]}/#{n}.png\")}, (only screen and (min-width: 1350px))]\"\n q << \"[#{image_path(\"icons/#{options[:style]}/64x64/#{n}.png\")}, (only screen and (min-width: 1024px) and (max-width: 1349px))]\"\n q << \"[#{image_path(\"icons/#{options[:style]}/48x48/#{n}.png\")}, (only screen and (max-width: 768px))]\"\n\n image_tag(\"#{website.folder}/logo.png\",\n class: \"no-resize no-resize-for-small\",\n alt: Setting.site_name(website),\n data: { interchange: q.join(\", \") })\n html += link_to(image_tag(\"icons/#{options[:style]}/#{options[:size]}/#{n}.png\",\n style: \"vertical-align: middle;\",\n size: options[:size],\n data: { interchange: q.join(\", \") }),\n rss_url(format: \"xml\"), target: \"_blank\")\n else\n html += link_to(image_tag(\"icons/#{n}.png\", style: \"vertical-align: middle;\", size: options[:size]), rss_url(format: \"xml\"), target: \"_blank\")\n end\n\n elsif v = website.value_for(n)\n unless v.blank?\n v = (v =~ /^https/i) ? v : \"https://www.#{n}.com/#{v}\"\n presentation = n\n if options[:style] == \"font-awesome\"\n presentation = fa_icon(\"#{n} 2x\", :\"aria-label\" => n)\n elsif options[:style] && File.exist?(Rails.root.join(\"app/assets/images/icons/#{options[:style]}/#{options[:size]}\", \"#{n}.png\"))\n presentation = image_tag(\"icons/#{options[:style]}/#{options[:size]}/#{n}.png\",\n style: \"vertical-align: middle\",\n size: options[:size],\n alt: n,\n :\"aria-label\" => n)\n elsif options[:gray]\n presentation = image_tag(\"social/social-gray-#{n.downcase}.png\",\n class: \"no-resize\",\n alt: n,\n :\"aria-label\" => n)\n elsif File.exist?(Rails.root.join(\"app/assets/images/icons\", \"#{n}.png\"))\n presentation = image_tag(\"icons/#{n}.png\",\n style: \"vertical-align: middle\",\n size: options[:size],\n alt: n,\n :\"aria-label\" => n)\n end\n html += link_to(presentation, v, target: \"_blank\", :\"aria-label\" => n)\n end\n end\n end\n raw(html)\n end",
"def linkReturn(url)\n data = Nokogiri::HTML(open(url))\n links = data.css('.zone_B_with_ads')\n allUrl = links.css('div.tile__content a.tile__read_more').map { |var| var['href'] }\n allUrl.each do |i|\n puts scraper(i)\n puts ''\n #puts i\n end\nend",
"def get_card\n end",
"def additional_links\n @additional_links ||= begin\n links = {}\n\n main_link_label = ScihistDigicoll::Util.humanized_content_type(main_file.content_type)\n main_link_label << \" - \" + ScihistDigicoll::Util.simple_bytes_to_human_string(main_file.size)\n\n links[main_link_label] =\n shrine_file_url(shrine_file: main_file, disposition: \"attachment\", filename: item_filename)\n\n if flac_with_m4a?\n # add the original flac link too\n links[\"FLAC - #{ScihistDigicoll::Util.simple_bytes_to_human_string(asset.size)}\"] =\n shrine_file_url(shrine_file: asset.file,\n disposition: \"attachment\",\n filename: DownloadFilenameHelper.filename_for_asset(asset))\n end\n\n links\n end\n end",
"def link\n @link ||= \"#{IMAGE_URL}#{id}.#{IMAGE_EXTENSION}\"\n end",
"def caption_image_links(image_id)\n links = []\n links << original_image_link(image_id, \"lightbox_link\")\n links << \" | \"\n links << image_exif_link(image_id, \"lightbox_link\")\n content_tag(:div, class: \"caption-image-links my-3\") do\n safe_join(links)\n end\n end",
"def asset_links(lab)\n \"#{github_css_link(lab)} · #{github_html_link(lab)}\"\nend",
"def link(_content, _url)\n raise NotImplementedError\n end",
"def multiple_cards(address_book_id, uris)\n end",
"def party_link\n tds[1].css('a').first\n end",
"def create_link(item_nr)\n \"<a href=\\'/item/#{item_nr}\\'>#{self}</a>\"\n end",
"def external_link(link_label, url, options={})\n attributes = options[:attributes] || {}\n children = options[:children] || {}\n image = options[:image] || {}\n\n img =\"\"\n unless image.empty?\n img = self.external_image(image[:url], image, true) \n end\n\n child_elements = self.children_list(children) << img\n link_label = self.tag('label', link_label)\n url = self.tag('url', url)\n link = self.tag('externalLink', url << link_label << child_elements, attributes)\n\n cell = options[:cell] || {}\n row = options[:row] || {}\n self.row_cell(link, cell, row)\n end",
"def link_to(links)\n links.map { |link| \"<a href='#{link[:uri]}'>#{link[:name]}</a>\" }.join(\"<br>\")\nend",
"def card_label\n end",
"def link(link, title, content)\n link = OodAppkit.files.api(path: @app_path.to_s + '/' + link).to_s if @app_path && relative?(link)\n return \"<a href=\\\"#{link}\\\" rel=\\\"noopener\\\" target=\\\"_blank\\\">#{content}</a>\" unless id_link?(link)\n return \"<a href=\\\"#{link}\\\">#{content}</a>\"\n end",
"def news_links\n visit \"http://hk.apple.nextmedia.com/\"\n\n links = doc.css(\"#article_ddl option\").collect do |option|\n link = Link.new\n link.title = option.text\n link.url = option[\"value\"]\n link\n end.reject { |l| l.url.nil? }\n links\n end",
"def display (card)\n image_name = \"/images/cards/\" + card[0] + \"_\" + card[1] + \".jpg\"\n image_name\n end",
"def link_related_cases\n [original_case, original_ico_appeal].each { |source_case| link_cases_related_to(source_case) }\n end",
"def link_stories! \n story_ids = find_all_story_ids\n return if story_ids.empty?\n\n message = \"### Clubhouse Stories\\n\\n\"\n story_ids.each do |id|\n message << \"* [#{story_link(id)}](#{story_link(id)}) \\n\"\n end \n markdown message\n end",
"def get_info(card_id)\n credit_card = \"\"\n Cards::CreditCard.all.find {|card| credit_card = card if card.id == card_id}\n\n card_page = Nokogiri::HTML(open(credit_card.href))\n puts \"\\n#{card_page.css(\".head-contain h1\").text.strip}\".bold # Card Title\n puts \"\\nOffer: #{credit_card.offer}\"\n puts \"Fees: #{credit_card.fees}\"\n puts \"#{card_page.css(\"ul li.overall\").text.strip}\".white.bold # Rating\n\n puts \"\\n#{card_page.css(\".sec .title\")[1].text}\".blue.bold # Title \"The Good\"\n puts \"#{card_page.css(\".content .review\")[1].text.strip}\" # The Good\n puts \"\\n#{card_page.css(\".sec .title\")[2].text}\".blue.bold # Tilte \"The Not So Good\"\n puts \"#{card_page.css(\".content .review\")[2].text.strip}\" # The Not So Good\n puts \"\\n#{card_page.css(\".sec .title\")[0].text}\".blue.bold # Title \"Bottom Line\"\n puts \"#{card_page.css(\".content .review\")[0].text.strip}\" # Bottom Line\n puts \"\"\n end",
"def maybe_item_thumb_link(shortlist_item_id, item_code)\n maybe_item_id_root_div(shortlist_item_id).link(:class => \"img\", :href => /#{item_code}/)\n end",
"def link\n @link ||= uri.to_s\n end",
"def external_link_inventory # make this an object attribute for every page object, along with base url, and other helpful state info\n []\n end",
"def links\n @creditor_bank_account_links ||= Links.new(@links)\n end",
"def link_elements(identifier)\n platform.links_for(identifier.clone)\n end",
"def imdb_link(lnk)\n if lnk =~ /^https?:/\n lnk\n else\n IMDB_BASE + lnk\n end\nend",
"def display_link\n link.sub(SCHEME_PATTERN, '').truncate(48) if link\n end",
"def get_links(blob)\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] Entering\")\n link = []\n\n if !blob[\"link\"].blank?\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] adding link #{blob[\"link\"]}\")\n\n link = ::Api::Helpers::Parser.get_documents({:text => blob[\"link\"]})\n\n #reset the mime to system type. give higher priority to mime found by our system\n mime = ::Api::Helpers::Parser.map_type_to_mime(blob[\"type\"])\n\n link[0][:mime] = mime if mime != AppConstants.mime_remote_link\n\n link[0][:description] = blob[\"description\"]\n link[0][:title] = blob[\"name\"]\n\n link[0][:provider] =~ /facebook.com/ ? link[0][:ignore] = true : link[0][:ignore] = false\n\n link[0][:source_object_id] = blob[\"object_id\"]\n\n #extract image_url\n if !blob[\"picture\"].blank?\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] CGI EXTRACTION #{cgi}\")\n\n u = URI.unescape(blob[\"picture\"])\n cgi = CGI::parse(u)\n\n #internal images are encoded in src(fbcdn) and external are encoded in\n url = cgi[\"url\"]\n url = cgi[\"src\"] if url.blank?\n\n\n if !cgi.blank? and !url.blank?\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] adding Picture Url #{link[0][:image_url]} \")\n\n link[0][:image_url] = url[0]\n link[0][:image_width] = cgi[\"w\"][0] if !cgi[\"w\"].blank?\n link[0][:image_height] = cgi[\"h\"][0] if !cgi[\"h\"].blank?\n end\n end\n end\n\n #attach embedded links also link array\n #duplicate document is removed in create_activity\n if !blob[\"message\"].blank?\n\n embedded_links = ::Api::Helpers::Parser.get_documents({:text => blob[\"message\"]})\n if link.blank?\n link = embedded_links if !embedded_links.blank?\n else\n embedded_links.each do |elem|\n #remove duplicates ..\n #give priority to attr[links] as they will be mostly resolved\n next if link[0][:url] == elem[:url]\n link << elem\n end\n end\n end\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] Leaving \")\n link\n rescue => e\n Rails.logger.error(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] **** RESCUE **** => #{e.message} for #{blob.inspect}\")\n return []\n end",
"def publication_link\n h.link_to \"Read Now\" , object.publication_url , title: 'Read Now' , class: 'btn waves-effect waves-light btn-primary custom-btn' , target: '_blank'\n end",
"def links\n return unless success? and body\n\n doc = Nokogiri::HTML(@body)\n \n links = []\n\n doc.css('div.list-lbc a').each do |a|\n link = {\n :url => a['href'],\n :title => a.css('div.title').first.content.strip\n }\n\n link[:ad_id] = link[:url][/^http:\\/\\/www.leboncoin.fr\\/locations\\/(\\d+).*/,1]\n links << link\n yield link if block_given?\n end\n\n links\n end",
"def link_to_identifier; end",
"def link_to_identifier; end",
"def get_bardahl_product_data\n agent = Mechanize.new\n page = agent.get('https://allbardahl.ru/catalog/additives/')\n review_links = page.links_with(text: /[a-zA-Z]/, href: %r{/\\w+})[1, 76]\n\n array_links = []\n review_links.map.with_index do |elem, i|\n i % 2 == 0 ? array_links << elem : next\n end\n array_links\nend",
"def create\n url = card_params[:url]\n\n existing_card = Card.where(\"url LIKE ?\", url).first\n\n if (existing_card.nil? || existing_card.blank?)\n og_card = OpenGraph.fetch(url)\n @card = Card.new(card_params)\n @card.title = og_card.title if og_card && og_card.has_key?(:title)\n @card.image_url = \"http://upload.wikimedia.org/wikipedia/commons/e/eb/Blank.jpg\" # Default image\n @card.image_url = og_card.image if og_card && og_card.has_key?(:image)\n @card.description = og_card.description if og_card && og_card.has_key?(:description)\n @card.poster = current_user.name\n @card.poster_uid = current_user.uid\n @card.poster_profile_url = \"http://graph.facebook.com/\" + @card.poster_uid + \"/picture?type=small\"\n @card.count_read = 0\n @card.count_liked = 0\n @card.votes_count = 0\n\n respond_to do |format|\n if @card.save\n format.html { redirect_to @card, notice: 'Card was successfully created.' }\n format.json { render :show, status: :created, location: @card }\n else\n format.html { render :new }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to existing_card, notice: 'Card already exists.' }\n format.json { render :show, status: :created, location: existing_card }\n end\n end\n end",
"def links\n if @links.blank?\n @links = []\n link_nodes =\n FeedTools::XmlHelper.combine_xpaths_all(self.channel_node, [\n \"atom10:link\",\n \"atom03:link\",\n \"atom:link\",\n \"link\",\n \"channelLink\",\n \"a\",\n \"url\",\n \"href\"\n ])\n for link_node in link_nodes\n link_object = FeedTools::Link.new\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:href\",\n \"@atom03:href\",\n \"@atom:href\",\n \"@href\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.href == \"atom10:\" ||\n link_object.href == \"atom03:\" ||\n link_object.href == \"atom:\"\n link_object.href = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@href\"\n ], :select_result_value => true)\n end\n if link_object.href.nil? && link_node.base_uri != nil\n link_object.href = \"\"\n end\n begin\n if !(link_object.href =~ /^file:/) &&\n !FeedTools::UriHelper.is_uri?(link_object.href)\n link_object.href = FeedTools::UriHelper.resolve_relative_uri(\n link_object.href,\n [link_node.base_uri, self.base_uri])\n end\n rescue\n end\n if self.configurations[:url_normalization_enabled]\n link_object.href =\n FeedTools::UriHelper.normalize_url(link_object.href)\n end\n link_object.href.strip! unless link_object.href.nil?\n next if link_object.href.blank?\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:hreflang\",\n \"@atom03:hreflang\",\n \"@atom:hreflang\",\n \"@hreflang\"\n ], :select_result_value => true)\n if link_object.hreflang == \"atom10:\" ||\n link_object.hreflang == \"atom03:\" ||\n link_object.hreflang == \"atom:\"\n link_object.hreflang = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@hreflang\"\n ], :select_result_value => true)\n end\n unless link_object.hreflang.nil?\n link_object.hreflang = link_object.hreflang.downcase\n end\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:rel\",\n \"@atom03:rel\",\n \"@atom:rel\",\n \"@rel\"\n ], :select_result_value => true)\n if link_object.rel == \"atom10:\" ||\n link_object.rel == \"atom03:\" ||\n link_object.rel == \"atom:\"\n link_object.rel = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@rel\"\n ], :select_result_value => true)\n end\n unless link_object.rel.nil?\n link_object.rel = link_object.rel.downcase\n end\n if link_object.rel.nil? && self.feed_type == \"atom\"\n link_object.rel = \"alternate\"\n end\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:type\",\n \"@atom03:type\",\n \"@atom:type\",\n \"@type\"\n ], :select_result_value => true)\n if link_object.type == \"atom10:\" ||\n link_object.type == \"atom03:\" ||\n link_object.type == \"atom:\"\n link_object.type = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@type\"\n ], :select_result_value => true)\n end\n unless link_object.type.nil?\n link_object.type = link_object.type.downcase\n end\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:title\",\n \"@atom03:title\",\n \"@atom:title\",\n \"@title\",\n \"text()\"\n ], :select_result_value => true)\n if link_object.title == \"atom10:\" ||\n link_object.title == \"atom03:\" ||\n link_object.title == \"atom:\"\n link_object.title = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@title\"\n ], :select_result_value => true)\n end\n # This catches the ambiguities between atom, rss, and cdf\n if link_object.title == link_object.href\n link_object.title = nil\n end\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@atom10:length\",\n \"@atom03:length\",\n \"@atom:length\",\n \"@length\"\n ], :select_result_value => true)\n if link_object.length == \"atom10:\" ||\n link_object.length == \"atom03:\" ||\n link_object.length == \"atom:\"\n link_object.length = FeedTools::XmlHelper.try_xpaths(link_node, [\n \"@length\"\n ], :select_result_value => true)\n end\n if !link_object.length.nil?\n link_object.length = link_object.length.to_i\n else\n if !link_object.type.nil? && link_object.type[0..4] != \"text\" &&\n link_object.type[-3..-1] != \"xml\" &&\n link_object.href =~ /^http:\\/\\//\n # Retrieve the length with an http HEAD request\n else\n link_object.length = nil\n end\n end\n @links = [] if @links.nil?\n @links << link_object\n end\n end\n return @links\n end",
"def link\n\t\tpage_id.present? ? short_page_path(Page.find(page_id)) : href\n\tend",
"def link_of_item(kind)\n\titem = @items.find { |i| i.attributes()[:kind] == kind }\n\tlink_to(kind.capitalize, @site.config()[:base_url] + item.path) unless item.nil?\nend",
"def link\n Html::Link.new(:href => url) << display_name\n end",
"def size_link(size)\n link = images.find { |i| i.classifier == size }\n link ? link.url : nil\n end",
"def links\n construct_html(self.items)\n end",
"def item_link(item)\n if !item.new_record?\n if item.respond_to?(:name)\n content_tag(:li, link_to(item.name, [:cms, @available_locale, item]), class: 'current hide-for-small')\n elsif item.respond_to?(:headline)\n content_tag(:li, link_to(item.headline.truncate(30), [:cms, @available_locale, item]), class: 'current hide-for-small')\n elsif item.respond_to?(:title)\n content_tag(:li, link_to(item.title.truncate(30), [:cms, @available_locale, item]), class: 'current hide-for-small')\n end\n end\n end",
"def vcard_link(title=nil, **kwargs)\n link_to(title || config.vcard_name, vcard_path, kwargs)\n end",
"def media_link &block\n ASObj.generate :media_link,true,&block\n end",
"def link_self; end",
"def article_action_links( article )\n \n available_actions = []\n\n case current_user.role.downcase.to_sym\n when :writer\n if article.status == Article::Status[:unsubmitted]\n available_actions << :edit\n available_actions << :destroy if article.user_id==current_user.id\n end\n when :editor\n if [ Article::Status[:unsubmitted], \n Article::Status[:editing] \n ].include?(article.status)\n available_actions << :edit\n available_actions << :destroy\n end\n when :subeditor\n available_actions << :download\n if [ Article::Status[:unsubmitted], \n Article::Status[:editing],\n Article::Status[:subediting] \n ].include?(article.status)\n available_actions << :edit\n available_actions << :destroy\n end\n when :publisher, :admin\n available_actions << :download\n available_actions << :edit\n available_actions << :destroy\n if article.live?\n available_actions << :unpublish\n end\n end\n \n output = \"\"\n \n # Include locking support\n if available_actions.include? :edit\n if article.locked? && (article.lock.user != current_user)\n output << link_to( \"Edit article\", \n edit_admin_article_path(article),\n :title=>\"Edit article\",\n :class=>\"article_edit locked\",\n :confirm => \"This article is currently being edited by #{article.lock.user.email} as of #{article.lock.updated_at.strftime(\"%H:%M\")}.\\n\\n\"+\n \"You may overwrite changes or lose your data if you continue to edit this article.\\n\\nDo you want to override the lock and open the article for editing?\"\n )\n else\n output << link_to( \"Edit article\", \n edit_admin_article_path(article),\n :title=>\"Edit article\",\n :class=>\"article_edit\"\n )\n end\n end\n \n \n output << link_to( \"Show article\", \n admin_article_path(article), \n :title=>\"Show article\", \n :class=>:article_show) if available_actions.include? :download\n \n output << link_to( \"Print article\", \n print_admin_article_path(article), \n :title=>\"Print article\",\n :class=>:article_print) if available_actions.include? :download\n \n output << link_to( \"Download for InDesign\", \n admin_article_path(article, :format=>:indtt), \n :title=>\"Download for InDesign\", \n :class=>:article_indesign) if available_actions.include? :download\n \n output << link_to(\"Unpublish article\", \n unpublish_admin_article_path(article), \n :title=>\"Unpublish article\", :method => :post,\n :class=>:article_unpublish) if available_actions.include? :unpublish\n \n output << link_to(\"Obliterate article\", \n admin_article_path(article), \n :method=>:delete, \n :confirm => \"Are you sure? If you obliterate this article, it will be removed and will not be recoverable.\",\n :title=>\"Obliterate article\", \n :class=>:article_destroy) if available_actions.include? :destroy\n \n return output.html_safe\n end",
"def nexia_link # :doc:\n content_box.a(:text => \"nexiahome.com\")\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 get_crafted_items(index)\n page = get_additional_info(index)\n elements = page.css('.content-body-title a')\n items = []\n\n elements.each do |el|\n href = /item\\/(\\d+)/.match(el['href'])\n id = nil\n\n if (href && href.length > 1)\n items.push(href[1])\n end\n end\n\n items\nend",
"def link!\n self.linkbutton = true\n self.save\n self.linkbutton\n end",
"def github_code_link code_link, chapter_name\n backend_github_repo = $config['backend_github_repo']\n frontend_github_repo = $config['frontend_github_repo']\n frontend_fb_login_github_repo = $config['frontend_fb_login_github_repo']\n frontend_user_mgmt_github_repo = $config['frontend_user_mgmt_github_repo']\n backend_mono_github_repo = $config['backend_mono_github_repo']\n\n if (code_link === 'backend_full')\n text = \"For reference, here is the complete code for the backend\"\n elsif (code_link == 'frontend_full')\n text = \"For reference, here is the complete code for the frontend\"\n else\n text = \"For reference, here is the code we are using\"\n end\n\n if (code_link === 'backend')\n link_text = \"Backend Source: #{chapter_name}\"\n link = \"#{backend_github_repo}/tree/#{chapter_name}\"\n\n elsif (code_link === 'frontend')\n link_text = \"Frontend Source: #{chapter_name}\"\n link = \"#{frontend_github_repo}/tree/#{chapter_name}\"\n\n elsif (code_link === 'backend_full')\n link_text = \"Backend Source\"\n link = \"#{backend_github_repo}\"\n\n elsif (code_link === 'frontend_full')\n link_text = \"Frontend Source\"\n link = \"#{frontend_github_repo}\"\n\n elsif (code_link === 'mono-repo')\n link_text = \"Mono-repo Backend Source\"\n link = \"#{backend_mono_github_repo}\"\n\n elsif (code_link === 'facebook-login')\n link_text = \"Facebook Login Frontend Source\"\n link = \"#{frontend_fb_login_github_repo}\"\n\n elsif (code_link === 'user-management')\n link_text = \"User Management Frontend Source\"\n link = \"#{frontend_user_mgmt_github_repo}\"\n end\n\n link = \"\n\\\\awesomebox[serverless-purple]{1pt}{\\\\faGithub}{serverless-purple}{\n\\\\textbf{#{text}}\n\n\\\\href{#{link}}{#{link_text}}\n}\"\nend",
"def show_item_thumb(document)\n if document.do_url\n link_to(\n thumbnail_image_tag(document, css: ''),\n document.do_url\n )\n else\n thumbnail_image_tag(document, css: '') + visit_partner_button(document)\n end\n end",
"def next\n self.next_id == -1 ? nil : self.story.cards.find(self.next_id)\n end",
"def navBarLink(url,text, img_name, link_option)\n ### <%= link_to raw('<button type=\"button\" class=\"btn-img btn btn-default navbar-btn\">'+image_tag(\"list16x16.png\",{:title =>\"Ir al Listado\", :alt=>\"Listar\", :border => \"0\"})+\" Listado</button>\"), cargos_path %>\n\n link_to raw('<button type=\"button\" class=\"btn-img btn btn-default navbar-btn\">'+image_tag(img_name,{:border=>\"0\", :alt=>\"\"})+\" \"+text+\"</button>\"), url, link_option\n end",
"def linkpoint\n @enabled = Confline.get_value(\"Linkpoint_Enabled\", 0).to_i\n unless @enabled == 1\n render :text => \"\" and return false\n end\n @page_title = _('LinkPoint')\n @page_icon = \"money.png\"\n @currency = Confline.get_value(\"Linkpoint_Default_Currency\")\n\n end",
"def share\n @card = Card.find(params[:id])\n end",
"def split_off_absorption_to_link absorption, make_copy\n trace :datavault, \"Promote #{absorption.inspect} to a new Link\" do\n\n # REVISIT: Here we need a new objectified fact type with the same two players and the same readings,\n # complete with LinkFactTypes. Then we need two Absorptions, one for each LinkFactType, and with\n # the same child role names as the role names in our original fact type.\n #\n # The current code tries to re-use the same fact type, but the absorptions cannot work for both as\n # the parent object type can only be one of the two types. That's why this is currently failing its\n # validation tests.\n\n link_name =\n absorption.\n parent_role.\n fact_type.\n reading_preferably_starting_with_role(absorption.parent_role).\n expand([], false).words.capwords*' '\n # A simpler naming, not using the fact type reading\n # link_name = absorption.root.mapping.name + ' ' + absorption.child_role.name\n\n link_from = absorption.parent.composite\n link_to = absorption.foreign_key.composite\n\n # A new composition that maps the same object type as this absorption's parent:\n mapping = @constellation.Mapping(:new, name: link_name, object_type: absorption.parent_role.object_type)\n link = @constellation.Composite(mapping, composition: @composition)\n\n unless make_copy\n remove_indices absorption\n\n # Move the absorption across to here\n absorption.parent = mapping\n\n if absorption.foreign_key\n trace :datavault, \"Setting new source composite for #{absorption.foreign_key.inspect}\"\n absorption.foreign_key.source_composite = link\n debugger unless absorption.foreign_key.all_foreign_key_field.single\n fk2_component = absorption.foreign_key.all_foreign_key_field.single.component\n end\n end\n\n # Add a surrogate key:\n inject_surrogate link\n\n # Add a Surrogate foreign Key to the link_from composite\n fk1_target = link_from.primary_index.all_index_field.single\n raise \"Internal error: #{link_from.inspect} should have a surrogate key\" unless fk1_target\n # Here, we're jumping directly to the foreign key field.\n # Normally we'd have the Absorption of the object type, containing the FK field.\n # We have no fact type for this absorption; it should be the LinkFactType of the notional objectification\n # This affects the absorption path comment on the related SQL coliumn, for example.\n # REVISIT: Add the LinkFactType for the notional objectification, and use that.\n fk1_component = fk1_target.component.fork_to_new_parent mapping\n\n fk2_target = link_to.primary_index.all_index_field.single\n if make_copy\n # See the above comment for fk1_component; it applies here also\n fk2_component = fk2_target.component.fork_to_new_parent mapping\n else\n # We're using the leaf component of the absorption we moved across\n end\n\n # Add a natural key:\n natural_index =\n @constellation.Index(:new, composite: link, is_unique: true, composite_as_natural_index: link)\n @constellation.IndexField(access_path: natural_index, ordinal: 0, component: fk1_component)\n @constellation.IndexField(access_path: natural_index, ordinal: 1, component: fk2_component)\n\n # Add ForeignKeys\n fk1 = @constellation.ForeignKey(\n :new,\n source_composite: link,\n composite: link_from\n )\n @constellation.ForeignKeyField(foreign_key: fk1, ordinal: 0, component: fk1_component)\n # REVISIT: This should be filled in by complete_foreign_keys, but it has no Absorption\n @constellation.IndexField(access_path: fk1, ordinal: 0, component: fk1_target.component)\n\n if make_copy\n fk2 = @constellation.ForeignKey(\n :new,\n source_composite: link,\n composite: link_to\n )\n @constellation.ForeignKeyField(foreign_key: fk2, ordinal: 0, component: fk2_component)\n # This can't be filled in by complete_foreign_keys because it has no Absorption\n @constellation.IndexField(access_path: fk2, ordinal: 0, component: fk2_target.component)\n absorption.foreign_key.retract\n end\n inject_audit_fields link, link_from\n\n # split_satellites_from link, false\n @link_composites << link\n end\n end",
"def link(link, title, content)\n \"#{content} (#{link})\"\n end",
"def find_links_box\n @links_box = @node.content\n end",
"def fries_offer_link\n fries_popup.find(:link_class => 'fries_cta')\n end",
"def custom_link\n if self.permalink.blank?\n self.company_name\n else\n self.permalink\n end\n end"
] |
[
"0.64916915",
"0.6406079",
"0.60592794",
"0.60592794",
"0.59337217",
"0.59147525",
"0.5896554",
"0.5819199",
"0.581119",
"0.5795779",
"0.5795779",
"0.57876265",
"0.5740186",
"0.57041407",
"0.5689508",
"0.5683463",
"0.5683463",
"0.5661261",
"0.5657326",
"0.56467515",
"0.56272256",
"0.5626917",
"0.56216204",
"0.5606642",
"0.5597619",
"0.5595897",
"0.559409",
"0.5581528",
"0.5571659",
"0.55677104",
"0.55650455",
"0.55567425",
"0.5550595",
"0.5548427",
"0.55389154",
"0.5525433",
"0.54835945",
"0.5470876",
"0.54496574",
"0.54445076",
"0.5439582",
"0.54320395",
"0.53948355",
"0.5388938",
"0.5376834",
"0.5363342",
"0.53467786",
"0.53417563",
"0.533196",
"0.53281265",
"0.5326705",
"0.53204757",
"0.5316248",
"0.5307525",
"0.5302665",
"0.52951765",
"0.52938527",
"0.5293778",
"0.5290882",
"0.5284375",
"0.52770793",
"0.52731454",
"0.52718115",
"0.52651256",
"0.5264201",
"0.5261499",
"0.52593285",
"0.5244756",
"0.52439326",
"0.5232559",
"0.5232393",
"0.52285105",
"0.52285105",
"0.5227126",
"0.52261406",
"0.52195275",
"0.5217588",
"0.52174103",
"0.5216647",
"0.5212393",
"0.5207421",
"0.5206058",
"0.5204751",
"0.5191424",
"0.5186236",
"0.51854503",
"0.5183433",
"0.51833093",
"0.5175544",
"0.5169662",
"0.51655865",
"0.5164748",
"0.51625884",
"0.5149769",
"0.5148616",
"0.5140768",
"0.5140184",
"0.51380146",
"0.51369154",
"0.5134572",
"0.51341444"
] |
0.0
|
-1
|
========================== SAVED DEAL STUFF ==================================
|
def category_active_for?(category)
!!category_preferences.try(:any?) { |cp| cp.category_id == category.id }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_report_item(employee, record)\n if record.hours_worked != 0 \n amount_paid = 0\n case employee.job_group\n when \"A\"\n amount_paid += record.hours_worked * 30\n when \"B\"\n amount_paid += record.hours_worked * 20\n end\n current_date = record.date\n case current_date.day\n when 1..15\n pay_start_date = current_date.beginning_of_month\n pay_end_date = Date.new(current_date.year, current_date.month, 15)\n when 16..31\n pay_start_date = Date.new(current_date.year, current_date.month, 16)\n pay_end_date = current_date.end_of_month \n end\n report = Report.where(employee_id: employee.id, pay_start_date: pay_start_date, pay_end_date: pay_end_date).first_or_create\n report.amount_paid ||= 0\n report.amount_paid += amount_paid\n report.save!\n end\n end",
"def save_detail() \n check_purchase_date(self.date_purchase,self.value, self.scrap_value,self.valuable_age) \n AccountingFixedAssetDetail.create(\n :transaction_date => self.date_purchase,\n :asset_values => self.value, \n :depreciation_values => $value,\n :aje_values => self.value - $value,\n :fixed_asset_id => self.id,\n :account_id => get_account_id(self.adjustment_account_id)\n )\n end",
"def calculate_and_save_delta_ps\n\n fittings = PipeSizing.fitting1\n orifice_id = nil\n fittings.each {|item| orifice_id = item[:id] if item[:value] == 'Orifice' }\n\t orifice_dp = self.discharge_circuit_piping.sum(:delta_p, :conditions => ['fitting = ? ', orifice_id])\n\n #calculate flow elements sum\n flow_element_ids = []\n\n fittings.each do |item| \n if item[:value].include?(\"Flow\")\n flow_element_ids << item[:id] \n end\n end\n\n flow_elements_dp_sum = 0.0\n self.discharge_circuit_piping.where({:fitting => flow_element_ids}).each do |f|\n flow_elements_dp_sum = flow_elements_dp_sum + f.delta_p\n end\n\n #add flow elements dp sum to orifice dp\n orifice_dp = orifice_dp + flow_elements_dp_sum\n\n equipment_id = nil\n fittings.each {|item| equipment_id = item[:id] if item[:value] == 'Equipment' }\n\t equipment_dp = self.discharge_circuit_piping.sum(:delta_p, :conditions => ['fitting = ? ', equipment_id])\n\n control_valve_id = nil\n fittings.each {|item| control_valve_id = item[:id] if item[:value] == 'Control Valve' }\n\t control_valve_dp = self.discharge_circuit_piping.sum(:delta_p, :conditions => ['fitting = ? ', control_valve_id])\n\n\ttotal_system_dp = discharge_circuit_piping.sum(:delta_p)\n fitting_dp = total_system_dp - (equipment_dp + control_valve_dp + orifice_dp)\n\n\tunit_decimals = self.pump_sizing.project.project_units\n\n\tpressure_at_discharge_nozzle = destination_pressure + total_system_dp\n\n \tupdate_attributes(\n :fitting_dp => fitting_dp.round(unit_decimals[\"Pressure\"][\"Differential\"][:decimal_places].to_i),\n\t\t:equipment_dp => equipment_dp.round(unit_decimals[\"Pressure\"][\"Differential\"][:decimal_places].to_i),\n\t\t:control_valve_dp => control_valve_dp.round(unit_decimals[\"Pressure\"][\"Differential\"][:decimal_places].to_i),\n\t\t:orifice_dp => orifice_dp.round(unit_decimals[\"Pressure\"][\"Differential\"][:decimal_places].to_i),\n\t\t:total_system_dp => total_system_dp.round(unit_decimals[\"Pressure\"][\"General\"][:decimal_places].to_i),\n\t\t:pressure_at_discharge_nozzle_dp => pressure_at_discharge_nozzle.round(unit_decimals[\"Pressure\"][\"General\"][:decimal_places].to_i)\n\t)\n end",
"def add_due\n \t\t# if !self.company.plan.custom\n \t\t# \tcompany = self.company\n \t\t# \tday_number = DateTime.now.day\n # \t\tmonth_number = DateTime.now.month\n # \t\tmonth_days = DateTime.now.days_in_month\n \t\t# \tcompany.due_amount += (((month_days - day_number + 1).to_f / month_days.to_f) * company.company_plan_setting.base_price * company.computed_multiplier).round(2)\n \t\t# \tcompany.save\n \t\t# end\n \tend",
"def business_plan\n end",
"def substract_due\n \t\t# if !self.company.plan.custom\n \t\t# \tcompany = self.company\n \t\t# \tday_number = DateTime.now.day\n # \t\tmonth_number = DateTime.now.month\n # \t\tmonth_days = DateTime.now.days_in_month\n \t\t# \tcompany.due_amount -= (((month_days - day_number + 1).to_f / month_days.to_f) * company.company_plan_setting.base_price * (company.computed_multiplier + company.company_plan_setting.locations_multiplier)).round(2)\n \t\t# \tcompany.save\n \t\t# end\n \tend",
"def revenue\n##ONLY ONE I NEED TO WORK ON!!!!\n\n end",
"def free_storage_valid_thru_date\n sale_date =\n if self.auction_datum.present? && self.auction_datum.auction_date.present?\n self.yard.utc_sale_date_with_time_for_date(self.auction_datum.auction_date)\n elsif self.sale_confirmed_date.present?\n self.sale_confirmed_date\n else\n DateTime.now\n end\n # No bid history at all may be a data issue,\n # but as far as we're concerned here, it's \n # 3 business days.\n if self.bid_histories.empty?\n self.three_business_days_later_inclusive(sale_date)\n # Kiosk winners get 3 days\n elsif self.high_bid_is_kiosk?\n self.three_business_days_later_inclusive(sale_date)\n # Next scenarios depend on bid type existing\n elsif self.bid_histories.first.bid_type.present?\n bid_type_code = self.bid_histories.first.bid_type.code\n # Live Auction winners / prelim-bid winners / \n # counter-bid (offline) / Buy Now winners / Sale Now \n # winners get 7 days (counting sale_date).\n if bid_type_code == BidType::AURORA_LIVE_BID_CODE || \n bid_type_code == BidType::AURORA_PRELIM_BID_CODE || \n bid_type_code == BidType::AURORA_BUY_NOW_CODE || \n bid_type_code == BidType::FIGS_SALE_NOW_CODE ||\n !self.current_buyer_also_high_bidder?\n sale_date + 6.days\n # Unknown code was received, per Karla they get 3\n # days. (todo: important enough to email us so we know?)\n elsif bid_type_code.present?\n logger.info(\"Unknown bid type received, code is: #{bid_type_code}\")\n self.three_business_days_later_inclusive(sale_date)\n # Code not present also gets the three (we should prevent\n # this scenario in the api, but you know, safety first)\n else\n logger.info(\"BidType.code not present on bid type of description: #{self.bid_histories.first.bid_type.description}\")\n self.three_business_days_later_inclusive(sale_date)\n end\n # All other scenarios get 3 business days\n # (so incomplete data scenarios will get 3 days).\n else\n self.three_business_days_later_inclusive(sale_date)\n end\n end",
"def add_deal_to_all_mi(day, deal_name,bur_cat)\n return 'replace with create_deal_for_category'\n end",
"def create\n \n inv_trip_params = invoiced_trip_params.merge(:total_amount => (invoiced_trip_params[\"amount\"].to_d/\n Conversion.find_by_sql([\"SELECT * FROM conversions where conversions.currency_id = ? and \n conversions.date <= ? order by conversions.date asc\", invoiced_trip_params[\"currency_id\"], \n Date.new(invoiced_trip_params[\"date(1i)\"].to_i,invoiced_trip_params[\"date(2i)\"].to_i,\n invoiced_trip_params[\"date(3i)\"].to_i)])[0][\"conversion_rate\"]).round(2))\n\n @invoiced_trip = InvoicedTrip.new(inv_trip_params)\n \n if @invoiced_trip.brand != nil #_params.fetch(:brand).to_s.size\n @invoiced_trip.StartDate = Invoice.find_by(id: @invoiced_trip.invoice_id).date\n @invoiced_trip.typeT = true\n @invoiced_trip.save\n end\n\n @pricing = Pricing.find_by_sql([\"SELECT * FROM pricings where pricings.client_id = ? \n and pricings.DATETIME <= ? order by pricings.DATETIME desc\", @invoiced_trip.client_id, @invoiced_trip.StartDate ])\n \n if @invoiced_trip.typeT == 0\n @invoiced_trip.surcharge = @pricing[0].surcharge\n @invoiced_trip.price_per_km = @pricing[0].price_per_km\n else\n @invoiced_trip.surcharge = 0\n @invoiced_trip.price_per_km = 0\n end\n\n\n if @invoiced_trip.images.count>0\n @invoiced_trip.images.attach(params[:invoiced_trip][:images])\n end\n\n if @invoiced_trip.bill_of_lading.count>0\n @invoiced_trip.bill_of_lading.attach(params[:invoiced_trip][:images])\n end\n\n if @invoiced_trip.export_document.count>0\n @invoiced_trip.export_document.attach(params[:invoiced_trip][:images])\n end\n \n respond_to do |format|\n if @invoiced_trip.save\n format.html { redirect_to @invoiced_trip, notice: 'Invoiced trip was successfully created.' }\n format.json { render :show, status: :created, location: @invoiced_trip }\n else\n format.html { render :new }\n format.json { render json: @invoiced_trip.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def existing_clients_new_revenue \n existing_clients.where(new_money: true).sum(:first_year_comp)\nend",
"def admin_aircraft_report\n return unless has_permission :can_do_billing\n @page_title = \"Billing Report\"\n @earliest = FlightRecord.find(:first, :order => \"flight_date\")\n if @earliest.nil? or params[:date].nil? then return end\n\n @start_date = Time.local(params[:date][:year].to_i, params[:date][:month].to_i)\n @end_date = @start_date.months_since params[:date][:range].to_i \n @page_title = \"Billing Report for \" + @start_date.strftime(\"%b %Y\") + \" to \" + @end_date.strftime(\"%b %Y\")\n\n @solo = FlightRecord.sum('hobbs_end-hobbs_start',:group=>:aircraft,\n :conditions=>['aircraft_id is not NULL and instructor_id is NULL and flight_date>=? and flight_date<?',@start_date,@end_date])\n @dual = FlightRecord.sum('hobbs_end-hobbs_start',:group=>:aircraft,\n :conditions=>['aircraft_id is not NULL and instructor_id is not NULL and flight_date>=? and flight_date<?',@start_date,@end_date])\n @charges = FlightRecord.sum('charge_amount',:group=>:aircraft,\n :conditions=>['aircraft_id is not NULL and flight_date>=? and flight_date<?',@start_date,@end_date])\n @aircrafts = Aircraft.find(:all,:conditions=>['deleted=false'],:order=>'identifier')\n \n @solo_total = @solo.inject(0){|s,e| s = s + e[1].to_f}\n @dual_total = @dual.inject(0){|s,e| s = s + e[1].to_f}\n @time_total = @solo_total + @dual_total\n @charges_total = @charges.inject(0){|s,e| s = s + e[1].to_f} \nend",
"def stock\n\n inventory = case presentation_unit_type_measurement.name\n when PresentationUnitTypeMeasurement::SUPERFICIAL\n inventory_for_superficie_presentation_unit_type_measurement\n when PresentationUnitTypeMeasurement::LOGITUDINAL\n inventory_for_longitudinal_presentation_unit_type_measurement\n else\n #TODO LOGGER\n 0\n end\n\n \n\n invoiced = case presentation_unit_type_measurement.name\n when PresentationUnitTypeMeasurement::SUPERFICIAL\n invoiced_for_superficie_presentation_unit_type_measurement\n when PresentationUnitTypeMeasurement::LOGITUDINAL\n invoiced_for_longitudinal_presentation_unit_type_measurement\n else\n #TODO LOGGER\n 0\n end\n\n inventory - invoiced\n end",
"def daily_promotion_report\n variant = self.variant\n product = variant.product\n seller = product.seller\n ord_qty_hash = {}\n qty = 0\n total_qty = 0\n qty_daily = 0\n total_qty_daily = 0\n s_date = Time.now.beginning_of_day\n e_date = Time.now.end_of_day\n orders_daily = seller.orders.includes(:line_items).where(:order_date=>s_date..e_date).where(\"spree_line_items.variant_id=?\", variant.id)\n orders = seller.orders.includes(:line_items).where(:order_date=>self.created_at..e_date).where(\"spree_line_items.variant_id=?\", variant.id)\n ord_no = orders.map(&:cart_no).uniq.count\n ord_no_daily = orders_daily.map(&:cart_no).uniq.count\n orders.each do |ord|\n total_qty = total_qty + ord.line_items.map(&:quantity).sum\n end\n orders_daily.each do |ord|\n total_qty_daily = total_qty_daily + ord.line_items.map(&:quantity).sum\n end\n case self.next_type\n when \"Revert to Previous Qty\"\n qty = total_qty\n qty_daily = total_qty_daily\n when \"Sync with FBA\"\n qty = total_qty - self.previous_quantity\n qty_daily = total_qty_daily - self.previous_quantity\n when \"Reset to Zero\"\n qty = total_qty - self.previous_quantity\n qty_daily = total_qty_daily - self.previous_quantity\n else \n qty = total_qty - self.previous_quantity\n qty_daily = total_qty_daily - self.previous_quantity\n end \n qty = qty < 0 ? 0 : qty\n qty_daily = qty_daily < 0 ? 0 : qty_daily \n ord_qty_hash.merge!(variant.id=>[seller.name.capitalize, variant.name, variant.sku, ord_no, total_qty, qty, ord_no_daily, total_qty_daily, qty_daily, self.end_date.strftime(\"%d/%m/%Y\"), ])\n return ord_qty_hash\n end",
"def daily_promotion_report\n variant = self.variant\n product = variant.product\n seller = product.seller\n ord_qty_hash = {}\n qty = 0\n total_qty = 0\n qty_daily = 0\n total_qty_daily = 0\n s_date = Time.now.beginning_of_day\n e_date = Time.now.end_of_day\n orders_daily = seller.orders.includes(:line_items).where(:order_date=>s_date..e_date).where(\"spree_line_items.variant_id=?\", variant.id)\n orders = seller.orders.includes(:line_items).where(:order_date=>self.created_at..e_date).where(\"spree_line_items.variant_id=?\", variant.id)\n ord_no = orders.map(&:cart_no).uniq.count\n ord_no_daily = orders_daily.map(&:cart_no).uniq.count\n orders.each do |ord|\n total_qty = total_qty + ord.line_items.map(&:quantity).sum\n end\n orders_daily.each do |ord|\n total_qty_daily = total_qty_daily + ord.line_items.map(&:quantity).sum\n end\n case self.next_type\n when \"Revert to Previous Qty\"\n qty = total_qty\n qty_daily = total_qty_daily\n when \"Sync with FBA\"\n qty = total_qty - self.previous_quantity\n qty_daily = total_qty_daily - self.previous_quantity\n when \"Reset to Zero\"\n qty = total_qty - self.previous_quantity\n qty_daily = total_qty_daily - self.previous_quantity\n else \n qty = total_qty - self.previous_quantity\n qty_daily = total_qty_daily - self.previous_quantity\n end \n qty = qty < 0 ? 0 : qty\n qty_daily = qty_daily < 0 ? 0 : qty_daily \n ord_qty_hash.merge!(variant.id=>[seller.name.capitalize, variant.name, variant.sku, ord_no, total_qty, qty, ord_no_daily, total_qty_daily, qty_daily, self.end_date.strftime(\"%d/%m/%Y\"), ])\n return ord_qty_hash\n end",
"def investor\n end",
"def apply_additional_metadata(depositor_id)\n #Here's where we call specific additional metadata changes...\n\t\tif self.respond_to?(:apply_content_specific_additional_metadata)\n self.apply_content_specific_additional_metadata\n end\t\n\n\t\t#We are setting the ownerId within apply_addtional_metadata due to a Fedora bug (FCREPO-963 - which means we can't set it on ingest).\n\t\t#It only sets the ownerId with the depositor id if its in the proto queue\n \t\tif self.queue_membership.include? :proto\n\t\t\tself.owner_id = depositor_id\n\t\tend\n\t\t\t\n\t\tdc_ds = self.dc\n\t\tdescMetadata_ds = self.descMetadata\n\n unless dc_ds.nil?\n dc_ds.update_indexed_attributes([:dc_title]=> self.get_values_from_datastream(\"descMetadata\", [:title], {}).to_s)\n begin\n date_issued = self.get_values_from_datastream(\"descMetadata\", [:origin_info,:date_issued], {})\n\t\t\t\tdate_valid = self.get_values_from_datastream(\"descMetadata\", [:origin_info,:date_valid], {})\n \n if date_issued.to_s != \"\"\n \tdc_ds.update_indexed_attributes([:dc_date]=> date_issued.to_s) if date_issued.present?\n\t\t\t\telse\n\t\t\t\t\tdc_ds.update_indexed_attributes([:dc_date]=> date_valid.to_s) if date_valid.present?\n\t\t\t\tend\n rescue OM::XML::Terminology::BadPointerError => e\n logger.error \"ERROR when trying to copy date on #{self.class} #{self.pid}:\\n\\t#{e.message}\"\n end\n end\n\t\n\t\tunless descMetadata_ds.nil?\n\t\t\tdescMetadata_ds.update_indexed_attributes ([:record_info,:record_change_date] => Time.now.strftime(\"%Y-%m-%d\"))\n\t\tend\n\n\t\tself.label = generate_object_label\n\t\t\n\t return true\n end",
"def market\n end",
"def all_expense_items\n owing_expense_items + paid_expense_items\n end",
"def smart_save\n existing = find_existing(origin, destination, departure_date)\n\n (existing && existing.price == self.price) ? existing.touch : self.save\n end",
"def saving(point)\n (point.price * volume) - (price * volume)\n end",
"def before_create\n select = \"#{Company.table_name}.id\"\n \n # serialized adjustments. initialize the array.\n self.adjustments = []\n \n case payable_type\n when \"OrderEntityCost\" \n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{OrderEntityCost.table_name} AS oec ON oec.order_entity_id = oe.id\"\n c = \"oec.id = #{payable_id}\" \n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.name\n when \"OrderEntity\"\n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n c = \"oe.id = #{payable_id}\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.label + ' charge' #<-- OrderTypeEntity.label [Pickup Agent, Carrier, Delivery-agent, etc]\n when \"CompanySalesAccount\"\n j = \"LEFT OUTER JOIN #{Account.table_name} AS a ON a.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{CompanySalesAccount.table_name} AS csa ON csa.account_id = a.id\"\n c = \"csa.id = #{payable_id}\"\n self.name = \"Commission\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id \n end\n end",
"def shipping_report\n @data.start_date = DionDate.new(\"start\", Time.now)\n @data.end_date = DionDate.new(\"end\", Time.now)\n shipping_report_common\n end",
"def save_additional_data\n end",
"def shipped\n corresponding_item = self.item.take\n current_inventory = corresponding_item.inventory_level\n corresponding_item.update_attribute(:inventory_level, (self.quantity + current_inventory)) unless previous.nil?\n self.update_attribute(:shipped_on, date.current.to_date)\n\n def item_exists_and_active?\n all_active_items = Item.active.all.map(&:id)\n if all_active_items.include?(self.item_id)\n return true\n end\n errors.add(:item_id, \"is not an active item at the chess store\")\n return false\n end\n\n def subtotal(date = nil)\n end\n\n def valid_quantity?\n if self.quantity >= 0\n return true\n end\n stock_quantity = self.item.inventory_level\n if (self.quantity* -1) > stock_quantity\n errors.add(:quantity, \"too much purchase quantity\")\n return false\n end\n return true\n end\nend",
"def particular_and_discount_details\n include_particular_associations = @financefee.tax_enabled ? [:pay_all_discounts] : [:collection_tax_slabs]\n @fee_particulars = @date.finance_fee_particulars.all(:conditions => \"batch_id=#{@financefee.batch_id}\",\n :include => include_particular_associations).select do |par|\n (par.receiver_type=='Student' and\n par.receiver_id==@student.id) ? par.receiver=@student : par.receiver; (par.receiver.present?) and\n (par.receiver==@student or par.receiver==@financefee.student_category or\n par.receiver==@financefee.batch)\n end\n @categorized_particulars=@fee_particulars.group_by(&:receiver_type)\n if @financefee.tax_enabled?\n @tax_collections = @financefee.tax_collections.all(:include => :tax_slab)\n # (:select => \"distinct tax_collections.*,\n # ctxs.tax_slab_id as tax_slab_id, ffp.name as particular_name\",\n # :include => :tax_slab,\n # :joins => \"INNER JOIN collectible_tax_slabs ctxs\n # ON ctxs.collectible_entity_type = tax_collections.taxable_entity_type AND\n # ctxs.collectible_entity_id = tax_collections.taxable_entity_id AND\n # ctxs.collection_id = #{@financefee.fee_collection_id} AND\n # ctxs.collection_type = 'FinanceFeeCollection'\n # INNER JOIN tax_slabs\n # ON tax_slabs.id = ctxs.tax_slab_id\n # INNER JOIN finance_fee_particulars ffp\n # ON ffp.id=tax_collections.taxable_entity_id\")\n\n @total_tax = @tax_collections.map do |x|\n FedenaPrecision.set_and_modify_precision(x.tax_amount).to_f\n end.sum.to_f\n\n # @tax_slabs = @tax_collections.map {|tax_col| tax_col.tax_slab }.uniq\n\n # @tax_slabs = TaxSlab.all(:conditions => {:id => @tax_collections.keys })\n @tax_slabs = @tax_collections.group_by { |x| x.tax_slab }\n\n @tax_config = Configuration.get_multiple_configs_as_hash(['FinanceTaxIdentificationLabel',\n 'FinanceTaxIdentificationNumber']) if @tax_slabs.present?\n end\n @discounts=@date.fee_discounts.all(:conditions => \"batch_id=#{@financefee.batch_id}\").\n select do |par|\n (par.receiver.present?) and\n ((par.receiver==@financefee.student or\n par.receiver==@financefee.student_category or\n par.receiver==@financefee.batch) and\n (par.master_receiver_type!='FinanceFeeParticular' or\n (par.master_receiver_type=='FinanceFeeParticular' and\n (par.master_receiver.receiver.present? and\n @fee_particulars.collect(&:id).include? par.master_receiver_id) and\n (par.master_receiver.receiver==@financefee.student or\n par.master_receiver.receiver==@financefee.student_category or\n par.master_receiver.receiver==@financefee.batch))))\n end\n @categorized_discounts=@discounts.group_by(&:master_receiver_type)\n @total_discount = 0\n @total_payable=@fee_particulars.map { |s| s.amount }.sum.to_f\n @total_discount =@discounts.map do |d|\n d.master_receiver_type=='FinanceFeeParticular' ?\n (d.master_receiver.amount * d.discount.to_f/(d.is_amount? ? d.master_receiver.amount : 100)) :\n @total_payable * d.discount.to_f/(d.is_amount? ? @total_payable : 100)\n end.sum.to_f unless @discounts.nil?\n end",
"def unit_saving(point)\n point.price - price\n end",
"def prep_for_save\n # what about when doing the set deposited flag ????\n # if @allow_edit\n # @employee_benefit[\"deposit\"] = round_money(@employee_benefit[\"monthly_benefit\"] - tot_current_benefit)\n # end\n # Deposit to make calculation\n self.deposit =\n self.monthly_benefit.to_f - # Required Total Benefit\n self.tot_current_benefit.to_f - # Current Benefit without DBP (Employee Hourly Benefit (rate) * Total Hours (of Benefit record)\n self.tot_deposits_made.to_f # Previous Deposits (sum of all Employee Benefits for this month that have already been deposited)\n if self && !self.reg_hours\n self.reg_hours = 0.0\n end\n if self && !self.ot_hours\n self.ot_hours = 0.0\n end\n end",
"def stock_market; end",
"def insert_meta_data(zone_value, page, field_name, field_value, account_state, record_pointer, confidence)\n if field_name == \"date_of_service_from\"\n svc_from_date, svc_to_date = standardize_svc_dates field_value rescue nil\n record_pointer.update_attributes(:date_of_service_from => svc_from_date, :date_of_service_to => svc_to_date)\n elsif field_name == \"check_date\" or field_name == \"date_of_service_to\"\n date = datify field_value rescue nil\n record_pointer.update_attribute(\"#{field_name}\",\"#{date}\")\n else\n record_pointer.update_attribute(\"#{field_name}\",\"#{field_value}\") unless field_value == \"0.00\" or field_value == \"0.0\"\n end\n if field_name == \"patient_account_number\"\n record_pointer.image_page_no = page\n record_pointer.sub_job_id = @job.id\n end\n unless field_value == \"0.00\" or field_value == \"0.0\"\n field_ocr_output=field_name +\"_ocr_output\"\n field_data_origin=field_name +\"_data_origin\"\n field_number_page=field_name +\"_page\"\n field_number_coordinates=field_name +\"_coordinates\"\n field_number_state = field_name +\"_ocr_state\"\n field_number_confidence = field_name +\"_confidence\"\n record_pointer.details[field_ocr_output.to_sym] = field_value if field_value\n confidence_value = find_the_data_origin_of(account_state.to_s, confidence)\n record_pointer.details[field_data_origin.to_sym] = confidence_value\n record_pointer.details[field_number_page.to_sym] = page\n record_pointer.details[field_number_coordinates.to_sym] = zone_value\n record_pointer.details[field_number_state.to_sym] = account_state.to_s\n record_pointer.details[field_number_confidence.to_sym] = confidence.to_i\n end\n record_pointer.save(:validate => false)\n end",
"def buy()\n #films the customer has tickets to\n all_films = films()\n #sum the films (as there can be more than one) and from each film add the price up and assign it to price\n price = all_films.sum{|film| film.price}\n remaining_funds = @funds - price\n @funds = remaining_funds\n update() #update the customer's funds!\n end",
"def save_pricing\n\tif !(Time.current.beginning_of_day..Time.current.end_of_day).include?(@aws_offer_code.offer_code_update_statuses.last.try(:for_date))\n\t\toffer_code_update_statuses = @aws_offer_code.offer_code_update_statuses.create(for_date: Time.current)\n\t\t@json_res[\"terms\"][\"OnDemand\"].each do |k,v|\n\t\t\tprice_json = v.to_a\n\t\t\tget_final_json = price_json[0][1]\n\t\t\tprice_dimension_json = get_final_json[\"priceDimensions\"].to_a[0][1]\n\t\t\tcurrency_json = price_dimension_json[\"pricePerUnit\"].to_a[0]\n\t\t\tcurrency_id = MasterCurrency.get_id(currency_json[0])\n\t\t\tprice_per_unit = currency_json[1]\n\t\t\tif get_final_json.present?\n\t\t\t\taws_price_params = {\n\t\t\t\t\tsku: get_final_json[\"sku\"],\n\t\t\t\t\teffective_date: get_final_json[\"effectiveDate\"],\n\t\t\t\t\tcurrency_id: currency_id,\n\t\t\t\t\tdescription: price_dimension_json[\"description\"],\n\t\t\t\t\tbegin_range: price_dimension_json[\"beginRange\"],\n\t\t\t\t\tend_range: price_dimension_json[\"endRange\"],\n\t\t\t\t\tunit: price_dimension_json[\"unit\"],\n\t\t\t\t\tprice_per_unit: price_per_unit\n\t\t\t\t}\n\t\t\t\tputs \"#{get_final_json[\"sku\"]} saved\"\n\t\t\t\toffer_code_update_statuses.aws_offer_code_prices.create(aws_price_params)\n\t\t\tend\n\t\tend\n\telse\n\t\tputs \"Price can be update once in a day\"\n\tend\nend",
"def total_to_be_disbursed_savings\n member_id_list = self.preserved_active_group_loan_memberships.map{|x| x.member_id }\n \n SavingBook.where(:member_id => member_id_list).sum(\"total_extra_savings\")\n end",
"def save_local_data_to_order_and_items\n self.price = subtotal - self.used_credit.to_f\n self.discount = discount_subtotal + self.used_credit.to_f\n self.size = quantity\n\n line_items.each do |i|\n i.price = i.sell_price\n i.discount_rate = i.discount\n end\n end",
"def sales\n end",
"def shipped\n \n end",
"def book_sales(period='enddate', basis, exclude)\n royalty_period = Period.where([\"currentperiod = ? and client_id = ?\", true, self.client_id])\n if period == 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, royalty_period.first.startdate, basis, exclude)\n else #if period isn't 'startdate'\n self.calculate_book_royalties(self, royalty_period.first.enddate, \"1900-01-01\", basis, exclude)\n end\n end",
"def purchase_sub_existing\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\nend",
"def pre_pay_offered\n end",
"def revenue_and_profit(cust_id, start_date = nil, end_date = nil)\n\n start_date = Date.parse('0000-01-01') if (start_date.nil?)\n end_date = Date.parse('3000-01-01') if (end_date.nil?)\n\n order_data = CustomerOrder.find_by_sql(\"SELECT SUM(price) AS total,\n COUNT(1) AS copies,\n COUNT(DISTINCT(orders.orderID)) AS orders\n FROM orders, lineItem\n WHERE orders.customer_id = #{cust_id}\n AND orders.orderID = lineItem.orderID\n AND lineItem.live = 1\n AND orderDate >= '#{start_date.to_s}'\n AND orderDate <= '#{end_date.to_s}'\")[0]\n\n revenue = order_data.total.to_f\n copies = order_data.copies.to_f\n orders = order_data.orders.to_f\n\n costs = 0.0\n\n ##############################################\n # Processing costs, as percent of total inflow\n ##############################################\n\n # 2.19% credit card processing fees\n processing_fee_perc = 0.0219\n\n costs += revenue * processing_fee_perc\n\n #################\n # Per order costs\n #################\n\n # $0.49 per-transaction credit card processing fee\n processing_fee_flat = 0.49\n\n costs += orders * processing_fee_flat\n\n ###############\n # Per DVD costs\n ###############\n\n # $1.50 / DVD depreciation\n depreciation = 1.50\n\n # $0.50 / DVD shipping labor\n shipping_labor = 0.50\n\n costs += copies * (depreciation + shipping_labor)\n\n ####################\n # Per shipment costs\n ####################\n\n # $0.04 outgoing label (label and laser)\n outgoing_label = 0.04\n\n # $0.05 return label\n return_label = 0.05\n\n # $0.06 instructions\n instructions = 0.06\n\n # $0.11 adhesive tabs\n adhesive_tabs = 0.11\n\n # $0.13 postage machine rental and ink\n postage_machine = 0.13\n\n # Mail shipping rates, based on number of DVDs\n shipping_rates = { 1 => 0.87, 2 => 0.87, 3 => 1.11, 4 => 1.35, 5 => 1.83,\n 6 => 2.07, 7 => 2.31, 8 => 2.31, 9 => 2.55, 10 => 2.79 }\n\n # Shipping containers, based on number of DVDs\n shipping_containers = { 1 => 0.46, 2 => 0.46, 3 => 0.46, 4 => 0.46 }\n # Everything not 1-4 costs 0.60\n shipping_containers.default = 0.60\n\n # lookup table for cost per shipment, based on shipment size\n\n shipment_costs = Hash.new(10.00) # default for customers with > 10 items left to ship, might be low?\n\n shipping_rates.each_key do |size|\n shipment_costs[size] = (shipping_rates[size] * 2) + shipping_containers[size] + outgoing_label +\n return_label + instructions + adhesive_tabs + postage_machine\n end\n\n # Note: this assumes all unshipped items will be bundled together\n shipments = CustomerOrder.find_by_sql(\"SELECT shipmentID, count(1) as size\n FROM orders, lineItem\n WHERE orders.customer_id = #{cust_id}\n AND orders.orderID = lineItem.orderID\n AND lineItem.live = 1\n AND orderDate >= '#{start_date.to_s}'\n AND orderDate <= '#{end_date.to_s}'\n GROUP BY shipmentID\")\n\n shipments.each { |shipment| costs += shipment_costs[shipment.size.to_i] }\n\n # We don't need to include reship rate, since reshipments have line\n # items that are included here, with $0.00 revenue attached\n\n profit = revenue - costs\n\n return revenue, profit, copies, orders, shipments.size.to_i\n\nend",
"def call\n results = []\n @save.provinces.each do |id, province|\n next unless province.owner\n next if province.has_manufactory?\n\n # Could also include subjects\n next unless province.owner == @save.player_tag\n\n trade_goods = province.trade_goods\n trade_node_name = province.trade_node_name\n price = @save.trade_good_prices[trade_goods]\n trade_node = @save.trade_network[trade_node_name]\n owner_trade_share = trade_node.total_collector_share[province.owner]\n owner_trade_value = (owner_trade_share * price / 12.0).round(6)\n\n # Can't build manufactory anyway\n next if trade_goods == \"gold\" or trade_goods == \"unknown\"\n\n # This is not from the save, we recalculate estimate\n autonomy = province.effective_autonomy\n autonomy = 0 if province.estate == \"burghers\"\n usefulness = 1.0 - autonomy/100.0\n base_production_income = 1.0 * price / 12.0\n workshop_multiplier = 1.0\n workshop_multiplier = 1.5 if province.buildings.include?(\"workshop\")\n workshop_multiplier = 2.0 if province.buildings.include?(\"counting_house\")\n\n # This is multiplied by a lot of things\n # - goods produced\n # - prosperity 25%\n # - production leader 10%\n # - war exhaustion -X%\n # - nearby merchant companies +X%\n # - nearby trade companies +X%\n # - happy burgers 10%\n # - national ideas\n # - furnacess\n # - trading in coal\n # - local production efficiency\n # - workshops [TAKEN INTO ACCOUNT]\n # - production efficiency\n # - adm tech bonus 0% to 20%\n # - ahead of time adm bonus 20%\n # and maybe others, for ballpark figure picking 1.50x\n estimated_production_value = (base_production_income * workshop_multiplier * usefulness)\n estimated_production_value *= 1.50\n\n estimated_total_value = (owner_trade_value + estimated_production_value).round(6)\n\n results << [country_name(province.owner), estimated_total_value, trade_goods, id, province.name]\n results[-1] << \"[construction in progress]\" if province.construction_in_progress?\n end\n results.sort_by{|t,v,g,i,pn| [t,-v,g,i,pn]}.each do |row|\n puts row.join(\"\\t\")\n end\n end",
"def invested(domain)\n #identify unique rounds to this vc\n #go through my startups and identify the domain \n #if domain string == the startup domain, return the startup investment \n myStartupRound = FundingRound.all.select do |round|\n round.startup.domain == domain\n end\n myInvestment = myStartupRound.map do |round|\n round.investment\n end\n myInvestment.sum\n end",
"def get_total_apply_amount\n total=0\n if self.doc_type==1\n total+= amount_for :borrow_doc_details\n end\n if doc_type==2\n total+= amount_for :pay_doc_details\n end\n if doc_type==3\n total+= amount_for :rec_notice_details\n end\n if doc_type==4 and inner_remittance!=nil\n total=inner_remittance.amount || 0\n end\n if doc_type==5 and inner_transfer !=nil\n total=inner_transfer.amount || 0\n end\n if doc_type==6 and inner_cash_draw!=nil\n inner_cash_draw.cash_draw_items.each do |c_item|\n next if c_item.apply_amount==nil or c_item.marked_for_destruction?\n total+=c_item.apply_amount\n end\n end\n if doc_type==7 and buy_finance_product!=nil\n total=buy_finance_product.amount\n end\n if doc_type==8 and redeem_finance_product!=nil\n total=redeem_finance_product.amount\n end\n if doc_type==9\n %w(rd_travels rd_transports rd_lodgings other_riems).each do |rd|\n total+=amount_for rd \n end\n end\n if doc_type==10\n total+=amount_for :rd_communicates\n end\n if doc_type==11\n %w(rd_extra_work_cars rd_extra_work_meals).each do |rd|\n total+=amount_for rd\n end\n end\n if doc_type==12\n %w(rd_common_transports rd_work_meals common_riems).each do |rd|\n total+=amount_for rd\n end\n end\n if doc_type==13\n total+= amount_for :rd_benefits\n end\n if doc_type==14\n # todo\n # total+=amount_for :fixed_properties\n end\n total\n end",
"def calculateSummary\n\n # Get start of month balances\n Array[@month1, @month2, @month3, @month4, @month5].each do |month|\n # Get start of month balances.\n thisMonthBalances = {}\n @bankAccounts.each do |bankAccount|\n bankAccount = bankAccount[1]\n case bankAccount['bank_account_type_id'].to_i\n when 1\n bankAccountTable = 'bank_account_type_bank_account'\n when 2\n bankAccountTable = 'bank_account_type_credit_card'\n when 3\n bankAccountTable = 'bank_account_type_isa'\n else\n raise(RuntimeError, \"bank_account_type => #{bankAccount['bank_account_type']} doesn't exist.\")\n end\n balance = @databaseConnection.query(\"SELECT * FROM #{bankAccountTable} WHERE bank_account_id='#{bankAccount['id']}' AND (date_fetched>='#{month.strftime('%Y-%m-01')}' AND date_fetched<='#{month.strftime('%Y-%m-07')}') ORDER BY date_fetched ASC LIMIT 1\")\n thisMonthBalances[bankAccount['id'].to_i] = balance.fetch_hash\n balance.free\n end\n monthObject = getMonthObject(month.strftime('%Y-%m'))\n monthObject[:starting_balances] = calculateTotals(thisMonthBalances)\n end\n\n @transactions.each do |transaction|\n\n # Skip internal transfers\n if isInternalTransfer(transaction)\n next\n end\n\n # Find out what month we're in and retrieve relevant location in memory for object.\n monthObject = getMonthObject(DateTime.strptime(transaction['date'], '%Y-%m-%d').strftime('%Y-%m'))\n\n # If it's a month we don't recognize, skip to next transaction.\n if monthObject.nil?\n next\n end\n\n transactionRecognized = false\n transactionAdded = false\n\n # Check if transaction is recognized.\n @recognizedTransactions.each do |rt|\n if transaction['bank_account_id'].to_i == rt[:bank_account_id] && transaction['type'] == rt[:type] && rt[:terms].any? { |w| transaction['description'] =~ /#{w}/ }\n transactionRecognized = rt[:id]\n break\n end\n end\n\n # Process recurring transactions\n if transactionRecognized\n transactionAdded = true\n rt = @recognizedTransactionsIndexedID[\"#{transactionRecognized}\"]\n if rt[:intTypeID] == 1\n monthObject[:cash_in] = monthObject[:cash_in] + transaction['paid_in'].to_f\n elsif rt[:intTypeID] == 2\n if monthObject[:\"#{rt[:id]}\"].nil?\n monthObject[:\"#{rt[:id]}\"] = 0\n end\n monthObject[:\"#{rt[:id]}\"] = monthObject[:\"#{rt[:id]}\"] + transaction['paid_in'].to_f\n elsif rt[:intTypeID] == 3\n if monthObject[:\"#{rt[:id]}\"].nil?\n monthObject[:\"#{rt[:id]}\"] = 0\n end\n monthObject[:\"#{rt[:id]}\"] = monthObject[:\"#{rt[:id]}\"] + transaction['paid_out'].to_f\n else\n transactionAdded = false\n end\n end\n\n # Process remaining transactions (un-recurring)\n unless transactionAdded\n if transaction['paid_in'].to_f > 0\n monthObject[:misc_in] = monthObject[:misc_in] + transaction['paid_in'].to_f\n elsif transaction['paid_out'].to_f > 0\n monthObject[:misc_out] = monthObject[:misc_out] + transaction['paid_out'].to_f\n end\n end\n\n # Calculate Totals (for all transactions)\n if transaction['paid_in'].to_f > 0\n monthObject[:total_in] = monthObject[:total_in] + transaction['paid_in'].to_f\n elsif transaction['paid_out'].to_f > 0\n monthObject[:total_out] = monthObject[:total_out] + transaction['paid_out'].to_f\n end\n end\n\n # Monthly Totals\n @summaryData.each do |monthObject|\n if monthObject[0].to_s != 'monthTotal'\n monthObject[1].each do |key, value|\n unless key.to_s == 'starting_balances'\n if @summaryData[:monthTotal][:\"#{key}\"].nil?\n @summaryData[:monthTotal][:\"#{key}\"] = 0\n end\n @summaryData[:monthTotal][:\"#{key}\"] = @summaryData[:monthTotal][:\"#{key}\"] + value\n end\n end\n end\n end\n\n # Montly Profit Loss\n @summaryData.each do |monthObject|\n monthObject[1][:profit_loss] = monthObject[1][:total_in] - monthObject[1][:total_out]\n end\n end",
"def book_quantity(period='enddate', basis, exclude)\n volarray = []\n sales = self.book_sales(period, basis, exclude)\n sales.each do |sale|\n volarray << sale.quantities_by_band.inject(0) { |sum, i| sum + i }\n end\n book_quantity = volarray.inject(0) { |sum, i| sum +i.to_f }\n end",
"def getMiniWater\n #Water\n \n oldDate = nil\n if ( ! @water.nil? && @water.size > 0) then\n \n if ( @chartoptions[:water][0])\n \n @set1 = ChartItem.new(\"Ounces Water\") \n\n for water in @water\n if oldDate.nil?\n daily_water_sum = water.ounces\n oldDate = water.date.to_date\n @set1.addPoint(water.date.to_time.to_i * 1000, daily_water_sum)\n elsif oldDate != water.date.to_date\n @set1.addPoint(water.date.to_time.to_i * 1000, daily_water_sum)\n daily_water_sum = water.ounces\n oldDate = water.date.to_date\n else #must be same date as previous record (records should be ordered)\n daily_water_sum += water.ounces\n @set1.addPoint(water.date.to_time.to_i * 1000, daily_water_sum)\n end\n end \n \n #Make last post to chart\n if oldDate != @water.last.date.to_date then\n daily_water_sum += water.ounces\n @set1.addPoint(water.date.to_time.to_i * 1000, daily_water_sum)\n end\n \n \n if @chartoptions[:water][0]\n @miniWater.add(@set1)\n end \n end \n \n end\nend",
"def products_billing_summary_by_stock(year)\n\n current_year = DateTime.now.year\n\n # Build the result holder\n total_cost = 0\n stock_items = if current_year == year\n ::Yito::Model::Booking::BookingItem.all(conditions: {active: true},\n fields: [:reference, :cost],\n order: [:category_code, :reference])\n else\n BookingDataSystem::Booking.historic_stock(year).map do |item|\n OpenStruct.new({reference: item.item_reference, cost: 0})\n end\n end\n\n summary = stock_items.inject({}) do |result, item|\n data_holder = {}\n (1..12).each { |item| data_holder.store(item, 0) }\n data_holder.store(:total, 0)\n data_holder.store(:cost, item.cost || 0)\n data_holder.store(:percentage, 0)\n total_cost = total_cost + item.cost unless item.cost.nil?\n result.store(item.reference, data_holder)\n result\n end\n data_holder = {}\n (1..12).each { |item| data_holder.store(item, 0) }\n data_holder.store(:total, 0)\n data_holder.store(:cost, 0)\n data_holder.store(:percentage, 0)\n summary.store(:TOTAL, data_holder)\n # Fill the data\n data = query_strategy.products_billing_summary_by_stock(year)\n data.each do |data_item|\n if summary.has_key?(data_item.reference)\n # stock\n summary[data_item.reference][data_item.period.to_i] = data_item.total_item_cost\n summary[data_item.reference][:total] += data_item.total_item_cost\n if summary[data_item.reference][:cost] and summary[data_item.reference][:cost] > 0\n summary[data_item.reference][:percentage] = summary[data_item.reference][:total] /\n summary[data_item.reference][:cost] * 100\n end\n # total\n summary[:TOTAL][data_item.period.to_i] += data_item.total_item_cost\n summary[:TOTAL][:total] += data_item.total_item_cost\n summary[:TOTAL][:cost] = total_cost\n if summary[:TOTAL][:cost] and summary[:TOTAL][:cost] > 0\n summary[:TOTAL][:percentage] = summary[:TOTAL][:total] /\n summary[:TOTAL][:cost] * 100\n end\n end\n end\n\n return summary\n end",
"def set_doe_util_changes\n\n # there is no bldg_id column for sca projects\n buildings = self.school_buildings\n\n buildings_ids_array = buildings.map {|b| b['bldg_id']}.uniq\n\n doe_significant_utilization_changes = CeqrData::DoeSignificantUtilizationChanges.version(\n data_package.table_for(\"doe_significant_utilization_changes\")\n ).doe_util_changes_matching_with_building_ids(buildings_ids_array)\n\n self.doe_util_changes = doe_significant_utilization_changes.map do |d|\n {\n url: d[:url],\n title: d[:title],\n org_id: d[:org_id],\n bldg_id: d[:bldg_id],\n vote_date: d[:vote_date],\n at_scale_year: d[:at_scale_year],\n at_scale_enroll: d[:at_scale_enroll],\n bldg_id_additional: d[:bldg_id_additional]\n }\n end\nend",
"def revenue_account_for_journal\n revenue_account\n end",
"def stored_data; end",
"def store_yardi_summary_files\n doc = Document.find_by_id(@options[:doc_id])\n period = ''\n date_err = false\n month = year = nil\n get_all_sheets.each do |sheet|\n if !read_via_numeral_abs(1, 1, sheet).blank? and read_via_numeral_abs(1, 1, sheet).downcase == 'boxscore summary'\n unless read_via_numeral_abs(3, 1, sheet).blank?\n dts = read_via_numeral_abs(3, 1, sheet).split(' = ').last.split('-')\n begin\n dts[0] = dts[0].to_date\n dts[1] = dts[1].to_date\n rescue\n date_err = true\n end\n unless date_err\n if dts[0] < dts[1] && dts[0].month == dts[1].month && (dts[1] - dts[0]).to_i > 27 && dts[1].year == dts[0].year\n month = dts[0].month\n year = dts[0].year\n period = 'year'\n elsif dts[0] < dts[1] && (dts[1] - dts[0]).to_i == 6\n period = 'weekly'\n else\n period = 'quit'\n doc.update_attribute('parsing_done',false)\n end\n end\n end\n if period == 'year'\n 6.upto find_last_base_cell(sheet) do |row|\n if read_via_numeral_abs(row, 1, sheet).blank? and !read_via_numeral_abs(row, 2, sheet).blank? and read_via_numeral_abs(row, 2, sheet).strip == 'Total'\n property_occupancy_summary = PropertyOccupancySummary.find_or_create_by_real_estate_property_id_and_year_and_month(doc.real_estate_property_id, year, month)\n property_occupancy_summary.total_building_rentable_s = read_via_numeral_abs(row, 3, sheet)\n property_occupancy_summary.current_year_sf_occupied_actual = (property_occupancy_summary.total_building_rentable_s.to_f * (read_via_numeral_abs(row,17,sheet).blank? ? 1 : read_via_numeral_abs(row,17,sheet).to_f)) / 100 rescue 0\n property_occupancy_summary.current_year_sf_vacant_actual = property_occupancy_summary.total_building_rentable_s - property_occupancy_summary.current_year_sf_occupied_actual rescue 0\n property_occupancy_summary.vacant_leased_number = read_via_numeral_abs(row, 7, sheet).blank? ? 0 : read_via_numeral_abs(row, 7, sheet).to_i\n property_occupancy_summary.vacant_leased_percentage = (property_occupancy_summary.vacant_leased_number.to_f / (read_via_numeral_abs(row, 5, sheet).blank? ? 1 : read_via_numeral_abs(row, 5, sheet).to_f)) * 100 rescue 0\n property_occupancy_summary.currently_vacant_leases_number = property_occupancy_summary.vacant_leased_number + (read_via_numeral_abs(row, 8, sheet).blank? ? 0 : read_via_numeral_abs(row, 8, sheet).to_f)\n property_occupancy_summary.currently_vacant_leases_percentage = ( property_occupancy_summary.currently_vacant_leases_number.to_f / (read_via_numeral_abs(row, 5, sheet).blank? ? 1 : read_via_numeral_abs(row, 5, sheet).to_f)) * 100 rescue 0\n property_occupancy_summary.occupied_preleased_number = read_via_numeral_abs(row, 9, sheet).blank? ? 0 : read_via_numeral_abs(row, 9, sheet).to_i\n property_occupancy_summary.occupied_preleased_percentage = (property_occupancy_summary.occupied_preleased_number.to_f / (read_via_numeral_abs(row, 5, sheet).blank? ? 1 : read_via_numeral_abs(row, 5, sheet).to_f)) * 100 rescue 0\n property_occupancy_summary.occupied_on_notice_number = property_occupancy_summary.occupied_preleased_number + (read_via_numeral_abs(row, 10, sheet).blank? ? 0 : read_via_numeral_abs(row, 10, sheet).to_i)\n property_occupancy_summary.occupied_on_notice_percentage = (property_occupancy_summary.occupied_on_notice_number.to_f / (read_via_numeral_abs(row, 5, sheet).blank? ? 1 : read_via_numeral_abs(row, 5, sheet).to_f)) * 100 rescue 0\n property_occupancy_summary.net_exposure_to_vacancy_number = (property_occupancy_summary.currently_vacant_leases_number - property_occupancy_summary.vacant_leased_number) + (property_occupancy_summary.occupied_on_notice_number - property_occupancy_summary.occupied_preleased_number)\n property_occupancy_summary.net_exposure_to_vacancy_percentage = (property_occupancy_summary.net_exposure_to_vacancy_number.to_f / (read_via_numeral_abs(row, 5, sheet).blank? ? 1 : read_via_numeral_abs(row, 5, sheet).to_f)) * 100 rescue 0\n property_occupancy_summary.current_year_units_total_actual = read_via_numeral_abs(row, 5, sheet).to_f\n property_occupancy_summary.current_year_units_occupied_actual = (property_occupancy_summary.current_year_units_total_actual.to_f * (read_via_numeral_abs(row,17,sheet).blank? ? 1 : read_via_numeral_abs(row,17,sheet).to_f)) / 100 rescue 0\n property_occupancy_summary.current_year_units_vacant_actual = property_occupancy_summary.current_year_units_total_actual - property_occupancy_summary.current_year_units_occupied_actual rescue 0\n property_occupancy_summary.save\n break\n end\n end if !date_err && month && year && period # check the excel file is valid.\n elsif period == \"weekly\"\n index_hash = {}\n availability, conversion = false, false\n 4.upto find_last_base_cell(sheet) do |row|\n if !read_via_numeral_abs(row, 1, sheet).blank? && [\"Availability\", \"Conversion Ratios\", \"Resident Activity\"].include?(read_via_numeral_abs(row, 1, sheet))\n availability = true if read_via_numeral_abs(row, 1, sheet) == \"Availability\"\n conversion = true if read_via_numeral_abs(row, 1, sheet) == \"Conversion Ratios\"\n elsif read_via_numeral_abs(row, 1, sheet).blank? && !read_via_numeral_abs(row, 2, sheet).blank? && read_via_numeral_abs(row, 2, sheet) == 'Total'\n availability, conversion = false, false\n elsif !read_via_numeral_abs(row, 1, sheet).blank? && !read_via_numeral_abs(row, 2, sheet).blank?\n if availability\n index_hash.update({read_via_numeral_abs(row, 1, sheet)=> ''})\n elsif conversion\n index_hash.update({read_via_numeral_abs(row, 1, sheet)=> row}) if index_hash.include? read_via_numeral_abs(row, 1, sheet)\n end\n end\n end\n 4.upto find_last_base_cell(sheet) do |row|\n unless read_via_numeral_abs(row, 1, sheet) == 'Code' && index_hash.include?(read_via_numeral_abs(row, 1, sheet))\n obj = PropertyWeeklyOsr.find_or_initialize_by_real_estate_property_id_and_floor_plan_and_time_period(doc.real_estate_property_id, read_via_numeral_abs(row, 1, sheet),dts[1].strftime(\"%Y-%m-%d\"))\n obj.user_id = doc.user_id\n obj.units = read_via_numeral_abs(row, 5, sheet)\n obj.prelsd = read_via_numeral_abs(row, 7, sheet).blank? ? 0 : read_via_numeral_abs(row, 7, sheet).to_i\n obj.vacant_total = obj.prelsd + (read_via_numeral_abs(row, 8, sheet).blank? ? 0 : read_via_numeral_abs(row, 8, sheet).to_i)\n obj.prelsd2 = read_via_numeral_abs(row, 9, sheet).blank? ? 0 : read_via_numeral_abs(row, 9, sheet).to_i\n obj.ntv_status_total = obj.prelsd2 + (read_via_numeral_abs(row, 10, sheet).blank? ? 0 : read_via_numeral_abs(row, 10, sheet).to_i)\n obj.current = obj.vacant_total + obj.ntv_status_total\n obj.pi_total = read_via_numeral_abs(index_hash[read_via_numeral_abs(row, 1, sheet)], 3, sheet)\n obj.wi_total = read_via_numeral_abs(index_hash[read_via_numeral_abs(row, 1, sheet)], 4, sheet)\n obj.dep_total = read_via_numeral_abs(index_hash[read_via_numeral_abs(row, 1, sheet)], 9, sheet)\n obj.dep_rej = read_via_numeral_abs(index_hash[read_via_numeral_abs(row, 1, sheet)], 14, sheet)\n obj.dep_canc = read_via_numeral_abs(index_hash[read_via_numeral_abs(row, 1, sheet)], 15, sheet)\n obj.save\n end if !read_via_numeral_abs(row, 1, sheet).blank? && !read_via_numeral_abs(row, 2, sheet).blank?\n break if read_via_numeral_abs(row, 1, sheet).blank? && !read_via_numeral_abs(row, 2, sheet).blank? && read_via_numeral_abs(row, 2, sheet) == 'Total'\n end unless index_hash.empty?\n end\n end\n end\n end",
"def save\n update_dc\n super \n end",
"def calculated; end",
"def mark_up()\n return @retail_price-@buying_cost\n end",
"def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end",
"def manufacture; end",
"def industry; end",
"def revenue\n end",
"def getSavingsPaymentCollectionRecordObjName\r\n\t\t return \"mfiforce__savings_payment_collection_record__c\"\r\n\t\tend",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def revenue_report(start_date,end_date)\n report = OpenStruct.new\n\n days_range = [30,(end_date - start_date).to_i].max\n\n articles = self.articles.no_agcon.where(\"pub_date IN (?)\",start_date..end_date)\n articles_and_views = articles.joins(:views).where(\"views.article_age <= ?\",days_range)\n stats = self.site_stats.where(\"month IN (?)\", start_date..end_date)\n\n report.new_articles_count = articles.count\n\n report.gross_revenue = stats.sum(:revenue)\n report.total_content_cost = articles.sum(:total_cost)\n report.average_content_cost = articles.average(:total_cost)\n\n report.net_revenue = report.gross_revenue - report.total_content_cost\n\n report.total_views = stats.sum(:pageviews).to_i\n report.new_content_views = articles_and_views.sum(:pageviews).to_i\n report.old_content_views = report.total_views - report.new_content_views\n\n\n report.gross_revenue_per_view = report.gross_revenue/report.total_views\n report.old_content_revenue = report.gross_revenue_per_view * report.old_content_views\n\n report.new_content_avg_views = report.new_content_views/report.new_articles_count\n\n report.new_content_gross_revenue = report.gross_revenue_per_view * report.new_content_views\n report.new_content_net_revenue = report.new_content_gross_revenue - report.total_content_cost\n\n report.new_content_avg_gross_revenue = report.new_content_gross_revenue/report.new_articles_count\n report.new_content_avg_net_revenue = report.new_content_net_revenue/report.new_articles_count\n\n return report\n\n\n end",
"def assign_back_office_data(response)\n @flbt_type = response[:flbt_type]\n @srv_code = response[:service_code]\n @version = response[:tare_version]\n @submitted_date = response[:submitted_date]\n @effective_date = response[:effective_date]\n @filing_date = response[:filing_date]\n @number_of_buyers = response[:no_of_buyers].to_i\n @ads_included = (response[:ads_included] == 'Y')\n @ads_amount = response[:ads_amount]\n end",
"def savings\n read_attribute(:price) - read_attribute(:sale_price)\n end",
"def store; end",
"def store; end",
"def store; end",
"def summer_paralympics_sport; end",
"def calculate!\n # When expanding the application to support multi-week pay periods, this code must be modified\n minutes_this_week = []\n daily_limit = 8 * 60 # in minutes\n weekly_limit = 40 * 60 # in minutes\n\n entries = employee_entries.reload # TODO: sort logic here \n \n entries.each do |e|\n duration = e.duration || 0\n date = e.payroll_worked_date = e.ticket.first_employee_entry\n \n minutes_this_week[e.employee_id] ||= { total: 0 }\n minutes_this_week[e.employee_id][date] ||= 0\n minutes_this_week[e.employee_id][date] += duration\n minutes_this_week[e.employee_id][:total] += duration\n \n overtime_today = minutes_this_week[e.employee_id][date] - daily_limit\n overtime_this_week = minutes_this_week[e.employee_id][:total] - weekly_limit\n overtime_max = [overtime_today, overtime_this_week, 0].max\n \n e.payroll_duration_standard = duration - overtime_max\n e.payroll_duration_standard = 0 if e.payroll_duration_standard < 0\n e.payroll_duration_overtime = duration - e.payroll_duration_standard\n \n e.payroll_bill_to = e.ticket.bill_to\n e.payroll_job_id = e.ticket.job_id\n e.payroll_status = if e.on_the_job? and e.payroll_job_id\n :bill_to_job\n else\n :overhead\n end\n e.payroll_pay_rate = if e.ticket.job\n e.ticket.pay_rate\n else\n :day_pay\n end\n \n e.payroll_category_string = \"#{e.employee_id} - #{e.payroll_bill_to} - #{e.payroll_job_id} - #{e.payroll_pay_rate} - #{e.payroll_status}\"\n \n e.save!\n end\n end",
"def get_da_summary(page, da_container, detail_page)\n #get info by list item page\n item_general_info = get_item_general_info(page, da_container)\n da_summary = false\n p \"KKKKKKKKKKKKKK\"\n p Date.parse(item_general_info[:date_received])\n p FROM_DATE\n if Date.parse(item_general_info[:date_received]) >= FROM_DATE\n #get info by item detail page\n item_detail_info= get_item_detail_info(detail_page)\n da_summary = {\n 'council_reference' => item_general_info[:council_reference],\n 'address' => item_general_info[:address],\n 'description' => item_general_info[:description],\n 'info_url' => item_general_info[:info_url],\n 'comment_url' => item_general_info[:comment_url],\n 'date_scraped' => item_general_info[:date_scraped],\n \n 'applicant' => item_detail_info[:applicant],\n 'decision' => item_detail_info[:decision],\n 'date' => item_detail_info[:date],\n 'date_received' => item_general_info[:date_received] \n }\n end\n return da_summary\nend",
"def get_da_summary(page, da_container, detail_page)\n #get info by list item page\n item_general_info = get_item_general_info(page, da_container)\n da_summary = false\n p \"KKKKKKKKKKKKKK\"\n p Date.parse(item_general_info[:date_received])\n p FROM_DATE\n if Date.parse(item_general_info[:date_received]) >= FROM_DATE\n #get info by item detail page\n item_detail_info= get_item_detail_info(detail_page)\n da_summary = {\n 'council_reference' => item_general_info[:council_reference],\n 'address' => item_general_info[:address],\n 'description' => item_general_info[:description],\n 'info_url' => item_general_info[:info_url],\n 'comment_url' => item_general_info[:comment_url],\n 'date_scraped' => item_general_info[:date_scraped],\n \n 'applicant' => item_detail_info[:applicant],\n 'decision' => item_detail_info[:decision],\n 'date' => item_detail_info[:date],\n 'date_received' => item_general_info[:date_received] \n }\n end\n return da_summary\nend",
"def save_expiry_date_period(month, year, day, product_id, part_number)\n\n \t# First we check if the date is already in the table\n \tif(Calendar.where(year: year, month: month).blank?)\n \t c = Calendar.new(year: year, month: month)\n \t c.info = get_info(day, product_id, part_number)\n \t c.save\n \telse\n \t c = Calendar.where(month: month, year: year)\n \t string = c.info\n \t c.info = get_info(day, product_id, part_number, string)\n \t c.info.save\n \tend\n end",
"def update_defaultee_savings_deduction\n default_payment = self.default_payment \n total_compulsory_savings = self.total_compulsory_savings\n total_voluntary_savings = self.total_voluntary_savings\n total_deductible_member_savings = total_compulsory_savings + total_extra_savings\n \n # refresh the state \n default_payment.compulsory_savings_deduction_amount = BigDecimal(\"0\")\n default_payment.voluntary_savings_deduction_amount = BigDecimal(\"0\")\n default_payment.amount_to_be_shared_with_non_defaultee = BigDecimal(\"0\")\n \n total_amount = default_payment.outstanding_grace_period_amount \n \n if total_amount <= total_compulsory_savings\n default_payment.compulsory_savings_deduction_amount = total_amount \n elsif total_amount > total_compulsory_savings && total_amount <= total_deductible_member_savings \n default_payment.amount_of_compulsory_savings_deduction = total_compulsory_savings \n default_payment.voluntary_savings_deduction_amount = total_amount - total_compulsory_savings\n elsif total_amount > total_deductible_member_savings \n default_payment.compulsory_savings_deduction_amount = total_compulsory_savings \n default_payment.voluntary_savings_deduction_amount = total_extra_savings\n default_payment.amount_to_be_shared_with_non_defaultee = total_amount - total_deductible_member_savings\n end \n \n default_payment.save\n end",
"def compute_and_present(reports)\n alltime_proceeds_per_currency = {} #currency is the key, value is the proceeds\n alltime_renewables = 0\n alltime_apps = {}\n alltime_payed_units = 0\n alltime_inapp_units = 0\n alltime_free_units = 0\n alltime_updated_units = 0\n \n first_date = reports[0].split('_').last.split('.').first\n reports.each do |alltime_filename|\n\n puts \"Processing #{alltime_filename}\".green if @beVerbose\n\n #get the date from the filename\n date = alltime_filename.split('_').last.split('.').first #filename example: S_D_80076793_20120706.txt\n\n report_data = File.open(alltime_filename, \"rb\").read \n\n report = parse(report_data)\n #puts report.class\n if report #report parsed\n apps = {}\n total_payed_units = 0\n total_inapp_units = 0\n total_free_units = 0\n total_updated_units = 0\n report.each do |item| #report is a hash \n if item\n sku = item[:sku] #group data by app sku\n if apps.has_key? sku #app is already cached\n app = apps[sku]\n else #initially insert app\n app = {:sku=>sku, :title=>item[:title], :sold_units=>0, :updated_units=>0}\n apps[sku] = app\n end\n #ensure currency sum\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] = 0.0 unless alltime_proceeds_per_currency[item[:currency_of_proceeds]]\n \n #count units\n if SALE_IDENTS.include? item[:product_type_id] #count sales\n app[:sold_units] += item[:units]\n if item[:customer_price]==0 #a free app\n total_free_units += item[:units]\n else \n total_payed_units += item[:units]\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] += item[:developer_proceeds] * item[:units]\n end\n elsif INAPP_SALE_IDENTS.include? item[:product_type_id]\n app[:sold_units] += item[:units]\n total_inapp_units += item[:units]\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] += item[:developer_proceeds] * item[:units]\n if item[:product_type_id] == \"IAY\" #InAppPurchase\n alltime_renewables += item[:units]\n end\n elsif UPDATE_IDENTS.include? item[:product_type_id] #count updates\n app[:updated_units] += item[:units]\n total_updated_units += item[:units]\n end \n else # only if item \n puts \"null report\".red\n end\n end\n\n #add to the alltime stats\n alltime_payed_units += total_payed_units\n alltime_inapp_units += total_inapp_units\n alltime_free_units += total_free_units\n alltime_updated_units += total_updated_units\n \n apps.each do |alltime_sku, apps_app| \n #select the app\n if alltime_apps.has_key? alltime_sku\n #already cached\n alltime_app = alltime_apps[alltime_sku]\n else\n #insert for the first time\n alltime_app = {:sku=>alltime_sku, :title=>apps_app[:title], :sold_units=>0, :updated_units=>0} \n alltime_apps[alltime_sku] = alltime_app\n end\n #add stats\n alltime_app[:sold_units] += apps_app[:sold_units]\n alltime_app[:updated_units] += apps_app[:updated_units]\n end\n\n if @beVerbose && reports.size>1\n #report for date\n puts \"\\n\\n______________________________________________________________\".blue\n puts \"Report for #{date}\"\n puts \"\\n\" + \"Product\".ljust(40).blue + \": \" +\"Downloads\".green + \" / \" + \"Updates\".green\n puts \"______________________________________________________________\".yellow\n apps.each do |app_sku,apps_app|\n puts \"#{apps_app[:title].ljust(40).blue}: #{apps_app[:sold_units].to_s.ljust(10).green} / #{apps_app[:updated_units].to_s.rjust(7).dark_green}\"\n end \n puts \"______________________________________________________________\".yellow\n puts \"#{'InApp Purchases'.ljust(40).green}: #{total_inapp_units}\"\n puts \"#{'Payed Downloads'.ljust(40).green}: #{total_payed_units}\"\n puts \"#{'Free Downloads'.ljust(40).dark_green}: #{total_free_units}\"\n puts \"#{'Updates'.ljust(40).dark_green}: #{total_updated_units}\"\n puts \"______________________________________________________________\".blue\n puts \"\\n\\n\"\n end #if @beVerbose\n\n else \n puts \"null report parsed\".red\n end #if report parsed\n \n end #reports.each\n\n #report alltime\n puts \"\\n\\n______________________________________________________________\".blue\n from = Date.strptime first_date, '%Y%m%d'\n age = Date.today - from \n formatted_from = from.strftime(\"%b %d %Y\")\n puts \"Report\" + (ARGV[0]? \" #{ARGV[0]}\":\" daily\") + \", from #{formatted_from}, #{age.to_i} days\"\n puts \"\\n\" + \"Product\".ljust(40).blue + \": \" +\"Downloads\".green + \" / \" + \"Updates\".green\n puts \"______________________________________________________________\".yellow\n alltime_apps.each do |app_sku, aapp|\n puts \"#{aapp[:title].ljust(40).blue}: #{aapp[:sold_units].to_s.ljust(10).green} / #{aapp[:updated_units].to_s.rjust(7).dark_green}\"\n end \n puts \"______________________________________________________________\".yellow\n puts \"#{'InApp Purchases'.ljust(40).green}: #{alltime_inapp_units}\" + ( alltime_renewables > 0.0 ? \" / #{alltime_renewables} Auto-Renewed\" : \"\")\n puts \"#{'Payed Downloads'.ljust(40).green}: #{alltime_payed_units}\"\n puts \"#{'Free Downloads'.ljust(40).dark_green}: #{alltime_free_units}\"\n puts \"#{'Updates'.ljust(40).dark_green}: #{alltime_updated_units}\"\n puts \"\\n#{'Proceeds'.red}:\\n\\n\"\n total_proceeds = 0.0\n alltime_proceeds_per_currency.each do |proceed_key, proceed| \n formatted_sum = proceed > 0.0 ? \"#{proceed}\".green : \"#{proceed}\".red\n if proceed > 0.0\n if proceed_key == @convertTo\n total_proceeds += proceed\n puts \"#{proceed_key} : #{formatted_sum}\"\n else\n #convert using google\n data = open(\"http://www.google.com/ig/calculator?q=#{proceed}#{proceed_key}=?#{@convertTo}\").read\n #fix broken json\n data.gsub!(/lhs:/, '\"lhs\":')\n data.gsub!(/rhs:/, '\"rhs\":')\n data.gsub!(/error:/, '\"error\":')\n data.gsub!(/icc:/, '\"icc\":')\n data.gsub!(Regexp.new(\"(\\\\\\\\x..|\\\\\\\\240)\"), '') \n #puts data\n converted = JSON.parse data\n converted_proceed = converted[\"rhs\"].split(' ').first.to_f\n total_proceeds += converted_proceed\n puts \"#{proceed_key} : #{formatted_sum} / #{converted['rhs']}\"\n end\n end\n end\n puts \"\\n#{'Total'.green}: #{total_proceeds} #{@convertTo}\"\n puts \"______________________________________________________________\".blue\n puts \"\\n\\n\" \nend",
"def update_total_savings_account\n incoming = member.savings_entries.where(\n :savings_status => SAVINGS_STATUS[:savings_account],\n :direction => FUND_DIRECTION[:incoming]\n ).sum(\"amount\") \n \n outgoing = member.savings_entries.where(\n :savings_status => SAVINGS_STATUS[:savings_account],\n ).sum(\"amount\")\n \n self.total_savings_account = incoming - outgoing \n self.save\n end",
"def create_amount_to_bill_report\n\t\t\n\t\treport = {}\n\n\t\t@partners.each do |partner|\n\t\t\tnext if(partner.program_type == :direct) \n\t\t\treport[partner.partner_name] = {}\n\n\t\t\treport[partner.partner_name][:amount_to_bill] = partner.amount_due \n\t\tend\n\n\t\treport\n\tend",
"def update_deal_costs(deal)\n end",
"def sum_auction(sold_flg, date_type, domestic_flg)\n # use plus if bought\n auction = Auction.select(\"SUM(price * (tax_rate + 100) / 100 + \" \\\n + \"COALESCE(payment_cost, 0) + COALESCE(shipment_cost, 0)) as amount\") if sold_flg == 0\n # use minus if sold\n auction = Auction.select(\"SUM(price * (tax_rate + 100) / 100 - \" \\\n + \"COALESCE(payment_cost, 0) - COALESCE(shipment_cost, 0)) as amount\") if sold_flg == 1\n # for domestic_flg\n auction = auction.joins(\" LEFT OUTER JOIN pa_maps ON auctions.auction_id = pa_maps.auction_id \") \\\n .joins(\" LEFT JOIN products ON pa_maps.product_id = products.product_id \") if domestic_flg != 2\n # for domestic_flg\n auction = auction.where(\" (products.is_domestic is null or products.is_domestic != 0) \") if domestic_flg == 1\n auction = auction.where(\" products.is_domestic = 0 \") if domestic_flg == 0\n # for sold_flg\n auction = auction.where(sold_flg: sold_flg)\n # all\n return auction.reorder('').first.amount.to_i if date_type == 0\n # date interval\n beginning_date = Time.zone.now.beginning_of_year\n beginning_date = Time.zone.now.beginning_of_month if date_type == 2\n end_date = Time.zone.now.end_of_year\n end_date = Time.zone.now.end_of_month if date_type == 2\n # year or month\n return auction.where(\"end_time >= :date_s\", {:date_s => beginning_date}) \\\n .where(\"end_time <= :date_e\", {:date_e => end_date}).reorder('').first.amount.to_i\n end",
"def recalc_totals_from_db!\n self.subtotal = self.time_entries.sum(:total_amount) + self.expense_entries.sum(:total_amount)\n self.paid = self.payment_allocates.sum(:amount)\n self.save!\n end",
"def weighIntrade()\n\n end",
"def new_flight_record\n return unless has_permission :can_do_billing\n @page_title = 'New Flight Record Sheet'\n \n @users = User.find(:all,:conditions=>['account_suspended = false'])\n @instructors = Group.users_in_group('instructor')\n former_instructors = Group.users_in_group('former_instructor')\n former_instructors.each{|i|\n if not @instructors.include?(i)\n @instructors << i\n end\n }\n \n @aircrafts = Aircraft.find(:all,:conditions=>['deleted = false'])\nend",
"def daily_aggregate_data\n data = FbPost.select(\"count(*) AS post_count,sum(likes) as likes, sum(comments) as comments, sum(shares) as shares,sum(replies_to_comment) as replies_to_comment\").\n where(account_id: self.id).to_a.first\n if data\n z = self.graph_api.get_object self.object_name\n options = {:likes=>data.likes, \n :comments=>data.comments,\n :shares=>data.shares,\n :posts => data.post_count,\n :replies_to_comment => data.replies_to_comment\n }\n if z['likes']\n options[:total_likes]=z['likes']\n today_page.total_likes=z['likes']\n end\n if z['talking_about_count']\n options[:total_talking_about] = z['talking_about_count']\n today_page.total_talking_about=z['talking_about_count']\n end\n curr_date = Time.zone.now.middle_of_day\n options[:post_created_time] = curr_date\n if today_page.total_likes && yesterday_page && yesterday_page.total_likes\n today_page.fan_adds_day =today_page.total_likes - yesterday_page.total_likes\n end\n today_page.update_attributes options\n today_fbpage.update_attributes options # for table fbpages\n logger.debug \" daily_aggregate_data for #{curr_date.to_s(:db)}\"\n else\n logger.debug \" daily_aggregate_data NOT RECORDS for \"\n end\n end",
"def aggregate\r\n calc_id = Calculation.find(params[:id]).id\r\n # loeschen alter Werte\r\n Demand0.where(calculation_id: calc_id).delete_all\r\n Demand1.where(calculation_id: calc_id).delete_all\r\n Demand2.where(calculation_id: calc_id).delete_all\r\n @specialty = Specialty.all\r\n\r\n #if Demand0.where(calculation_id: calc_id).empty?\r\n \r\n dem_mon = 0\r\n dem_tue = 0\r\n dem_wed = 0\r\n dem_thu = 0\r\n dem_fri = 0\r\n\r\n# Fuer alle Specialties summiere die OP Zeiten der Patienten Typ 0 \r\n @specialty.each do |n|\r\n dem_mon = Patient.where(:specialty_id => [Specialty.find(n).id]).where(:startday_of_stay =>'Mon').where(:type_of_patient =>'0').sum(:op_time)\r\n dem_tue = Patient.where(:specialty_id => [Specialty.find(n).id]).where(:startday_of_stay =>'Tue').where(:type_of_patient =>'0').sum(:op_time)\r\n dem_wed = Patient.where(:specialty_id => [Specialty.find(n).id]).where(:startday_of_stay =>'Wed').where(:type_of_patient =>'0').sum(:op_time)\r\n dem_thu = Patient.where(:specialty_id => [Specialty.find(n).id]).where(:startday_of_stay =>'Thu').where(:type_of_patient =>'0').sum(:op_time)\r\n dem_fri = Patient.where(:specialty_id => [Specialty.find(n).id]).where(:startday_of_stay =>'Fri').where(:type_of_patient =>'0').sum(:op_time)\r\n Demand0.create!(calculation_id: calc_id, specialty_id: Specialty.find(n).id, Mon: dem_mon, Tue: dem_tue, Wed: dem_wed, Thu: dem_thu, Fri: dem_fri)\r\n end\r\n\r\n @specialty.each do |m|\r\n dem_mon = Patient.where(:specialty_id => [Specialty.find(m).id]).where(:startday_of_stay =>'Mon').where(:type_of_patient =>'1').sum(:op_time)\r\n dem_tue = Patient.where(:specialty_id => [Specialty.find(m).id]).where(:startday_of_stay =>'Tue').where(:type_of_patient =>'1').sum(:op_time)\r\n dem_wed = Patient.where(:specialty_id => [Specialty.find(m).id]).where(:startday_of_stay =>'Wed').where(:type_of_patient =>'1').sum(:op_time)\r\n dem_thu = Patient.where(:specialty_id => [Specialty.find(m).id]).where(:startday_of_stay =>'Thu').where(:type_of_patient =>'1').sum(:op_time)\r\n dem_fri = Patient.where(:specialty_id => [Specialty.find(m).id]).where(:startday_of_stay =>'Fri').where(:type_of_patient =>'1').sum(:op_time)\r\n Demand1.create!(calculation_id: calc_id, specialty_id: Specialty.find(m).id, Mon: dem_mon, Tue: dem_tue, Wed: dem_wed, Thu: dem_thu, Fri: dem_fri)\r\n end\r\n\r\n @specialty.each do |o|\r\n dem_mon = Patient.where(:specialty_id => [Specialty.find(o).id]).where(:startday_of_stay =>'Mon').where(:type_of_patient =>'2').sum(:op_time)\r\n dem_tue = Patient.where(:specialty_id => [Specialty.find(o).id]).where(:startday_of_stay =>'Tue').where(:type_of_patient =>'2').sum(:op_time)\r\n dem_wed = Patient.where(:specialty_id => [Specialty.find(o).id]).where(:startday_of_stay =>'Wed').where(:type_of_patient =>'2').sum(:op_time)\r\n dem_thu = Patient.where(:specialty_id => [Specialty.find(o).id]).where(:startday_of_stay =>'Thu').where(:type_of_patient =>'2').sum(:op_time)\r\n dem_fri = Patient.where(:specialty_id => [Specialty.find(o).id]).where(:startday_of_stay =>'Fri').where(:type_of_patient =>'2').sum(:op_time)\r\n Demand2.create!(calculation_id: calc_id, specialty_id: Specialty.find(o).id, Mon: dem_mon, Tue: dem_tue, Wed: dem_wed, Thu: dem_thu, Fri: dem_fri)\r\n end\r\n\r\n flash[:started] = \"Demands calculated!\"\r\n redirect_to calculations_path\r\n # else\r\n # flash[:not_available] = \"Demands already aggregated!\"\r\n # redirect_to calculations_path\r\n # end\r\n end",
"def trade; end",
"def offenses; end",
"def offenses; end",
"def offenses; end",
"def create_additional_records\n case params[:mx_type]\n when 'gmail'\n create_gmail_records\n when 'godaddy'\n create_godaddy_records\n when 'networksolutions'\n create_networksolutions_records\n else\n return\n end\n end",
"def record_sales\n @deleted_lines.each {|l| l.delete}\n @deleted_lines.clear\n calc_values\n save\n @lines.each do |li|\n li.li_order_id = @data_object.order_id\n li.save\n end\n end",
"def import_stock_daily\n JdeItemAvailability.checking_stock_daily\n end",
"def company; end",
"def company; end",
"def group_matter_accounting_rpt(tcol,ecol)\r\n conditions,data,total_data,total_expenses,matter_name = {},[],{},{},nil\r\n lookup_activities = current_company.company_activity_types\r\n activities = ReportsHelper.get_lookups(lookup_activities)\r\n lookup_activities = Physical::Timeandexpenses::ExpenseType.find(:all)\r\n exp_activities = ReportsHelper.get_lookups(lookup_activities)\r\n tcol.group_by(&:matter_id).each_value do|col|\r\n key,contact = nil,nil\r\n duration,billamount,discount,override,markup,finalamount = 0.00,0.00,0.00,0.00,0.00,0.00\r\n col.each do |obj|\r\n @dur_setng_is_one100th ? actual_duration = one_hundredth_timediffernce(obj.actual_duration) : actual_duration = one_tenth_timediffernce(obj.actual_duration)\r\n next unless obj.matter\r\n key = obj.matter.clipped_name unless key\r\n matter_name = obj.matter.name unless matter_name\r\n contact = (obj.matter.contact ? obj.matter.contact.name : nil) unless contact\r\n duration += actual_duration.to_f if actual_duration\r\n billamount = billamount + (obj.actual_activity_rate * actual_duration.to_f)\r\n discount += obj.billing_percent if obj.billing_percent\r\n override += obj.final_billed_amount if obj.billing_method_type == 3\r\n finalamount += obj.final_billed_amount if obj.final_billed_amount \r\n data << [obj.time_entry_date.to_s,obj.performer.try(:full_name).try(:titleize),rounding(actual_duration.to_f),activities[obj.activity_type],obj.is_billable ? \"Yes\" : \"No\",rounding(obj.actual_activity_rate),rounding(obj.actual_activity_rate * actual_duration.to_f),rounding(obj.billing_percent),obj.billing_method_type == 3 ? rounding(obj.final_billed_amount) : '',rounding(obj.final_billed_amount)]\r\n end\r\n next unless key\r\n \r\n total_data[key] = data\r\n conditions[key] = [contact,rounding(duration),rounding(billamount),rounding(discount),rounding(override),rounding(finalamount),matter_name]\r\n data = []\r\n end\r\n\r\n ecol.group_by(&:matter_id).each_value do|col| \r\n key,contact = nil,nil\r\n override,finalamount,markupamt,bill_amount,disc_sum = 0.00,0.00,0.00,0.00,0.00\r\n col.each do |obj|\r\n next unless obj.matter\r\n bill_amount += obj.expense_amount if obj.expense_amount\r\n disc_sum += obj.billing_percent if obj.billing_percent\r\n override += obj.final_expense_amount if obj.billing_method_type == 3\r\n markupamt += obj.markup if obj.markup\r\n finalamount += obj.final_expense_amount if obj.final_expense_amount\r\n key = obj.matter.clipped_name unless key\r\n contact = (obj.matter.contact ? obj.matter.contact.name : nil) unless contact\r\n data << [obj.expense_entry_date.to_s,obj.performer.try(:full_name).try(:titleize),exp_activities[obj.expense_type],obj.is_billable ? \"Yes\" : \"No\",rounding(obj.expense_amount),rounding(obj.billing_percent),obj.billing_method_type == 3 ? rounding(obj.final_expense_amount) : '',markupamt,rounding(obj.final_expense_amount)]\r\n end\r\n next unless key\r\n \r\n total_expenses[key] = [data,rounding(override),rounding(finalamount),rounding(bill_amount),rounding(disc_sum),rounding(markupamt)]\r\n unless conditions.has_key?(key)\r\n conditions[key] = [contact]\r\n end\r\n data = []\r\n end\r\n [total_data,total_expenses,conditions]\r\n \r\n end",
"def get_view_and_redemption_count_by_day(deals, start_date, end_date, total)\n overall_deals_array = Array.new\n deals.each do |d|\n num_view_array = Array.new\n num_redeem_array = Array.new\n deal_array = Array.new\n view_start_date = Viewcount.where(:deal_id => d.id).order(created_at: :asc).first\n if view_start_date.blank?\n view_start_date = DateTime.now.in_time_zone(\"Singapore\").beginning_of_day\n else\n view_start_date = view_start_date.created_at.beginning_of_day\n end\n temp = view_start_date\n\n # If start date of deal is after given start date, we will start from deal start date\n if d.start_date > start_date\n redemption_start_date = d.start_date.in_time_zone(\"Singapore\").beginning_of_day\n else\n redemption_start_date = start_date.in_time_zone(\"Singapore\").beginning_of_day\n end\n\n # If end date of deal is before given end date, we will end at deal end date\n if d.expiry_date < end_date\n temp_end_date = d.expiry_date.in_time_zone(\"Singapore\").end_of_day\n else\n temp_end_date = end_date.in_time_zone(\"Singapore\").end_of_day\n end\n\n deal_array << d.title\n deal_array << Time.parse((redemption_start_date).to_s).to_f * 1000\n\n if total\n while view_start_date <= temp_end_date\n num_view_array << Viewcount.where(deal_id: d.id).where(created_at: d.created_at..view_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n view_start_date = view_start_date + 1.days\n end\n\n while redemption_start_date <= temp_end_date\n num_redeem_array << Redemption.where(deal_id: d.id).where(created_at: d.created_at..redemption_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n redemption_start_date = redemption_start_date + 1.days\n end\n else\n while view_start_date <= temp_end_date\n num_view_array << Viewcount.where(deal_id: d.id).where(created_at: view_start_date.beginning_of_day..view_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n view_start_date = view_start_date + 1.days\n end\n\n while redemption_start_date <= temp_end_date\n num_redeem_array << Redemption.where(deal_id: d.id).where(created_at: redemption_start_date.beginning_of_day..redemption_start_date.to_datetime.in_time_zone(\"Singapore\").end_of_day).count\n redemption_start_date = redemption_start_date + 1.days\n end\n end\n deal_array << num_view_array\n deal_array << num_redeem_array\n deal_array << Time.parse((temp).to_s).to_f * 1000\n overall_deals_array << deal_array\n end\n overall_deals_array\n end",
"def sell_pending\n end",
"def calculate_current_balance\n if transactionmode == \"Credit\"\n savingsdeposit.current_balance += self.transaction_amount.to_i\n elsif transactionmode == \"Debit\"\n savingsdeposit.current_balance -= self.transaction_amount.to_i\n else\n :savingsdeposits\n end\n savingsdeposit.save\n\nend",
"def assign_company_values\n if Company.where(:stock_ticker => self.stock_ticker).empty?\n c = Company.new\n c.industry = StockInfo.where(ticker_sign: self.stock_ticker).first.industry\n c.sic_code = StockInfo.where(ticker_sign: self.stock_ticker).first.sic_code\n c.exchange = StockInfo.where(ticker_sign: self.stock_ticker).first.exchange\n c.risk_free_rate = self.class.risk_free_rate\n c.market_growth_rate = self.class.market_growth_rate\n c.stock_ticker = self.stock_ticker\n c.company_name = self.name_stock\n c.current_stock_price = self.current_stock_price\n c.free_cash_flow = self.free_cash_flow\n c.num_shares = self.num_shares\n c.PE_ratio = self.PE_ratio\n c.beta = self.beta\n c.cost_of_equity = self.cost_of_equity\n c.fcf_share_value = self.fcf_share_value\n c.capm_share_value = self.capm_share_value\n c.composite_share_value = self.composite_share_value\n c.complete = true\n c.save\n else\n b = Company.where(:stock_ticker => self.stock_ticker).first\n b.risk_free_rate = ((self.class.risk_free_rate).to_f).round(4)\n b.market_growth_rate = ((self.class.market_growth_rate).to_f).round(4)\n b.current_stock_price = self.current_stock_price\n b.free_cash_flow = self.free_cash_flow\n b.num_shares = self.num_shares\n b.PE_ratio = self.PE_ratio\n b.beta = self.beta\n b.cost_of_equity = self.cost_of_equity\n b.fcf_share_value = self.fcf_share_value\n b.capm_share_value = self.capm_share_value\n b.composite_share_value = self.composite_share_value\n b.complete = true\n b.save\n end\n end",
"def business_decision_support \n end",
"def archive\n PastStanding.create!({:standing_id => self.id, :channel_id => self.channel_id, :rank => self.rank,\n :share => self.share, :count0 => self.count0, :count1 => self.count1, :tallied_at => self.tallied_at})\n end",
"def create_location_process\n if !self.company.plan.custom\n if self.company.locations.count > 1\n company = self.company\n day_number = DateTime.now.day\n month_number = DateTime.now.month\n month_days = DateTime.now.days_in_month\n\n #Process changes according to status.\n #If status is \"Activo\", then current month was already payed and due_amount should increase for the new location for month's days left and all months active left.\n #If status is \"Emitido\", \"Vencido\" or \"Bloqueado\", then month hasn't been payed and the price will rise, so we should substract due_amount for month's days past.\n if company.payment_status = PaymentStatus.find_by_name(\"Activo\")\n #Increase is: days_left * base_price * 0.5\n company.due_amount += (((month_days - day_number + 1).to_f / month_days.to_f) * company.company_plan_setting.base_price * 0.5) + (company.company_plan_setting.base_price * 0.5) * (company.months_active_left - 1)\n company.save\n elsif [\"Emitido\", \"Vencido\", \"Bloqueado\"].include?(company.payment_status.name)\n #Decrease is: past_days * base_price * 0.5\n company.due_amount -= ((day_number).to_f / month_days.to_f) * company.company_plan_setting.base_price * 0.5\n company.save\n end\n\n end\n end\n end",
"def partner\n @services = Service.all\n @countries = Country.all\n @departments = Department.all\n end",
"def investment\n if buy_price\n num_of_shares * buy_price\n end\n end"
] |
[
"0.5839521",
"0.57344776",
"0.5588279",
"0.5581184",
"0.5471951",
"0.53904265",
"0.5389306",
"0.53693074",
"0.5362871",
"0.53023636",
"0.5295318",
"0.5295076",
"0.52892804",
"0.5279958",
"0.5279958",
"0.5272267",
"0.5252071",
"0.52325547",
"0.52265126",
"0.5207843",
"0.51891994",
"0.5188567",
"0.5188368",
"0.5185464",
"0.5179979",
"0.5175926",
"0.5173828",
"0.5164247",
"0.51603466",
"0.5153335",
"0.5146675",
"0.51414984",
"0.5141037",
"0.5127349",
"0.51188236",
"0.51175207",
"0.5115903",
"0.51153326",
"0.51021343",
"0.51005995",
"0.5093589",
"0.50930166",
"0.50906867",
"0.50840765",
"0.5080878",
"0.50741273",
"0.5068174",
"0.5067264",
"0.5063065",
"0.5061523",
"0.5055655",
"0.5049536",
"0.5048926",
"0.5045001",
"0.50402945",
"0.5032816",
"0.50244015",
"0.5021536",
"0.50173885",
"0.5016879",
"0.5016877",
"0.50130904",
"0.50097233",
"0.5009033",
"0.5009033",
"0.5009033",
"0.50059",
"0.50031805",
"0.49988645",
"0.49988645",
"0.49961028",
"0.49941123",
"0.49903977",
"0.49874255",
"0.49873635",
"0.49832517",
"0.49791402",
"0.49782944",
"0.49737334",
"0.49724567",
"0.4972335",
"0.49711046",
"0.49701372",
"0.49674553",
"0.49674553",
"0.49674553",
"0.4962942",
"0.49606213",
"0.4958594",
"0.49570763",
"0.49570763",
"0.49539524",
"0.49532273",
"0.49530277",
"0.4950089",
"0.49497852",
"0.49479547",
"0.4946709",
"0.49454618",
"0.49448323",
"0.4941062"
] |
0.0
|
-1
|
Overrides the parent method to ensure the current ping node is destroyed
|
def inherit(node)
ping.remove
super
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def on_node_destroy( node )\n\t\t\tself.log.debug \"unhandled on_node_destroy for %p\" % [ node ]\n\t\tend",
"def delete_ping\n delete 'ping'\n end",
"def teardown\n response = Vanagon::Utilities.http_request(\n \"#{@pooler}/vm/#{@target}\",\n \"DELETE\",\n nil,\n { 'X-AUTH-TOKEN' => @token }\n )\n if response and response[\"ok\"]\n Vanagon::Driver.logger.info \"#{@target} has been destroyed\"\n $stderr.puts \"#{@target} has been destroyed\"\n else\n Vanagon::Driver.logger.info \"#{@target} could not be destroyed\"\n warn \"#{@target} could not be destroyed\"\n end\n rescue Vanagon::Error => e\n Vanagon::Driver.logger.info \"#{@target} could not be destroyed (#{e.message})\"\n warn \"#{@target} could not be destroyed (#{e.message})\"\n end",
"def destroy\n @node = Node.scopied.find(params[:id])\n @node.kill\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy!\n self.poll = nil\n super\n end",
"def terminate()\n connection.nodes.terminate(uuid).tap{ self.forget }\n end",
"def destroy\n self.poll = nil\n super\n end",
"def destroy\n kill\n reset\n end",
"def throw_away!\n pool.remove self\n disconnect!\n end",
"def kill\n @alive = false\n end",
"def node\n purge_node[:node]\n end",
"def destroy\n @pm_node.destroy\n respond_to do |format|\n format.html { redirect_to pm_nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def teardown\n with_vsphere_connection do |dc|\n nodes.each do |k,v|\n storage = RSpec.configuration.rs_storage[:nodes][k]\n\n if storage.nil?\n log.info \"No entry for node #{k}, no teardown necessary\"\n next\n end\n\n ssh = storage[:ssh]\n unless ssh.nil? or ssh.closed?\n ssh.close\n end\n\n if destroy\n log.info \"Destroying instance #{k}\"\n vm_name = storage[:vm]\n if vm_name == nil\n log.error \"No vm object for #{k}\"\n next\n end\n\n # Traverse folders to find target folder for new vm's\n vm_folder = dc.vmFolder.traverse(vmconf[:dest_dir], RbVmomi::VIM::Folder)\n raise \"VirtualMachine folder #{vmconf[:dest_dir]} not found\" if vm_folder.nil?\n vm = vm_folder.find(vm_name, RbVmomi::VIM::VirtualMachine)\n raise \"VirtualMachine #{vm_name} not found in #{vmconf[:dest_dir]}\" if vm.nil?\n\n begin\n vm.PowerOffVM_Task.wait_for_completion\n rescue RbVmomi::Fault => e\n log.error \"Fault attempting to power off node #{k}, #{e.message}\"\n ensure\n begin\n vm.Destroy_Task.wait_for_completion\n rescue RbVmomi::Fault => e\n log.error \"Fault attempting to destroy node #{k}, #{e.message}\"\n end\n end\n else\n next\n end\n end\n end\n\n nil\n end",
"def tor_exit_node?; end",
"def tor_exit_node?; end",
"def cleanup\n delete!\n return true\n rescue PoolNode::Conflict\n # still in use\n return false\n end",
"def kill\n Souffle::Log.info \"#{@node.log_prefix} Killing node...\"\n provider.kill([@node])\n end",
"def destroy\n @ui.logger.debug { \"Container Destroy: #{self.id}\" }\n\n self.node.alive? or return false\n\n please_wait(:ui => @ui, :message => format_object_action(self, 'Destroy', :red)) do\n self.lxc.destroy(%(-f))\n self.lxc_clone.destroy(%(-f))\n\n do_provisioner_callbacks(self, :destroy, @ui)\n end\n\n true\n end",
"def cleanup\n super\n disconnect\n end",
"def destroy\n @node_rack = @object\n begin\n @node_rack.destroy\n rescue Exception => destroy_error\n respond_to do |format|\n flash[:error] = destroy_error.message\n format.html { redirect_to node_rack_url(@node_rack) and return}\n format.xml { head :error } # FIXME?\n end\n end\n \n # Success!\n respond_to do |format|\n format.html { redirect_to node_racks_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n b.node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy_empty\n @obj = Node.find(params[:id])\n @obj.destroy_empty\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heartbeat.destroy\n\n head :no_content\n end",
"def teardown\n nodes.each do |k,v|\n storage = RSpec.configuration.rs_storage[:nodes][k]\n\n next if storage.nil?\n\n ssh = storage[:ssh]\n ssh.close unless ssh.closed?\n end\n\n if destroy\n output << bold(color(\"localhost$\", :green)) << \" vagrant destroy --force\\n\"\n vagrant(\"destroy --force\")\n end\n\n nil\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def on_tag_destroy( node )\n\t\t\tself.log.debug \"unhandled on_node_destroy for %p\" % [ node ]\n\t\tend",
"def cleanup\n cleanup_primitive full_name, hostname\n wait_for_status name\n end",
"def release!\n PoolNode.delete(@id, node)\n end",
"def clean_cached_node(node)\n Puppet::Node.indirection.destroy(node)\n Puppet.info \"#{node}'s cached node removed\"\n end",
"def check_out\n @server[\"/worker\"].put({\n :name => @name,\n :terminated => true\n })\n log 'exiting'\n end",
"def nuke\n self.open_graph_event.destroy unless self.open_graph_event.nil?\n self.teamsheet_entries.destroy_all\n self.messages.destroy_all\n self.activity_items.destroy_all\n self.result.destroy unless self.result.nil?\n self.destroy\n end",
"def do_kill\n\n return kill_when_ended if node_ended?\n #return kill_when_closed if node_closed? # nothing of the sort\n\n kill\n end",
"def teardown\n nodes.each do |k,v|\n storage = RSpec.configuration.rspec_storage[:nodes][k]\n\n next if storage.nil?\n\n ssh = storage[:ssh]\n ssh.close unless ssh.closed?\n end\n\n if destroy\n output << bold(color(\"localhost$\", :green)) << \" vagrant destroy --force\\n\"\n vagrant(\"destroy --force\")\n end\n nil\n end",
"def delete_node\n delete(@nodename)\n end",
"def destroy\n conn.delete(self_link)\n end",
"def nuke\n unless @instance.nil?\n @instance.stop\n @instance = nil\n end\n end",
"def kill_node\n return if ws_running? < 2\n puts 'Low load, let\\'s kill a node..'\n to_kill = get_container_id(image=@ws_image)\n unregister_server(to_kill.id)\n container = Docker::Container.get(to_kill.id, to_kill.connection).kill\n end",
"def destroy\n getnodes.each{|node|\n Sys.exec(\"vagrant destroy #{node.name} -f\")\n }\n end",
"def teardown\n Process.kill('KILL',@pid)\n end",
"def kill() end",
"def destroy\n @node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node.destroy\n respond_to do |format|\n format.html { redirect_to nodes_url, notice: 'Node was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def check_out\n @current_guests = nil\n end",
"def delete!\n PoolNode.rmdir(@id)\n super\n Address.delete(@id)\n Subnet.delete(@subnet)\n end",
"def destroy\n Segment.find_by_guid(source.guid).destroy if source && Segment.find_by_guid(source.guid)\n Segment.find_by_guid(target.guid).destroy if target && Segment.find_by_guid(target.guid)\n successors.each {|successor| NetworkConnection.find_by_guid(successor.guid).destroy if successor}\n super\n end",
"def on_remove\n @context.notifications.off(\"graph.start\", self)\n @context.notifications.off(\"graph.stop\", self)\n\n io.outputs.each { |k, o| @context.connections.delete(o.guid) }\n io.unregister_inputs\n var.unregister\n stop\n end",
"def delete_node\n node.destroy if node\n end",
"def purge \n\t\t@head = nil\n\t\t@tail = nil\n\tend",
"def terminate()\n connection.node_clusters.terminate(uuid).tap{ self.forget }\n end",
"def destroy\n @newnode.destroy\n respond_to do |format|\n format.html { redirect_to newnodes_url, notice: 'Newnode was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @parent = nil\n @root = nil\n end",
"def resurrect!\n alive! if resurrectable?\n end",
"def destroy\n @retain_node = RetainNode.find(params[:id])\n @retain_node.destroy\n\n respond_to do |format|\n format.html { redirect_to(retain_nodes_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def forget_peer(peer)\n unless root_object?\n raise ArgumentError, \"#{self} is not root\"\n end\n\n each_plan_child do |child|\n child.forget_peer(peer)\n end\n super\n end",
"def destroy(state)\n hostname = state[:hostname]\n poolsclosed_delete(hostname)\n state.delete(:hostname)\n end",
"def destroy\n run_callbacks :destroy do\n self.update(active: false)\n end\n end",
"def stop\n @manager.shutdown\n @nodes.each(&:stop)\n end",
"def destroy\n run_callbacks :destroy do\n connection.delete(element_path, encode, self.class.headers)\n end\n end",
"def ping_nodes\n\t\twhile true\n\t\t\tsleep(rand(60))\n\t\t\tn = rand(@neighbour_nodes.count)\n\t\t\tnode = @neighbour_nodes[n]\n\t\t\ts = UDPSocket.new\n\t\t\tbegin\n\t\t\t\tTimeout::timeout(10){ \n\t\t\t\t\tputs \"Pinging #{node}\"\n\t\t\t\t\tsend_message [\"PING\", @info], 0, node.host, node.port\n\t\t\t\t\t@waiting = true\n\t\t\t\t\twhile waiting?\n\t\t\t\t\t\tsleep(0.2)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\trescue Timeout::Error => ex\n\t\t\t\tif waiting?\n\t\t\t\t\tputs \"Conenction to #{node} timed out, sending DROP_NODE to all remaining nodes\"\n\t\t\t\t\t@neighbour_nodes - [node]\n\t\t\t\t\t@neighbour_nodes.each do |n|\n\t\t\t\t\t\tsend_message [\"DROP_NODE\", node], 0, n.host, n.port\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Socket::Error => ex\n\t\t\t\tputs \"Connection to #{node} failed, trying again in 60 seconds\"\n\t\t\trescue => ex\n\t\t\t\tputs ex.message\n\t\t\tend\n\t\tend\n\tend",
"def destroy\n super do\n graph.delete [source.to_term, nil, nil]\n parent.delete [parent, nil, source.to_term]\n end\n end",
"def destroy\n @obj = Node.find(params[:id])\n @obj.destroy\n\n respond_to do |format|\n format.html { redirect_to :back}\n format.json { head :no_content }\n end\n end",
"def purge\r\n @head = nil\r\n @tail = nil\r\n end",
"def teardown\n @p.destroy\n end",
"def destroy\n ValidNetwork.find_by_guid(valid_network.guid).destroy if valid_network && ValidNetwork.find_by_guid(valid_network.guid)\n super\n end",
"def ping\n self.last_ping = Time.now\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sock.cmd(\"String\"=>\"quit\")\n @sock.close\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n \n Action.log :controller => params[:controller], :action => params[:action], :target_id => params[:id], :user => current_user\n\n respond_to do |format|\n format.html { redirect_to :root, notice: 'Node was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n exitMaintenanceMode\n rescue\n Puppet.err 'Could not find Host system.Either Host is not exist or disconnected'\n end\n end",
"def destroy(state)\n info(\"Destroying instance #{instance.name}\")\n return if state[:server_id].nil?\n instance.transport.connection(state).close\n domain = load_domain(state[:server_id])\n destroy_domain(domain) unless domain.nil?\n info(\"Libvirt instance #{state[:server_id]} destroyed.\")\n state.delete(:server_id)\n state.delete(:hostname)\n end",
"def kill!() end",
"def destroy\n run_callbacks :destroy do\n rpc_execute('unlink', [id], context)\n @destroyed = true\n freeze \n end\n end",
"def destroy\r\n @node.destroy\r\n respond_to do |format|\r\n format.html { redirect_to nodes_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def kill_and_recreate\n Souffle::Log.info \"#{@node.log_prefix} Recreating node...\"\n provider.kill_and_recreate([@node])\n end",
"def destroy\n router_bgp('no')\n end",
"def destroy\n @node_rack_node_assignment = @object\n @node_rack = @node_rack_node_assignment.node_rack\n return unless filter_perms(@auth,@node_rack,'updater')\n @node = @node_rack_node_assignment.node\n return unless filter_perms(@auth,@node,'updater')\n\n @node_rack_node_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to node_rack_node_assignments_url }\n format.js {\n render(:update) { |page|\n page.replace_html 'node_rack_node_assignments', {:partial => 'node_racks/node_assignments', :locals => { :node_rack => @node_rack} }\n # We expect this AJAX deletion to come from one of two places,\n # the rack show page or the node show page. Depending on\n # which we do something slightly different.\n if request.env[\"HTTP_REFERER\"].include? \"node_racks\"\n page.replace_html 'node_rack_node_assignments', :partial => 'node_racks/node_assignments', :locals => { :node_rack => @node_rack }\n elsif request.env[\"HTTP_REFERER\"].include? \"nodes\"\n page.replace_html 'node_rack_node_assignments', :partial => 'nodes/node_rack_assignment', :locals => { :node => @node }\n end\n }\n }\n format.xml { head :ok }\n end\n end",
"def destroy\n @map_node = Map::Node.find(params[:id])\n @map_node.destroy\n\n respond_to do |format|\n format.html { redirect_to map_nodes_url }\n format.json { head :ok }\n end\n end",
"def purge_node(imagename)\n stdout, stderr, status = Open3.capture3('/usr/local/bin/bolt', 'command', 'run', \"/usr/local/bin/puppet node purge #{imagename}\", '-n', 'slice-master', '-u', 'root', '--tty') \n if stdout.include? 'was purged.'\n purge_hash = '###'.yellow\n purge_msg = \"Node #{imagename} certificate has been purged.\"\n puts \"#{purge_hash} \" + \"#{purge_msg}\"\n end\nend",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :ok }\n end\n end",
"def terminate\n self.destroy\n end",
"def delete_pid()\n if @pid.ours? then\n @pid.delete()\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_path }\n format.json { head :ok }\n end\n end",
"def empty\n delete_old_nodes 0\n end",
"def destroy(_ = nil)\n OneProvisionLogger.info('(Destroy skipped)')\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n project = Project.where(:user_id => current_user[:id]).first\n project.optimized = false\n project.loading = false\n project.save\n @nodes = Node.where(:user_id => current_user[:id])\n @nodes.each do |node|\n node.jobnumber = nil\n node.vehicle_id = nil\n node.servicetime = nil\n node.tour_id = nil\n node.save\n end\n respond_to do |format|\n format.html { redirect_to(nodes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n if @origin\n @origin.remove_exit(self)\n @origin = nil\n end\n if @destination\n @destination.remove_entrance(self)\n @destination = nil\n end\n super\n return\n end",
"def destroy\n # Shutdown pool if active\n service.pool_action uuid, :destroy if active?\n # If this is a persistent domain we need to undefine it\n service.pool_action uuid, :undefine if persistent?\n end",
"def destroy\n @node = Node.find(params[:id])\n myWorkingName = @node.working_name\n @node.destroy\n\n respond_to do |format|\n flash[:notice] = (\"Node \" + myWorkingName + \" has been deleted\")\n format.html { redirect_to root_path(tab:\"nodelist\") }\n format.json { head :no_content }\n end\n end",
"def unbind\n #@node.notifiers.unsubscribe(@notify_sid) if @notify_sid\n @node.command_connections.delete(self)\n end",
"def ping!\n @session.ping!\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @node = Node.find(params[:id])\n @node.destroy\n\n respond_to do |format|\n format.html { redirect_to nodes_url }\n format.json { head :no_content }\n end\n end",
"def destroy_self\n \tdestroy_record_of_self\n \t@db_alive = false\n \treturn nil\n end",
"def destroy\n @nepal.destroy\n\n head :no_content\n end"
] |
[
"0.6354683",
"0.633756",
"0.6294712",
"0.6251677",
"0.62298685",
"0.618085",
"0.6174263",
"0.61154544",
"0.6078201",
"0.6063464",
"0.6055601",
"0.605479",
"0.5984734",
"0.5982262",
"0.5982262",
"0.5952237",
"0.5900358",
"0.5863139",
"0.5787076",
"0.5766752",
"0.57618076",
"0.5744129",
"0.57403547",
"0.57226384",
"0.5703241",
"0.5701944",
"0.56945556",
"0.56705993",
"0.5669507",
"0.5636232",
"0.56248987",
"0.5624642",
"0.560845",
"0.55987036",
"0.55863583",
"0.55831987",
"0.5572668",
"0.5553711",
"0.5543796",
"0.5532682",
"0.5531753",
"0.5531753",
"0.5531753",
"0.5517169",
"0.55084145",
"0.550818",
"0.55024254",
"0.5494965",
"0.54862714",
"0.5467621",
"0.54660124",
"0.5441999",
"0.543237",
"0.5428736",
"0.5423453",
"0.5419039",
"0.5416506",
"0.540655",
"0.5405018",
"0.5404756",
"0.5398029",
"0.5392383",
"0.5390766",
"0.5384795",
"0.5374913",
"0.53706354",
"0.53656644",
"0.53656644",
"0.53656644",
"0.53656644",
"0.53656644",
"0.535",
"0.53466016",
"0.5346325",
"0.5345882",
"0.5336977",
"0.53363395",
"0.53294367",
"0.53279585",
"0.53278905",
"0.5327557",
"0.53213084",
"0.53176576",
"0.5315976",
"0.53120273",
"0.53066075",
"0.53054625",
"0.53051865",
"0.53034484",
"0.53026617",
"0.5300109",
"0.5292022",
"0.528468",
"0.5283006",
"0.5280069",
"0.52788603",
"0.52788603",
"0.52788603",
"0.5275277",
"0.5271795"
] |
0.6927966
|
0
|
Ping node accessor If a ping node exists it will be returned. Otherwise a new node will be created and returned
|
def ping
p = find_first 'ns:ping', :ns => self.class.registered_ns
unless p
(self << (p = XMPPNode.new('ping', self.document)))
p.namespace = self.class.registered_ns
end
p
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ping\n response = connection.get(get_ping_url)\n if response.success?\n PingResponse.new(response.body)\n end\n end",
"def pingnode(address, interface=nil)\n out = interface ? `ping -I #{interface} -c 5 #{address}` : `ping -c 5 #{address}`\n if $? != 0\n # Ping command failed, return empty hash.\n puts \"Failed to ping #{address} on #{interface}\"\n Hash.new\n else\n res = parseping(out)\n res[:address] = address\n res\n end\nend",
"def ping\n TaxCloud::Responses::Ping.parse request(:ping)\n end",
"def ping\n @conn.ping\n end",
"def ping\n client.ping\n end",
"def ping(calling_node)\n @router.touch(calling_node)\n return true\n end",
"def ping\n if !block_given?\n return @j_del.java_method(:ping, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling ping()\"\n end",
"def ping()\n #This is a stub, used for indexing\n end",
"def ping\n raise NotImplementedError\n end",
"def ping\n with_client do |client|\n client.ping\n end\n end",
"def ping\n get('')\n end",
"def ping()\n #This is a stub, used for indexing\n end",
"def ping\n check_connection\n @protocol.ping_command\n self\n end",
"def ping\n sanity_check\n @handle.ping\n end",
"def ping\n uri = _parse_uri('/ping')\n headers = _get(uri)\n Ping.new.tap do |model|\n model.status = 'ok'\n model.build = headers['X-Influxdb-Build']\n model.version = headers['X-Influxdb-Version']\n model.message = 'ready for queries and writes'\n end\n rescue StandardError => e\n Ping.new.tap do |model|\n model.status = 'fail'\n model.message = e.message\n end\n end",
"def ping?\n rpc.request Util::MessageCode::PING_REQUEST\n\n return rpc.status\n end",
"def ping()\n _params = {}\n return @master.call 'users/ping2', _params\n end",
"def ping\n @redis.ping\n end",
"def ping\n @ping = Time.now\n end",
"def ping\n SAP_LOGGER.debug(\"In #{self.class} ping ...\")\n\t \t return nil unless self.handle\n SAP_LOGGER.debug(\"In #{self.class} handle: #{self.handle} ...\")\n return self.handle.ping()\n\t\tend",
"def ping\n @client.peek( name )\n return true\n end",
"def ping\n return_code, response = send_command(\"ping\")\n return_code == \"200\"\n end",
"def get_node\n # @@neo = Neography::Rest.new\n begin\n # qur = \"MATCH (n {object_id: \"+self.id.to_s+\", object_type: \\'\"+self.class.to_s+\"\\' }) RETURN n LIMIT 1\"\n # response = @@neo.execute_query(qur)\n # node_id = response[\"data\"].flatten.first[\"metadata\"][\"id\"]\n node_id = self.get_node_id\n node = (node_id ? Neography::Node.load(node_id, @@neo) : nil)\n return node\n rescue Exception\n return nil\n end\n end",
"def ping\n send_command(\"ping\")\n end",
"def ping\n true\n end",
"def get_or_create_node(conn, index, data)\n\n\tvalue = data.object.to_s.unpack('U*').pack('C*').force_encoding(\"UTF-8\")\n\turi = data.subject.to_s\n\n\t# look for node in the index\n\t#r = conn.get(\"/db/data/index/node/#{index}/name/#{URI.escape(value).gsub(\"?\",\"%3F\")}\")\n\tr = conn.get(\"/db/data/index/node/#{index}/uri/#{CGI.escape(uri)}\")\n\tnode = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n\t\n\tunless node\n\t\t# no indexed node found, so create a new one\n\t\tr = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => value, \"uri\" => uri}), HEADER)\n\n\t\tnode = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n\t\t# add new node to an index\n\t\tnode_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\", \\\"value\\\" : \\\"#{value}\\\"}\"\n\t\tconn.post(\"/db/data/index/node/#{index}_names\", node_data, HEADER)\n\n\t\tnode_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"uri\\\", \\\"value\\\" : \\\"#{uri}\\\"}\"\n\t\tconn.post(\"/db/data/index/node/#{index}\", node_data, HEADER)\t\n\n\t\tnode_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\", \\\"value\\\" : \\\"#{value}\\\"}\"\t\t\n\t\tconn.post(\"/db/data/index/node/fulltext\",node_data,HEADER)\n\t\tconn.post(\"/db/data/index/node/#{index}_fulltext\",node_data,HEADER)\n\tend\n\tnode\nend",
"def get_node(id)\n CloudLB::Node.new(self,id)\n end",
"def ping!\n @session.ping!\n end",
"def ping\n @tag = Tag.first || Tag.new\n end",
"def ping\n end",
"def ping\n self.last_ping = Time.now\n end",
"def ping?\n tcp_ping.ping?\n end",
"def ping\n response, body = send_request :get, '', :binary\n true\n end",
"def get_or_create_node(conn, index, value)\n # look for node in the index\n r = conn.get(\"/db/data/index/node/#{index}/name/#{CGI.escape(value)}\")\n node = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n unless node\n # no indexed node found, so create a new one\n r = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => value}), HEADER)\n node = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n # add new node to an index\n node_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\",\n \\\"value\\\" : \\\"#{CGI.escape(value)}\\\"}\"\n conn.post(\"/db/data/index/node/#{index}\", node_data, HEADER)\n end\n node\nend",
"def request!\n PoolNode.create_or_get(@id, node)\n end",
"def create_ping\n post 'ping'\n end",
"def get_or_create_node(conn, index, value)\n # look for node in the index\n r = conn.get(\"/db/data/index/node/#{index}/name/#{CGI.escape(value)}\")\n node = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n unless node\n # no indexed node found, so create a new one\n r = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => value}), HEADER)\n node = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n # add new node to an index\n node_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \n \\\"key\\\" : \\\"name\\\", \n \\\"value\\\" : \\\"#{CGI.escape(value)}\\\"}\"\n conn.post(\"/db/data/index/node/#{index}\", node_data, HEADER)\n end\n node\nend",
"def ping\n 'pong'\n end",
"def ping?\n false\n end",
"def node(reload=false)\n\n nid = @values[:nid]; return nil unless nid\n exe = execution(reload); return nil unless exe\n\n nodes = exe.data['nodes']; return nil unless nodes\n nodes[nid]\n end",
"def ping\n return true unless active? && heartbeat_path.present?\n\n resp = http_get(uri: \"#{api_base_url}#{heartbeat_path}\")\n resp.present? && resp.code == 200\n end",
"def get_node(node)\n\t\t\t@nodes[node]\n\t\tend",
"def ping(opts = {})\n data, _status_code, _headers = ping_with_http_info(opts)\n data\n end",
"def ping\n return true unless active && heartbeat_path.present?\n\n resp = http_get(uri: \"#{api_base_url}#{heartbeat_path}\")\n resp.present? && resp.code == 200\n end",
"def create_node(options={})\n (raise CloudLB::Exception::MissingArgument, \"Must provide a node IP address\") if options[:address].to_s.empty?\n (raise CloudLB::Exception::MissingArgument, \"Must provide a node TCP port\") if options[:port].to_s.empty?\n options[:condition] ||= \"ENABLED\"\n body = {:nodes => [options]}.to_json\n response = @connection.lbreq(\"POST\", @lbmgmthost, \"#{@lbmgmtpath}/loadbalancers/#{CloudLB.escape(@id.to_s)}/nodes\",@lbmgmtport,@lbmgmtscheme,{},body)\n CloudLB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n body = JSON.parse(response.body)['nodes'][0]\n return get_node(body[\"id\"])\n end",
"def node(name)\n return node_manager.find(name)\n end",
"def get_ping(data)\n end",
"def ping; end",
"def ping()\n\n ip = Resolv.getaddress(@host)\n puts ('ip: ' + ip.inspect).debug if @debug\n valid = pingecho(ip)\n puts ('valid: ' + valid.inspect).debug if @debug \n \n @results[:ping] = if valid then\n a = [valid]\n 4.times {sleep 0.01; a << pingecho(ip)}\n (a.min * 1000).round(3)\n else\n nil\n end\n\n end",
"def ping() path = \"/api/v2/utilities/ping\"\n get(path, {}, AvaTax::VERSION) end",
"def ping(t)\n \n end",
"def construct_ping\n msg = Protocol::Ping.new\n msg.ctime = DateTime.now\n msg.guid = @driver.guid\n msg.name = @driver.name\n msg.connection_count = @supernode_table.size\n Routing.update_ping_from_routing(msg,@driver.routing)\n msg\n end",
"def get_node(key, create = false)\n node = @hash[key]\n if node and node.expired?\n remove(key)\n node = nil\n end\n node ||= Node.new(key) if create\n node\n end",
"def update_ping\n put 'ping'\n end",
"def ping!\n send_message [IGNORE, 4, \"ping\"].pack(\"cNA4\")\n end",
"def pingable?\n true\n end",
"def node_get(node)\n nodes.fetch prepare_key(node), nil\n end",
"def get_or_create_node(conn, uri)\n # PARSE URI\n _, namespace, name = uri.split(/^(.*[\\/|#])([^\\/|#]+)$/)\n # LOOK FOR THIS NODE IN THE INDEX\n r = conn.get(\"/db/data/index/node/#{CGI.escape(namespace)}/name/#{CGI.escape(name)}\")\n node = (JSON.parse(r.body).first || {})['self'] if r.status == 200\n #puts r.status, node\n unless node\n # THIS NODE IS NOT FOUND IN THE INDEX, SO CREATE IT\n r = conn.post(\"/db/data/node\", JSON.unparse({\"name\" => name, \"uri\" => uri}), HEADER)\n node = (JSON.parse(r.body) || {})['self'] if [200, 201].include? r.status\n # ADD THE NAME OF THE NEW NODE TO THE INDEX\n node_data = \"{\\\"uri\\\" : \\\"#{node}\\\", \\\"key\\\" : \\\"name\\\", \\\"value\\\" : \\\"#{CGI.escape(name)}\\\"}\"\n conn.post(\"/db/data/index/node/#{CGI.escape(namespace)}\", node_data, HEADER)\n # GET OR CREATE NAMESPACE NODE, AND CREATE RELATIONSHIP\n #namespace_node = get_or_create_namespace_node(conn, namespace)\n #get_or_create_relationship(conn, namespace_node, node, 'namespace_of')\n $load_n += 1\n else\n $skip_n += 1\n end\n # RETURN NEO4J'S NODE OBJECT\n node\nend",
"def ping(&blk)\n if block_given?\n websocket.subscribe :ping, &blk\n else\n http.get :ping\n end\n end",
"def method_missing(method_name, *args)\r\n get_or_create_node(method_name.to_s, true)\r\n end",
"def ping?\n base_url = url.end_with?(\"/\") ? url[0..-2] : url\n\n if normalized_api_version.nil?\n # for v4\n base_url = url.end_with?(\"/\") ? url[0..-2] : url\n public_url = \"#{base_url}/index.html\"\n else\n # for v5\n public_url = \"#{base_url}/api/v1/status/public\"\n end\n\n http = Net::Ping::HTTP.new(public_url)\n\n # use GET for v5\n http.get_request = true if normalized_api_version\n\n http.ping?\n end",
"def ping\n\t\tputs \"Pinging #{@ip} ...\"\n\t\tsystem \"ping #{ip_string}\"\n\tend",
"def perform\n @client.rest_get_with_token('/ping', {}, {})\n end",
"def exists(node)\n Arel::Nodes::Exists.new(node)\n end",
"def getNodeStatus(node_id) \n cm_url = APP_CONFIG['cm_ip'] + ':' + APP_CONFIG['cm_port'].to_s\n res = HTTParty.get(cm_url+\"/resources/node/\"+ node_id)\n # puts \"status \"+node_id\n # puts res\n return res\n\n end",
"def ping(tag_id, value=nil)\n self[tag_id].ping(value)\n end",
"def ping\n stats\n true\n rescue Errno::ECONNREFUSED\n false\n end",
"def method_missing(method, *args, &block)\n get_node.send(method, *args, &block)\n end",
"def ping\n response = self.class.post('/', :body => self.class.build_XML_request('Session.Ping', self))\n self.class.response_valid? response\n response['YourMembership_Response']['Session.Ping'] == '1'\n end",
"def node(name)\n if name =~ /\\./\n # probably got a fqdn, since periods are not allowed in node names.\n # so, take the part before the first period as the node name\n name = name.split('.').first\n end\n @nodes[name]\n end",
"def get(\n id,\n deadline: nil\n )\n req = V1::NodeGetRequest.new()\n if not @parent.snapshot_time.nil?\n req.meta = V1::GetRequestMetadata.new()\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.id = (id)\n tries = 0\n plumbing_response = nil\n loop do\n begin\n plumbing_response = @stub.get(req, metadata: @parent.get_metadata(\"Nodes.Get\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n break\n end\n\n resp = NodeGetResponse.new()\n resp.meta = Plumbing::convert_get_response_metadata_to_porcelain(plumbing_response.meta)\n resp.node = Plumbing::convert_node_to_porcelain(plumbing_response.node)\n resp.rate_limit = Plumbing::convert_rate_limit_metadata_to_porcelain(plumbing_response.rate_limit)\n resp\n end",
"def ping!\n @transmission_state.enqueue_ping\n end",
"def [](name)\r\n get_or_create_node(name.to_s, false)\r\n end",
"def ping_request(ping, opts = {})\n data, _status_code, _headers = ping_request_with_http_info(ping, opts)\n data\n end",
"def ping\n begin \n @connection = $redis.ping\n rescue => e\n @connection = {status: 500, message: e.message }\n end\n\n respond_to do |format|\n format.json { render json: @connection }\n end\n end",
"def ping()\n # Use the activity client 'client' to invoke the say_hello activity\n pong=client.ping()\n \"Got #{pong}\"\n end",
"def update_node(node_updates)\n \n config[:disable_editing] = true\n \n node_name = node_updates['name']\n begin\n \n # load then update and save the node\n node = Chef::Node.load(node_name)\n \n if node_updates['chef_environment'] && node_updates['chef_environment'] != node['chef_environment']\n check_chef_env(node_updates['chef_environment']) \n end\n \n if updated_values = update_node_with_values(node, node_updates)\n ui.info \"Updating #{updated_values.join(', ')} on node #{node.name}\"\n node.save\n ui.output(format_for_display(node)) if config[:print_after]\n else\n ui.info \"No updates found for node #{node.name}\"\n end\n\n rescue Net::HTTPServerException => e\n raise unless e.to_s =~ /^404/\n # Node has not been created\n end\n \n return node\n end",
"def create_node(configuration = Jabber::PubSub::NodeConfig.new)\n unless node_exist?\n super(@nodename,configuration)\n else\n false\n end\n end",
"def create\n Souffle::Log.info \"#{@node.log_prefix} Creating a new node...\"\n provider.create_node(@node)\n end",
"def ping()\n result = SaResult.new()\n\n if lines[0].chop =~ /(.+)\\/(.+) (.+) (.+)/\n result.response_version = $2\n result.response_code = $3\n result.response_message = $4\n end\n\n return result\n\n end",
"def ping(*args)\n get '/invoke/wm.server/ping'\n end",
"def get_node(id)\n get_object('node', id)\n end",
"def ping?\n false unless connected?\n false|stat('/')\n rescue ZK::Exceptions::KeeperException\n false\n end",
"def ping\n RestClient.get $api +'v1/upstart', { params: { keepalive: 1 } } rescue nil\n end",
"def node\n publish[:node]\n end",
"def ping_nodes\n\t\twhile true\n\t\t\tsleep(rand(60))\n\t\t\tn = rand(@neighbour_nodes.count)\n\t\t\tnode = @neighbour_nodes[n]\n\t\t\ts = UDPSocket.new\n\t\t\tbegin\n\t\t\t\tTimeout::timeout(10){ \n\t\t\t\t\tputs \"Pinging #{node}\"\n\t\t\t\t\tsend_message [\"PING\", @info], 0, node.host, node.port\n\t\t\t\t\t@waiting = true\n\t\t\t\t\twhile waiting?\n\t\t\t\t\t\tsleep(0.2)\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\trescue Timeout::Error => ex\n\t\t\t\tif waiting?\n\t\t\t\t\tputs \"Conenction to #{node} timed out, sending DROP_NODE to all remaining nodes\"\n\t\t\t\t\t@neighbour_nodes - [node]\n\t\t\t\t\t@neighbour_nodes.each do |n|\n\t\t\t\t\t\tsend_message [\"DROP_NODE\", node], 0, n.host, n.port\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue Socket::Error => ex\n\t\t\t\tputs \"Connection to #{node} failed, trying again in 60 seconds\"\n\t\t\trescue => ex\n\t\t\t\tputs ex.message\n\t\t\tend\n\t\tend\n\tend",
"def node\n @node ||= Socket.gethostname\n end",
"def node(id, params = {})\n get \"nodes/#{id}\", {query: params}\n end",
"def ping() \n \"Pong from #{Socket.gethostname}\"\n end",
"def ping(timeout=nil)\n request = Message::Ping.new(Thread.mailbox)\n send_request request, :request, timeout\n end",
"def new_node(addrinfo)\n ip = extract_ip addrinfo\n\n found = search_node ip\n\n if found\n raise Errors::NodeAlreadyKnownError, \"Node #{found} already known\"\n end\n\n node = Node.new(ip)\n @known_nodes << node\n end",
"def reachable?\n ping\n true\n rescue Orocos::ComError\n false\n end",
"def ping(options = {})\n client = extract_client!(options)\n !!client.get(\"/api/system/ping\")\n rescue Error::ConnectionError\n false\n end",
"def ping(nonce = SecureRandom.hex)\t\n\t\t\tbegin\n\t\t\t\tresponse = RestClient.get(build_url(\"ping\") + \"?echo=#{nonce}\")\n\t\t\t\tresponse = JSON.parse(response)\n\n\t\t\t\tresponse[\"echo\"] == nonce\n\t\t\trescue => e\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def get_node(id)\n @nodes[id.to_i]\n end",
"def ping(req)\n Lynr.metrics.time('time.render:ping') do\n Rack::Response.new('PONG', 200, headers)\n end\n end",
"def ping_api\n res=api_call('PingAPI')\n if res[:data]==1\n res=true\n else\n res=false\n end\n res\n end",
"def send_ping(target_node_id, host, port)\n ping = Ping.new(to: To.from_host_port(host, port), \n from: From.new(\n sender_ip: IPAddr.new(@host).to_i,\n sender_udp_port: @udp_port,\n sender_tcp_port: @tcp_port),\n expiration: Time.now.to_i + MESSAGE_EXPIRATION_IN)\n ping_msg = Message.pack(ping, private_key: @private_key)\n send_msg(ping_msg.encode_message, host, port)\n @peer_store.update_ping(target_node_id, ping_msg.message_hash)\n end",
"def parse_node\n id = attribute( 'id' )\n label = attribute( 'label' )\n root = attribute( 'root' ) ? true : false\n\n #is this node taxon linked\n if otu_id = attribute( 'otu' )\n otu = cache[ otu_id ]\n end\n\n node = NeXML::Node.new( id, :otu => otu, :root => root, :label => label )\n cache node\n\n #according to the schema a 'node' may have no child element.\n return node if empty_element?\n\n #else, if 'node' has child elements\n while next_node\n case local_name\n when 'node'\n #end of current 'node' element has been reached\n break\n end\n end\n\n #return the 'node' object\n node\n end",
"def search_node(ip)\n found = nil\n @known_nodes.each do |node|\n if node.is_you? ip\n found = node\n end\n end\n return found\n end"
] |
[
"0.6521571",
"0.6185138",
"0.61219424",
"0.6079024",
"0.6055741",
"0.6040929",
"0.6020641",
"0.5991688",
"0.5990256",
"0.5943572",
"0.59406835",
"0.59399575",
"0.58999497",
"0.5873468",
"0.5872066",
"0.58527225",
"0.58280146",
"0.58013415",
"0.57956356",
"0.57860965",
"0.5722188",
"0.57208776",
"0.5708677",
"0.5702076",
"0.56885004",
"0.5683582",
"0.5677886",
"0.5671487",
"0.5660906",
"0.56052005",
"0.5586371",
"0.55790997",
"0.5554407",
"0.55371314",
"0.5522674",
"0.5520294",
"0.5517535",
"0.54879415",
"0.5485023",
"0.5477786",
"0.54086906",
"0.5403665",
"0.5401102",
"0.53905195",
"0.53876233",
"0.5387382",
"0.5377992",
"0.5373228",
"0.5366357",
"0.5332517",
"0.5311417",
"0.5311397",
"0.5311349",
"0.53047717",
"0.52849114",
"0.5273028",
"0.52676433",
"0.5260465",
"0.52451605",
"0.52301776",
"0.51917034",
"0.5178726",
"0.51745164",
"0.51666516",
"0.5164425",
"0.51642716",
"0.51586527",
"0.51568604",
"0.5154934",
"0.5152671",
"0.5120593",
"0.5106603",
"0.5096573",
"0.5095162",
"0.5086932",
"0.5074228",
"0.50707465",
"0.5068461",
"0.50607026",
"0.5057619",
"0.5051596",
"0.5050515",
"0.5045948",
"0.5044964",
"0.503926",
"0.50323",
"0.503155",
"0.50293976",
"0.50269514",
"0.5023792",
"0.5015664",
"0.5013945",
"0.5008353",
"0.50078046",
"0.50074005",
"0.50002134",
"0.49960533",
"0.49932453",
"0.49837363",
"0.4975568"
] |
0.7059382
|
0
|
GET /boat_types GET /boat_types.json
|
def index
@boat_types = params[:ids].blank? ? BoatType.active : BoatType.where(id: params[:ids])
if params[:ids].blank?
@boat_types = BoatType.active
#parameter_filter_data = BoatParameterType.filter_data
#option_filter_data = BoatOptionType.filter_data
# @filter_data = parameter_filter_data.merge(option_filter_data)
# @default_boats = BoatForSale.active.ids
else
@boat_types = BoatType.with_bfs.where(id: params[:ids])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def index\n @bet_types = Bet::Type.all\n end",
"def index\n @kind_of_boats = KindOfBoat.all\n end",
"def index\n @bs_types = BsType.all\n end",
"def index\n @bagtypes = Bagtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bagtypes }\n end\n end",
"def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end",
"def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def show\n render json: @bike_type\n end",
"def index\n @brake_types = BrakeType.all\n end",
"def index\n @bows = Bow.all\n @types = Bowtype.all\n end",
"def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end",
"def booking_ambiance_types_get(opts = {})\n data, _status_code, _headers = booking_ambiance_types_get_with_http_info(opts)\n data\n end",
"def index\n @clothing_types = ClothingType.all\n end",
"def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end",
"def index\n @bed_types = BedType.all\n end",
"def court_types\n render json: GamePass.court_types_options\n end",
"def index\n @cloth_types = ClothType.all\n end",
"def index\n @observation_types = ObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @observation_types }\n end\n end",
"def index\n @weapons_types = WeaponsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weapons_types }\n end\n end",
"def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def index\n @weapon_types = WeaponType.all\n\n render json: @weapon_types\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def index\n # @donor_types = DonorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @donor_types }\n end\n end",
"def index\n authorize @thing, :get_types?\n @thing_types = @thing.thing_types\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def index\n @type_bonds = TypeBond.all\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def index\n @vehicle_types = VehicleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vehicle_types }\n end\n end",
"def freebase_types\n _response_entity.fetch(\"freebaseTypes\", [])\n end",
"def index\n @businesstypes = Businesstype.all\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def index\n @company_types = CompanyType.all\n\n render json: @company_types\n end",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def show\n @bagtype = Bagtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bagtype }\n end\n end",
"def api_block_type_list\n arr = BlockType.where(\"parent_id is null and share = ?\", true).reorder(:name).all.collect do |bt|\n { 'name' => bt.name, 'description' => bt.description }\n end \n render :json => arr \n end",
"def index\n @types = Type.all\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def index\n @typeconges = Typeconge.all\n end",
"def index\n add_breadcrumb \"<i class='fa fa-info-circle'></i> #{I18n.t(\"activerecord.models.card_type\", count: 2)}\".html_safe, card_types_path\n @card_types = CardType.all\n respond_to do |format|\n format.html\n format.json {\n render json: {head: :no_content}\n }\n end\n end",
"def get_available_types_from_usage(usage) #TODO: Research use\n return @client.raw(\"get\", \"/helpers/available-types/#{usage}\")\n end",
"def show\n @api_v1_user_types = Api::V1::UserType.all\n end",
"def index\n @api_v1_user_types = Api::V1::UserType.all\n end",
"def types()\n\t\t@pokemon_types = []\n\t\t@pokemon_api[\"types\"].each do |i|\n\t\t\t@pokemon_types.push(i[\"type\"][\"name\"].capitalize)\n\t\tend\n\t\treturn @pokemon_types\n\tend",
"def index\n @thing_types = ThingType.all\n end",
"def index\n @typebourses = Typebourse.all\n end",
"def available_types\n # TODO pull this from DB or config\n [\n :kiosk,\n :ride,\n :store,\n :restaurant\n ]\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end",
"def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end",
"def show\n @all_type=Api::V1::AdminType.all\n render json: @all_type\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def show\n @business_type = BusinessType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @business_type }\n end\n end",
"def index\n @myers_briggs_types = MyersBriggsType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @myers_briggs_types }\n end\n end",
"def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end",
"def index\n @costtypes = Costtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @costtypes }\n end\n end",
"def index\n @boats = Boat.all\n end",
"def index\n @boats = Boat.all\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def index\n @credit_types = CreditType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @credit_types }\n end\n end",
"def index\n @brew_types = BrewType.all\n end",
"def describe_types\n [@options[:type]].flatten.join('/')\n end",
"def index\n @leavetypes = Leavetype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leavetypes }\n end\n end",
"def index\n @leavetypes = Leavetype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leavetypes }\n end\n end",
"def index\n @novelty_types = NoveltyType.all\n end",
"def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end",
"def index\n @ctypes = Ctype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ctypes }\n end\n end",
"def index\n @trait_types = TraitType.all\n\n render json: @trait_types\n end",
"def get_available_types_from_usage(usage)\n # TODO: Research use\n @client.raw('get', \"/helpers/available-types/#{usage}\")\n end",
"def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def index\n @shape_types = ShapeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_types }\n end\n end",
"def all_btypes_str\n services.map{|el| BILLING_TYPES.invert[el[:btype]].to_s}\n end",
"def set_kind_of_boat\n @kind_of_boat = KindOfBoat.find(params[:id])\n end",
"def index\n if params[:title]\n @boats = Boat.where title: params[:title]\n else\n if params[:open_seats]\n @boats = Boat.where open_seats: params[:open_seats]\n else\n @boats = Boat.all\n end\n end\n render json: @boats\n end",
"def index\n @types = ItemType.all\n end",
"def index\n @box_request_abuse_types = BoxRequestAbuseType.all\n end",
"def index\n pet_type = PetType.find(params[:pet_type_id])\n @pet_breeds = pet_type.pet_breeds.select { | match | match.published }\n\n respond_to do | format |\n format.html #index.html.erb\n format.json { render json: @pet_breeds }\n end\n end",
"def show\n @budgeting_type = BudgetingType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @budgeting_type }\n end\n end",
"def index\n @typeofstatuses = Typeofstatus.all.page params[:page]\n end",
"def index\n @grouptypes = Grouptype.all\n end",
"def boat_type_params\n params.require(:boat_type).permit(:ru_name, :en_name, :design_category, :copy_params_table_from_id, :boat_series_id, :body_type, :ru_description, :en_description, :ru_slogan, :en_slogan, :cnf_data_file_url, :base_cost, :is_deprecated, :is_active, :trademark_id, :use_on_ru, :use_on_en)\n end",
"def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n end\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end",
"def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @product_types }\n end\n end",
"def type\n @json['type']\n end",
"def cmd_types argv\n setup argv\n response = @api.types\n msg response\n return response\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def index\n render json: usage(params[:type])\n end",
"def index\n #@boats = Boat.order(sort_column + ' ' + sort_direction)\n # @boats = Boat.all\n # if params[:search]\n @boats = Boat.search(params[:search])\n # else\n # @boats = Boat.order(sort_column + ' ' + sort_direction)\n # end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boats }\n end\n end",
"def type\n response[\"type\"]\n end",
"def type\n response[\"type\"]\n end",
"def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end",
"def index\n @admission_types = AdmissionType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @admission_types }\n end\n end",
"def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end",
"def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end",
"def create\n @boat_type = BoatType.new(boat_type_params)\n respond_to do |format|\n if @boat_type.save\n format.html { redirect_to edit_boat_type_path(@boat_type)}\n format.json { render json: @boat_type.hash_view('control'), status: :created, location: @boat_type }\n else\n format.html { render :new }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.7141829",
"0.7024058",
"0.685896",
"0.6825305",
"0.6786215",
"0.6741766",
"0.6609532",
"0.64806306",
"0.6408396",
"0.6390036",
"0.6381461",
"0.6358417",
"0.6297997",
"0.6288923",
"0.6232363",
"0.6232077",
"0.6203449",
"0.6180284",
"0.6166267",
"0.6157862",
"0.6138943",
"0.61368644",
"0.6126525",
"0.6120666",
"0.6110923",
"0.6099607",
"0.60932267",
"0.6088754",
"0.60809255",
"0.6055016",
"0.60527015",
"0.6047586",
"0.60318035",
"0.60256064",
"0.6022054",
"0.6018284",
"0.59984595",
"0.599803",
"0.59961975",
"0.5976124",
"0.597075",
"0.5967303",
"0.5959321",
"0.5958894",
"0.5952533",
"0.59474164",
"0.5944855",
"0.59391826",
"0.5935277",
"0.5924586",
"0.5924213",
"0.5920043",
"0.59155786",
"0.5912998",
"0.59082866",
"0.59058",
"0.5903368",
"0.5900013",
"0.5895117",
"0.5895117",
"0.58948666",
"0.58868086",
"0.58704096",
"0.5863872",
"0.5859837",
"0.5859837",
"0.58589834",
"0.5858893",
"0.5857913",
"0.58567",
"0.5855984",
"0.5854267",
"0.5850273",
"0.5848605",
"0.5848443",
"0.58479184",
"0.58477485",
"0.5818876",
"0.5816574",
"0.5816207",
"0.5810237",
"0.5808263",
"0.579572",
"0.5789146",
"0.5787701",
"0.5784816",
"0.5775316",
"0.5775099",
"0.57686627",
"0.5767308",
"0.5766907",
"0.57668704",
"0.57610464",
"0.5760152",
"0.5760152",
"0.5758948",
"0.57577837",
"0.57561076",
"0.5753993",
"0.5749687"
] |
0.61379623
|
21
|
GET /boat_types/1 GET /boat_types/1.json
|
def show
@title = @header = @boat_type.catalog_name
#@data = is_control? ? {boat_type: @boat_type.hash_view(current_site, cur_locale.to_s), trademarks: @trademarks, boat_series: @boat_series} : {boat_type: @boat_type}
respond_to do |format|
format.html
format.json { render json: @data}
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @bet_types = Bet::Type.all\n end",
"def index\n @kind_of_boats = KindOfBoat.all\n end",
"def index\n @bagtypes = Bagtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bagtypes }\n end\n end",
"def index\n @bs_types = BsType.all\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def show\n render json: @bike_type\n end",
"def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def show\n @bagtype = Bagtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bagtype }\n end\n end",
"def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}\n end\n end",
"def show\n @business_type = BusinessType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @business_type }\n end\n end",
"def set_kind_of_boat\n @kind_of_boat = KindOfBoat.find(params[:id])\n end",
"def index\n @bows = Bow.all\n @types = Bowtype.all\n end",
"def index\n @brake_types = BrakeType.all\n end",
"def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end",
"def show\n @budgeting_type = BudgetingType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @budgeting_type }\n end\n end",
"def index\n @clothing_types = ClothingType.all\n end",
"def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end",
"def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end",
"def index\n @boat_types = params[:ids].blank? ? BoatType.active : BoatType.where(id: params[:ids])\n if params[:ids].blank? \n @boat_types = BoatType.active\n #parameter_filter_data = BoatParameterType.filter_data\n #option_filter_data = BoatOptionType.filter_data \n # @filter_data = parameter_filter_data.merge(option_filter_data)\n # @default_boats = BoatForSale.active.ids \n else\n @boat_types = BoatType.with_bfs.where(id: params[:ids])\n end\n end",
"def create\n @boat_type = BoatType.new(boat_type_params)\n respond_to do |format|\n if @boat_type.save\n format.html { redirect_to edit_boat_type_path(@boat_type)}\n format.json { render json: @boat_type.hash_view('control'), status: :created, location: @boat_type }\n else\n format.html { render :new }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @observation_types = ObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @observation_types }\n end\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def index\n @weapons_types = WeaponsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weapons_types }\n end\n end",
"def index\n @cloth_types = ClothType.all\n end",
"def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end",
"def index\n @type_bonds = TypeBond.all\n end",
"def get_batterie_by_building\n @battery = Battery.where(building_id: params[:building_id])\n respond_to do |format| \n format.json { render :json => @battery }\n end\n \n end",
"def index\n # @donor_types = DonorType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @donor_types }\n end\n end",
"def index\n @boats = Boat.all\n end",
"def index\n @boats = Boat.all\n end",
"def index\n @brags = Brag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @brags }\n end\n end",
"def index\n @bed_types = BedType.all\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def index\n @weapon_types = WeaponType.all\n\n render json: @weapon_types\n end",
"def index\n @businesstypes = Businesstype.all\n end",
"def type\n @json['type']\n end",
"def show\n @api_v1_user_types = Api::V1::UserType.all\n end",
"def type\n response[\"type\"]\n end",
"def type\n response[\"type\"]\n end",
"def set_bs_type\n @bs_type = BsType.find(params[:id])\n end",
"def new\n @boat = Boat.new\n @boat_types = BoatType.all.map {|bt| [bt.name, bt.id]}\n @sails = Sail.all.map {|bt| [bt.number, bt.id]}\n @equipments = Equipment.all.map {|bt| [bt.prod_number, bt.id]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boat }\n end\n end",
"def set_bread_type\n @bread_type = BreadType.find(params[:id])\n end",
"def index\n @vehicle_types = VehicleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vehicle_types }\n end\n end",
"def index\n @company_types = CompanyType.all\n\n render json: @company_types\n end",
"def set_boat_type\n #boat_type = \n #redirect_to boat_type.boat_type and return if boat_type.is_modification? \n @boat_type = BoatType.find(params[:id])\n end",
"def index\n @thing_types = ThingType.all\n end",
"def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end",
"def get_break_type(id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::GET,\n '/v2/labor/break-types/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def index\n @myers_briggs_types = MyersBriggsType.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @myers_briggs_types }\n end\n end",
"def new\n @boat = Boat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @boat}\n end\n end",
"def index\n authorize @thing, :get_types?\n @thing_types = @thing.thing_types\n end",
"def index\n @api_v1_user_types = Api::V1::UserType.all\n end",
"def show\n @all_type=Api::V1::AdminType.all\n render json: @all_type\n end",
"def index\n @types = Type.all\n end",
"def index\n if params[:title]\n @boats = Boat.where title: params[:title]\n else\n if params[:open_seats]\n @boats = Boat.where open_seats: params[:open_seats]\n else\n @boats = Boat.all\n end\n end\n render json: @boats\n end",
"def index\n @costtypes = Costtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @costtypes }\n end\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def index\n @typebourses = Typebourse.all\n end",
"def index\n add_breadcrumb \"<i class='fa fa-info-circle'></i> #{I18n.t(\"activerecord.models.card_type\", count: 2)}\".html_safe, card_types_path\n @card_types = CardType.all\n respond_to do |format|\n format.html\n format.json {\n render json: {head: :no_content}\n }\n end\n end",
"def court_types\n render json: GamePass.court_types_options\n end",
"def show\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @crate_type }\n end\n end",
"def show\n @boat_sub_type_section = BoatSubTypeSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @boat_sub_type_section }\n end\n end",
"def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end",
"def index\n @ctypes = Ctype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ctypes }\n end\n end",
"def show\n @bus_seat_type = BusSeatType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bus_seat_type }\n end\n end",
"def index\n @brew_types = BrewType.all\n end",
"def show\n @boat = Boat.find(params[:id])\n @dockyard_spot = DockyardSpot.find_by_boat_id(@boat.id)\n @dockyard = Dockyard.find(@dockyard_spot.dockyard_id) unless @dockyard_spot.nil?\n @berth = Berth.where(:boat_id => @boat.id).first\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boat }\n end\n end",
"def index\n pet_type = PetType.find(params[:pet_type_id])\n @pet_breeds = pet_type.pet_breeds.select { | match | match.published }\n\n respond_to do | format |\n format.html #index.html.erb\n format.json { render json: @pet_breeds }\n end\n end",
"def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end",
"def index\n render json: usage(params[:type])\n end",
"def type\r\n\t\t\t`#{BITS::BITSADMIN} /gettype {#{@id}}`\r\n\t\tend",
"def show\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def index\n @typeconges = Typeconge.all\n end",
"def show\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_type }\n end\n end",
"def show\n @observation_type = ObservationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @observation_type }\n end\n end",
"def index\n @credit_types = CreditType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @credit_types }\n end\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 index\n #@boats = Boat.order(sort_column + ' ' + sort_direction)\n # @boats = Boat.all\n # if params[:search]\n @boats = Boat.search(params[:search])\n # else\n # @boats = Boat.order(sort_column + ' ' + sort_direction)\n # end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boats }\n end\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def battery_select\n p params[\"building_id\"]\n @batteries = Battery.where(building_id: params[\"building_id\"])\n respond_to do |format |\n format.json {\n render json: {\n batteries: @batteries\n }\n }\n end\n end",
"def show\n render json: @weapon_type\n end",
"def booking_ambiance_types_get(opts = {})\n data, _status_code, _headers = booking_ambiance_types_get_with_http_info(opts)\n data\n end",
"def api_block_type_list\n arr = BlockType.where(\"parent_id is null and share = ?\", true).reorder(:name).all.collect do |bt|\n { 'name' => bt.name, 'description' => bt.description }\n end \n render :json => arr \n end",
"def show\n @building_type = BuildingType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @building_type }\n end\n end",
"def index\n @leavetypes = Leavetype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leavetypes }\n end\n end",
"def index\n @leavetypes = Leavetype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leavetypes }\n end\n end",
"def boat_type_params\n params.require(:boat_type).permit(:ru_name, :en_name, :design_category, :copy_params_table_from_id, :boat_series_id, :body_type, :ru_description, :en_description, :ru_slogan, :en_slogan, :cnf_data_file_url, :base_cost, :is_deprecated, :is_active, :trademark_id, :use_on_ru, :use_on_en)\n end",
"def show\n @appliance_type = ApplianceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @appliance_type }\n end\n end",
"def index\n @shape_types = ShapeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_types }\n end\n end",
"def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end",
"def index\n @novelty_types = NoveltyType.all\n end",
"def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end",
"def show\n @type_of_cleaning_and_washing = TypeOfCleaningAndWashing.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type_of_cleaning_and_washing }\n end\n end",
"def index\n @typeofstatuses = Typeofstatus.all.page params[:page]\n end",
"def index\n @types = ItemType.all\n end",
"def index\n @sample_types = SampleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sample_types }\n end\n end"
] |
[
"0.68144935",
"0.6812647",
"0.6690859",
"0.6667126",
"0.66632307",
"0.65838933",
"0.6528449",
"0.65258443",
"0.64698774",
"0.64322037",
"0.6415081",
"0.63811886",
"0.6324647",
"0.6309668",
"0.6308188",
"0.6288893",
"0.62323195",
"0.62296927",
"0.61586994",
"0.61488205",
"0.61379486",
"0.6052765",
"0.60439235",
"0.60348564",
"0.6032545",
"0.603171",
"0.60304487",
"0.6028705",
"0.60246146",
"0.60053957",
"0.59975815",
"0.5982034",
"0.5982034",
"0.59725773",
"0.5962609",
"0.5943442",
"0.5934231",
"0.5923238",
"0.5919673",
"0.59036446",
"0.5900484",
"0.5900484",
"0.58998406",
"0.5899039",
"0.5890552",
"0.5868224",
"0.5861704",
"0.58598405",
"0.5858308",
"0.58549726",
"0.5853498",
"0.584797",
"0.5843529",
"0.58372283",
"0.5833455",
"0.58262414",
"0.5825866",
"0.5821831",
"0.58185554",
"0.5812704",
"0.5812561",
"0.5811695",
"0.5811095",
"0.5808682",
"0.57999074",
"0.5792966",
"0.5791936",
"0.57890433",
"0.5775275",
"0.5770715",
"0.57622576",
"0.5753056",
"0.5752844",
"0.57526284",
"0.5743145",
"0.5737536",
"0.57343173",
"0.573078",
"0.5729569",
"0.5724658",
"0.57222265",
"0.572065",
"0.5719757",
"0.5719369",
"0.5714472",
"0.5714248",
"0.5711729",
"0.57105523",
"0.57099",
"0.57099",
"0.5706583",
"0.57037085",
"0.57008773",
"0.5698228",
"0.56977856",
"0.56818295",
"0.5674584",
"0.5671313",
"0.5664617",
"0.566402"
] |
0.5753815
|
71
|
POST /boat_types POST /boat_types.json
|
def create
@boat_type = BoatType.new(boat_type_params)
respond_to do |format|
if @boat_type.save
format.html { redirect_to edit_boat_type_path(@boat_type)}
format.json { render json: @boat_type.hash_view('control'), status: :created, location: @boat_type }
else
format.html { render :new }
format.json { render json: @boat_type.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def boat_type_params\n params.require(:boat_type).permit(:ru_name, :en_name, :design_category, :copy_params_table_from_id, :boat_series_id, :body_type, :ru_description, :en_description, :ru_slogan, :en_slogan, :cnf_data_file_url, :base_cost, :is_deprecated, :is_active, :trademark_id, :use_on_ru, :use_on_en)\n end",
"def create\n @kind_of_boat = KindOfBoat.new(kind_of_boat_params)\n\n respond_to do |format|\n if @kind_of_boat.save\n format.html { redirect_to @kind_of_boat, notice: 'Kind of boat was successfully created.' }\n format.json { render :show, status: :created, location: @kind_of_boat }\n else\n format.html { render :new }\n format.json { render json: @kind_of_boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bs_type = BsType.new(bs_type_params)\n\n respond_to do |format|\n if @bs_type.save\n format.html { redirect_to @bs_type, notice: 'Bs type was successfully created.' }\n format.json { render :show, status: :created, location: @bs_type }\n else\n format.html { render :new }\n format.json { render json: @bs_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_break_type(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/labor/break-types',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def create\n @bet_type = Bet::Type.new(bet_type_params)\n\n respond_to do |format|\n if @bet_type.save\n format.html { redirect_to @bet_type, notice: 'Type was successfully created.' }\n format.json { render :show, status: :created, location: @bet_type }\n else\n format.html { render :new }\n format.json { render json: @bet_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bagtype = Bagtype.new(params[:bagtype])\n\n respond_to do |format|\n if @bagtype.save\n format.html { redirect_to @bagtype, notice: 'Bagtype was successfully created.' }\n format.json { render json: @bagtype, status: :created, location: @bagtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bagtype.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 create\n @brake_type = BrakeType.new(brake_type_params)\n\n respond_to do |format|\n if @brake_type.save\n format.html { redirect_to brake_types_path, notice: 'Brake type was successfully created.' }\n format.json { render :show, status: :created, location: @brake_type }\n else\n format.html { render :new }\n format.json { render json: @brake_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end",
"def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end",
"def kind_of_boat_params\n params.require(:kind_of_boat).permit(:kind)\n end",
"def create\n @bike_type = BikeType.new(bike_type_params)\n\n if @bike_type.save\n audit(@bike_type, current_user)\n render json: @bike_type, status: :created\n else\n render json: @bike_type.errors, status: :unprocessable_entity\n end\n end",
"def create_types\n @types.each do |type|\n create_type(type) unless Type.where(name: type['name']).first\n end\n end",
"def create\n @business_type = BusinessType.new(params[:business_type])\n\n respond_to do |format|\n if @business_type.save\n format.html { redirect_to @business_type, notice: 'Business type was successfully created.' }\n format.json { render json: @business_type, status: :created, location: @business_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @business_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_types\n\t[]\nend",
"def create_types\n\t[]\nend",
"def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boat, status: 201\n \tend\n\tend",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t\t[]\n\tend",
"def bs_type_params\n params.require(:bs_type).permit(:bs_db_id, :name, :short_name, :is_precision, :is_scale, :delflag)\n end",
"def brake_type_params\n params.require(:brake_type).permit(:name, :model_part, :status)\n end",
"def create\n @boat = Boat.new(boat_params)\n\n respond_to do |format|\n if @boat.save\n format.html { redirect_to @boat, notice: 'Boat was successfully created.' }\n format.json { render :show, status: :created, location: @boat }\n else\n format.html { render :new }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_kind_of_boat\n @kind_of_boat = KindOfBoat.find(params[:id])\n end",
"def bath_type_params\n params.permit(:name)\n end",
"def create\n @type_bond = TypeBond.new(type_bond_params)\n\n respond_to do |format|\n if @type_bond.save\n format.html { redirect_to @type_bond, notice: 'Type bond was successfully created.' }\n format.json { render :show, status: :created, location: @type_bond }\n else\n format.html { render :new }\n format.json { render json: @type_bond.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end",
"def create\n @type = Type.new(type_params)\n @sub_types = params[:subtype_attributes]\n if @type.save\n @sub_types.each do |subtype|\n @subtype = @type.subtype.new\n @subtype.name = subtype[\"name\"]\n @subtype.code = subtype[\"code\"]\n @subtype.save\n end\n flash[:notice] = 'Type was successfully created.'\n redirect_to types_path\n else\n flash[:error] = @type.errors.full_messages\n render \"new\"\n end\n end",
"def types\n commit('types', nil)\n end",
"def set_boat_type\n #boat_type = \n #redirect_to boat_type.boat_type and return if boat_type.is_modification? \n @boat_type = BoatType.find(params[:id])\n end",
"def index\n @bs_types = BsType.all\n end",
"def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end",
"def brew_type_params\n params.require(:brew_type).permit(:name, :description)\n end",
"def index\n @bet_types = Bet::Type.all\n end",
"def bread_type_params\n params.require(:bread_type).permit(:name, :sour_dough, :notes, :wholesale_only)\n end",
"def type_breeder_params\n params.require(:type_breeder).permit(:name)\n end",
"def create\n @boat = current_user.boats.build(boat_params)\n @boat.create_boat_features_set\n respond_to do |format|\n if @boat.save\n format.html { redirect_to edit_boat_path(@boat), notice: _(\"Boat was successfully created\") }\n format.json { render :edit, status: :created, location: @boat }\n else\n # pictures must be rebuilt to make the field appear in the form\n @boat.pictures.build unless @boat.pictures.any?\n format.html { render :new }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @bagtypes = Bagtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bagtypes }\n end\n end",
"def create\n @bus_seat_type = BusSeatType.new(params[:bus_seat_type])\n\n respond_to do |format|\n if @bus_seat_type.save\n format.html { redirect_to @bus_seat_type, notice: 'Bus seat type was successfully created.' }\n format.json { render json: @bus_seat_type, status: :created, location: @bus_seat_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bus_seat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boat_params\n params.require(:boat).permit(:name, :containers, :location)\n end",
"def create\n @crossbowtype = Crossbowtype.new(crossbowtype_params)\n\n respond_to do |format|\n if @crossbowtype.save\n format.html { redirect_to @crossbowtype, notice: 'Crossbowtype was successfully created.' }\n format.json { render action: 'show', status: :created, location: @crossbowtype }\n else\n format.html { render action: 'new' }\n format.json { render json: @crossbowtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @brew_type = BrewType.new(brew_type_params)\n\n respond_to do |format|\n if @brew_type.save\n format.html { redirect_to @brew_type, notice: 'Brew type was successfully created.' }\n format.json { render :show, status: :created, location: @brew_type }\n else\n format.html { render :new }\n format.json { render json: @brew_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type_bond_params\n params.require(:type_bond).permit(:name, :abbreviation)\n end",
"def create\n @register_animal_type = Register::AnimalType.new(register_animal_type_params)\n\n respond_to do |format|\n if @register_animal_type.save\n format.html { redirect_to register_animal_types_path, success: 'O tipo de animal foi criado com sucesso.' }\n format.json { render :index, status: :created, location: @register_animal_type }\n else\n format.html { render :new }\n format.json { render json: @register_animal_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def clothing_type_params\n params.require(:clothing_type).permit(:name)\n end",
"def type_params\n params.require(:type).permit( :name)\n end",
"def bet_type_params\n params.require(:bet_type).permit(:group_id, :name, :find_names, :created, :api_xbet_id, :api_xbet_params)\n end",
"def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end",
"def create\n @customer = Customer.new(params[:customer])\n @customer_types =\n CustomerType.new(\n :customer_type => params[:customer_type],\n :customer_type_name => params[:customer_type_name],\n :zip_number => params[:zip_number],\n :prefecture_cd => params[:prefecture_cd],\n :city => params[:city],\n :oaza => params[:oaza],\n :town => params[:town],\n :building_name => params[:building_name],\n :customer_type_memo => params[:customer_type_memo])\n\n @customer.customer_types << @customer_types\n\n respond_to do |format|\n if @customer.save\n format.html { redirect_to @customer, notice: '以下の情報が登録されました。' }\n format.json { render json: @customer, status: :created, location: @customer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @observation_type = ObservationType.new(params[:observation_type])\n\n respond_to do |format|\n if @observation_type.save\n format.html { redirect_to @observation_type, notice: 'Observation type was successfully created.' }\n format.json { render json: @observation_type, status: :created, location: @observation_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @observation_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end",
"def typeconge_params\n params.require(:typeconge).permit(:typeconge)\n end",
"def set_bs_type\n @bs_type = BsType.find(params[:id])\n end",
"def type_params\n params.require(:type).permit(:common_name, :botanical_name, :info_panel, :count)\n end",
"def create\n @bus_type = BusType.new(bus_type_params)\n\n respond_to do |format|\n if @bus_type.save\n format.html { redirect_to bus_type_path(@bus_type.slug), notice: \"#{_('Bus type')} #{_('was successfully')} #{_('created')}.\" }\n format.json { render :show, status: :created, location: @bus_type }\n else\n format.html {\n add_breadcrumb :new, new_bus_type_path\n render :new\n }\n format.json { render json: @bus_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @type_breeder = TypeBreeder.new(type_breeder_params)\n respond_to do |format|\n if @type_breeder.save\n format.html { redirect_to admin_type_breeders_url, notice: 'El tipo criador fue creador' }\n format.json { render :show, status: :created, location: @type_breeder }\n else\n format.html { render :new }\n format.js\n format.json { render json: @type_breeder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def crossbowtype_params\n params.require(:crossbowtype).permit(:name)\n end",
"def court_types\n render json: GamePass.court_types_options\n end",
"def index\n @kind_of_boats = KindOfBoat.all\n end",
"def type_params\n params.require(:type).permit(:name)\n end",
"def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end",
"def housing_type_params\n params.require(:housing_type).permit(:name)\n end",
"def create\n @appliance_type = ApplianceType.new(params[:appliance_type])\n\n respond_to do |format|\n if @appliance_type.save\n format.html { redirect_to @appliance_type, notice: 'Appliance type was successfully created.' }\n format.json { render json: @appliance_type, status: :created, location: @appliance_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @appliance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_bread_type\n @bread_type = BreadType.find(params[:id])\n end",
"def new\n @boat = Boat.new\n @boat_types = BoatType.all.map {|bt| [bt.name, bt.id]}\n @sails = Sail.all.map {|bt| [bt.number, bt.id]}\n @equipments = Equipment.all.map {|bt| [bt.prod_number, bt.id]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boat }\n end\n end",
"def create\n @bed_type = BedType.new(bed_type_params)\n\n respond_to do |format|\n if @bed_type.save\n format.html { redirect_to @bed_type, notice: 'Bed type was successfully created.' }\n format.json { render :show, status: :created, location: @bed_type }\n else\n format.html { render :new }\n format.json { render json: @bed_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @type_of_cleaning_and_washing = TypeOfCleaningAndWashing.new(params[:type_of_cleaning_and_washing])\n\n respond_to do |format|\n if @type_of_cleaning_and_washing.save\n format.html { redirect_to type_of_cleaning_and_washings_path, notice: 'Type of cleaning and washing was successfully created.' }\n format.json { render json: @type_of_cleaning_and_washing, status: :created, location: @type_of_cleaning_and_washing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @type_of_cleaning_and_washing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @building_type = BuildingType.new(params[:building_type])\n\n respond_to do |format|\n if @building_type.save\n format.html { redirect_to @building_type, notice: 'Building type was successfully created.' }\n format.json { render json: @building_type, status: :created, location: @building_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @building_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cloth_type_params\n params.require(:cloth_type).permit(:name)\n end",
"def create\n @weapon_type = WeaponType.new(weapon_type_params)\n\n if @weapon_type.save\n render json: @weapon_type, status: :created, location: @weapon_type\n else\n render json: @weapon_type.errors, status: :unprocessable_entity\n end\n end",
"def create\n @boat = @harbour.boats.build(boat_params)\n @boat.save\n redirect_to harbour_boats_path(@harbour)\n # respond_to do |format|\n # if @boat.save\n # format.html { redirect_to harbour_boats_path, notice: 'Boat was successfully created.' }\n # format.json { render :show, status: :created, location: @boat }\n # else\n # format.html { render :new }\n # format.json { render json: @boat.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create \n @typeio = Typeio.new(typeio_params)\n @typeio.bulletin_board = @bulletin_board\n @typeio.user = current_user\n\t\n respond_to do |format|\n if @typeio.save\n format.html { redirect_to @typeio.bulletin_board, notice: 'Typeio was successfully created.' }\n format.json { render :show, status: :created, location: @typeio }\n else\n format.html { render :new }\n format.json { render json: @typeio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booktype = Booktype.new(booktype_params)\n\n respond_to do |format|\n if @booktype.save\n format.html { redirect_to @booktype, notice: 'Booktype was successfully created.' }\n format.json { render :show, status: :created, location: @booktype }\n else\n format.html { render :new }\n format.json { render json: @booktype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @typeofstatus = Typeofstatus.new(typeofstatus_params)\n\n respond_to do |format|\n if @typeofstatus.save\n format.html { redirect_to @typeofstatus, notice: 'Typeofstatus was successfully created.' }\n format.json { render :show, status: :created, location: @typeofstatus }\n else\n format.html { render :new }\n format.json { render json: @typeofstatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @act_type = ActType.new(params[:act_type])\n\n respond_to do |format|\n if @act_type.save\n format.html { redirect_to @act_type, notice: 'Тип документа успешно создан.' }\n format.json { render json: @act_type, status: :created, location: @act_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @act_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @novelty_type = NoveltyType.new(novelty_type_params)\n\n respond_to do |format|\n if @novelty_type.save\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully created.' }\n format.json { render :show, status: :created, location: @novelty_type }\n else\n format.html { render :new }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @brake_types = BrakeType.all\n end",
"def create\n @realty_type = RealtyType.new(params[:realty_type])\n\n respond_to do |format|\n if @realty_type.save\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully created.' }\n format.json { render json: @realty_type, status: :created, location: @realty_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def location_type_params\n params.require(:location_type).permit(:name,\n :location_types => [])\n end",
"def create\n @businesstype = Businesstype.new(businesstype_params)\n\n respond_to do |format|\n if @businesstype.save\n format.html { redirect_to @businesstype, notice: 'Businesstype was successfully created.' }\n format.json { render :show, status: :created, location: @businesstype }\n else\n format.html { render :new }\n format.json { render json: @businesstype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @weapons_type = WeaponsType.new(params[:weapons_type])\n\n respond_to do |format|\n if @weapons_type.save\n format.html { redirect_to @weapons_type, notice: 'Weapons type was successfully created.' }\n format.json { render json: @weapons_type, status: :created, location: @weapons_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weapons_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @typebourse = Typebourse.new(typebourse_params)\n\n respond_to do |format|\n if @typebourse.save\n format.html { redirect_to @typebourse, notice: 'Typebourse was successfully created.' }\n format.json { render :show, status: :created, location: @typebourse }\n else\n format.html { render :new }\n format.json { render json: @typebourse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bus_type_params\n params.require(:bus_type).permit(:name, :capacity, :left, :right, :facility => [])\n end",
"def create\n @company_type = CompanyType.new(company_type_params)\n\n if @company_type.save\n render json: @company_type, status: :created, location: @company_type\n else\n render json: @company_type.errors, status: :unprocessable_entity\n end\n end",
"def add_type(type)\n end",
"def create\n @crate_type = CrateType.new(params[:crate_type])\n\n respond_to do |format|\n if @crate_type.save\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully created.' }\n format.json { render :json => @crate_type, :status => :created, :location => @crate_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @types_of_apprenticeship = TypesOfApprenticeship.new(params[:types_of_apprenticeship])\n\n respond_to do |format|\n if @types_of_apprenticeship.save\n format.html { redirect_to @types_of_apprenticeship, notice: 'Types of apprenticeship was successfully created.' }\n format.json { render json: @types_of_apprenticeship, status: :created, location: @types_of_apprenticeship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @types_of_apprenticeship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @clothing_type = ClothingType.new(clothing_type_params)\n\n respond_to do |format|\n if @clothing_type.save\n format.html { redirect_to @clothing_type, notice: 'Clothing type was successfully created.' }\n format.json { render :show, status: :created, location: @clothing_type }\n else\n format.html { render :new }\n format.json { render json: @clothing_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @water_type = WaterType.new(water_type_params)\n\n respond_to do |format|\n if @water_type.save\n format.html { redirect_to admin_water_types_path, notice: 'Water type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @water_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @water_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @typeconge = Typeconge.new(typeconge_params)\n\n respond_to do |format|\n if @typeconge.save\n format.html { redirect_to @typeconge, notice: 'Typeconge was successfully created.' }\n format.json { render :show, status: :created, location: @typeconge }\n else\n format.html { render :new }\n format.json { render json: @typeconge.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_types\n\t\t[]\n\tend",
"def update_types\n\t\t[]\n\tend",
"def show\n render json: @bike_type\n end",
"def bed_type_params\n params.permit(:name)\n end",
"def index\n @bows = Bow.all\n @types = Bowtype.all\n end",
"def client_type_params\n params.require(:client_type).permit(:category, :status)\n end",
"def create\n @girltype = Girltype.new(params[:girltype])\n\n respond_to do |format|\n if @girltype.save\n format.html { redirect_to @girltype, notice: 'Girltype was successfully created.' }\n format.json { render json: @girltype, status: :created, location: @girltype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @girltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ref_mkb_type = Ref::MkbType.new(params[:ref_mkb_type])\n\n respond_to do |format|\n if @ref_mkb_type.save\n format.html { redirect_to ref_mkb_types_path, notice: I18n.t(:record_created) }\n format.json { render json: @ref_mkb_type, status: :created, location: @ref_mkb_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ref_mkb_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_types\n\t[]\nend",
"def update_types\n\t[]\nend"
] |
[
"0.6612902",
"0.65330064",
"0.6479013",
"0.63873273",
"0.63754666",
"0.629241",
"0.6270711",
"0.6210799",
"0.618794",
"0.614453",
"0.6124388",
"0.61091834",
"0.60448927",
"0.6033925",
"0.60282665",
"0.59335744",
"0.59335744",
"0.5928024",
"0.5919358",
"0.5919358",
"0.58681124",
"0.5863842",
"0.5862015",
"0.58410573",
"0.5820749",
"0.581666",
"0.581184",
"0.57880336",
"0.5784831",
"0.5764372",
"0.57573926",
"0.5731893",
"0.5711593",
"0.5710856",
"0.5699836",
"0.5698669",
"0.5698221",
"0.5670733",
"0.56650126",
"0.56521493",
"0.5643734",
"0.5641134",
"0.56407833",
"0.56371456",
"0.56326294",
"0.5629309",
"0.5621835",
"0.561938",
"0.5618835",
"0.5618179",
"0.5609284",
"0.55951387",
"0.5584178",
"0.5581126",
"0.55725574",
"0.556556",
"0.5560213",
"0.55546707",
"0.55503565",
"0.55435055",
"0.55132014",
"0.55106217",
"0.55035037",
"0.54966563",
"0.5496452",
"0.54908967",
"0.5471673",
"0.5466106",
"0.5464804",
"0.54647523",
"0.5464098",
"0.5461981",
"0.54543316",
"0.5439244",
"0.5434282",
"0.5426275",
"0.54218054",
"0.54148716",
"0.54080856",
"0.5399681",
"0.53996253",
"0.539387",
"0.539367",
"0.5391519",
"0.53913456",
"0.53781",
"0.53736347",
"0.5367417",
"0.53593427",
"0.53562754",
"0.53548634",
"0.53548634",
"0.53467005",
"0.5345137",
"0.5344441",
"0.53366154",
"0.53358644",
"0.5334177",
"0.5330838",
"0.5330838"
] |
0.6875857
|
0
|
PATCH/PUT /boat_types/1 PATCH/PUT /boat_types/1.json
|
def update
prms = @boat_type.is_modification? ? modification_params : boat_type_params
respond_to do |format|
if @boat_type.update(prms)
format.html { redirect_to edit_boat_type_path(@boat_type), notice: 'Тип лодки успешно обновлён' }
format.json { render json: @boat_type.hash_view('control'), status: :ok}
else
format.html { render :edit }
format.json { render json: @boat_type.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n respond_to do |format|\n if @kind_of_boat.update(kind_of_boat_params)\n format.html { redirect_to @kind_of_boat, notice: 'Kind of boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @kind_of_boat }\n else\n format.html { render :edit }\n format.json { render json: @kind_of_boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @brake_type.update(brake_type_params)\n format.html { redirect_to brake_types_path, notice: 'Brake type was successfully updated.' }\n format.json { render :show, status: :ok, location: @brake_type }\n else\n format.html { render :edit }\n format.json { render json: @brake_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def set_boat_type\n #boat_type = \n #redirect_to boat_type.boat_type and return if boat_type.is_modification? \n @boat_type = BoatType.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @bs_type.update(bs_type_params)\n format.html { redirect_to @bs_type, notice: 'Bs type was successfully updated.' }\n format.json { render :show, status: :ok, location: @bs_type }\n else\n format.html { render :edit }\n format.json { render json: @bs_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bagtype = Bagtype.find(params[:id])\n\n respond_to do |format|\n if @bagtype.update_attributes(params[:bagtype])\n format.html { redirect_to @bagtype, notice: 'Bagtype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bagtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_boat\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to harbour_boats_path, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_kind_of_boat\n @kind_of_boat = KindOfBoat.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @bet_type.update(bet_type_params)\n format.html { redirect_to @bet_type, notice: 'Type was successfully updated.' }\n format.json { render :show, status: :ok, location: @bet_type }\n else\n format.html { render :edit }\n format.json { render json: @bet_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bike_type = BikeType.find(params[:id])\n\n if @bike_type.update(bike_type_params)\n audit(@bike_type, current_user)\n render json: @bike_type, status: :ok\n else\n render json: @bike_type.errors, status: :unprocessable_entity\n end\n end",
"def update_break_type(id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/labor/break-types/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def update\n @business_type = BusinessType.find(params[:id])\n\n respond_to do |format|\n if @business_type.update_attributes(params[:business_type])\n format.html { redirect_to @business_type, notice: 'Business type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @business_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @type_bond.update(type_bond_params)\n format.html { redirect_to @type_bond, notice: 'Type bond was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_bond }\n else\n format.html { render :edit }\n format.json { render json: @type_bond.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @crossbowtype.update(crossbowtype_params)\n format.html { redirect_to @crossbowtype, notice: 'Crossbowtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @crossbowtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n if @boat.update_attributes(params[:boat])\n format.html { redirect_to(@boat, :notice => 'Boat was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boat.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clothing_type.update(clothing_type_params)\n format.html { redirect_to @clothing_type, notice: 'Clothing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @clothing_type }\n else\n format.html { render :edit }\n format.json { render json: @clothing_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @boat_sub_type_section = BoatSubTypeSection.find(params[:id])\n\n respond_to do |format|\n if @boat_sub_type_section.update_attributes(params[:boat_sub_type_section])\n format.html { redirect_to(@boat_sub_type_section, :notice => 'Boat sub type section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boat_sub_type_section.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @box_request_abuse_type.update(box_request_abuse_type_params)\n format.html { redirect_to @box_request_abuse_type, notice: 'Box request abuse type was successfully updated.' }\n format.json { render :show, status: :ok, location: @box_request_abuse_type }\n else\n format.html { render :edit }\n format.json { render json: @box_request_abuse_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: _(\"Boat was successfully updated\") }\n format.js\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.js\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @brew_type.update(brew_type_params)\n format.html { redirect_to @brew_type, notice: 'Brew type was successfully updated.' }\n format.json { render :show, status: :ok, location: @brew_type }\n else\n format.html { render :edit }\n format.json { render json: @brew_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @type_breeder.update(type_breeder_params)\n format.html { redirect_to admin_type_breeders_url, notice: 'El tipo criador fue modificado' }\n format.json { render :show, status: :ok, location: @type_breeder }\n else\n flash[:notice] = 'Tipo de criador no puede ser modificado'\n format.html { render :edit }\n format.json { render json: @type_breeder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @boat_engine_fuel_type = BoatEngineFuelType.find(params[:id])\n\n respond_to do |format|\n if @boat_engine_fuel_type.update_attributes(params[:boat_engine_fuel_type])\n format.html { redirect_to(@boat_engine_fuel_type, :notice => 'Boat engine fuel type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @boat_engine_fuel_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @boat = Boat.find(params[:id])\n @boat.update({\n name: params[:boat][:name],\n maxcontainers: params[:boat][:maxcontainers],\n company_id: params[:boat][:company_id],\n location: params[:boat][:location],\n image: params[:boat][:image]\n })\n\n if (@boat)\n redirect_to url_for(:controller => :boats, :action => :index)\n else\n redirect_to url_for(:controller => :boats, :action => :edit)\n end\n end",
"def update\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n if @crate_type.update_attributes(params[:crate_type])\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n if @boat.update_attributes(boat_params)\n=begin\n @user = User.find_by_mobile_no(@boat.mobile_no)\n @boat.user_id = @user.id if @user.present?\n @boat.save\n=end\n format.html {redirect_to @boat, notice: 'Boat was successfully updated.'}\n format.json {head :no_content}\n else\n format.html {render action: \"edit\"}\n format.json {render json: @boat.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n respond_to do |format|\n if @my_boice.update(my_boice_params)\n format.html { redirect_to @my_boice, notice: 'My boice was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_boice }\n else\n format.html { render :edit }\n format.json { render json: @my_boice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bus_seat_type = BusSeatType.find(params[:id])\n\n respond_to do |format|\n if @bus_seat_type.update_attributes(params[:bus_seat_type])\n format.html { redirect_to @bus_seat_type, notice: 'Bus seat type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bus_seat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @appliance_type = ApplianceType.find(params[:id])\n\n respond_to do |format|\n if @appliance_type.update_attributes(params[:appliance_type])\n format.html { redirect_to @appliance_type, notice: 'Appliance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @appliance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bounty.update(bounty_params)\n format.html { redirect_to @bounty, notice: 'Bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @novelty_type.update(novelty_type_params)\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully updated.' }\n format.json { render :show, status: :ok, location: @novelty_type }\n else\n format.html { render :edit }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cloth_type.update(cloth_type_params)\n format.html { redirect_to @cloth_type, notice: \"Cloth type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cloth_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cloth_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bus_type.update(bus_type_params)\n format.html { redirect_to bus_type_path(@bus_type.slug), notice: \"#{_('Bus type')} #{_('was successfully')} #{_('updated')}.\" }\n format.json { render :show, status: :ok, location: @bus_type }\n else\n format.html {\n add_breadcrumb :edit, edit_bus_type_path(@bus_type.slug)\n render :edit\n }\n format.json { render json: @bus_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @type.update(type_params)\n end",
"def update\n @benchmark_type = BenchmarkType.find(params[:id])\n\n respond_to do |format|\n if @benchmark_type.update_attributes(params[:benchmark_type])\n format.html { redirect_to @benchmark_type, :notice => 'Benchmark type was successfully updated.' }\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @benchmark_type.errors, :status => :unprocessable_entity }\n format.xml { render :xml => @benchmark_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n if @client_type.update_attributes(params[:client_type])\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat_attachment.update(boat_attachment_params)\n format.html { redirect_to @boat_attachment, notice: 'Boat attachment was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat_attachment }\n else\n format.html { render :edit }\n format.json { render json: @boat_attachment.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @boat_document.update(boat_document_params)\n format.html { redirect_to @boat_document, notice: 'Boat document was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat_document }\n else\n format.html { render :edit }\n format.json { render json: @boat_document.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @thing_type.update(thing_type_params)\n format.html { redirect_to @thing_type, notice: 'Thing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_type }\n else\n format.html { render :edit }\n format.json { render json: @thing_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n\n respond_to do |format|\n if @ref_mkb_type.update_attributes(params[:ref_mkb_type])\n format.html { redirect_to ref_mkb_types_path, notice: I18n.t(:record_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ref_mkb_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update \t\n record = AssetType.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end",
"def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend",
"def update\n @type_of_cleaning_and_washing = TypeOfCleaningAndWashing.find(params[:id])\n\n respond_to do |format|\n if @type_of_cleaning_and_washing.update_attributes(params[:type_of_cleaning_and_washing])\n format.html { redirect_to type_of_cleaning_and_washings_path, notice: 'Type of cleaning and washing was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @type_of_cleaning_and_washing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bill.type_of_bill_id = 1\n respond_to do |format|\n if @bill.update(bill_params)\n format.html { redirect_to bills_url, notice: 'Счет успешно обновлен.' }\n format.json { render :show, status: :ok, location: @bill }\n log(current_user.id,\"Обновил счет\",\"\")\n else\n format.html { render :edit }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @gift_type.update(gift_type_params)\n format.html { redirect_to admin_gift_type_url(@gift_type), notice: 'Gift type was successfully updated.' }\n format.json { render :show, status: :ok, location: @gift_type }\n else\n format.html { render :edit }\n format.json { render json: @gift_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pet_breed.update(pet_breed_params)\n format.html { redirect_to pet_type_path(@pet_breed.pet_type), notice: 'Pet breed was successfully updated.' }\n format.json { render :show, status: :ok, location: @pet_breed }\n else\n format.html { render :edit }\n format.json { render json: @pet_breed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @observation_type = ObservationType.find(params[:id])\n\n respond_to do |format|\n if @observation_type.update_attributes(params[:observation_type])\n format.html { redirect_to @observation_type, notice: 'Observation type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @observation_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @girltype = Girltype.find(params[:id])\n\n respond_to do |format|\n if @girltype.update_attributes(params[:girltype])\n format.html { redirect_to @girltype, notice: 'Girltype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @girltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boleta.update(boleta_params)\n format.html { redirect_to @boleta, notice: 'Boleta was successfully updated.' }\n format.json { render :show, status: :ok, location: @boleta }\n else\n format.html { render :edit }\n format.json { render json: @boleta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booktype.update(booktype_params)\n format.html { redirect_to @booktype, notice: 'Booktype was successfully updated.' }\n format.json { render :show, status: :ok, location: @booktype }\n else\n format.html { render :edit }\n format.json { render json: @booktype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n if @realty_type.update_attributes(params[:realty_type])\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boat_type = BoatType.new(boat_type_params)\n respond_to do |format|\n if @boat_type.save\n format.html { redirect_to edit_boat_type_path(@boat_type)}\n format.json { render json: @boat_type.hash_view('control'), status: :created, location: @boat_type }\n else\n format.html { render :new }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n @boat = Boat.find(params[:id])\n @boat.update_attributes! params[:boat]\n flash[:notice] = \"Boat updated\"\n return redirect_to(:action => :index)\n rescue ActiveRecord::RecordNotFound\n @entry = nil\n flash[:error] = \"Unable to find boat with id #{params[:id]}\"\n return redirect_to(:action => :index)\n rescue Exception => e\n flash[:error] = \"Unable to update boat: #{e}\"\n end\n\n respond_to do |format|\n format.html { render :action => :edit }\n end\n end",
"def update\n #@title = @header = \"Изменение торговой марки\"\n respond_to do |format|\n if @boat_series.update(boat_series_params)\n #format.html { redirect_to @boat_series, notice: 'Торговая марка успешно изменена' }\n format.json { render json: @boat_series.to_json }\n else\n #format.html { render :edit }\n format.json { render json: @boat_series.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opportunity_type = OpportunityType.find(params[:id])\n\n respond_to do |format|\n if @opportunity_type.update_attributes(params[:opportunity_type])\n format.html { redirect_to @opportunity_type, notice: 'Opportunity type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opportunity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @businesstype = Businesstype.find(params[:id])\n\n respond_to do |format|\n if @businesstype.update_attributes(params[:businesstype])\n format.html { redirect_to @businesstype, notice: 'Businesstype was successfully updated.' }\n format.json { render :show, status: :ok, location: @businesstype }\n else\n format.html { render :edit }\n format.json { render json: @businesstype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @block_type.update(block_type_params)\n format.html { redirect_to block_types_url, notice: 'Block type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @block_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_billable\n @billable_type = BillableType.find_by_id(params[:id])\n if @billable_type\n else\n \trender json: { valid: false}, status: 404\n end\n end",
"def set_bet_type\n @bet_type = Bet::Type.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @call_type.update(call_type_params)\n format.html { redirect_to @call_type, notice: 'Call type was successfully updated.' }\n format.json { render :show, status: :ok, location: @call_type }\n else\n format.html { render :edit }\n format.json { render json: @call_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @typebourse.update(typebourse_params)\n format.html { redirect_to @typebourse, notice: 'Typebourse was successfully updated.' }\n format.json { render :show, status: :ok, location: @typebourse }\n else\n format.html { render :edit }\n format.json { render json: @typebourse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @model_type.update(model_type_params)\n format.html { redirect_to @model_type, notice: 'Model type was successfully updated.' }\n format.json { render :show, status: :ok, location: @model_type }\n else\n format.html { render :edit }\n format.json { render json: @model_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @building_type = BuildingType.find(params[:id])\n\n respond_to do |format|\n if @building_type.update_attributes(params[:building_type])\n format.html { redirect_to @building_type, notice: 'Building type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @building_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @typeio.update(typeio_params)\n format.html { redirect_to @bulletin_board, notice: 'Typeio was successfully updated.' }\n format.json { render :show, status: :ok, location: @typeio }\n else\n format.html { render :edit }\n format.json { render json: @typeio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @company_type = CompanyType.find(params[:id])\n\n if @company_type.update(company_type_params)\n head :no_content\n else\n render json: @company_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n @agency_type = AgencyType.find(params[:id])\n\n respond_to do |format|\n if @agency_type.update_attributes(params[:agency_type])\n format.html { redirect_to @agency_type, notice: 'Agency type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agency_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mall_type = MallType.find(params[:id])\n\n respond_to do |format|\n if @mall_type.update_attributes(params[:mall_type])\n format.html { redirect_to @mall_type, notice: 'Mall type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mall_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @claim_type.update(claim_type_params)\n format.html { redirect_to @claim_type, notice: 'Claim type was successfully updated.' }\n format.json { render :show, status: :ok, location: @claim_type }\n else\n format.html { render :edit }\n format.json { render json: @claim_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @banco.update(banco_params)\n format.html { redirect_to(:bancos, :notice => t('activerecord.successful.messages.updated', :model => @banco.class.model_name.human))}\n format.json { render :show, status: :ok, location: @banco }\n else\n format.html { render :edit }\n format.json { render :json => { :errors => @banco.errors.full_messages }, :status => 422 }\n end\n end\n end",
"def set_boat\n @boat = Boat.find(params[:boat_id])\n end",
"def update\n @boxtype = Boxtype.find(params[:id])\n\n respond_to do |format|\n if @boxtype.update_attributes(params[:boxtype])\n format.html { redirect_to @boxtype, notice: 'Boxtype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boxtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @breet.update(breet_params)\n format.html { redirect_to @breet, notice: 'Breet was successfully updated.' }\n format.json { render :show, status: :ok, location: @breet }\n else\n format.html { render :edit }\n format.json { render json: @breet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @myers_briggs_type = MyersBriggsType.find(params[:id])\n\n respond_to do |format|\n if @myers_briggs_type.update_attributes(params[:myers_briggs_type])\n flash[:notice] = 'Myers Briggs Type was successfully updated.'\n format.html { redirect_to(@myers_briggs_type) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @myers_briggs_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bingo.update(bingo_params)\n format.html { redirect_to @bingo, notice: \"Bingo was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bingo }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bingo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n if @special_needs_type.update_attributes(params[:special_needs_type])\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @act_type = ActType.find(params[:id])\n\n respond_to do |format|\n if @act_type.update_attributes(params[:act_type])\n format.html { redirect_to @act_type, notice: 'Данные типа документа успешно обновлены.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @act_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boc.update(boc_params)\n format.html { redirect_to @boc, notice: 'Boc was successfully updated.' }\n format.json { render :show, status: :ok, location: @boc }\n else\n format.html { render :edit }\n format.json { render json: @boc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def boat_type_params\n params.require(:boat_type).permit(:ru_name, :en_name, :design_category, :copy_params_table_from_id, :boat_series_id, :body_type, :ru_description, :en_description, :ru_slogan, :en_slogan, :cnf_data_file_url, :base_cost, :is_deprecated, :is_active, :trademark_id, :use_on_ru, :use_on_en)\n end",
"def update\n @gearbox_type = GearboxType.find(params[:id])\n\n respond_to do |format|\n if @gearbox_type.update_attributes(params[:gearbox_type])\n format.html { redirect_to(@gearbox_type, :notice => 'Gearbox type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gearbox_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @loan_type.update(loan_type_params)\n format.html { redirect_to @loan_type, notice: 'Loan type was successfully updated.' }\n format.json { render :show, status: :ok, location: @loan_type }\n else\n format.html { render :edit }\n format.json { render json: @loan_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_bread_type\n @bread_type = BreadType.find(params[:id])\n end",
"def destroy\n if !@boat_type.is_modification?\n @boat_type.destroy\n respond_to do |format|\n format.html { redirect_to manage_boat_types_url, notice: 'Тип лодки был успешно удалён' }\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n if @boat_type.boat_type.modifications.size > 1 \n @boat_type.destroy\n format.json { head :no_content }\n else\n format.json {render json: {message: 'Нельзя удалить компоновку, если она единственная'}, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @roof_type.update(roof_type_params)\n format.html { redirect_to roof_types_path, notice: 'Roof type was successfully updated.' }\n format.json { render :show, status: :ok, location: @roof_type }\n else\n format.html { render :edit }\n format.json { render json: @roof_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @brony.update(brony_params)\n format.html { redirect_to @brony, notice: 'Brony was successfully updated.' }\n format.json { render :show, status: :ok, location: @brony }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @brony.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @blivot.update(blivot_params)\n format.html { redirect_to @blivot, notice: 'Blivot was successfully updated.' }\n format.json { render :show, status: :ok, location: @blivot }\n else\n format.html { render :edit }\n format.json { render json: @blivot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @breadcrumb = 'update'\n @entity_type = EntityType.find(params[:id])\n @entity_type.updated_by = current_user.id if !current_user.nil?\n \n respond_to do |format|\n if @entity_type.update_attributes(params[:entity_type])\n format.html { redirect_to @entity_type,\n notice: (crud_notice('updated', @entity_type) + \"#{undo_link(@entity_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @budgeting_type = BudgetingType.find(params[:id])\n\n respond_to do |format|\n if @budgeting_type.update_attributes(user_params)\n format.html { redirect_to @budgeting_type, notice: 'Budgeting type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @budgeting_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_admin_type.update(api_v1_admin_type_params)\n format.html { redirect_to @api_v1_admin_type, notice: 'Admin type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_admin_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_admin_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jewelry_type = JewelryType.find(params[:id])\n\n respond_to do |format|\n if @jewelry_type.update_attributes(params[:jewelry_type])\n format.html { redirect_to @jewelry_type, notice: 'Jewelry type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jewelry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @breadcrumb = 'update'\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n @contracting_request_document_type.updated_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @contracting_request_document_type.update_attributes(params[:contracting_request_document_type])\n format.html { redirect_to @contracting_request_document_type,\n notice: (crud_notice('updated', @contracting_request_document_type) + \"#{undo_link(@contracting_request_document_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boook.update(boook_params)\n format.html { redirect_to @boook, notice: 'Boook was successfully updated.' }\n format.json { render :show, status: :ok, location: @boook }\n else\n format.html { render :edit }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @addtype.update(addtype_params)\n format.html { redirect_to @addtype, notice: '变动方式修改成功!' }\n format.json { render :show, status: :ok, location: @addtype }\n else\n format.html { render :edit }\n format.json { render json: @addtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end",
"def update\n respond_to do |format|\n if @bolt.update(bolt_params)\n format.html { redirect_to @bolt, notice: 'Bolt was successfully updated.' }\n format.json { render :show, status: :ok, location: @bolt }\n else\n format.html { render :edit }\n format.json { render json: @bolt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @typeofstatus.update(typeofstatus_params)\n format.html { redirect_to @typeofstatus, notice: 'Typeofstatus was successfully updated.' }\n format.json { render :show, status: :ok, location: @typeofstatus }\n else\n format.html { render :edit }\n format.json { render json: @typeofstatus.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @club_type.update(club_type_params)\n format.html { redirect_to @club_type, notice: 'Club type was successfully updated.' }\n format.json { render :show, status: :ok, location: @club_type }\n else\n format.html { render :edit }\n format.json { render json: @club_type.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.69488794",
"0.67846626",
"0.6779809",
"0.67107934",
"0.6644783",
"0.65858734",
"0.65858734",
"0.65858734",
"0.65431744",
"0.6492222",
"0.6469287",
"0.64582306",
"0.64381003",
"0.6426274",
"0.6350214",
"0.6291226",
"0.6237887",
"0.6204577",
"0.6184031",
"0.6162096",
"0.6146152",
"0.61457825",
"0.6122355",
"0.6054078",
"0.6027757",
"0.6024475",
"0.6011195",
"0.60052514",
"0.6000359",
"0.59934175",
"0.5962777",
"0.5960815",
"0.59504783",
"0.5948662",
"0.59373355",
"0.59305114",
"0.592051",
"0.59199744",
"0.59183234",
"0.59048325",
"0.5896981",
"0.5892178",
"0.5891656",
"0.58755887",
"0.5858629",
"0.58554584",
"0.5847317",
"0.58418566",
"0.5835172",
"0.5826654",
"0.5825307",
"0.5819181",
"0.58076346",
"0.5802438",
"0.57997304",
"0.57992995",
"0.57983875",
"0.5775922",
"0.57591265",
"0.5753715",
"0.57398176",
"0.573505",
"0.57307583",
"0.57303256",
"0.57287574",
"0.5728718",
"0.5727007",
"0.57195866",
"0.57173455",
"0.57163644",
"0.5715514",
"0.5708863",
"0.5707924",
"0.57033813",
"0.5702622",
"0.5699025",
"0.56989235",
"0.569865",
"0.56935203",
"0.56923616",
"0.56898326",
"0.5687293",
"0.5683407",
"0.56805456",
"0.56791633",
"0.5678008",
"0.56740284",
"0.56662405",
"0.56658155",
"0.56643224",
"0.5660157",
"0.5658551",
"0.56558305",
"0.56520534",
"0.5651289",
"0.5647748",
"0.56430024",
"0.5640707",
"0.5638701",
"0.5631086"
] |
0.7168352
|
0
|
DELETE /boat_types/1 DELETE /boat_types/1.json
|
def destroy
if !@boat_type.is_modification?
@boat_type.destroy
respond_to do |format|
format.html { redirect_to manage_boat_types_url, notice: 'Тип лодки был успешно удалён' }
format.json { head :no_content }
end
else
respond_to do |format|
if @boat_type.boat_type.modifications.size > 1
@boat_type.destroy
format.json { head :no_content }
else
format.json {render json: {message: 'Нельзя удалить компоновку, если она единственная'}, status: :unprocessable_entity }
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @bagtype = Bagtype.find(params[:id])\n @bagtype.destroy\n\n respond_to do |format|\n format.html { redirect_to bagtypes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bs_type.destroy\n respond_to do |format|\n format.html { redirect_to bs_types_url, notice: 'Bs type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brake_type.destroy\n respond_to do |format|\n format.html { redirect_to brake_types_url, notice: 'Brake type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @business_type = BusinessType.find(params[:id])\n @business_type.destroy\n\n respond_to do |format|\n format.html { redirect_to business_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n audit(@bike_type, current_user)\n @bike_type.destroy\n\n head :no_content\n end",
"def destroy\n set_boat\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to harbour_boats_path}\n format.json { head :no_content }\n end\n end",
"def destroy\n @crossbowtype.destroy\n respond_to do |format|\n format.html { redirect_to crossbowtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html {redirect_to boats_url}\n format.json {head :no_content}\n end\n end",
"def destroy\n @boat = Boat.find(params[:id])\n remove_reknro_from_berth\n @boat.destroy\n\n respond_to do |format|\n format.html { redirect_to boats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bet_type.destroy\n respond_to do |format|\n format.html { redirect_to bet_types_url, notice: 'Type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kind_of_boat.destroy\n respond_to do |format|\n format.html { redirect_to kind_of_boats_url, notice: 'Kind of boat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type_bond.destroy\n respond_to do |format|\n format.html { redirect_to type_bonds_url, notice: 'Type bond was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to boats_url, notice: _(\"Boat was successfully destroyed\") }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat.destroy\n\n head :no_content\n end",
"def destroy\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to boats_url, notice: 'Boat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to boats_url, notice: 'Boat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to boats_url, notice: 'Boat was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to bounties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brew_type.destroy\n respond_to do |format|\n format.html { redirect_to brew_types_url, notice: 'Brew type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crate_type = CrateType.find(params[:id])\n @crate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to crate_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @girltype = Girltype.find(params[:id])\n @girltype.destroy\n\n respond_to do |format|\n format.html { redirect_to girltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mall_type = MallType.find(params[:id])\n @mall_type.destroy\n\n respond_to do |format|\n format.html { redirect_to mall_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bus_seat_type = BusSeatType.find(params[:id])\n @bus_seat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to bus_seat_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @budgeting_type = BudgetingType.find(params[:id])\n @budgeting_type.destroy\n\n respond_to do |format|\n format.html { redirect_to budgeting_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @benchmark_type = BenchmarkType.find(params[:id])\n @benchmark_type.destroy\n\n respond_to do |format|\n format.html { redirect_to benchmark_types_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @boat_sub_type_section = BoatSubTypeSection.find(params[:id])\n @boat_sub_type_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(boat_sub_type_sections_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @appliance_type = ApplianceType.find(params[:id])\n @appliance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to appliance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @disaster_type = DisasterType.find(params[:id])\n @disaster_type.destroy\n\n respond_to do |format|\n format.html { redirect_to disaster_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type_breeder.destroy\n respond_to do |format|\n format.html { redirect_to admin_type_breeders_url, notice: 'Type breeder was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html { redirect_to(boats_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @agency_type = AgencyType.find(params[:id])\n @agency_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agency_types_url }\n format.json { head :no_content }\n end\n end",
"def delete_break_type(id:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::DELETE,\n '/v2/labor/break-types/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'accept'))\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n redirect_to boats_path\n end",
"def destroy\n @clothing_type.destroy\n respond_to do |format|\n format.html { redirect_to clothing_types_url, notice: 'Clothing type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @box_request_abuse_type.destroy\n respond_to do |format|\n format.html { redirect_to box_request_abuse_types_url, notice: 'Box request abuse type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat_engine_fuel_type = BoatEngineFuelType.find(params[:id])\n @boat_engine_fuel_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(boat_engine_fuel_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @observation_type = ObservationType.find(params[:id])\n @observation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to observation_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n asset_type = AssetType.find(params[:id])\n asset_type.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block_type.destroy\n respond_to do |format|\n format.html { redirect_to block_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block_type.destroy\n respond_to do |format|\n format.html { redirect_to block_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @businesstype.destroy\n respond_to do |format|\n format.html { redirect_to businesstypes_url, notice: 'Businesstype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cloth_type.destroy\n respond_to do |format|\n format.html { redirect_to cloth_types_url, notice: \"Cloth type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_mkb_type = Ref::MkbType.find(params[:id])\n @ref_mkb_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_mkb_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @type_debit.destroy\n respond_to do |format|\n format.html { redirect_to type_debits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to realty_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diet_type.destroy\n respond_to do |format|\n format.html { redirect_to diet_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @activity_type = ActivityType.find(params[:id])\n @activity_type.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @water_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_water_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n admin_only do\n @browsertype.destroy\n log_action('Delete', current_user ? current_user.username : 'Anonymous', params[:id], 'BrowserType')\n respond_to do |format|\n format.html { redirect_to browsertypes_url, notice: 'Browsertype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def delete(type, id)\n http_delete @target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\", @auth_header, @zone\n end",
"def destroy\n @myers_briggs_type = MyersBriggsType.find(params[:id])\n @myers_briggs_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(myers_briggs_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish_type.destroy\n respond_to do |format|\n format.html { redirect_to dish_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @type_of_cleaning_and_washing = TypeOfCleaningAndWashing.find(params[:id])\n @type_of_cleaning_and_washing.destroy\n\n respond_to do |format|\n format.html { redirect_to type_of_cleaning_and_washings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @novelty_type.destroy\n respond_to do |format|\n format.html { redirect_to novelty_types_url, notice: 'Novelty type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loan_type.destroy\n respond_to do |format|\n format.html { redirect_to loan_types_url, notice: 'Loan type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad_type = AdType.find(params[:id])\n @ad_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @act_type = ActType.find(params[:id])\n @act_type.destroy\n\n respond_to do |format|\n format.html { redirect_to act_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident_type = IncidentType.find(params[:id])\n @incident_type.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @addtype.destroy\n respond_to do |format|\n format.html { redirect_to addtypes_url, notice: '变动方式删除成功!.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admission_type = AdmissionType.find(params[:id])\n @admission_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admission_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_type.destroy\n respond_to do |format|\n format.html { redirect_to client_types_url, notice: 'Tipo de Cliente deletado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gig_type.destroy\n respond_to do |format|\n format.html { redirect_to gig_types_url, notice: 'Gig type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @club_type.destroy\n respond_to do |format|\n format.html { redirect_to club_types_url, notice: 'Club type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rcadmin_cabinet_type.destroy\n flash[:notice] = 'Cabinet type was successfully deleted'\n respond_to do |format|\n format.html { redirect_to rcadmin_cabinet_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foiltype = Foiltype.find(params[:id])\n @foiltype.destroy\n\n respond_to do |format|\n format.html { redirect_to foiltypes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @gift_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_gift_types_url, notice: 'Gift type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fueltype = Fueltype.find(params[:id])\n @fueltype.destroy\n\n respond_to do |format|\n format.html { redirect_to fueltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing_type.destroy\n respond_to do |format|\n format.html { redirect_to thing_types_url, notice: 'Thing type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @broad = Broad.find(params[:id])\n @broad.destroy\n\n respond_to do |format|\n format.html { redirect_to broads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @weapons_type = WeaponsType.find(params[:id])\n @weapons_type.destroy\n\n respond_to do |format|\n format.html { redirect_to weapons_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @member.abo_types.delete_all\n respond_to do |format|\n if @member.destroy\n format.html { redirect_to members_url, notice: t('flash.notice.deleting_member') }\n format.json { head :no_content }\n else\n format.html { render :show, alert: t('flash.alert.deleting_member') }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @heat_type = HeatType.find(params[:id])\n @heat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contractor_type = ContractorType.find(params[:id])\n @contractor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to contractor_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to segment_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boxtype = Boxtype.find(params[:id])\n @boxtype.destroy\n\n respond_to do |format|\n format.html { redirect_to boxtypes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bounty = Bounty.find(params[:id])\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to controller: 'home', action: 'bounty_market' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drum_type.destroy\n respond_to do |format|\n format.html { redirect_to drum_types_url, notice: 'Drum type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jewelry_type = JewelryType.find(params[:id])\n @jewelry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to jewelry_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bl = Bl.find(params[:id])\n @bl.destroy\n\n respond_to do |format|\n format.html { redirect_to bls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contract_type = ContractType.find(params[:id])\n @contract_type.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @vehicle_type.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @typeconge.destroy\n respond_to do |format|\n format.html { redirect_to typeconges_url, notice: 'Typeconge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brag = Brag.find(params[:id])\n @brag.destroy\n\n respond_to do |format|\n format.html { redirect_to brags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection_type = CollectionType.find(params[:id])\n @collection_type.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to bowls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brave_burst.destroy\n respond_to do |format|\n format.html { redirect_to brave_bursts_url }\n format.json { head :no_content }\n end\n end"
] |
[
"0.71177554",
"0.7064494",
"0.69310373",
"0.69107395",
"0.6897441",
"0.68961865",
"0.6882408",
"0.6837989",
"0.6821159",
"0.6790682",
"0.6788256",
"0.67847127",
"0.6774259",
"0.6676323",
"0.6658198",
"0.66345865",
"0.66345865",
"0.66345865",
"0.6620957",
"0.66179925",
"0.66155374",
"0.66109616",
"0.6604846",
"0.65956146",
"0.6592339",
"0.6590077",
"0.6579833",
"0.65775144",
"0.6566462",
"0.6547945",
"0.6534655",
"0.65296507",
"0.65127665",
"0.6508737",
"0.65038216",
"0.649749",
"0.64901185",
"0.6489069",
"0.64714926",
"0.64714056",
"0.6470758",
"0.64573866",
"0.64375633",
"0.64375633",
"0.64223045",
"0.64178234",
"0.6413464",
"0.6413079",
"0.64067626",
"0.6401145",
"0.637837",
"0.63763934",
"0.63651764",
"0.6354085",
"0.6351844",
"0.63490105",
"0.63455874",
"0.63451034",
"0.63401145",
"0.63375556",
"0.63325226",
"0.63245314",
"0.6321724",
"0.632061",
"0.63204056",
"0.6313892",
"0.63094014",
"0.62976336",
"0.6278023",
"0.62765014",
"0.6272487",
"0.626955",
"0.6266931",
"0.62608844",
"0.62451816",
"0.62421614",
"0.6234455",
"0.6230622",
"0.6229913",
"0.62294513",
"0.6225698",
"0.62251216",
"0.62237895",
"0.6221202",
"0.62201726",
"0.6214619",
"0.6214583",
"0.62132704",
"0.62107116",
"0.62069863",
"0.62057966",
"0.620174",
"0.62008786",
"0.620057",
"0.61969084",
"0.61956483",
"0.6194888",
"0.6193296",
"0.6193284",
"0.6187253"
] |
0.7007574
|
2
|
Use callbacks to share common setup or constraints between actions.
|
def set_boat_type
#boat_type =
#redirect_to boat_type.boat_type and return if boat_type.is_modification?
@boat_type = BoatType.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup_handler\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def before_dispatch(env); end",
"def process_action(...)\n send_action(...)\n end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def action\n end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def config(action, *args); end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def setup_signals; end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; end",
"def around_hooks; end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def call\n setup_context\n super\n end",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def duas1(action)\n action.call\n action.call\nend"
] |
[
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.5328757",
"0.5310255",
"0.5300339",
"0.5298796",
"0.5295774",
"0.5256034",
"0.5243039",
"0.5236007",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.5235239",
"0.52321917",
"0.5227032",
"0.52216744",
"0.5216349",
"0.52161187",
"0.5210265",
"0.5207244",
"0.5177388",
"0.5177142",
"0.51747334",
"0.516293",
"0.51629275",
"0.5155534",
"0.51540613",
"0.515197",
"0.5151636",
"0.5145279",
"0.51380795",
"0.5135777",
"0.5117378",
"0.5115066",
"0.5115066",
"0.5110235",
"0.5106418",
"0.50917816",
"0.50909185",
"0.50855017",
"0.5082105",
"0.506359",
"0.5055345",
"0.50546116",
"0.50523037",
"0.50523037",
"0.50327307",
"0.5024364",
"0.5021113",
"0.50174654",
"0.50163317",
"0.5000553",
"0.50002855",
"0.49991882",
"0.49905527",
"0.49905527",
"0.49849054",
"0.4982546",
"0.4980941",
"0.4979153",
"0.49693102",
"0.4967172",
"0.49594432",
"0.49564302",
"0.49552485",
"0.49533385",
"0.49506924",
"0.49452737",
"0.49442786",
"0.49347955",
"0.49341312",
"0.49295264",
"0.49261844",
"0.4925649",
"0.49251428",
"0.4920729",
"0.49177617",
"0.4916373",
"0.49158472",
"0.4915794",
"0.49156648"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def boat_type_params
params.require(:boat_type).permit(:ru_name, :en_name, :design_category, :copy_params_table_from_id, :boat_series_id, :body_type, :ru_description, :en_description, :ru_slogan, :en_slogan, :cnf_data_file_url, :base_cost, :is_deprecated, :is_active, :trademark_id, :use_on_ru, :use_on_en)
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
|
enables mass assignment of players attributes Determine is current player made winning move return true if this is the case else return false
|
def winner?(curr_player_moves)
WINNING_MOVES.each { |winning_moves| return true if winning_moves & curr_player_moves == winning_moves }
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_player_move?(player, move)\n if possible_plays.include?(move)\n player.move = move\n true\n else\n false\n end\n end",
"def set_computer_moves?(player)\n if player.is_computer?\n move = possible_plays.sample\n player.move = move\n true\n else\n false\n end\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 has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move?(lawn_mowers_positions)\n\t \tend\n \t\treturn false\n \tend",
"def moves_available?(player)\n !@board.moves(player).empty?\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 winning_move\n simulate_move(@player_num)\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 movable?\n\t\tking = @board.board.select { |square, piece| piece.class == Pieces::King && piece.white == @player.white }.keys[0]\n\t\t[-1,-7,-8,-9,1,7,8,9].each do |spot| \n\t\t\tif square(calc_move(king, spot)) == \" \" || square(king).white != square(calc_move(king, spot)).white \n\t\t\t\treturn true unless getting_into_check?(king, calc_move(king, spot))\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def Winner?(player)\r\n end",
"def has_possible_moves\n \t\t@mowers.each do |mower|\n \t\t\treturn true if mower.can_move? && !mower.is_going_outside?(lawn_x, lawn_y)\n\t \tend\n \t\treturn false\n \tend",
"def is_acting_player?\n\t\t\t@_iap ||= @state_hash['state']['acting_player']['id'] == @player_id\n\t\tend",
"def is_acting_player?\n\t\t\t@_iap ||= @state_hash['state']['acting_player']['id'] == @player_id\n\t\tend",
"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 winning_state_for_next_move?\n # for each possible move that could be made:\n # return true if the move leaves a losing_state_for_next_move for the opponent\n # else\n # false\n # end\n\n\n # a player can win with one move\n # / there is a move that makes true losing_state_for_next_move\n\n # if you can set up 1,1,1 by making your move, it's a winning move\n end",
"def no_player_can_move?\n !valid_move?(:black) && !valid_move?(:red)\n end",
"def update_transferplayer?\r\n # Abort loop if player isn't place moving\r\n unless $game_temp.player_transferring\r\n return true\r\n end\r\n # Run place move\r\n transfer_player\r\n return false\r\n end",
"def move_valid_for?(player_id)\n return false if last_player_id == player_id\n\n true\n end",
"def is_player_winner(moves)\n grid = map_to_grid moves\n is_winner grid\n end",
"def is_win(x, y, player)\n create_pivot_vectors(x, y)\n\n # TODO: parameter key not used (fix)\n @moves.each do |key, array|\n win3 = 0\n array.each do |key, val|\n if val == player\n win3 += 1\n return true if win3 == @win_with\n else\n win3 = 0\n end\n end\n end\n false\n end",
"def is_current_players_turn?(current_player)\n if self.up_next == current_player.username\n true\n else\n false\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 won_game?\n @points > @opponent.points + 1 && @points >= 3\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 win?\n milestones.each do |mile|\n return false unless mile.status == 'Aprobado'\n end\n true\n end",
"def players_allowed_to_play\n return if self.manager.nil? || self.players.nil?\n\n self.players.each do |p|\n unless p.tournaments.include? self.manager\n errors.add(:match, \"players must be in same tournament as match\")\n end\n end\n end",
"def over?\n self.player.points == self.board.total_points\n end",
"def can_pass_to? target_player\n\t\treturn false unless target_player.is_a? Player\n\t\tres = can_move?\n\t\tres &= @has_ball\n\t\tres &= !@team.pass?\n\t\tres &= target_player\n\t\tres &= target_player != self\n\t\tres &= target_player.team == @team\n\t\tres &= target_player.health == Health::OK\n\t\tres &= dist(self, target_player) <= 10.5\n\tend",
"def won_with_all_moves?(winning_rounds)\n winning_rounds.any? { |round| round[:move].rock? } &&\n winning_rounds.any? { |round| round[:move].paper? } &&\n winning_rounds.any? { |round| round[:move].scissors? }\n end",
"def human_turn?\n @current_player != @computer_player\n end",
"def new_player_allowed?; false 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 advantage?\n @player1.points >= 4 && @player1.points == (@player2.points + 1) ||\n @player2.points >= 4 && @player2.points == (@player1.points + 1)\n end",
"def playedAtLeastTwo\n self.moves <2 ? false : true\n end",
"def minimum_players?\n self.players.count == MIN_PLAYERS\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 checkmate?\n return unless @game.determine_checkmate\n\n if @game.turn_number.even?\n @game.update(winning_player_id: @game.black_player_id)\n elsif game.turn_number.odd?\n @game.update(winning_player_id: @game.white_player_id)\n end\n end",
"def can_player_make_another_action_choice?\n @player_actions.size.upto(@logic.battle_info.vs_type - 1) do |position|\n next_pokemon = @logic.battler(0, position)\n # If there's no Pokemon at this position, then it's probably the end of the team\n break unless next_pokemon\n # If it's not our Pokemon we don't control it\n next(@player_actions << {}) if next_pokemon.party_id != 0\n # If the Pokemon is dead, we also don't control it\n next(@player_actions << {}) if next_pokemon.dead?\n # This Pokemon can be controlled\n return true\n end\n return false\n end",
"def valid_player?(player)\n @current_player == player.to_sym\n end",
"def mark_winner\n winning_team = teams.reject{|team| team.goals < 10}.sort_by(&:goals).last\n winning_team.is_winner = true unless winning_team.nil?\n self.goals_count = teams.collect(&:goals).inject(&:+)\n\n if rating_pending? && !Game.before(self).with_rating_pending.exists?\n set_ratings\n end\n return true\n end",
"def move_available?\n total_available_moves > 0\n end",
"def winner=(player)\n self.save && self.reload\n # The winner scores 1\n process_result(player, 1)\n # The other players score 0\n self.players.to_a.each do |one_player|\n unless one_player == player\n process_result(one_player, 0)\n end\n end\n end",
"def check_player\n if self.moves == nil or self.moves.length % 2 == 0\n @current_player = 1\n else\n @current_player = 2\n end \n end",
"def won?\n WIN_COMBINATIONS.detect do |win_combination|\n\n # win_combination is a 3 element array of indexes that compose a win, [0,1,2]\n # grab each index from the win_combination that composes a win, and load the value of the board at position x\n\n position_1 = self.board.cells[win_combination[0]] # load the value of the self.class at win_index_1\n position_2 = self.board.cells[win_combination[1]] # load the value of the self.class at win_index_2\n position_3 = self.board.cells[win_combination[2]] # load the value of the self.class at win_index_3\n\n position_1 == position_2 && position_2 == position_3 && (position_1 == self.player_1.token || position_1 == self.player_2.token)\n end\n end",
"def won?\n @game.started? && !detectives_won? && detectives_cannot_move?\n end",
"def game_over?\n remaining_players == 1\n end",
"def won_match?\n @sets_won == 3\n end",
"def winning_move?\n winning_moves = [[1,2,3], [4,5,6], [7,8,9], [1,4,7], [2,5,8], [3,6,9], [1,5,9], [3,5,7]]\n winning_moves.each do |set|\n #check game board to see if XXX or OOO combination exists\n if (@board[set[0]] == \"X\") && (@board[set[1]] == \"X\") && (@board[set[2]] == \"X\")\n @winner = \"X\"\n return true\n elsif (@board[set[0]] == \"O\") && (@board[set[1]] == \"O\") && (@board[set[2]] == \"O\")\n @winner = \"O\"\n return true\n end\n end\n return false\n end",
"def new_player_required?; false end",
"def at_max_players?\n self.player_count == MAX_PLAYERS\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 is_acceptable(move)\n\t\t@@ACCEPTABLE_MOVES.include?(move)\n\tend",
"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 right_player?\n current_player == Player.find(@piece.owner)\n end",
"def get_move(player_number, current_move)\n if check_if_valid(current_move) == true\n if player_number == 1\n then\n @player1.move = current_move\n else\n @player2.move = current_move\n end\n else\n return false\n end\n return true\n end",
"def game_over?\n return true if victory? || (@turns == 12)\n false\n end",
"def current_player?\n !!current_player\n #!! turns the object into a boolean\n #NB current_player is not a local variable. It's a call to the method current_player\n end",
"def start_new_match\n @player1.points = 0\n @player1.deuce = false\n @player1.advantage = false\n @player1.win = false\n @player1.games_won = 0\n @player1.sets_won = 0\n\n @player2.points = 0\n @player2.deuce = false\n @player2.advantage = false\n @player2.win = false\n @player2.games_won = 0\n @player2.sets_won = 0\n end",
"def can_use_move?\n moves = @moveset\n # TODO : Implement all the move conditions\n return moves.any? { |move| move.pp > 0 }\n end",
"def easy_win(player)\n win if player.points == 4 && player.opponent.points < 3\n end",
"def checkWin()\n # bool vars to check valid moves \n player1Valid = false\n player2Valid = false\n\n if @player1.numPlayedPieces <=2 && @player1.numUnplayedPieces == 0 \n puts \"Player 2 has won the game!\"\n return true\n elsif @player2.numPlayedPieces <=2 && @player2.numUnplayedPieces == 0 \n puts \"Player 1 has won the game!\"\n return true\n else\n # both players have more then 2 pieces on the bord.\n # check if players have valid moves left.\n if @player1.numUnplayedPieces > 0 \n # No winner there is a valid move for player1.\n puts \"Player 1 has valid moves\"\n return false\n elsif @player2.numUnplayedPieces > 0 \n puts \"Player 2 has valid moves\"\n return false\n else\n # check if any moves are possible.\n\n # player 1\n # until true, loop through played pieces, for each location call validMove(). there is no (get adjacent function so this is clunky sorry)\n for piece in @player1.playedPieces\n \n @board.locations.each do |row|\n row.each do |location|\n \n # validMove will return true if it is valid. \n if validMove(piece, location)\n player1Valid = true\n end \n break if player1Valid \n end\n break if player1Valid \n end\n break if player1Valid \n end\n\n #player2\n for piece in @player2.playedPieces\n \n @board.locations.each do |row|\n row.each do |location|\n \n # validMove will return true if it is valid. \n if validMove(piece, location)\n player2Valid = true\n end \n break if player2Valid \n end\n break if player2Valid \n end\n break if player2Valid \n end\n \n\n if !player1Valid && !player2Valid \n puts \"Both Player's have no moves. The game is a draw\"\n return true\n \n elsif !player1Valid\n # player1 has no remaining moves\n puts @player1.name +\" has no valid moves,\" + @player2.name + \" wins!\"\n return true\n\n \n elsif !player2Valid\n # player1 has no rem\n puts @player2.name +\" has no valid moves,\" + @player1.name + \" wins!\"\n return true\n \n else\n puts \" both players have valid moves left. The game is not over.\"\n return false\n end\n end\n end\n\n end",
"def new_game?\n moves.empty?\n end",
"def validate_player_move(move)\r\n \r\n #Return a value of false is the square has already been\r\n #selected\r\n return false if move == \"A1\" && $A1 != \" \"\r\n return false if move == \"B1\" && $B1 != \" \"\r\n return false if move == \"C1\" && $C1 != \" \"\r\n return false if move == \"A2\" && $A2 != \" \"\r\n return false if move == \"B2\" && $B2 != \" \"\r\n return false if move == \"C2\" && $C2 != \" \"\r\n return false if move == \"A3\" && $A3 != \" \"\r\n return false if move == \"B3\" && $B3 != \" \"\r\n return false if move == \"C3\" && $C3 != \" \" \r\n \r\n #Return a value of true if the square is available\r\n return true\r\n \r\n end",
"def battler_acting?\n return true if @user_casting[0] > 0 || @targeting[0]\n return true if @knockdown_data[0] > 0 and battler.deadposing.nil?\n return true if @anime_speed > 0\n return true if @hookshoting[0] || @making_spiral\n if self.is_a?(Game_Player)\n $game_player.followers.each {|f| return true if f.battler_acting?}\n end\n return false\n end",
"def playable\r\n\t\t@phand.each do |x| #go through player hand\r\n\t\t\tif @attack[-1].suit == @trump.suit && x.suit == @trump.suit && x.value > @attack[-1].value\r\n\t\t\t\tx.canplay = true\r\n\t\t\telsif x.suit == @trump.suit && @attack[-1].suit != @trump.suit #player can always trump any non trump\r\n\t\t\t\tx.canplay = true\r\n\t\t\telsif x.suit == @attack[-1].suit && x.value > @attack[-1].value #player can play a higher card of the same suit\r\n\t\t\t\tx.canplay = true\r\n\t\t\telsif x.value == @attack[-1].value && @defend.count == 0\r\n\t\t\t\tx.canplay = true\r\n\t\t\telse\r\n\t\t\t\tx.canplay = false\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def can_move?\n counts = ticket_counts\n\n # Performs an optimisation to prevent unnecessary SQL queries\n # Since all nodes support taxi and black tickets, the player may naturally move if they have any\n return true if counts.values_at(:taxi, :black).reduce(&:+) > 0\n\n check_player_can_use_tickets(counts)\n\n publish(:fail, @errors) if @errors.any?\n\n @errors.empty?\n end",
"def is_valid_move x,y\n return false unless (0..3) === x\n return false unless (0..3) === y\n return @field[x][y].player == 0\n end",
"def regular_turn?(turn)\n min_turn = @players_count * 2 + 1\n turn >= min_turn\n end",
"def computer_opens_game\n @avail_moves.length == 8 && @depth == 1 ? true : false\n end",
"def played?\n winner.present?\n end",
"def check_for_win(player)\n\tif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"tc\"] == player) && ($grid_hash[\"tr\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"cl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"cr\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"bl\"] == player) && ($grid_hash[\"bc\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"cl\"] == player) && ($grid_hash[\"bl\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tc\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"bc\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tr\"] == player) && ($grid_hash[\"cr\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"tl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"br\"] == player)\n\t\twin(player)\n\telsif ($grid_hash[\"bl\"] == player) && ($grid_hash[\"cc\"] == player) && ($grid_hash[\"tr\"] == player)\n\t\twin(player)\n\telse\n\t\tcheck_for_tie\n\tend\nend",
"def win?\n if won_game?\n @games_won += 1\n won_set\n return true\n end\n end",
"def game_over?\n losing_players != nil ? 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 someone_won_round?\r\n !!winner\r\n end",
"def advanced?(move)\n !!(hunters_move_for(move_id: move.id)&.advanced)\n end",
"def blocked(player)\n # check every piece on the board\n (0..23).each do |i|\n # if it's the player's piece check if it can move\n if @myPositions[i].player == player\n\n # if it can move up, down, left, or right then the player isn't blocked\n\t \t\tif @myPositions[i].up != nil && @myPositions[i].up.player == Controller::Player::NEUTRAL\n\t\t\t \treturn false\n end\n\n\t\t \tif @myPositions[i].down != nil && @myPositions[i].down.player == Controller::Player::NEUTRAL\n\t\t\t\t return false\n end\n\n\t\t\t if @myPositions[i].left != nil && @myPositions[i].left.player == Controller::Player::NEUTRAL\n\t\t\t\t return false\n end\n\n\t\t\t if @myPositions[i].right != nil && @myPositions[i].right.player == Controller::Player::NEUTRAL\n\t\t\t\t return false\n end\n end\n end\n\n\t # we must be blocked\n \treturn true\n end",
"def round_over? \n\t\tplayers.one?{ |player| !player.folded? }\n\tend",
"def legal_move?(new_x, new_y)\n return false unless actual_move?(new_x, new_y)\n return_val = false\n piece_moved_start_x = x_position\n piece_moved_start_y = y_position\n piece_captured = nil\n piece_captured_x = nil\n piece_captured_y = nil\n # check if you are moving pawn in en passant capture of enemy pawn\n if type == PAWN && !square_occupied?(new_x, new_y)\n if (new_x - piece_moved_start_x).abs == 1 && (new_y - piece_moved_start_y).abs == 1\n piece_captured = game.get_piece_at_coor(new_x, piece_moved_start_y)\n piece_captured_x = new_x\n piece_captured_y = piece_moved_start_y\n end\n end\n # return false if move is invalid for this piece for any of the reasons checked in piece #valid_move?\n return false unless valid_move?(new_x, new_y)\n # If square is occupied, respond according to whether piece is occupied by friend or foe\n if square_occupied?(new_x, new_y)\n occupying_piece = game.get_piece_at_coor(new_x, new_y)\n return false if (occupying_piece.is_white && is_white?) || (!occupying_piece.is_white && !is_white?)\n # since player is trying to capture a friendly piece\n piece_captured = occupying_piece\n piece_captured_x = occupying_piece.x_position\n piece_captured_y = occupying_piece.y_position\n capture_piece(occupying_piece)\n end\n # only here do we update coordinates of piece moved, once we have saved all starting coordinates of piece moved and any piece it captured\n update(x_position: new_x, y_position: new_y)\n increment_move\n return_val = true unless game.check?(is_white)\n update(x_position: piece_moved_start_x, y_position: piece_moved_start_y)\n piece_captured.update(x_position: piece_captured_x, y_position: piece_captured_y) unless piece_captured.nil?\n decrement_move\n return_val\n end",
"def advantage?\n @points == @opponent.points + 1\n end",
"def advantage?\n @points == @opponent.points + 1\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 stalemate?\n\t\tpieces = @board.board.select { |square, piece| piece.class != String && piece.white == @player.white }\n\t\tperi = [-17,-15,-10,-9,-8,-7,-6,-1,1,6,7,8,9,10,15,17]\n\t\tpieces.each do |from, piece|\n\t\t\tperi.each do |to|\n\t\t\t\tif piece.legal_move?(from, calc_move(from, to)) && (square(calc_move(from, to)) == \" \" || square(calc_move(from, to)).white != @player.white)\n\t\t\t\t\tunless getting_into_check?(from, calc_move(from, to))\n\t\t\t\t\t\tif (piece.class == Pieces::Pawn && square(calc_move(from, to)) == \" \") || piece.class == Pieces::King\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\telsif piece.class == Pieces::Knight && from[1] != to[1]\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\telsif piece.class != Pieces::Pawn && piece.legal_list(from, calc_move(from, to)).all? { |t| square(t) == \" \" }\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telsif piece.class == Pieces::Pawn && [7,9].any? { |t| calc_move(from, t) == to } && piece.white\n\t\t\t\t\treturn false\n\t\t\t\telsif piece.class == Pieces::Pawn && [-7,-9].any? { |t| calc_move(from, t) == to } && !piece.white\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tunless check?(@board.board)\n\t\t\t@stalemate = true\n\t\t\treturn true\n\t\tend\n\tend",
"def forty?\n @points == 3 && @points != @opponent.points\n end",
"def check_for_mate\n if @board.in_checkmate?( match.next_to_move )\n match.active = false\n match.winner = (match.next_to_move==:white ? match.player2 : match.player1)\n match.save\n end\n end",
"def game_over?\n alive_players.count == 1\n end",
"def deuce?\n @player1.points == 3 && @player2.points == 3\n end",
"def need_update(member)\n return false if (member.x == @x and member.y == @y) \n return false if player_distance(member) and not @start_moving\n return false if @move_update.empty?\n @start_moving = true\n if @move_update[0] == 'move_left'\n return false if (member.x + 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_right'\n return false if (member.x - 1 == @x and member.y == @y)\n elsif @move_update[0] == 'move_up'\n return false if (member.y + 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_down'\n return false if (member.y - 1 == @y and member.x == @x)\n elsif @move_update[0] == 'move_upper_left'\n return false if (member.x + 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_upper_right'\n return false if (member.x - 1 == @x and member.y + 1 == @y)\n elsif @move_update[0] == 'move_lower_left'\n return false if (member.x + 1 == @x and member.y - 1 == @y)\n elsif @move_update[0] == 'move_lower_right'\n return false if (member.x - 1 == @x and member.y - 1 == @y)\n end\n return true\n end",
"def check_if_valid(player_move)\n [\"rock\", \"paper\", \"scissors\", \"spock\", \"lizard\"].include?(player_move.downcase)\n end",
"def valid_move?(start_x, start_y, player)\n return false if get(start_x, start_y) != SPOT_OPEN\n\n # Counts the total flips that would result from this move\n flips = 0\n\n opponent = OthelloBoard::opponent_of(player)\n enumerator = Proc.new do |points, direction|\n # Counts the total flips that would result from this direction\n temp_flips = 0\n points.each do |point|\n x, y = point\n\n case get(x, y)\n when opponent\n temp_flips += 1\n when SPOT_OPEN\n temp_flips = 0\n break\n when player\n flips += temp_flips\n break\n end\n end\n end\n enumerate_around(start_x, start_y, enumerator)\n\n if flips == 0\n return false\n else\n return flips\n end\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 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 check_mate(player)\n player_pieces = []\n if player.colour == \"BLACK\"\n player_pieces = @black_pieces\n elsif player.colour == \"WHITE\"\n player_pieces = @white_pieces\n else\n print \"ERROR\"\n end\n\n all_moves = []\n\n player_pieces.each do |piece|\n moves = allowed_moves(piece)\n all_moves << moving_into_check(piece, moves)\n end\n\n if all_moves.flatten.length.zero?\n puts \"******** CHECK MATE ********\"\n return true\n else\n return false\n end\n end",
"def can_move?\n @max_movement > 0\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 victory?\n won = false\n @board.winning_combos.each do |combo|\n won = true if (combo & @other_player.squares) == combo\n end\n won\n end",
"def check_victory_condition\n\t\t@winner = @board.victory?\n\n\t\tif @winner == 'X'\n\t\t\t@player_2.declare_defeated @board, @id, 2\n\t\t\t@player_1.declare_victorious @board, @id, 1\n\t\t\ttrue\n\t\telsif @winner == 'O'\n\t\t\t@player_2.declare_victorious @board, @id, 2\n\t\t\t@player_1.declare_defeated @board, @id, 1\n\t\t\ttrue\n\t\telsif @winner == 'DRAW'\n\t\t\t@player_2.declare_draw @board, @id, 2\n\t\t\t@player_1.declare_draw @board, @id, 1\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def nextTurnAllowed\n return (@currentPlayer.nil? or @currentPlayer.validState)\n end",
"def if_player_1_wins?\n\t($p1 == \"scissors\" && $p2 == \"paper\") || ($p1 == \"rock\" && $p2 == \"scissors\") || ($p1 == \"paper\" && $p2 == \"rock\") || ($p1 == \"rock\" && $p2 == \"lizard\") || ($p1 == \"spock\" && $p2 == \"scissors\") || ($p1 == \"scissors\" && $p2 == \"lizard\") || ($p1 == \"spock\" && $p2 == \"rock\") || ($p1 == \"lizard\" && $p2 == \"paper\") || ($p1 == \"paper\" && $p2 == \"spock\")|| ($p1 == \"lizard\" && $p2 == \"spock\") \nend",
"def is_won?\n\t\tcase\n\t\twhen self.is_match?(@cells[0..2]) then true\n\t\twhen self.is_match?(@cells[3..5]) then true\n\t\twhen self.is_match?(@cells[6..8]) then true\n\t\twhen self.is_match?([@cells[0], @cells[3], @cells[6]]) then true\n\t\twhen self.is_match?([@cells[1], @cells[4], @cells[7]]) then true\n\t\twhen self.is_match?([@cells[2], @cells[5], @cells[8]]) then true\n\t\twhen self.is_match?([@cells[0], @cells[4], @cells[8]]) then true\n\t\twhen self.is_match?([@cells[2], @cells[4], @cells[6]]) then true\n\t\telse false\n\t\tend\n\tend"
] |
[
"0.6679295",
"0.6618854",
"0.661398",
"0.6547951",
"0.65041393",
"0.6427369",
"0.63887286",
"0.63825715",
"0.6337874",
"0.6328532",
"0.63208014",
"0.6313209",
"0.6313209",
"0.6276137",
"0.6244411",
"0.6239199",
"0.62288225",
"0.6227944",
"0.620031",
"0.6160615",
"0.61495996",
"0.6149398",
"0.6147874",
"0.6143843",
"0.6143625",
"0.61389345",
"0.6135157",
"0.6119952",
"0.6106317",
"0.6097035",
"0.6088042",
"0.6073255",
"0.6059787",
"0.6055937",
"0.6044792",
"0.6040718",
"0.6039404",
"0.60306054",
"0.60281104",
"0.602628",
"0.6015113",
"0.6013855",
"0.6002556",
"0.60004866",
"0.5997328",
"0.59971714",
"0.599166",
"0.5991124",
"0.5983608",
"0.59821635",
"0.5979752",
"0.59730554",
"0.5969431",
"0.59625566",
"0.59481424",
"0.5944437",
"0.59386784",
"0.59371924",
"0.5934366",
"0.5934102",
"0.5926598",
"0.592255",
"0.5922445",
"0.5922104",
"0.5910275",
"0.5907758",
"0.5907693",
"0.5904722",
"0.59002185",
"0.5899188",
"0.58980936",
"0.5895631",
"0.58955944",
"0.58927375",
"0.58820754",
"0.5878319",
"0.58745295",
"0.5857723",
"0.58575815",
"0.58560973",
"0.58560973",
"0.58481574",
"0.5846719",
"0.5836456",
"0.5829161",
"0.58254683",
"0.5825198",
"0.58239514",
"0.5819106",
"0.5810477",
"0.5809259",
"0.5804699",
"0.57936287",
"0.5792899",
"0.5791939",
"0.5790432",
"0.5776554",
"0.5775338",
"0.5774957",
"0.57693195"
] |
0.6409368
|
6
|
Determine available moves receive p1 moves and p2 moves return array of available moves
|
def open_squares(p1_moves, p2_moves)
avail_moves = Array.new
SQUARES.each { |n| avail_moves << n unless p1_moves.include?(n) || p2_moves.include?(n) }
return avail_moves
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def moves_available\n # return what moves are available to this piec\n end",
"def moves\n available_moves = []\n\n deltas.each do |delta|\n next_move = self.position.zip_sum(delta)\n break unless on_board?(next_move)\n break unless empty_square?(next_move)\n available_moves << next_move\n end\n\n available_moves + capture_moves\n end",
"def next_possible_moves\n positions_array = []\n x = @position[0]\n y = @position[1]\n next_position = [x+1,y+2]\n positions_array << next_position if position_check(next_position)\n next_position = [x+1,y-2]\n positions_array << next_position if position_check(next_position)\n next_position = [x-1,y+2]\n positions_array << next_position if position_check(next_position)\n next_position = [x-1,y-2]\n positions_array << next_position if position_check(next_position)\n next_position = [x+2,y+1]\n positions_array << next_position if position_check(next_position)\n next_position = [x+2,y-1]\n positions_array << next_position if position_check(next_position)\n next_position = [x-2,y+1]\n positions_array << next_position if position_check(next_position)\n next_position = [x-2,y-1]\n positions_array << next_position if position_check(next_position)\n positions_array\n end",
"def moves\n available_moves = []\n\n deltas.each do |delta|\n next_move = self.position.zip_sum(delta)\n break unless empty_square?(next_move)\n if on_board?(next_move)\n available_moves << next_move\n end\n end\n\n available_moves + capture_moves\n end",
"def moves\n poss_moves = []\n determine_moves.each do |diff| #array of directions\n poss_moves += grow_unblocked_moves_in_dir(diff[0],diff[1])\n end\n poss_moves\n end",
"def get_possible_moves\n moves = \n\t @@offsets.collect do |move| \n\t row = @position[:row] + move[0]\n\t col = @position[:col] + move[1]\n\t\t[row, col] if row.between?(0, 7) && col.between?(0, 7)\n\t end\n\tmoves.compact\n end",
"def available_moves(position = player.position, all: false)\n [\n Point.new(position.x - 1, position.y),\n Point.new(position.x, position.y - 1),\n Point.new(position.x + 1, position.y),\n Point.new(position.x, position.y + 1),\n ].select { |point| all || is_legit_move?(point) }\n end",
"def possible_moves(board)\n poss_move_array = []\n current_square = @history.last\n current_coords = parse_coord(current_square)\n\n poss_move_array.push(single_march(current_coords, board)) if single_march(current_coords, board)\n\n poss_move_array.push(double_march(current_coords, board)) if first_move? && double_march(current_coords, board)\n\n valid_diagonals(current_coords, board).each { |move| poss_move_array.push(move) }\n\n # en passant only allowed opportunity first created\n poss_move_array.push(en_passant?(current_coords, board)) if en_passant?(current_coords, board)\n\n poss_move_array\n end",
"def moves\n [player_one_move, player_two_move].compact\n end",
"def getPossibleFrom move\n possibleFrom = []\n move.board.pieces[move.piece.colour][move.piece.class.to_s.to_sym].each do |coord, piece|\n possibleFrom << coord\n end\n possibleFrom\n end",
"def select_moves(position, posibles)\n moves = []\n posibles.each { |move| moves << [position[0] + move[0], position[1] + move[1]] }\n moves = moves.select { |move| move[0].between?(1,8) && move[1].between?(1,8) }\nend",
"def possible_moves\n possible_moves = []\n\n # move up\n up_right = [start[X] + 1, start[Y] + 2]\n possible_moves << up_right\n\n up_left = [start[X] - 1, start[Y] + 2]\n possible_moves << up_left\n\n # move right\n right_up = [start[X] + 2, start[Y] + 1]\n possible_moves << right_up\n\n right_down = [start[X] + 2, start[Y] - 1]\n possible_moves << right_down\n\n # move down\n down_right = [start[X] + 1, start[Y] - 2]\n possible_moves << down_right\n\n down_left = [start[X] - 1, start[Y] - 2]\n possible_moves << down_left\n\n # move left\n left_up = [start[X] - 2, start[Y] + 1]\n possible_moves << left_up\n\n left_down = [start[X] - 2, start[Y] - 1]\n possible_moves << left_down\n\n possible_moves.select { |move| @board.valid_position?(move) }\n\n end",
"def next_positions(pos)\n\tresult = []\n\tmoves = [[1, 2], [-1, 2], [1, -2], [-1, -2], [2, 1], [2, -1], [-2, 1], [-2, -1]]\n\tmoves.each do |move|\n\t\tpossibility = [pos[0] + move[0], pos[1] + move[1]]\n\t\tif possibility[0].between?(0, 7) && possibility[1].between?(0, 7)\n\t\t\tresult << possibility\n\t\tend\n\tend\n\treturn result\nend",
"def available_moves(from_cell, chessboard)\n map_chess_move_array(from_cell, available_cells(from_cell, chessboard))\n end",
"def possible_moves\n return []\n end",
"def find_possible_moves diffs\n [].tap do |possible_moves|\n diffs.each do |row|\n possible_moves << [self.pos[0] + row[1], self.pos[1] + row[0]]\n end\n end \n end",
"def moves\n output = []\n move_one = false\n @directions = @directions.take(3) if position != @initial_position\n directions.each_index do |index|\n possible_position = [position[0] + directions[index][0],position[1] + directions[index][1]]\n if index.even?\n if board.in_bounds?(possible_position) && occupied?(possible_position)\n output << possible_position unless board[possible_position].color == board[position].color\n end\n elsif index == 1\n if board.in_bounds?(possible_position) && !occupied?(possible_position)\n output << possible_position\n move_one = true\n end\n elsif board.in_bounds?(possible_position) && !occupied?(possible_position)\n output << possible_position if move_one\n end\n end\n output\n end",
"def possible_moves(x, y)\n @moves = [[x+1,y+2], [x+1,y-2],\n [x-1,y+2], [x-1,y-2],\n [x+2,y+1], [x+2,y-1],\n [x-2,y+1], [x-2,y-1]]\n\n end",
"def min_player_moves(player_moves)\n player_moves[1] << @avail_moves.shift\n end",
"def possible_moves\n all_moves = []\n x, y = @position\n moves = [[x, y-1], [x-1, y-1], [x-1, y], [x-1, y+1], [x, y+1], [x+1, y+1], [x+1, y], [x+1, y-1]]\n moves.each do |position|\n all_moves << [position] if position.all? { |number| number.between?(0,7) }\n end\n all_moves\n end",
"def valid_moves\n (slide_moves + jump_moves).select { |move| valid_move_seq?([move]) }\n end",
"def get_moves\n [\n { row: @row + 1, col: @col + 2 },\n { row: @row + 1, col: @col - 2 },\n { row: @row + 2, col: @col + 1 },\n { row: @row + 2, col: @col - 1 },\n { row: @row - 1, col: @col + 2 },\n { row: @row - 1, col: @col - 2 },\n { row: @row - 2, col: @col + 1 },\n { row: @row - 2, col: @col - 1 }\n ].select do |move|\n [:blank_space, :enemy_piece].include? describe_location(move[:row], move[:col])\n end\n end",
"def available_moves\n @available_moves = []\n first_row = [35, 36, 37, 38, 39, 40, 41]\n first_row.each do |position|\n until UI.game.board.cells[position].empty? || position < 0\n position -= 7\n end\n @available_moves << position unless position < 0\n end\n return @available_moves\n end",
"def valid_moves(from)\r\n\tpossible_moves(from).select { |move| valid_position?(move) }\r\nend",
"def get_poss_moves\n x = @location[0] #x is row\n y = @location[1] #y is column\n\n move_list = [] #quarter circle forward punch\n\n if @colour == \"white\"\n move_list = white_pawn_moves(x,y)\n else\n move_list = black_pawn_moves(x,y)\n end\n\n possible_moves = move_list.select { |e|\n (e[0] >= 0) && (e[0] <= 7) && (e[1] >= 0) && (e[1] <= 7)\n }\n possible_moves\n end",
"def moves\n # create array to collect moves\n final_array = []\n\n\n\n pos = self.move_dirs\n\n pos.each do |optional_pos|\n\n end\n\n # Note do these logics for all the optional positions \n spec_dx = pos[0]\n spec_dy = pos[1]\n\n possible_movements = grow_unblocked_moves_in_dir(spec_dx, spec_dy)\n possible_movements\n # ending\n\n\n # iterate over each of the directions in which a slideable piece can move\n # use the Piece subclass' `#move_dirs` method to get this info\n # for each direction, collect all possible moves in that direction\n # and add them to your moves array \n # (use the `grow_unblocked_moves_in_dir` helper method)\n\n # return the final array of moves (containing all possible moves in all directions)\n end",
"def moves!\n total_possible_moves = []\n total_possible_moves.concat(diag_moves(diag_initializer))\n total_possible_moves.concat(straight_moves(move_initializer))\n total_possible_moves.select { |move| self.valid_move?(move) }\n end",
"def possibleMovements\n deltas = []\n DIRECTIONS.each do |delta|\n deltas.push(delta) if canMoveBy? delta\n end\n deltas\n end",
"def possible_moves(from)\n\tpositions = []\n\tpair = { 1 => [2, -2], 2 => [1, -1] }\n row_change = [-2, -1, 1, 2]\n row_change.each do |change|\n \tpositions << add_positions(from, [change, pair[change.abs][0]])\n \tpositions << add_positions(from, [change, pair[change.abs][1]])\n end\n\tpositions\nend",
"def selected_valid_moves(x, y)\n return [] if self[x, y].nil?\n @selected_valids ||= self[x, y].valid_moves([x, y])\n end",
"def getPossibleMoves(move)\n board = move.board\n possibleMoves = []\n if move.from.nil?\n possibleFrom = getPossibleFrom(move)\n possibleFrom.each do |from|\n possibleMove = Move.new(board, move.board.getSquare(from).occupancy, move.to, from)\n possibleMoves << possibleMove\n end\n else\n # Make sure the piece trying to be moved exists\n if(board.getSquare(move.from).occupied? &&\n board.getSquare(move.from).occupancy.class == move.piece.class &&\n board.getSquare(move.from).occupancy.colour == move.piece.colour)\n move.piece = move.board.getSquare(move.from).occupancy\n possibleMoves << move\n end\n end\n possibleMoves\n end",
"def possibleMoves(arr,visited)\n moves = []\n VALID_MOVES.each do |x,y|\n if valid?([arr[0]+x,arr[1]+y],visited)\n moves.push([arr[0]+x,arr[1]+y])\n end\n end\n return moves\n end",
"def possible_moves(from)\r\n\tpositions = []\r\n\tpair = { 1 => [2, -2], 2 => [1, -1] }\r\n row_change = [-2, -1, 1, 2]\r\n row_change.each do |change|\r\n \tpositions << add_positions(from, [change, pair[change.abs][0]])\r\n \tpositions << add_positions(from, [change, pair[change.abs][1]])\r\n end\r\n\tpositions\r\nend",
"def possible_pawn_moves(start_arr)\n\t\tx = start_arr[1]\n\t\ty = start_arr[0]\n\t\tcandidates = []\n\t\tcandidates << [y+1, x]\n\t\t# If pawn has not moved before, it can take a double step straight forward.\n\t\tif y == 1\n\t\t\tcandidates << [y+2, x]\n\t\tend\n\t\tchoices = []\n\t\t# Not a candidate if player's own pieces in the way\n\t\tcandidates.delete_if do |pos|\n\t\t\tif !(@board[pos] == \"*\") && (@board[pos].color == @board[start_arr].color)\n\t\t\t\ttrue\n\t\t\tend\n\t\tend\n\t\t# Can only move up 2 pieces if no pieces in the way.\n\t\tif (candidates.include? [y+2, x]) && !(candidates.include? [y+1,x])\n\t\t\tcandidates = []\n\t\tend\n\t\t# Make sure possible move is on the board\n\t\tchildren = candidates.select { |pos| pos[0] >= 0 && pos[1] >= 0 && pos[0] <= 7 && pos[1] <= 7}\n\tend",
"def get_possible_moves_for(position)\n possible = []\n x = position.square[0]\n y = position.square[1]\n moves = [\n Placement.new([x-1,y-2], position), \n Placement.new([x-1,y+2], position), \n Placement.new([x-2,y-1], position), \n Placement.new([x-2,y+1], position), \n Placement.new([x+1,y+2], position), \n Placement.new([x+1,y-2], position), \n Placement.new([x+2,y-1], position), \n Placement.new([x+2,y+1], position)\n ]\n moves.each do |move|\n possible << move unless Chess.not_on_board?(move)\n end\n possible\n end",
"def get_valid_moves\n possible_moves.select do |dir, moves| \n moves.select! { |mov| check_bounds(mov[0], mov[1]) }\n !moves.empty? && move_directions.include?(dir)\n end\n end",
"def find_possible_moves(board)\n possibilities = []\n move_set.each do |move|\n rank = @location[0] + move[0]\n file = @location[1] + move[1]\n next unless valid_location?(rank, file)\n\n possibilities << [rank, file] unless board.data[rank][file]\n end\n possibilities\n end",
"def possible_moves(side)\n possible_moves = []\n # initialize an 8x8 array of coordinates 1-8\n coords = Array.new(8) { [*1..8] }\n coords.each_with_index do |i, j|\n i.each do |t|\n # t is the x, i[j] is the y\n side.each do |test_piece|\n # Run move validation tests on every piece\n next unless test_piece.move_tests(to_x: t, to_y: i[j])\n # if a move passes validations, push the pieces ID and the\n # coordinates of a successful move to the possible_moves array\n possible_moves << [test_piece.id, t, i[j]]\n end\n end\n end\n possible_moves\n end",
"def find_possible_moves\n @possible_moves = []\n\n @moveset.each do |move, value|\n x = @x + value[0]\n y = @y + value[1]\n\n next unless ChessBoard.check_boundaries(x, y) && !visited_coordinates.include?([x, y])\n\n @possible_moves << move\n end\n end",
"def available_moves\n adjacent_tiles(*@hole)\n end",
"def valid_moves(from)\n\tpossible_moves(from).select { |move| valid_position?(move) }\nend",
"def jump_moves\n moves = [] # initializes empty move array\n\n # choses \"forward\" y direction based on piece team\n if @team == \"l\"\n dir = 1\n else\n dir = -1\n end\n\n # looks at the two forward far diagonal positions and adds them to moves array if there are no pieces there and an opponent piece in between\n pos1 = [@x_pos + 2, @y_pos + 2*dir]\n moves << pos1 if Piece.all.find{|p| p.x_pos == @x_pos + 1 && p.y_pos == @y_pos + dir && p.team != @team} && Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos1}\n pos2 = [@x_pos - 2, @y_pos + 2*dir]\n moves << pos2 if Piece.all.find{|p| p.x_pos == @x_pos - 1 && p.y_pos == @y_pos + dir && p.team != @team} && Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos2}\n \n\n # deletes any moves with coordinates that aren't on the board\n moves.delete_if{|move| move.find{|n| n < 0 || n > 7}}\n return moves\n end",
"def get_moves\n reset_moves\n jump_moves\n base_moves if @valid_moves.empty?\n end",
"def possible_moves(pos)\n\tchanges = [[-2,-1],[-2,1],[-1,-2],[-1,2],[2,-1],[2,1],[1,-2],[1,2]]\n\tmoves = []\n\tchanges.each { |change| moves << [pos[0]+change[0], pos[1]+change[1]] }\n\tmoves.select { |move| is_valid_position?(move) }\nend",
"def find_possible_moves(board)\n possible_moves = []\n move_mechanics.each do |move|\n rank = @location[0] + move[0]\n file = @location[1] + move[1]\n next unless valid_location?(rank, file)\n\n possible_moves << [rank, file] unless board.data[rank][file]\n end\n possible_moves\n end",
"def take_moves(pieces)\n\t\tarrPos = []\n\t\tif team == 1\n\t\t\tarrPos << [@xCord - 1, @yCord + 1] if square_taken_opponent?(pieces, [@xCord - 1, @yCord + 1])\n\t\t\tarrPos << [@xCord + 1, @yCord + 1] if square_taken_opponent?(pieces, [@xCord + 1, @yCord + 1])\n\t\telsif team == 2\n\t\t\tarrPos << [@xCord - 1, @yCord - 1] if square_taken_opponent?(pieces, [@xCord - 1, @yCord - 1])\n\t\t\tarrPos << [@xCord + 1, @yCord - 1] if square_taken_opponent?(pieces, [@xCord + 1, @yCord - 1])\n\t\tend\n\t\tarrPos\t\n\tend",
"def group_possible_moves_rook(pm)\n result = []\n\n result << pm.select do |p|\n p[0] == position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] == position[0] && p[1] > position[1]\n end\n\n result << pm.select do |p|\n p[1] == position[1] && p[0] < position[0]\n end\n\n result << pm.select do |p|\n p[1] == position[1] && p[0] > position[0]\n end\n result[0].reverse!\n result[2].reverse!\n result\n end",
"def compare_available_positions(king, moves)\n checkmate = []\n # Get king moves using King location\n king_moves = possible_moves(king[0], king[1])\n\n # Check if king moves are available\n king_moves.each do |move|\n list_of_moves = moves.flatten(1)\n checkmate << list_of_moves.include?(move)\n end\n\n # Is it checkmate?\n return true if checkmate.all? { |result| result == true }\n\n false\n end",
"def get_moves(pieces)\n\t\tarrPos = [] \n\t\tif team == 1\n\t\t\tarrPos << [@xCord, @yCord + 1] if square_is_open?(pieces, [@xCord, @yCord + 1])\n\t\t\tarrPos << [@xCord, @yCord + 2] if @yCord == 1 && square_is_open?(pieces, [@xCord, @yCord + 2])\n\t\telsif team == 2\n\t\t\tarrPos << [@xCord, @yCord - 1] if square_is_open?(pieces, [@xCord, @yCord - 1])\n\t\t\tarrPos << [@xCord, @yCord - 2] if @yCord == 6 && square_is_open?(pieces, [@xCord, @yCord - 2])\n\t\tend\n\t\tarrPos\n\tend",
"def new_move_positions(pos)\n candidates = KnightPathFinder.valid_moves(pos)\n candidates = candidates.select { |e| !@considered_positions.include?(e) }\n @considered_positions.concat(candidates)\n return candidates\n #@considered_positions = (@considered_positions.concat(candidates)).uniq\n end",
"def player_moves(board)\n\t\tnew_hash_o = {} # Holds the winning combination positions the other player is occupying\n\t\tnew_hash_c = {} # Holds the winning combination positions the current player is occupying\n\t\tfinal_hash_o = {} # Holds the other player winning combination that need to be blocked on the next move\n\t\tfinal_hash_c = {} # Holds the move to be made for the current player winning combination\n\t\tWIN_COMBINATIONS.each do |k,v| # Check which of the other player's and current player's positions are part of a winning combination\n\t\t new_hash_o[k] = []\n\t\t new_hash_c[k] = []\n\t\t @other_player_positions.each do |t| # Check which of the other player's positions are part of a winning combination\n\t\t\t if v.include?(t)\n\t\t\t \tnew_hash_o[k] << t # If the position is part of a winning combination include it in the new hash\n\t\t \tend\n\t\t end\n\t\t @current_player_positions.each do |t| # Check which of the current player's positions are part of a winning combination\n\t\t\t if v.include?(t)\n\t\t\t \tnew_hash_c[k] << t # If the position is part of a winning combination include it in the new hash\n\t\t \tend\n\t\t end\n\t\tend\n\t\t@other_player_positions = [] # Clear the other player position results ready for the next turn\n\t\t@current_player_positions = [] # Clear the current player position results ready for the next turn\n\t\tnew_hash_o.each do |k,v| # Check whether the other player has one move to go on a winning combination\n\t\t\t# If there are two positions of a winning combination held by the other player include the combination in the final hash\n\t\t\tif new_hash_o[k].size > 1\n\t\t\t\tfinal_hash_o[k] = new_hash_o[k] # Final hash holds the vulnerable positions that need to be filled\n\t\t\tend\n\t\tend\n\t\tnew_hash_c.each do |k,v| # Check whether the current player has one move to go on a winning combination\n\t\t\t# If there are two positions of a winning combination held by the current player include the combination in the final hash\n\t\t\tif new_hash_c[k].size > 1\n\t\t\t\tfinal_hash_c[k] = new_hash_c[k] # Final hash holds the winning positions that need to be filled\n\t\t\tend\n\t\tend\n\t\t# Find the final position to move to block the other player's winning combination\n\t\t # Find the final position for current player to move to win\n\t\tWIN_COMBINATIONS.each do |k,v|\n\t\t\tif final_hash_o.include?(k)\n\t\t\t\t@move_o << WIN_COMBINATIONS[k] - final_hash_o[k]\n\t\t\t\tif !board.valid_move?(@move_o[0][0]) # Check whether the final position is a valid move\n\t\t\t\t\t@move_o.shift # If not a valid position remove the final move\n\t\t\t\tend\n\t\t\tend\n\t\t\tif final_hash_c.include?(k)\n\t\t\t\t@move_c << WIN_COMBINATIONS[k] - final_hash_c[k]\n\t\t\t\tif !board.valid_move?(@move_c[0][0]) # Check whether the final position is a valid move\n\t\t\t\t\t@move_c.shift # If not a valid position remove the final move from the array\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif !@move_o.empty? # Don't test and pass an empty array\n\t\t\t\t@move_o = @move_o.sample # Only one move can be made\n\t\t\t\t@move_o # Final move to block the other player's winning combination\n\t\tend\n\t\tif !@move_c.empty? # Don't test and pass an empty array\n\t\t\t\t@move_c = @move_c.sample # Only one move can be made\n\t\t\t\t@move_c # Final move to block the other player's winning combination\n\t\tend\n\tend",
"def possible_moves(x, y, dx, dy)\n return [[x - 1, y], [x, y + 1], [x, y - 1]] if dx > 0\n return [[x + 1, y], [x, y + 1], [x, y - 1]] if dx < 0\n return [[x + 1, y], [x, y + 1], [x - 1, y]] if dy > 0\n [[x + 1, y], [x, y - 1], [x - 1, y]]\n end",
"def findIntersectedPositions(moves)\n moves.inject([[0,0,'N'], [[0,0]].to_set, []]) do |acc, m|\n p = moveToNextPosition acc[0], m\n puts \"p = \" + p.to_s\n newPosition = [p[0], p[1]]\n visitedPositions = acc[1]\n puts \"vp = \" + visitedPositions.size.to_s\n crossedPositions = acc[2]\n if (visitedPositions & newPosition).size > 0\n puts \"contains: \" + newPosition.to_s\n c = crossedPositions + [newPosition]\n else\n c = crossedPositions\n end\n\n pathPositions = allPointsBetween acc[0], newPosition\n [p, visitedPositions + pathPositions, c]\n end\nend",
"def move_available?\n total_available_moves > 0\n end",
"def possible_moves(y_pos, x_pos, moves_list=[[y_pos,x_pos]])\n\t\t\n\t\treturn moves_list if moves_list.length > 64\n\n\t\tmove_square = y_pos+2, x_pos+1\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1]) \n\n\t\tmove_square = y_pos+2, x_pos-1\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmove_square = y_pos-2, x_pos+1\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmove_square = y_pos-2, x_pos-1\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmove_square = y_pos+1, x_pos+2\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmove_square = y_pos+1, x_pos-2\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmove_square = y_pos-1, x_pos+2\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmove_square = y_pos-1, x_pos-2\n\t\tmoves_list << move_square if check_legal_move(move_square[0],move_square[1])\n\n\t\tmoves_list.each { |move| possible_moves(move[0], move[1], moves_list) }\n\t\treturn moves_list\n\tend",
"def destinations(board)\n #selects destinations that are on the board\n dest_array = @moves.select do |move|\n move = [move[0] + @pos[0], move[1] + @pos[1]]\n move.all? {|i| (0..7).include?(i)}\n end\n\n #selects only destinations that are empty or have the opponents piece on it\n dest_array = dest_array.select do |pos|\n piece = board[pos[0]][pos[1]]\n piece.nil? || piece.player != @player\n end \n end",
"def possible_moves_in_board(position)\n POSSIBLE_MOVES.select do |move|\n x = position[0] + move[0]\n y = position[1] + move[1]\n\n within_board?(x, y)\n end\n end",
"def regular_moves\n moves = [] # initializes empty move array\n\n # choses \"forward\" y direction based on piece team\n if @team == \"l\"\n dir = 1\n else\n dir = -1\n end\n \n # looks at the two forward diagonal positions and adds them to moves array if there are no pieces there\n pos1 = [@x_pos + 1, @y_pos + dir]\n moves << pos1 if Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos1}\n pos2 = [@x_pos - 1, @y_pos + dir]\n moves << pos2 if Piece.all.none?{|p| [p.x_pos, p.y_pos] == pos2}\n \n # deletes any moves with coordinates that aren't on the board\n moves.delete_if{|move| move.find{|n| n < 0 || n > 7}}\n return moves \n end",
"def possible_moves(pos, board)\n moves = @moves.reduce([]) { |all_moves, move| all_moves.push(move.valid_moves(pos, board, @owner)) }\n moves.flatten(1)\n end",
"def valid_moves(pos)\n valids = []\n MOVE_DIFFERENTIALS.each do |move_diff|\n valids << [(pos[0] + move_diff[0]), (pos[1] + move_diff[1])]\n end\n valids.select { |move| on_board?(move) }\n end",
"def generate_possible_moves(state)\n end",
"def pieces_between(source, target)\n dir = smallest_vec(source, target)\n number_of_spaces = (differential(source, target)[0])/dir[0] - 1\n \n [].tap do |empties|\n (1..number_of_spaces).each do |i|\n pos = move(source, dir, i)\n empties << pos unless board.is_empty?(pos)\n end\n end\n end",
"def group_possible_moves_bishop(pm)\n result = []\n\n result << pm.select do |p|\n p[0] < position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] < position[0] && p[1] > position[1]\n end\n\n result << pm.select do |p|\n p[0] > position[0] && p[1] < position[1]\n end\n\n result << pm.select do |p|\n p[0] > position[0] && p[1] > position[1]\n end\n result[0].reverse!\n result[1].reverse!\n result\n end",
"def move(a, p)\n\t\treachable = []\n\t\ttemp = []\n\t\ttemp.push a\n\t\ttemp.flatten!\n\t\ttemp.each{ |v1|\n\t\t\tif(@transition[v1] != nil)\n\t\t\t\t@transition[v1].keys.sort.each{ |v2|\n\t\t\t\t\tif (get_transition(v1,v2) == p)\n\t\t\t\t\t\tif (!reachable.include?(v2))\n\t\t\t\t\t\t\treachable.push(v2)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\tend\n\t\t}\n\t\treachable\n\tend",
"def gifts_given_and_received\n return []\n gifts_given + gifts_received\n end",
"def available_moves(board)\n\t\tmoves = []\n\t\tboard.each_with_index{|cell, index| moves << index.to_s if cell == \" \"}\n\t\tmoves\n\tend",
"def possible_moves(start_node, destination)\n\t\n\t\tif start_node.value == destination\n\t\t\treturn start_node\n\t\telse\n\t\t\tgame.visited << start_node\n\t\t\tgame.unvisited = game.unvisited + (set_parent(start_node, possible_positions(start_node.value)) - game.visited)\n\t\t\tgame.unvisited.each do |position_node|\n\t\t\t\tif position_node.value == destination\n\t\t\t\t\treturn position_node\n\t\t\t\tend\n\t\t\t\tgame.visited << position_node\n\t\t\tend\n\t\t\tpossible_moves(game.unvisited.shift,destination) if game.unvisited.first != nil \n\t\tend\n\tend",
"def find_winning_moves(board)\n winning_moves = []\n winning_moves.concat(winning_rows(board))\n winning_moves.concat(winning_cols(board))\n winning_moves.concat(winning_diags(board))\n return winning_moves\n end",
"def find_available_combinations(board, token)\n if token == self.token\n valid_and_made_moves = self.find_available_moves(board) + self.find_moves_made(board, self.token)\n Game::WIN_COMBINATIONS.select do |combo|\n (valid_and_made_moves & combo).count > 2\n end\n else\n valid_and_made_moves = self.find_available_moves(board) + self.find_moves_made(board, self.opponent.token)\n Game::WIN_COMBINATIONS.select do |combo|\n (valid_and_made_moves & combo).count > 2\n end\n end\n end",
"def get_adj(wins, player, opponent)\n potential_wins = get_potential_wins(wins, player, opponent) # get potential wins for player\n o_forks = find_fork(wins, opponent, player) # get potential forks for opponent\n open_p = [] # array to collect all open positions that could create a player win\n potential_wins.each do |p_win| # check each win for player and opponent positions\n open_p.push(p_win - player) if (p_win & player).size == 1 && (p_win & opponent).size == 0\n end\n if o_forks == @opcor_1 || o_forks == @opcor_2 # return position to force block without opponent fork\n move = (open_p.flatten - o_forks).sample\n elsif (open_p.flatten & o_forks).size > 0\n move = (open_p.flatten & o_forks).sample\n else\n move = open_p.flatten.sample\n end\n end",
"def valid_moves\n valid = []\n all_moves = self.moves\n\n all_moves.each do |end_pos|\n valid << end_pos unless move_into_check(end_pos)\n end\n \n valid\n end",
"def calculate_future_moves(coord)\n possible_transitions = [[2, 1], [2, -1], [1, 2], [-1, 2], \n [-2, 1], [-2, -1], [-1, -2], [1, -2]]\n actual_transitions = []\n possible_transitions.each do |transition|\n new_position = [coord[0]+transition[0], coord[1]+transition[1]]\n if valid_coordinate?(new_position) && !@visited.include?(new_position)\n actual_transitions << new_position\n end\n end\n actual_transitions\n end",
"def create_moves\n valid_moves = []\n MOVES.each do |move|\n location = [move[0] + loc[0], move[1] + loc[1]]\n valid_moves << location if location[0].between?(0,7) && location[1].between?(0,7)\n end\n valid_moves\n end",
"def possible_moves\n # p possible_non_attack_moves\n # p possible_attack_moves\n moves = possible_non_attack_moves + possible_attack_moves\n moves.reject! { |move| move.any? { |c| c < 0 || c > 7} }\n moves\n end",
"def get_moves_2(piece, board)\n valid_col = case piece.name\n when ?A then 3\n when ?B then 5\n when ?C then 7\n when ?D then 9\n else 11\n end\n moves = []\n\n # If in hallway\n if piece.row == 1\n cols = valid_col < piece.col ? (valid_col...piece.col).to_a : (piece.col+1..valid_col).to_a\n if cols.count{|c| board[[1, c]] == ?.} == cols.length\n if board[[2, valid_col]] == ?. && board[[3, valid_col]] == piece.name && board[[4, valid_col]] == piece.name && board[[5, valid_col]] == piece.name\n moves << [[2, valid_col], (cols.count + 1) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == piece.name && board[[5, valid_col]] == piece.name\n moves << [[3, valid_col], (cols.count + 2) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == ?. && board[[5, valid_col]] == piece.name\n moves << [[4, valid_col], (cols.count + 3) * piece.cost]\n elsif board[[2, valid_col]] == ?. && board[[3, valid_col]] == ?. && board[[4, valid_col]] == ?. && board[[5, valid_col]] == ?.\n moves << [[5, valid_col], (cols.count + 4) * piece.cost]\n end\n end\n # If right column and something is underneath and nothing above\n # If in wrong column completely and nothing above\n elsif piece.row >= 2\n below = (piece.row+1..5).to_a\n above = (2..piece.row-1).to_a\n if ((piece.col == valid_col && below.count{|c| board[[c, piece.col]] != piece.name} != 0 && below.length != 0) || (piece.col != valid_col)) && (above.count{|c| board[[c, piece.col]] == ?.} == above.length)\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 1 + above.length\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n end\n end\n moves\nend",
"def move2(position, curr_player, other_player, path = 0)\n posibles = []\n \n #add [-2,0]\n other = false\n curr = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 2, position[1]] || piece.position == [position[0] - 1, position[1]]\n other = true\n end\n end\n curr_player.pieces.each do |piece|\n if piece.position == [position[0] - 2, position[1]] || piece.position == [position[0] - 1, position[1]]\n curr = true\n end\n end\n if (!other && !curr) && @path == 0\n posibles << [-2, 0]\n end\n \n #add [-1,0]\n other = false\n curr = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1]]\n other = true\n end\n end\n curr_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1]]\n curr = true\n end\n end\n if !other && !curr\n posibles << [-1, 0]\n end\n \n #add [-1,1]\n other = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1] + 1]\n other = true\n end\n end\n if other\n posibles << [-1, 1]\n end\n \n #add [-1, -1]\n other = false\n other_player.pieces.each do |piece|\n if piece.position == [position[0] - 1, position[1] - 1]\n other = true\n end\n end\n if other\n posibles << [-1, -1]\n end\n select_moves(position, posibles)\n end",
"def moves\n # create array to collect moves\n possible_moves = []\n move_dirs.each do |dir|\n possible_moves += grow_unblocked_moves_in_dir(dir[0],dir[1])\n end\n # iterate over each of the directions in which a slideable piece can move\n # use the Piece subclass' `#move_dirs` method to get this info\n # for each direction, collect all possible moves in that direction\n # and add them to your moves array \n # (use the `grow_unblocked_moves_in_dir` helper method)\n\n # return the final array of moves (containing all possible moves in all directions)\n possible_moves\n end",
"def moves\n\n #\n all_moves = sigma_deltas().map {|delta| transform(delta)}\n # all_moves.select { |move| board.on_board?(move)}\n end",
"def valid_moves(position)\n moves = []\n MOVES.each do |move|\n new_pos1 = move[0] + position[0]\n new_pos2 = move[1] + position[1]\n pos = [new_pos1, new_pos2]\n if pos.min >= 0 && pos.max < 9\n moves << pos\n end\n end\n moves\n end",
"def position_available(marker_pos, player1_obj, player2_obj)\n # test - marker_pos - index has a limit of 1 to 9\n return false if marker_pos.negative? || (marker_pos > 8)\n\n # test - new move - does not overlap any previous moves done.\n return true if (player1_obj.moves_arr[marker_pos].zero? && player2_obj.moves_arr[marker_pos].zero?) == true\n\n false\nend",
"def moves\n possible_moves = []\n\n self.move_dirs.each do |dir|\n num_steps = 1\n blocked = false\n\n until blocked\n next_step = [dir[0]*num_steps, dir[1]*num_steps]\n next_pos = [self.pos[0] + next_step[0], self.pos[1] + next_step[1]]\n\n break unless next_pos.all? { |i| i.between?(0,7) }\n\n if self.board[next_pos]\n blocked = true\n possible_moves << next_pos unless self.color == self.board[next_pos].color\n else\n possible_moves << next_pos\n num_steps += 1\n end\n end\n end\n\n possible_moves\n end",
"def all_moves(start, directed_moves)\n # Array of valid moves\n all_moves = []\n\n directed_moves.each do |ele|\n ele[0] = ele[0] + start[0]\n ele[1] = ele[1] + start[1]\n all_moves << ele\n end\n all_moves\n end",
"def moves\n\t\tm = []\n\t\t@@moves.each do |move|\n\t\t\tfrom, to = move\n\n\t\t\tp1 = @value & MASKS[from]\n\t\t\tp2 = @value & MASKS[to]\n\n\t\t\tshift = (to - from) * 3\n\t\t\tp1 = p1 >> shift\n\t\t\tp2 = p2 << shift\n\n\t\t\tnum = (@value & INV_MASKS[from]) | p2\n\t\t\tnum = (num & INV_MASKS[to]) | p1\n\n\t\t\tm << State.new(num, @n_moves + 1)\n\t\tend\n\t\tm\n\tend",
"def valid_moves(pos)\n valid_moves = []\n long = [-2,2]\n short = [1,-1]\n valid_moves += valid_moves_helper(pos, long, short)\n valid_moves += valid_moves_helper(pos, short, long)\n end",
"def force_check_filter(board, moves)\n force_check_moves = Hash.new { |hash, key| hash[key] = [] }\n\n moves.each do |start_pos, end_positions|\n end_positions.each do |end_pos|\n new_board = DeepClone.clone(board)\n new_board.move_piece(start_pos, end_pos)\n if new_board.in_checkmate?(opponent_color)\n @end_pos = end_pos\n return start_pos\n elsif new_board.in_check?(opponent_color)\n force_check_moves[start_pos] << end_pos\n end\n end\n end\n\n new_moves = force_check_moves.empty? ? moves : force_check_moves\n highest_value_capture_filter(board, new_moves)\n end",
"def moves; [] end",
"def peo_moves\n\t\tadjacent = adjacent_peo\n\t\t## direction = 1\n\t\tif adjacent == 0\n\t\t\tpawn_moves(1)\n\t\telsif adjacent == 1\n\t\t\tmoves = cross_moves\n\t\t\tmoves = moves.concat( calculate_single_take(@row+1, @column+1) )\n\t\t\tmoves = moves.concat( calculate_single_take(@row+1, @column-1) )\n\t\telse\n\t\t\tking_moves\n\t\tend\n\tend",
"def max_player_moves(player_moves)\n player_moves[0] << @avail_moves.shift\n end",
"def valid_moves\n moves = []\n\n # go in all directions\n (-1..1).each do |_x_step|\n (-1..1).each do |_y_step|\n # start walking in that direction\n (1..7).each do |steps|\n x = x_coordinate + steps * x_direction\n y = y_coordinate + steps * y_direction\n\n # stop walking if you hit a wall\n break unless valid_move?(x, y)\n\n # remember the valid moves\n moves.push(Move.new(x, y))\n end\n end\n end\n moves\n end",
"def valid_moves(from)\n piece = @board.at(from)\n if piece.king? || piece.knight?\n piece.moves.map do |move|\n to = relative_coords(from, move)\n to if possible_move?(to)\n end.compact\n elsif piece.pawn?\n pawn_valid_moves(from)\n else\n valid_moves_recursive(from)\n end\n end",
"def get_valid_moves\n # delta = color == :white ? 1 : -1\n pos = [position[0] + direction, position[1]]\n validated_moves = capture_spaces\n validated_moves << pos if valid_move?(pos)\n unless @moved || !validated_moves.include?(pos)\n\n pos = [position[0] + (2*direction), position[1]]\n validated_moves += valid_move?(pos) ? [pos] : []\n end\n\n validated_moves\n end",
"def moves\n result = []\n\n color_setter = (color == :black ? 0 : 1)\n\n ## handles single moves\n d_pos = DELTA[color_setter]\n new_move = calc_new_move(d_pos)\n result << new_move if in_bounds?(new_move) && !occupied?(new_move)\n\n ## handles double move\n d_pos = DOUBLE_MOVE[color_setter]\n new_move = calc_new_move(d_pos)\n result << new_move if in_bounds?(new_move) && !moved? && !result.empty? && !occupied?(new_move)\n\n ## handles capture moves\n CAPTURE_MOVES[color_setter].each do |c_pos|\n new_move = calc_new_move(c_pos)\n result << new_move if in_bounds?(new_move) && capturable?(new_move)\n end\n\n result\n end",
"def protecting_moves(pieces)\n\t\tarrPos = []\n\t\tif team == 1\n\t\t\tarrPos << [@xCord - 1, @yCord + 1] if square_taken_teammate?(pieces, [@xCord - 1, @yCord + 1])\n\t\t\tarrPos << [@xCord + 1, @yCord + 1] if square_taken_teammate?(pieces, [@xCord + 1, @yCord + 1])\n\t\telsif team == 2\n\t\t\tarrPos << [@xCord - 1, @yCord - 1] if square_taken_teammate?(pieces, [@xCord - 1, @yCord - 1])\n\t\t\tarrPos << [@xCord + 1, @yCord - 1] if square_taken_teammate?(pieces, [@xCord + 1, @yCord - 1])\n\t\tend\n\t\tarrPos\t\n\tend",
"def get_moves(start)\n x = start.x\n y = start.y\n moves = []\n moves << Node.new(x+2, y+1)\n moves << Node.new(x+2, y-1)\n moves << Node.new(x+1, y+2)\n moves << Node.new(x+1, y-2)\n moves << Node.new(x-1, y+2)\n moves << Node.new(x-1, y-2)\n moves << Node.new(x-2, y+1)\n moves << Node.new(x-2, y-1)\n moves = moves.reject do |node|\n node.x < 0 || node.x > 8\n end\n moves = moves.reject do |node|\n node.y < 0 || node.y > 8\n end\n moves.each { |move| move.next_node = start }\nend",
"def rps_result(m1, m2)\n valid_move = [\"R\", \"P\", \"S\"]\n game_checker = [\"RS\", \"SP\", \"PR\", \"RR\", \"SS\", \"PP\" ]\n move = m1[1].upcase + m2[1].upcase\n if @debug\n printf m1[0] + \"(\" + m1[1] + \") against \" + m2[0] + \"(\" + m2[1] + \")\"\n printf \",move:\" + move\n end\n raise NoSuchStrategyError unless \n valid_move.include?(m1[1].upcase) && \n valid_move.include?(m2[1].upcase)\n if game_checker.include?(move) \n if @debug ; printf \">\" + m1[0] + \" wins\\n\" ; end \n return m1\n else\n if @debug ; printf \">\" + m2[0] + \" wins\\n\" ; end \n return m2\n end\nend",
"def available_moves\n raise NotImplementedException\n end",
"def valid_moves(temp_board)\n moves.select do |end_pos|\n temp_board.valid_pos?(end_pos) && temp_board.empty?(end_pos)\n end\n end",
"def options\n pieces = @board.pieces(@current_player)\n moves = []\n pieces.each do |location|\n piece = @board[location]\n piece.moves.each do |direction|\n neighbor1 = @board.neighbors(location)[direction] if @board.neighbors(location)\n neighbor2 = @board.neighbors(neighbor1)[direction] if @board.neighbors(neighbor1)\n moves << move_factory(location, neighbor1, neighbor2)\n end\n end\n moves.delete_if(&:nil?)\n\n if moves.map(&:class).include?(Checkers::Jump)\n moves.delete_if { |move| move.class == Checkers::Move }\n unless @moves.empty? || @current_player != @moves.last.owner\n # There are still jumps leftover\n moves.keep_if { |jump| jump.src == @moves.last.dest }\n end\n end\n \n moves\n end",
"def possible_king_moves(start_arr)\n\t\tx = start_arr[0]\n\t\ty = start_arr[1]\n\t\tcandidates = []\n\t\tcandidates << [x+1,y]\n\t\tcandidates << [x-1,y]\t\t\n\t\tcandidates << [x,y+1]\t\t\t\t\n\t\tcandidates << [x,y-1]\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tcandidates << [x+1,y+1]\n\t\tcandidates << [x-1,y-1]\t\n\t\tcandidates << [x-1,y+1]\t\t\t\t\n\t\tcandidates << [x+1,y-1]\t\t\t\t\n\t\tchildren = candidates.select { |pos| pos[0] >= 0 && pos[1] >= 0 && pos[0] <= 7 && pos[1] <= 7}\n\t\tchildren.delete_if do |child|\n\t\t\tif !(@board[child] == \"*\")\n\t\t\t\t# If pieces not same color\n\t\t\t\tif @board[child].color == @board[start_arr].color\n\t\t\t\t\tif occupied(child)\n\t\t\t\t\t\tcan_do = true\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tchildren\n\tend",
"def receive_move() #a request to move a piece from something to somewhere else\n print \"Where is the piece you want to move (e.g., B2)? \"\n from = gets.chomp.upcase\n valid_selection = false\n until valid_selection\n valid_selection = (from =~ /[A-Ha-h][1-8]/)\n break if valid_selection\n print \"Sorry, not a valid place on the board. Try something like A7. \"\n from = gets.chomp\n end\n m1 = from\n print \"Where would you like to move the piece to? \"\n to = gets.chomp.upcase\n valid_selection = false\n until valid_selection\n valid_selection = (to =~ /[A-Ha-h][1-8]/)\n break if valid_selection\n print \"Sorry, not a valid place on the board. Try something like A6. \"\n to = gets.chomp\n end\n m2 = to\n return [m1, m2]\n end"
] |
[
"0.72172505",
"0.6733831",
"0.6693919",
"0.6663384",
"0.64564115",
"0.64156556",
"0.64130557",
"0.64099115",
"0.6341616",
"0.6334819",
"0.6317007",
"0.6278047",
"0.6267057",
"0.62636286",
"0.6245892",
"0.6237971",
"0.62254995",
"0.62038827",
"0.61890054",
"0.6182633",
"0.6149566",
"0.6144741",
"0.612356",
"0.6120927",
"0.6113939",
"0.6111835",
"0.6041789",
"0.6037302",
"0.60309744",
"0.6030115",
"0.6029912",
"0.6008712",
"0.5992162",
"0.59779453",
"0.59748393",
"0.5974729",
"0.59736663",
"0.5973321",
"0.59722966",
"0.596593",
"0.59651375",
"0.5947212",
"0.59461075",
"0.5933919",
"0.5924565",
"0.5923308",
"0.59087664",
"0.58987105",
"0.5887828",
"0.58862704",
"0.5881494",
"0.5875024",
"0.5866888",
"0.5857029",
"0.585671",
"0.58520895",
"0.5833697",
"0.583274",
"0.583047",
"0.58304125",
"0.5782164",
"0.5773041",
"0.5770366",
"0.57610875",
"0.574772",
"0.5740518",
"0.5733442",
"0.5729824",
"0.5725397",
"0.5718995",
"0.57184535",
"0.5714665",
"0.570263",
"0.5698347",
"0.5691735",
"0.56888616",
"0.56820464",
"0.5678142",
"0.5669914",
"0.56633824",
"0.5656661",
"0.5653115",
"0.56527174",
"0.5651365",
"0.56419045",
"0.5636945",
"0.56322634",
"0.5631554",
"0.5626566",
"0.562544",
"0.56246793",
"0.562443",
"0.56230086",
"0.56119525",
"0.5604376",
"0.5603635",
"0.56035745",
"0.55982137",
"0.55955553",
"0.5595422"
] |
0.7014443
|
1
|
return true if game is draw (no remaining winning moves available), else return false. Improve by taking into account whose turn it is.
|
def draw?(p1_moves, p2_moves)
avail_moves = open_squares(p1_moves, p2_moves)
return true if winner?(p1_moves | avail_moves) == false && winner?(p2_moves | avail_moves) == false
return false
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def drawn?\n # Conditions:\n # 1. No move available\n # 2. And no one wins\n if !move_available? && !win?\n mark_drawn!\n\n return true\n end\n\n false\n end",
"def draw?\n !board.include?(0) && winner.nil?\n end",
"def draw?\n incomplete_board = !full?\n is_game_won = won?\n if incomplete_board == true\n return false\n elsif is_game_won.is_a?(Array)\n return false\n else\n return true\n end\n end",
"def draw?(board)\n if full?(board) && !(won?(board))\n return true\n else\n return false\n end\nend",
"def draw?\n if @board.include?(nil) \n return false\n elsif winner == false && @board.include?(nil) == false\n return true\n end\n end",
"def draw?(board)\n full?(board) && !won?(board)\n #full?(board) && won?(board) == false\n #with ^^ didnt \"return true for draw\"\nend",
"def draw?(board)\n if full?(board) && !won?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) && !won?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) && !(won?(board))\n true\n else\n false\n end\nend",
"def draw?(board)\n redundant = won?(board)\n if redundant\n return false\n end\n return true\nend",
"def draw?\n self.board.full? && !self.won?\n end",
"def draw?(board)\n if full?(board) && !won?(board)\n true\n elsif !(won?(board) && full?(board)) || won?(board)\n false\n end\nend",
"def draw?(board)\n if !(won?(board)) && full?(board)\n return true\n end\nend",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?(board)\n if (full?(board) && !won?(board))\n return true\n else\n return false\n end\nend",
"def draw?(board)\n #must be true for a draw, false for in progress,<<so use full? then && so that both sides must evauluate true and since it must be false for a won game >> !won?\n full?(board) && !won?(board)\nend",
"def draw?(board)\n if full?(board) && !won?(board) then return true\n end\nend",
"def draw?(board)\n if (full?(board) == false)\n return false\n else\n if (won?(board) != false)\n return false\n else\n return true\n end\n end\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n false\n end\nend",
"def draw?(board)\n if full?(board) && (won?(board) == false)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board)\n if !won?(board)\n return true\n else\n return false\n end\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n puts \"This game is draw - sorry ladies and gentlemen\"\n return true\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?()\n if full?() && !won?()\n return true\n end\n return false\n end",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n if !won?(board) && !full?(board) && won?(board)\n return false\n end\nend\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?\n !won? && board.full?\n end",
"def draw?(board)\n return full?(board) && !won?(board)\nend",
"def draw?(board)\n if won?(board)\n return false\n elsif !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?\n @board.full? && !won?;\n end",
"def draw? (board)\n if !won?(board) #returns true if no win\n if full?(board) #but board is full\n return true\n end\n end\n return false\nend",
"def draw?\n \t@game_over == true and @winner == false\n end",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n elsif !won?(board) && full?(board)\n return false\n elsif won?(board)\n return false\n end\n end",
"def draw?(board)\n if (!won?(board)) && (full?(board))\n return true\n end\n return false\nend",
"def done?\n # legal_moves(state).empty?\n # Try to speed up by disregarding possibility of draw\n false\n end",
"def draw?\n board.full? && self.won? == false\n end",
"def draw?(board)\n board_complete = full?(board)\n board_won = won?(board)\n board_complete && !board_won ? true : false\nend",
"def draw?\n if full?\n if !won?\n return true\n else\n return false\n end\n end\n end",
"def draw?\n if full? && !won?\n return true\n else\n return false\n end\n end",
"def draw?(board)\r\n if full?(board) && !won?(board)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?\n if not won?\n return full?\n else\n return false\n end\n end",
"def draw?\n if !won? && full?\n return true\n else\n return false\n end\n end",
"def draw?(board)\n full?(board) && !(won?(board))\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n elsif !won?(board) && !full?(board) || won?(board)\n return false\n end\nend",
"def draw?(board)\n if not won?(board)\n return full?(board)\n else\n return false\n end\nend",
"def draw?(board)\n return full?(board) && !won?(board) ? true : false\nend",
"def draw?(board)\n if won?(board) != false || full?(board) == false\n return false\n else\n return true\n end\nend",
"def draw?(board)\n if won?(board) || !full?(board)\n false\n else\n true\n end\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n if won?(board) # BROKEN! If #won? returns an array, return false\n false\n elsif !won?(board) && full?(board) # Draw conditions: No win and full board\n true\n else\n false\n end\nend",
"def draw?(board)\n if (!full?(board) && !won?(board)) || won?(board)\n false\n elsif full?(board) == true\n true\n end\nend",
"def draw?(board)\n\t if !won?(board) && full?(board)\n\t return true\n\t else\n\t return false\n\t end\nend",
"def draw?(board)\n return !won?(board) && full?(board)\nend",
"def draw?(board)\n full = full?(board) == true\n won = won?(board) != false\n\n if ( !won && full )\n return true\n\n elsif ( !won && !full )\n return false\n\n elsif ( won )\n return false\n end\nend",
"def draw?(board)\n if full?(board) == true && won?(board) == false\n return true\n end\nend",
"def draw?(board)\n if won?(board)\n return false\n else\n return true\n end\nend",
"def draw?\n if self.won? == nil && self.board.full?\n true\n elsif self.won? != nil || !self.board.full?\n false\n end\n end",
"def draw?\n !(won?) && (full?)\n end",
"def draw?(board)\n (full?(board)) && !(won?(board))\nend",
"def draw?\n if full?\n !won?\n\n else\n false\n end\n\n end",
"def draw?(board)\n if full?(board) == true && won?(board) == false\n true\n end\nend",
"def draw? (board)\n isFull = full?(board)\n isWon = won?(board)\n (isFull && isWon == false)\nend",
"def draw?\n if (!won?) && (full?)\n return true\n end\n return false\n end",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n elsif !won?(board) && !full?(board)\n return false\n else won?(board)\n return false\n end\n end",
"def draw?(board)\n (full?(board) && !won?(board)) ? true : false\nend",
"def draw?\n full? && !won?\n end",
"def draw?(board)\n won_check = won?(board)\n fullboard_check = full?(board)\n if won_check == false && fullboard_check == true\n return true\n elsif won_check == false && fullboard_check == false\n return false\n elsif won_check != false\n return false\n end\nend",
"def draw?(board)\n if won?(board) == false && full?(board) == true\n return true\n end\nend",
"def draw?\n !won? && full?\n end",
"def draw?(board)\n if (won?(board) != false)\n false\n elsif (won?(board) == false && full?(board) == false)\n false\n elsif (won?(board) == false && full?(board) == true)\n true\n end\nend",
"def draw?\n if full? && !won?\n true\n else\n false\n end\nend",
"def draw?\n !(won?) && full?\n end",
"def draw?(board)\n if !won?(board) && full?(board) \n return true \n elsif !won?(board) && !full?(board) \n return false \n elsif won?(board) \n return false\n end\nend",
"def draw?(board)\nfull?(board) && !won?(board)\nend",
"def draw?(board)\n if !won?(board) && !full?(board)\n elsif won?(board)\n else !won?(board) && full?(board)\n return true\n end\nend",
"def draw?(board)\n !won?(board) && full?(board)\n end",
"def draw?(board)\n if won?(board) == false && full?(board) == true\n return true\n else\n return false\n end\nend",
"def draw?(board)\n\n if full?(board) == true\n if won?(board) == nil\n return true\n else\n return false\n end\n else\n return false\n end\n\nend",
"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 draw?(board)\n won?(board) == false && full?(board) ? true : false\n # full?(board) && !won?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?\r\n !won? && full?\r\n end",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n return true\n end\nend",
"def draw?(board)\n if (full?(board) == TRUE && won?(board) == FALSE)\n return TRUE\n else\n return FALSE\n end\nend"
] |
[
"0.83163685",
"0.8150325",
"0.8088796",
"0.79780215",
"0.79609954",
"0.79577595",
"0.7927683",
"0.7927683",
"0.7917684",
"0.79171044",
"0.7915534",
"0.7912967",
"0.79019505",
"0.7896192",
"0.7896192",
"0.7893902",
"0.7893047",
"0.78823435",
"0.78822887",
"0.7877937",
"0.787746",
"0.7874458",
"0.7872308",
"0.7867749",
"0.7863814",
"0.7863814",
"0.7863814",
"0.78548473",
"0.78534544",
"0.78509384",
"0.78509384",
"0.785018",
"0.7846972",
"0.78432035",
"0.7841857",
"0.7841376",
"0.78386587",
"0.78343993",
"0.7832483",
"0.7831928",
"0.7831578",
"0.78300077",
"0.78269726",
"0.7826054",
"0.782255",
"0.7817708",
"0.78150284",
"0.78010786",
"0.78008646",
"0.77996427",
"0.77931",
"0.7787894",
"0.7783118",
"0.77811843",
"0.77786815",
"0.77786815",
"0.77786815",
"0.77786815",
"0.7773602",
"0.77651274",
"0.77643824",
"0.77623576",
"0.7759508",
"0.7751301",
"0.77434176",
"0.7740052",
"0.77384824",
"0.77383494",
"0.7736907",
"0.7729135",
"0.7728071",
"0.77231616",
"0.7713996",
"0.77118546",
"0.77097136",
"0.7707171",
"0.7703285",
"0.76953644",
"0.7690974",
"0.7688148",
"0.76874214",
"0.76866513",
"0.768475",
"0.76827896",
"0.76816946",
"0.7680444",
"0.76745385",
"0.76725876",
"0.7672025",
"0.76684356",
"0.7667616",
"0.76620305",
"0.76620305",
"0.76620305",
"0.76620305",
"0.76620305",
"0.76620305",
"0.76620305",
"0.7651276",
"0.7650797"
] |
0.7751086
|
64
|
say hi to everyone
|
def say_hi
if @names.nil?
puts "..."
elsif @names.respond_to?("each")
@names.each do |name|
puts "Hello #{name}"
end
else
puts "Hello #{@names}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sayHi\n\t\tputs(greet)\n\tend",
"def say_hi\n\t\tputs 'saying hi'\n\tend",
"def say_hi\n \tputs \"hello user\" #you must call the method by calling. out its name \"say_hi\"\n end",
"def greet\n self.say \"Hello, I am #{@config[:nick]}. I am the resident uber-bot. To learn more, type '.about'.\"\n end",
"def say_hi\n\t\tputs \"Hello!\"\n\tend",
"def say_hi\n puts \"hi\"\n end",
"def saymessage\n puts \"hi programers\"\n puts \"I am hungy\"\nend",
"def say_hi\n puts \"Hi!\"\n end",
"def greetings\n\tputs \"Greetings friend!\"\nend",
"def greeting_hello\n answer_with_message(\"Halo bos, ada yang bisa saya bantu ?\")\n end",
"def greet_user\n greetings = %w[\n bonjour hola hallo sveiki namaste shalom salaam szia halo ciao\n ]\n first_name = message.from.nil? ? '' : ', ' + message.from.first_name\n send_message \"#{greetings.sample.capitalize}#{first_name}!\\n Enter /help for options.\"\n end",
"def sayhi\n puts \"Hello user\"\nend",
"def say_hello\n\tputs \"Bonjour!\"\nend",
"def greet(m)\n return unless m.message =~ /\\b(hellos?|hi(ya)?|howdy|hey|greetings|yo|sup|hai|hola),? #{m.bot.nick}\\b/i\n greetings = ['Hello', 'Hi', 'Hola', 'Ni hao', 'Hey', 'Yo', 'Howdy']\n greeting = greetings[rand(greetings.size)]\n m.reply \"#{greeting}, #{m.user.nick}!\"\n end",
"def say_hi\n\t\tif @name.nil?\n\t\t\tputs \"...\"\n\t\telsif @names.respond_to(\"each\")\n\t\t\t# @names is a list of some kind, iterate!\n\t\t\t@names.each do |name|\n\t\t\t\tputs \"Hello #{name}!\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"Hello #{@names}!\"\n\t\tend\n\tend",
"def say_hi\n \"Hi!\"\n end",
"def greet\n puts '------------------------'\n puts \"Greetings to you #{@name}\"\n end",
"def greet\n puts \"# Welcome to Mastermind!\"\n puts \"# Good luck!\"\n end",
"def sayHi\n \n\t\tif @names.nil?\n\t\t\tputs \"...\"\n\t\t \n\t\telsif @names.respond_to?(\"each\")\n\t\t\t@names.each do |name|\n\t\t\tputs \"Hi #{name}!\"\n\t\tend\n\t\t\n\t\telse\n\t\t\tputs \"Hi #{@names}\"\n\t\tend\n \n\tend",
"def hi\n \t\t\tputs \"Ich heiße #{@name} und mir geht es zu #{@health}% gut.\"\n \t\tend",
"def say_hello (name)\n\t\t\t\tputs \"Ich bin #{name}\"\n\t\t\tend",
"def say_hello (name)\n\t\t\t\tputs \"Ich bin #{name}\"\n\t\t\tend",
"def say_hi\n\t\tif @names.nil?\n\t\t\tputs \"...\"\n\t\telsif @names.respond_to?(\"each\")\n\t\t\t@names.each do |name|\n\t\t\t\tputs \"Hello #{name}!\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"Hello #{@names}\"\n\t\tend\n\tend",
"def sayHi\n\t\tputs \"hello, my name is #{@name}\"\n\tend",
"def sayMessage\r\n puts \"Hey Programmers!\"\r\n puts \"What's for lunch?\"\r\nend",
"def say_hello\n\t'hello'\nend",
"def say_hi\n\t\tif names.nil?\n\t\t\tputs \"...\"\n\t\telsif @names.respond_to?(\"each\")\n\t\t\t@names.each do |name|\n\t\t\t\tputs \"Hello #{name}!\"\n\t\t\tend\t\n\t\telse\n\t\t\tputs \"Hello #{@names}!\"\n\t\tend\n\tend",
"def say_hi\n if @names.nil?\n puts \"...\"\n # If the @names object responds to each, it is something that you can iterate over, so iterate over it and greet each person in turn.\n #Finally, if @names is anything else, just let it get turned into a string automatically and do the default greeting.\n elsif @names.respond_to?(\"each\")\n #each is a method that accepts a block of code then runs that block of code for every element in a list, and the bit between do and end is just such a block.\n #A block is like ananonymous function or lambda. The variable between pipe characters is the parameter for this block.\n @names.each do |name|\n puts \"Hi #{name}\"\n end\n else\n puts \" Hi #{@names}\"\n end\n end",
"def speak\n puts \"I'm a person\"\n end",
"def say_hi\n puts \"hi\"\nend",
"def check_for_greet(cmd, nick)\n if cmd =~ /\\b(Hi|Hello|Hey|Hay|Hola|Sup|Whats up|Yo)\\b/i\n self.say \"#{@greetings[rand(@greetings.length)]}, #{nick}\"\n end\n end",
"def say_hi\n puts \"hi\"\nend",
"def say_hello (name, health=0)\n\t\t\t\t\"Ich bin #{name} mit einem Wert von #{health}\"\n\t\t\tend",
"def say_hello\t\t\t\t\t\n puts \"Dire Bonjour peut sauver des meres !\" \t\t#Petite référence à VALD\nend",
"def magic_welcome(event)\n # TODO: Ditch this call to report - move to report lib if necessary\n report \"#{event.from} welcome message: #{event.message}\"\n if (event.message =~ /(\\S+)!\\S+$/)\n @me = $1\n elsif (event.message =~ /(\\S+)$/)\n @me = $1\n end\n\n @registered = true\n mode @me, 'i'\n end",
"def speak\n puts \"ho, ho, ho! happy hollandaise!\"\n end",
"def say_hello\n puts \"Hello, what's your name?\"\n print \"User: \".blue\n name = gets.chomp\n bot_response(\"Hello #{name}\")\nend",
"def say_hello (name)\n\t\t\t\t\"Ich bin #{name}\"\n\t\t\tend",
"def say(message)\n output.puts message\n end",
"def say_hello_to(name)\n puts \"Hello, #{name}. It's good to see you.\"\n puts \" \"\n end",
"def say_hello\n\t\"Ich bin #{@name} mit einem Wert von #{@health}.\"\n\tend",
"def say_hi\n puts \"Hello\"\nend",
"def greet\n separator\n puts \"Welcome to #{pastel.bright_cyan('Groupie')}.\"\n puts \"Keep up with your favorite bands, never miss a show!\"\n puts \"Type #{pastel.bright_cyan('concerts')} to get started.\"\n separator\n end",
"def greet\n separator\n puts \"Welcome to #{pastel.bright_cyan('Groupie')}.\"\n puts \"Keep up with your favorite bands, never miss a show!\"\n puts \"Type #{pastel.bright_cyan('concerts')} to get started.\"\n separator\n end",
"def say_hello_personal(name)\n\tputs \"Hello \" + name\nend",
"def welcome\n puts message_list[:welcome]\n # help\n end",
"def say_name\n puts \"Bellossom!\"\n end",
"def say_hi()\n\t\"Hello\"\nend",
"def say_hello (name)\n\tputs \"Ich bin #{name}.\"\nend",
"def shout\n 'Yay!'\n end",
"def say\n send_text \"You just said: #{params}\"\n end",
"def say_name\n puts \"Bonsly!\"\n end",
"def say_hi\n if @names.nil?\n puts \"...\"\n else \n if @names.respond_to?(\"each\")\n @names.each do |name|\n puts \"Hello #{name.capitalize}!\"\n end\n else\n puts \"Hi #{@names}!\"\n end\n end\n end",
"def greet\n 'Ahoy Mateys!'\n end",
"def speak\n\t\tputs \"Meow. My name is #{@name.capitalize}.\"\n\t\tputs \"I am #{@age} years old and I live in #{@location}\"\n\t\tputs \"I am a #{@colour.downcase} #{@breed.downcase}.\"\n\tend",
"def say_greeting\n system 'say \"Good Luck\"'\n end",
"def welcome_user\n puts \"Welcome to #{pastel.bright_cyan('Groupie')}.\"\n puts \"Keep up with your favorite bands, never miss a show!\"\n puts \"Type #{pastel.bright_cyan('exit')} at any time to quit the app.\"\n puts \"Type #{pastel.bright_cyan('concerts')} to get started.\"\n end",
"def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end",
"def talk\n puts \"Hello!\"\n end",
"def greeting(m, message)\n if message =~ /help/\n m.reply help_message(m.user.nick)\n else\n m.reply \"#{m.user.nick}: Thanks for asking! I did not recognize your question. Try asking me for help.\"\n end\n end",
"def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n @names.each do |name|\n puts \"hello #{name}\"\n end\n else\n puts \"HELLO #{@names}\"\n end\n end",
"def personalChat\n puts \"This is a Personal Chat\"\n # puts message\n end",
"def greet\n\t\tputs \"Hi, my name is #{@name}\"\n\tend",
"def do_say(message)\n send \"You say '#{message}'\"\n other_players.each { |p| p.send \"#{name} says '#{message}'\" }\n end",
"def say_hello (name)\n\tputs \"Ich bin #{name}\"\nend",
"def greeter\nend",
"def say_hello\n puts \"Wilkomen Welt!\"\nend",
"def sayByeBye(user)\r\n puts \"Bye Bye #{user}\"\r\nend",
"def say text\n @output.say text\n end",
"def greets(name)\n puts \"hello #{name}, my name is #{@greeter_name}\"\n end",
"def say\n puts \"Hi\"\nend",
"def say\n puts \"Hi\"\nend",
"def speak\n puts \"WOOF WOOF\"\n end",
"def say_hello(name, num)\n\t\tputs \"Greetings, #{name}.\"\n\t\tputs \"you are number #{num}.\"\n\tend",
"def speak\n \"#{name} says Assalaam alaykum\"\n end",
"def hey(message)\n case message\n when shout then \"Woah, chill out!\"\n when question then \"Sure.\"\n when silence then \"Fine. Be that way!\"\n else \"Whatever.\"\n end\n end",
"def say(msg)\n print msg + \"\\r\\n\"\n end",
"def welcome_message\n puts \"Welcome to Everything but the Kitchen Sink!\"\n end",
"def say_hi \n expression = \"I am a genius\"\n puts expression\n end",
"def say(message)\n puts green(message) if self.verbose \n end",
"def greeting(name)\n\t\tputs \" Hi there #{name}, how are you doing today?\"\n\tend",
"def say_hello\n puts \"HELLOOOOO!\"\nend",
"def greet(folks); \"Hi, #{folks}!\"; end",
"def say_hello\n 'hello'\n end",
"def personal_chat(message) \n puts \"This is a Personal Chat\" \n puts message \n end",
"def say_hi\n if @names.nil?\n return '...'\n elsif @names.class == Array\n # @names is a list of some kind, iterate!\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n else\n return \"Hello #{@names}!\"\n end\n return '...' if @names.nil?\n return @names.map { |name| \"Hello #{name}!\" } if @names.class == Array\n \"Hello #{@names}!\"\n end",
"def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n # @names is a list of some kind, iterate!\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n else\n puts \"Hello #{@names}!\"\n end\n end",
"def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n # @names is a list of some kind, iterate!\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n else\n puts \"Hello #{@names}!\"\n end\n end",
"def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n # @names is a list of some kind, iterate!\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n else\n puts \"Hello #{@names}!\"\n end\n end",
"def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n # @names is a list of some kind, iterate!\n @names.each do |name|\n puts \"Hello #{name}!\"\n end\n else\n puts \"Hello #{@names}!\"\n end\n end",
"def tweet_greeting\n log \"greeting\"\n post \"Starting meitan-bot. Hello! #{Time.now.strftime('%X')}\"\n end",
"def hello(name)\n output = []\n output << \"from #{options[:from]}\" if options[:from]\n output << \"Hello #{name}\"\n output = output.join(\"\\n\")\n puts options[:yell] ? output.upcase : output\n puts \"> done saying hello\" if options[:verbose]\n end",
"def say_hello(name)\n\t\"Ich bin #{name}.\"\nend",
"def say_hi\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"each\")\n # @names appears to be an list (Array) of some kind, so lets iterate!\n @names.each do |name| # we specify that each item should be referenced by 'name'\n puts \"Hello #{name}!\"\n end\n else\n puts \"Hello #{@names}!\"\n end\n end",
"def welcome_the_user()\n puts \"Hi there!\"\nend",
"def say_name\n puts \"Marill!\"\n end",
"def speak\n puts 'bark bark bark'\n end",
"def say_that_thing_you_say\n \"#{self.name} always says: #{self.catchphrase}\"\n end",
"def welcome(nick_name, name)\n puts \"Hello, my friends call me #{nick_name}, but I prefer #{name}.\"\nend",
"def on_hello(content, client)\n OutputLogger.logger.info \"Bot is online!!!\"\n end"
] |
[
"0.7880603",
"0.7646402",
"0.75421375",
"0.7364657",
"0.7333217",
"0.73037755",
"0.72600377",
"0.7242886",
"0.7207713",
"0.7162793",
"0.71617854",
"0.7118497",
"0.7084572",
"0.70705736",
"0.70638174",
"0.70421696",
"0.70306635",
"0.70202744",
"0.7011164",
"0.6994244",
"0.690503",
"0.690503",
"0.6904669",
"0.6862394",
"0.6853572",
"0.6851126",
"0.6846743",
"0.6845176",
"0.6836863",
"0.6828644",
"0.6824468",
"0.68162906",
"0.6815418",
"0.67984426",
"0.67829376",
"0.6771003",
"0.6767758",
"0.67528355",
"0.6743891",
"0.67375475",
"0.67353046",
"0.67217004",
"0.6714995",
"0.6714995",
"0.67107904",
"0.670988",
"0.6702913",
"0.6699673",
"0.6699418",
"0.66939783",
"0.6663852",
"0.6661553",
"0.666059",
"0.66573536",
"0.6650559",
"0.66424334",
"0.66166073",
"0.66130805",
"0.66090167",
"0.6593337",
"0.6586419",
"0.6582989",
"0.65795255",
"0.6575595",
"0.65746236",
"0.6574143",
"0.6573579",
"0.6573315",
"0.65708935",
"0.6570803",
"0.657061",
"0.657061",
"0.65665466",
"0.6565965",
"0.65636384",
"0.6560336",
"0.65562063",
"0.6555426",
"0.65543884",
"0.65539175",
"0.6549622",
"0.65454775",
"0.6541222",
"0.6527012",
"0.6525197",
"0.65176827",
"0.65173334",
"0.65173334",
"0.65173334",
"0.65173334",
"0.65096796",
"0.65081596",
"0.6501896",
"0.6497764",
"0.64949995",
"0.6492449",
"0.6481959",
"0.6481851",
"0.647846",
"0.6471631"
] |
0.6521121
|
85
|
say goodbye to everyone
|
def say_bye
if @names.nil?
puts "..."
elsif @names.respond_to?("join")
puts "Goodbye #{names.join(", ")}"
else
puts "Goodbye #{names}"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def say_goodbye\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy\" +\n\t\t\t\t\"8-Ball game!\\n\\n\"\n\tend",
"def goodbye \n puts \"Don't leave hungry!\"\n end",
"def say_goodbye\r\n\t\tgoodbye = \"Thanks for playing the Virtual Crazy 8-Ball game! \\n\\n\" +\r\n\t\t\"Student: T. J. Flesher \\n\\nhttp://www.bellevue.edu/\"\t\t\r\n\t\tputs goodbye\r\n\tend",
"def goodbye\n puts Rainbow(\"Thanks for visiting. Goodbye...\").indianred.bright.underline\n end",
"def goodbye\n puts GOODBYE\n end",
"def say_bye\n\t\tif @names.nil?\n\t\t\tputs \"...\"\n\t\telsif @names.respond_to?(\"join\")\n\t\t\t\tputs \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n\n\t\telse\n\t\t\tputs \"Good bye #{@names}. Come back soon!\"\n\t\tend \n\tend",
"def goodbye\n puts \"\", \"Thank you! Goodbye :)\"\n end",
"def goodbye \nputs \"see you tomorrow for more Makeup :)\"\nend",
"def say_goodbye\r\n goodbye = \"Thanks for playing the Virtual Crazy 8-Ball game!\\n\\n\" +\r\n \"By Corey Hicks\\n\" +\r\n \"https://www.bruin.bellevue.edu\"\r\n puts goodbye\r\n end",
"def goodbye \n\t\tsystem(\"clear\")\n puts \"#######################\"\n puts \"# #\"\n puts \"# Thank you for #\"\n puts \"# #\"\n puts \"# visiting the #\"\n puts \"# #\"\n puts \"# Bank of Hamish #\"\n puts \"# #\"\n puts \"# GOODBYE! #\"\n puts \"# #\"\n puts \"# #\"\n\t\tputs \"#######################\"\n\tend",
"def goodbye\n puts \"Goodbye, thankyou for banking with AAB\".yellow\n end",
"def goodbye\n return \"Thanks for playing! See you soon!\".yellow\n system exit\n end",
"def goodbye\n puts \"Safe travels!\"\n end",
"def goodbye\n end",
"def ends_with_goodbye\n /WRITE ME/\n end",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")#반응하지않는다면 names는 문자열\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else\n puts \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def say_bye\n\t\tif@names.nil?\n\t\t\tputs \"...\"\t\n\t\telsif @names.respond_to?(\"join\")\n\t\t\t#join the list elements with commas\n\t\t\tputs \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n\n\t\telse\n\t\t\tputs \"Goodbye #{names}, come back soon\"\n\t\t\t\n\t\tend\n\tend",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else\n puts \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n # Join the list of items with commas\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else\n puts \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def goodbye\n puts \"Come back when you get hungry!!!\"\nend",
"def say_bye\n\t\tif @names.nil?\n\t\t\tputs \"...\"\n\t\telsif @names.respond_to?(\"join\")\t\n\t\t\t#join the list elements with commas\n\t\t\tputs \"Goodbye #{@names.join(\",\")}. come back son!\"\n\t\telse\n\t\t\tputs \"Goodbye #{@names}. come back soon\"\n\t\tend\n\tend",
"def good_bye\n puts \"Gracias por visitarnos. Regresa pronto\" \n end",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n p \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else\n p \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n puts \"Goodbye #{@names.join(', ')}. Come back soon!\"\n else\n puts \"GoodBye #{@names}. Come back soon!\"\n end\n end",
"def goodbye(drink)\n puts \"Here is your #{drink}, see you next time\"\n end",
"def farewell_message\n puts \"Program Exiting...\".red\n puts \"Goodbye #{@username}!\".blue\n end",
"def say_bye\n return '...' if @names.nil?\n if @names.class == Array\n # Join the list elements with commas\n return \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n end\n # return \"Goodbye #{@names.join(\", \")}. Come back soon!\" if @names.class == Array\n \"Goodbye #{@names}. Come back soon!\"\n>>>>>>> 2cd44c7 (Changes after Cesar verification)\n end",
"def goodbye\n\t\tputs \"\\nThanks for playing #{self.player_name}!\\n\"\n\t\tputs \"You finished with #{player_record[\"Wins\"]} wins and #{player_record[\"Losses\"]} losses\"\n\tend",
"def say_bye\n if names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n puts \" Goodbye #{@names.join(\" , \")}. Come back again!\"\n else\n puts \"Goodbye #{@names}. Come back again!\"\n end\n end",
"def bye\n puts \"bye\"\n end",
"def say_bye\r\n if @names.nil?\r\n puts \"...\"\r\n elsif @names.respond_to?(\"join\")\r\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\r\n else\r\n puts \"Goodbye #{@names}. Come back soon!\"\r\n end\r\n end",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n # join the list elements\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else\n puts \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def speak2\n puts \"Goodbye world\"\n end",
"def goodbye(name)\n say = \"Bye \" + name + \". \"\n return say\nend",
"def say_bye\n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n # Join the list elements with commas\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else\n puts \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def goodbye\n puts \"Thanks for using the Card Seeker. Come back soon.\"\n end",
"def exit\n \"Goodbye! Thanks for playing!\"\n end",
"def say_bye\n # If @names is empty, it will print ...\n if @names.nil?\n puts \"...\"\n # If @names responds to join, which is only useable on a list such as an array, it will put all of the names into one string\n elsif @names.respond_to?(\"join\")\n # Joins the list elements with commas\n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n # Runs if there is a single element stored in @names\n else\n puts \"Goodbye #{@names}. Come back soon!\"\n end\n end",
"def goodbye\n puts \"Thank you for using the Covid 19 CLI Tracker. Please Wash Your Hands.\"\n end",
"def someone_did_quit(stem, person, msg)\n end",
"def goodbye(name)\n\tstr = \"Bye \" + name + \".\"\n return str\nend",
"def bye_message\n message = \"Panacea's work is done, enjoy!\"\n say \"\\n\\n\\e[34m#{message}\\e[0m\"\n end",
"def say_bye\n if m_names.nil?\n puts \"...\"\n elsif m_names.respond_to?(\"join\")\n # Join the list elements with commas\n puts \"Goodbye #{m_names.join(\", \")}. Come back soon!\"\n else\n puts \"Goodbye #{m_names}. Come back soon!\"\n end\n end",
"def greeting_hello\n answer_with_message(\"Halo bos, ada yang bisa saya bantu ?\")\n end",
"def exit_now\n\t\tputs \"Goodbye!\"\n\tend",
"def saymessage\n puts \"hi programers\"\n puts \"I am hungy\"\nend",
"def greetings\n\tputs \"Greetings friend!\"\nend",
"def say_goodbye \n puts \"Thanks for running the program! This function was passed into a block using the yield keyword.\"\nend",
"def sayGoodbye\t\n\t\treturn super << \" and also from MyOtherClass\"\n\tend",
"def sayHi\n\t\tputs(greet)\n\tend",
"def say_bye\n puts \"Bye \" + define_names\n end",
"def say_bye \n if @names.nil?\n puts \"...\"\n elsif @names.respond_to?(\"join\")\n #Join the list elements with commas \n puts \"Goodbye #{@names.join(\", \")}. Come back soon!\"\n else \n puts \"Goodbye #{@names}. Come back soon!\"\n end \n end",
"def exit_jukebox\nputs \"Goodbye\"\nend",
"def bye; end",
"def die(reason)\n puts \"#{reason}, you did a good job though!\"\n exit(0)\nend",
"def seeYa()\n abort(\"\\nQuiting now. Bye!\") \nend",
"def sayGoodbye\n super\n return << \"and MyOtherClass\"\n end",
"def goodbye(name)\n return = \"Bye \" + name + \".\"\nend",
"def say_bye_and_exit\n puts\n puts \"\\033[1m\\033[34mHave a nice day!\\033[0m\"\n puts\n exit 0\nend",
"def exit_game\n puts \"Goodbye!\"\nend",
"def say_hello\t\t\t\t\t\n puts \"Dire Bonjour peut sauver des meres !\" \t\t#Petite référence à VALD\nend",
"def say_name\n puts \"Bellossom!\"\n end",
"def bark\n say('ouah ouah')\n nil\n end",
"def greet\n puts '------------------------'\n puts \"Greetings to you #{@name}\"\n end",
"def sayGoodbye\n super << ' and also from MyOtherClass'\n end",
"def quit(reason = \"You told me to\")\n @t.puts \"QUIT :#{reason}\"\n exit\n end",
"def sayMessage\r\n puts \"Hey Programmers!\"\r\n puts \"What's for lunch?\"\r\nend",
"def deaf\n\tputs \"Grandma: HELLO SONNY!\"\n\t\n\tloop do\n\t\ttriggered = false\n\t\tif talking() == false\n\t\t\tputs \"*Grandma doesn't want to say goodbye*\"\n\t\t\tif talking() == false\n\t\t\t\tputs \"*Grandma doesn't want to say goodbye*\"\n\t\t\t\tif talking() == false\n\t\t\t\t\ttriggered = true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tbreak if triggered == true\n\tend\nend",
"def greet\n self.say \"Hello, I am #{@config[:nick]}. I am the resident uber-bot. To learn more, type '.about'.\"\n end",
"def exit_game\n print clear_screen, \"\\n\"\n print \"\\\"What business is it of yours where I'm from, friendo?\\\"\", \"\\n\"\n print '-- Anton Chigurh : No Country for Old Men', \"\\n\\n\"\n throw :exit\n end",
"def say_hi\n\t\tputs \"Hello!\"\n\tend",
"def display_exiting!(text)\n # create goodbye message\n # display welformatted conclusion message\n system \"clear\"\n msg = colorize(\" #{text.upcase} \", $font_colors[:cyan])\n puts \"\\n#{msg.center(77)}\\n\\n\"\n end",
"def say_hello_to(name)\n puts \"Hello, #{name}. It's good to see you.\"\n puts \" \"\n end",
"def say_hi\n\t\tputs 'saying hi'\n\tend",
"def hey(message)\n case message\n when shout then \"Woah, chill out!\"\n when question then \"Sure.\"\n when silence then \"Fine. Be that way!\"\n else \"Whatever.\"\n end\n end",
"def goodbye\r\n\t\traise NoMethodError\r\n\tend",
"def almost_die\n puts 'Eva almost die!'\n end",
"def die(msg=\"unknown problem occurred\")\n abort [\n \"\",\n \"🐒\",\n \" ⌇\",\n \" 💩 DERP!! Um, whut: #{msg}\",\n \"\",\n \"\",\n ].join(\"\\n\")\n end",
"def say_hello\n\tputs \"Bonjour!\"\nend",
"def goodbye\n puts_blanks\n puts \"Have a great day!\".colorize( :blue )\n puts \"See you soon!\".colorize( :blue )\n blank\n # @market.clear_data\n end",
"def hi\n \t\t\tputs \"Ich heiße #{@name} und mir geht es zu #{@health}% gut.\"\n \t\tend",
"def exit_with(msg)\n say msg\n exit\nend",
"def greet\n puts \"# Welcome to Mastermind!\"\n puts \"# Good luck!\"\n end",
"def say_hi\n \tputs \"hello user\" #you must call the method by calling. out its name \"say_hi\"\n end",
"def leave(name)\n\t\tputs \"Thanks for playing #{name}, Come back soon!\"\n\t\tsleep(3)\n\t\tprint CLEAR\n\t\texit\n\tend",
"def end_game\n\t\tputs \"Goodbye!\"\n\t\texit\n\tend",
"def say_greeting\n system 'say \"Good Luck\"'\n end",
"def exit_program\n puts \"Thanks for playing!\"\n abort\nend",
"def greeting\n system 'clear'\n puts WELCOME_MESSAGE\n end",
"def exit_message \n\t\t\t\talert_menu \"Thanks for playing!\", false\n\t\t\tend",
"def saygoodbye(name=\"John\", surname=\"Doe\")\n puts (\"Good Bye \" + name + \" \" + surname)\nend",
"def exit_jukebox\n puts \"Goodbye\"\nend",
"def say_hello\n puts \"Wilkomen Welt!\"\nend",
"def say_hi\n puts \"Hi!\"\n end",
"def end_game\n puts \"Thank to play my game. See you again.\"\n end",
"def exit_jukebox\n puts \"Goodbye\"\nend",
"def exit_jukebox\n puts \"Goodbye\"\nend",
"def exit_jukebox\n puts \"Goodbye\"\nend",
"def exit_jukebox\n puts \"Goodbye\"\nend",
"def leave\n puts ' ____________________________________________________________ '\n puts '| |'\n puts '| Sorry to see you leave... |'\n puts '| Thank you for using Buda-Bot. See you soon! |'\n puts '|____________________________________________________________|'\nend"
] |
[
"0.8133046",
"0.8027566",
"0.7981967",
"0.7876905",
"0.7831334",
"0.7809996",
"0.7757461",
"0.76850945",
"0.7676737",
"0.76580435",
"0.7650922",
"0.76216084",
"0.7606529",
"0.7585609",
"0.7548504",
"0.75484043",
"0.75321233",
"0.75267005",
"0.74788994",
"0.7462179",
"0.74556035",
"0.7422584",
"0.7417692",
"0.741492",
"0.7390806",
"0.7384684",
"0.73072296",
"0.7296888",
"0.7296674",
"0.7292724",
"0.7280838",
"0.7232116",
"0.7209397",
"0.7186534",
"0.7174513",
"0.7168017",
"0.71291226",
"0.7126441",
"0.7041667",
"0.70319235",
"0.691839",
"0.68797565",
"0.68319297",
"0.6829716",
"0.6812672",
"0.679176",
"0.6790056",
"0.67877483",
"0.67738354",
"0.6772745",
"0.67091537",
"0.669285",
"0.6672262",
"0.6665383",
"0.6661453",
"0.66553473",
"0.66366076",
"0.6629306",
"0.6612319",
"0.65940267",
"0.65908915",
"0.6585607",
"0.6550402",
"0.6549631",
"0.6541406",
"0.65131205",
"0.65038556",
"0.64928496",
"0.6482982",
"0.6481883",
"0.6463931",
"0.64527714",
"0.64488024",
"0.64417934",
"0.6437471",
"0.64337575",
"0.64300656",
"0.64243126",
"0.64090514",
"0.64050424",
"0.6358797",
"0.6358759",
"0.63582236",
"0.6347763",
"0.63352185",
"0.63318616",
"0.63167346",
"0.6303248",
"0.629845",
"0.6288897",
"0.6278877",
"0.6277426",
"0.62759954",
"0.6275964",
"0.62697446",
"0.62643915",
"0.62643915",
"0.62643915",
"0.62643915",
"0.62508816"
] |
0.7564058
|
14
|
Get the value of key, if not found, returns nil.
|
def get key
@redis.get key
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get(key)\n position = find(key)\n if position != nil\n @values[position]\n else\n nil\n end\n end",
"def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end",
"def [](key)\n result = default(key)\n result ? result.value : nil\n end",
"def get(key)\n position = search(key)\n return nil if (key <=> @keys[position]) != 0\n @values[position]\n end",
"def get(key, default=nil)\n find = KeyValue.find_by_key(key)\n find ? find.value : default\n end",
"def get_key(key)\n return self.has_key?(key) ? self[key] : nil\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def get(key)\n index = key_index(key)\n if( index )\n self.values.get(index)\n else\n nil\n end\n end",
"def get(key)\r\n\t\treturn nil if !key\r\n\t\t# Get the hash of our key\r\n\t\tindex = key.hash % @size\r\n\t\t# If location in array is empty then return nil otherwise find the \r\n\t\t# key and return associated value from the list\r\n\t\treturn nil if !@arr[index]\r\n\t\treturn @arr[index].find(key)\r\n\tend",
"def get(key)\n self.map_var.each do |pair|\n return pair[1] if pair[0] == key\n end\n nil\n end",
"def getvalue(key)\r\n return @@params[key] if (key != nil)\r\n return nil\r\n end",
"def [](key)\n entry = find_entry(key)\n return(entry.nil? ? nil : entry[1])\n end",
"def get(key)\n node = get_rec(@root, key, 0)\n return nil if node.nil?\n return node.value\n end",
"def get(key)\n node = _get(@root, key)\n return nil unless node\n node.value\n end",
"def get( key )\n key = UniMap.str_to_key( key ) unless key.is_a?( Key )\n key && get_k( key )\n end",
"def getValue(key)\r\n \r\n return @aHash[key]\r\n end",
"def get_value(section, key)\n if section.nil?\n raise TypeError.new('nil not allowed')\n end\n section = 'default' if section.empty?\n get_key_string(section, key)\n end",
"def get(key)\n @hash.get(key)\n end",
"def get(key)\n return do_get(key, false)\n end",
"def get_value(key)\n self[key]\n end",
"def get(key)\n index = key_index(key)\n if( index )\n @i_values.get(index)\n else\n nil\n end\n end",
"def get_key(key, default: nil, error: false)\n if(has_key?(key))\n return self[key]\n end\n \n raise ArgumentError.new(\"Value #{key} not found.\") unless !error\n return default\n end",
"def get(key)\n a_hash[key] || -1 \n end",
"def lookup(key)\n @map.each { |k, v| return v if key == k }\n nil\n end",
"def read(key)\n exists?(key) ? @data[key] : nil\n end",
"def get(key)\n @hash[key]\n end",
"def find(key)\n if @root.nil?\n return nil\n elsif @root.key == key\n return @root.value\n else\n find_helper(@root, key)\n end\n end",
"def get_by_key(key)\n @store_[key] || YakvdConstants.key_not_found\n end",
"def obtain!(key)\n raise \"Missing key #{key}\" unless @hash.key?(key)\n @hash[key]\n end",
"def fetch(key)\n if key.empty?\n return @value\n end\n child = @children[key.shift]\n if child\n child.fetch(key)\n else\n return nil\n end\n end",
"def get(key)\n if @data.has_key?(key)\n return @data[key]\n else\n return false\n end\n end",
"def get(key)\n v = Nvmkv::kv_get(@kv_id, @pool_id, key)\n return (v != nil ? NVMKVValue.new(v) : nil)\n end",
"def get(key)\n _get_from_params(key) || _get_from_values(key)\n end",
"def try_get(namespace, key)\n begin\n return get(namespace, key)\n rescue ItemNotFoundError\n return nil\n end\n end",
"def get(key)\n\n\t\t#we will set the initial value of the variable as nil\n\t\tvalue = nil\n\t\t\n\t\t#iterate through the array\n\t\ti = 0\n\t\twhile i < @size\n\n\t\t\t#if we find the key inside the array\n\t\t\tif @array[i] == key\n\t\t\t\t#we will grab the next element (the value)\n\t\t\t\tvalue = @array[i+1]\n\t\t\t\t#and return it\n\t\t\t\treturn value\n\t\t\tend\n\n\t\t\t#go to all the even indexes\n\t\t\ti += 2\n\t\t\t\n\t\tend\n\n\t\t#if we don't find the key, return value as nil\n\t\treturn value\n\n\tend",
"def get(key)\n return nil if @root.nil?\n \n splay(key)\n (@root.key <=> key) == 0 ? @root.value : nil\n end",
"def value(key)\n @hash[key]\n end",
"def get_value(item, key, default: nil, **)\n return if key.blank?\n if key.is_a?(Array)\n key.find { |k| (v = get_value(item, k)) and break v }\n elsif item.respond_to?(key)\n item.send(key)\n elsif item.respond_to?(:emma_metadata) # Upload, etc.\n item.emma_metadata&.dig(key.to_sym)\n elsif item.is_a?(Hash)\n item[key.to_sym] || item[key.to_s]\n end.presence || default\n end",
"def get_value(data, key)\n if data.has_key?(key) == false || data[key].nil? || data[key] == []\n return ''\n end\n value = data[key]\n if value.is_a?(Array)\n return value[0]\n end\n return value\n end",
"def find(key)\n if !contains?(key)\n return nil\n end\n\n @semaphore.synchronize {\n @internal_clock += 1\n previous_data = @key_data[key]\n update_access_time_locked(key, @internal_clock, previous_data.access_time)\n\n return previous_data.value\n }\n end",
"def get(key)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key \n return ele[1]\n end\n end\n end",
"def get(key)\n self.data[key] && self.data[key][:value]\n end",
"def get(key, ignore: nil)\n if option = find(key)\n option.first\n else\n nil\n end\n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def [](key)\n dummy = Pair.new(key,nil)\n pair = @tree.get(dummy)\n return nil unless pair\n return pair.value\n end",
"def lookup(key)\n @map.each { |pair| return pair[1] if pair[0] == key }\n nil\n end",
"def [](key)\n begin\n rv = self.fetch(key)\n rescue IndexError\n rv = nil\n end\n if (rv == nil)\n begin\n rv = self.dcase_hash[key.downcase]\n rescue IndexError\n rv = nil\n end\n end\n\n return rv\n end",
"def value_by_key(hash, key)\n hash[key.to_s] || hash[key.to_sym]\n end",
"def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end",
"def get(key)\n get_all(key).first\n end",
"def [](key)\n find_value(key)\n end",
"def fetch_value( oid, key )\n\t\toid = normalize_oid( oid )\n\t\tkey = normalize_key( key )\n\t\tdata = @storage[ oid ] or return nil\n\n\t\treturn data[ key ]\n\tend",
"def get(key)\n map_array.each { |pair| return pair[1] if pair[0] == key }\n nil\n end",
"def get_key_value(key)\n if v = storage.get(key.object_id)\n return key.object_id, v\n end\n storage.get_candidates(key.hash).find do |k,v|\n candidate_key = get_object(k) or next\n candidate_key.eql? key\n end\n end",
"def find_value(calling_node, key)\n @router.touch(calling_node)\n value = @values[key.to_bin]\n return value unless value.nil?\n return find_node(key)\n end",
"def get_value (key)\r\n @redis.get key\r\n end",
"def get(key, default = nil)\n include?(key) ? @data[key.to_sym] : default\n end",
"def get(key)\n return @data[key.to_s]\n end",
"def [](key)\n entry = @data.find { |d| d[:key] == key && d[:operation] != :remove }\n return entry[:value] if entry\n\n nil\n end",
"def get!(key)\n get(key) || raise(Cooler::KeyNotFound)\n end",
"def get(key)\n node = @cache[key]\n return -1 if node.nil?\n move_to_head(node)\n node.value\n end",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def lookup(key)\n\t\t\t\treturn(@keys[key])\n\t\t\tend",
"def get(key)\n end",
"def get(key, default=nil)\n\t\t\tval = self.send(key)\n\t\t\tval || default\n\t\tend",
"def get_key_value_\n @redis.hget @url, 'key'\n end",
"def [](key)\n hash = to_h\n if hash.has_key?(key)\n hash[key]\n else\n default(key)\n end\n end",
"def get_result(key)\n r = results\n if r != nil\n return r.fetch(key, nil)\n end\n nil\n end",
"def [](key)\n return nil unless key\n @data[key.to_s] || @data[key.to_sym]\n end",
"def get(key)\n i = key.hash % @table.size\n node = @table[i]\n while node\n return node.value if key == node.key\n node = node.next\n end\n nil\n end",
"def get(key)\n data = request_data(:get, key_uri(key))\n return nil unless data\n if nodes = data[S_NODE][S_NODES]\n nodes.each_with_object({}) do |node, acc|\n acc[node[S_KEY]] = node[S_VALUE]\n end\n else\n data[S_NODE][S_VALUE]\n end\n end",
"def get(key)\n row = key >> 10\n column = @a[row].index{|(i,v)| i == key}\n if column\n return @a[row][column][1] \n else\n return -1\n end\n end",
"def get(key)\n @first.get(key)\n end",
"def get(key)\n node_for(key).get(key)\n end",
"def [](key)\n self.get(key) || default.get(key)\n end",
"def get(key)\n value = @data[key]\n validate!(key, value)\n end",
"def fetch(key)\n return nil unless (val = get(key.to_s))\n\n JSON.parse(val, symbolize_names: true)\n rescue JSON::ParserError\n nil\n end",
"def get(key)\n (@stack.length - 1).downto(0).each do |i|\n return @stack[i][key] if @stack[i].key? key\n end\n nil\n end",
"def get(key)\n return -1 if @h[key].nil?\n cut_list_item_and_put_it_first @h[key]\n @h[key].v\n end",
"def getValue(hash, key)\n key.to_s.split('.').inject(hash) { |h, k| h[k] unless h.nil? }\n end",
"def get(namespace, key)\n if @value_by_namespace_and_key.key?(namespace) && @value_by_namespace_and_key[namespace].key?(key)\n @value_by_namespace_and_key[namespace][key]\n elsif @parent.is_a?(self.class)\n @parent.get(namespace, key)\n else\n nil\n end\n end",
"def get(key)\n @map[key]\n end",
"def value_for_data(key, item, value_key = :value)\n if item and item[:data] and item[:data][key]\n return item[:data][key][value_key]\n end\n return nil\n end",
"def get(key)\n found = @hash[key]\n\n if found\n @list.move_node_to_head(found)\n return found\n end\n\n -1\n end",
"def get_tag_value(key)\n get_tag(key).try(:tag_value).try(:value)\n end",
"def [](key = nil)\n return @collection unless key\n\n result = @collection.find { |f| f.name == key }\n return result.value if result\n\n nil\n end",
"def get(key)\n end",
"def fetch(key, optional = {} )\n\n # self[key]\n if self.has_key?(key)\n self[key]\n else\n if optional.empty?\n raise KeyError\n else\n optional\n end\n end\n end",
"def [](key)\n @monitor.synchronize do\n _, value = get(key)\n value\n end\n end",
"def get(key)\n response = request(:get, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n if data.is_a?(Array)\n data.each_with_object({}) do |e, acc|\n acc[e[S_KEY]] = e[S_VALUE]\n end\n else\n data[S_VALUE]\n end\n else\n nil\n end\n end",
"def [](key)\n if @items[index(key, @items.length)] != nil && @items[index(key, @items.length)].key == key\n puts @items.length\n return @items[index(key, @items.length)].value\n else\n puts \"This value does not exist in the hash\"\n end\n end",
"def get(key)\n bucket = @map[key.hash % @size]\n pair = bucket.find {|k, v| k == key}\n if pair \n pair[1]\n else\n -1\n end\n end",
"def value_of(key)\n @root.value_of(key)\n end",
"def fetch(key, value = nil)\n if read = self[key]\n return read\n end\n block_given? ? yield(key) : value\n end",
"def get(key)\n key = normalize(key) or return\n table[key]\n end",
"def fetch_value(key)\n val = fetch_nested(key)\n return val if self[:no_pruning].include?(key)\n Prunable::VALUES.include?(val) ? Prunable::Value : val\n end",
"def value\n v = connection.get(key)\n rescue Memcached::NotFound\n if block\n value = block.call\n value\n end\n end",
"def find(key)\n if @root.nil?\n return nil\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key == key\n return current_node.value\n elsif current_node.key < key\n current_node = current_node.right\n elsif current_node.key > key\n current_node = current_node.left\n end\n end\n print \"No value found\"\n end"
] |
[
"0.82378495",
"0.80678195",
"0.78649604",
"0.78294224",
"0.7683201",
"0.7641144",
"0.7635554",
"0.76105917",
"0.7595014",
"0.75944793",
"0.7527879",
"0.74942994",
"0.7448325",
"0.7434273",
"0.73828065",
"0.7349438",
"0.7348137",
"0.73427093",
"0.73376626",
"0.73178023",
"0.7305724",
"0.72856814",
"0.7201567",
"0.71805346",
"0.7159696",
"0.7152092",
"0.71387494",
"0.7130977",
"0.7114126",
"0.71138597",
"0.7091298",
"0.7081528",
"0.7071966",
"0.70675766",
"0.7063928",
"0.7051892",
"0.7041438",
"0.7036817",
"0.703567",
"0.7035083",
"0.7018334",
"0.70142883",
"0.70055103",
"0.6997015",
"0.6997015",
"0.6997015",
"0.6997015",
"0.69868386",
"0.6971863",
"0.69695663",
"0.6967931",
"0.69622964",
"0.69602877",
"0.6949747",
"0.6935225",
"0.6930211",
"0.691857",
"0.69129294",
"0.68523395",
"0.68475276",
"0.68439984",
"0.6839037",
"0.68297374",
"0.68264425",
"0.6810881",
"0.6810881",
"0.67955387",
"0.6770077",
"0.6769999",
"0.67652804",
"0.67593825",
"0.675757",
"0.6753039",
"0.6752656",
"0.67498124",
"0.67481226",
"0.6738921",
"0.67282677",
"0.6724358",
"0.671988",
"0.6717675",
"0.6709061",
"0.6698211",
"0.66956663",
"0.669382",
"0.6690624",
"0.6689549",
"0.66858757",
"0.66677797",
"0.6660931",
"0.66609263",
"0.6652878",
"0.66423017",
"0.66401213",
"0.6628888",
"0.6628056",
"0.66194135",
"0.66170037",
"0.6614257",
"0.6607603",
"0.6600886"
] |
0.0
|
-1
|
Set key to hold the value and set key to timeout after the a given expiration time(in seconds).
|
def set key, value, exp
@redis.setex key, exp, value
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set(key, value, expires_in = 0)\n\n end",
"def setex(key, ttl, value); end",
"def setex(key, ttl, value); end",
"def set key, value, expiration\n backend.set key.to_s, serialize(value), expiration rescue nil\n end",
"def expire(key, seconds, **kwargs); end",
"def []=(key, value)\n v = TimedObject.new(value, Time.now + timeout)\n @store[key] = v\n end",
"def set(key, value, expiry_time = nil)\n do_with_logging(:set, key) do\n retryable do\n self.adapter.set(key, adapter.marshal(value), calculate_expiry_time(expiry_time))\n end\n end\n end",
"def set(key, value, expires_in = DEFAULT_TTL)\n k = build_key(key)\n\n v = if value.nil? || (value.is_a?(String) && value.strip.empty?)\n nil\n else\n serialize(value)\n end\n\n expiry_int = Integer(expires_in)\n expire_value = expiry_int.positive? ? expiry_int : Integer(DEFAULT_TTL)\n\n with_client do |client|\n client.multi do\n client.set(k, v)\n\n client.expire(k, expire_value)\n end\n end\n end",
"def put(key, value, timeout = @default_timeout)\n @store.synchronize do\n @store.put(key, value, timeout) unless value.nil?\n end\n end",
"def expire(key, seconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def setex(key, ttl, value)\n node_for(key).setex(key, ttl, value)\n end",
"def expire(key, seconds)\n # no-op\n end",
"def set(key, value, options = {})\n time = options[:time] || timeout\n \n # we can technically do away with checking against Integer explicitly since\n # the to_int call will take care of it for us through Integer#to_int returning\n # self, but it's here for the sake of clarity, mostly.\n #\n # on the other hand, the #to_time call is necessary, since, for some reason,\n # Time#to_time only exists if you require \"time\".\n time = case time\n when Integer\n Time.now + time\n when Time\n time\n else\n if time.respond_to?(:to_int)\n Time.now + time.to_int\n elsif time.respond_to?(:to_time)\n time.to_time\n end\n end\n \n raise(ArgumentError, \"time argument #{time.inspect} could not be converted to a time\") if time.nil?\n \n return nil if time <= Time.now\n \n v = TimedObject.new(value, time)\n @store[key] = v\n \n value\n end",
"def initialize(key, expiration_time = 10.minutes)\n @key = key\n @expiration_time = expiration_time\n end",
"def set(key, value, timeout = nil)\n begin\n @redis.set(key, value)\n @redis.expire(key, timeout) unless timeout.nil?\n rescue Redis::CannotConnectError => e\n $logger.error \"[Redis]Cannot set key #{key}\"\n $logger.error \"[Redis]Cannot connect to Redis: #{e.message}\"\n return false\n end\n end",
"def setex(key, ttl, value)\n send_command([:setex, key, Integer(ttl), value.to_s])\n end",
"def set(key, value, expires_in = 0)\n remove(key)\n expires = nil\n if expires_in > 0\n expires = Time.now.utc + expires_in\n end\n @store.push({ key: build_key(key), value: value, expires: expires})\n end",
"def set(key, value, ttl = 0)\n stats[:set] += 1\n handler.set key, value, ttl\n end",
"def pexpire(key, milliseconds, **kwarg); end",
"def set(key, value, ttl: ShopifyClient.config.cache_ttl)\n raise NotImplementedError\n end",
"def set(key, value, expiry = adapter.configuration.retrieve(:default_expiry, 0))\n do_with_logging(:set, key) do\n expiry = calculate_expiry_time(expiry)\n adapter.set(key.to_s, marshall(value), expiry.to_i)\n logger.info('', '', :expiry, cache_name, key, expiry.to_i)\n value\n end\n end",
"def add_pair_with_expire(key, value, expire_time)\r\n @redis.set(key, value)\r\n @redis.expire(key, expire_time) \r\n end",
"def psetex(key, ttl, value); end",
"def psetex(key, ttl, value); end",
"def store(key, value, options = {})\n expiration = options[:expire_after] || @default_expiration\n value = Marshal.dump(value)\n redis_key = prefix(key)\n if expiration > 0\n @redis.setex(redis_key, expiration, value)\n else\n @redis.set(redis_key, value)\n end\n value\n end",
"def set_data(key, value, expire_at: nil)\n key = key.to_sym\n ts = expire_at ? expire_at.to_i : nil\n\n (@data[key] = [value, ts]).first\n end",
"def set(key, value, timeout=nil)\n rtimeout = (Integer(timeout.to_s, 10) rescue nil)\n rvalue = value_to_json(value)\n fail ArgumentError, \"Timeout must be a number\" if timeout && rtimeout.nil?\n ensure_connected\n\n if timeout\n redis_handler.set(key.to_s, rvalue, ex: rtimeout)\n else\n redis_handler.set(key.to_s, rvalue)\n end\n\n self\n end",
"def write(key, value, expires_in: nil)\n @cache[key] = value\n @expires[key] = Faulty.current_time + expires_in unless expires_in.nil?\n end",
"def set_timer(key, time)\n transaction.timers[key] = time\n end",
"def expiration=(value)\n @expiration = value\n end",
"def pexpire(key, milliseconds, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def set_expire\n tag[id].setex timeout, id\n tag[:pull_list][id].expire timeout\n end",
"def autoexpire\n redis.expire(key, timespan)\n end",
"def value=(v)\n # AKK: 0 is no TTL\n connection.set(key, v, 0, false)\n end",
"def expire=(_); end",
"def simulate_expire; end",
"def expire_time(key)\n @store[key].expires_at\n end",
"def expire(key, seconds, **kwargs)\n node_for(key).expire(key, seconds, **kwargs)\n end",
"def lock(key, expiration)\n timeout = (expiration * 1000).to_i\n if @redis.set(\"SimpleRedisLock:#{key}\", Time.now.strftime('%Y-%m-%d %H:%M:%S.%L %z'), nx: true, px: timeout)\n if block_given?\n begin\n yield\n ensure\n release key\n end\n else\n true\n end\n end\n end",
"def psetex(key, ttl, value)\n node_for(key).psetex(key, ttl, value)\n end",
"def expireat(key, unix_time, **kwargs); end",
"def save_to_redis(key, value, time=1209600)\n $redis.with do |conn|\n conn.set key, value\n conn.expire key, time\n end\nend",
"def set(key, flags, expiration, length, data)\n storage[key] = {\n expiration: expiration,\n flags: flags,\n value: data\n }\n\n 'STORED'\n end",
"def reset_limit key, limit , time\n redis.set key , 1\n redis.expire key, time\n end",
"def put(value, timeout = nil)\n @mutex.synchronize do\n wait_for_empty(timeout)\n\n # If we timed out we won't be empty\n if unlocked_empty?\n @value = value\n @full_condition.signal\n apply_deref_options(value)\n else\n TIMEOUT\n end\n end\n end",
"def update_kase_expires_at\n if self.kase && self.kase.expires_at.nil? && self.expires_at && !self.has_expired?\n self.kase.class.transaction do \n self.kase.lock!\n self.kase.update_attribute(:expires_at, self.expires_at) if self.kase.expires_at.nil?\n end\n end\n end",
"def set(key, value = nil, lifetime = nil)\n\t\t\tlifetime = Picombo::Config.get('cache.'+@@group+'.lifetime').to_i if lifetime == nil\n\t\t\tunless key.is_a? Hash\n\t\t\t\tkey = {key => value}\n\t\t\tend\n\n\t\t\t@@driver.set(key, lifetime)\n\t\tend",
"def []=(key, val)\n @monitor.synchronize do\n expire!\n store(key, val)\n end\n end",
"def expires_in=(duration)\n self.expires_at = duration.from_now\n end",
"def set_expiration\n id = self.id\n self.delay(run_at: self.expiration, queue: id).set_archive(id)\n end",
"def expires_at=(time)\n self.expiry_option = :on\n self[:expires_at] = time\n end",
"def replace(key, value, ttl=nil, options=nil)\n set(key, value, ttl, options) if @store.has_key?(key)\n end",
"def put(key, value, lifetime: 2**32)\n synchronized do\n @hash[key] = {\n value: value,\n start: Time.now,\n lifetime: lifetime\n }\n end\n end",
"def extend_lock!\n Resque.redis.expire(key, timeout)\n end",
"def psetex(key, ttl, value)\n send_command([:psetex, key, Integer(ttl), value.to_s])\n end",
"def expire(key)\n true\n end",
"def touch(key, exptime)\n set(key, :exptime => exptime)\n end",
"def set(key, value, timestamp)\n \n end",
"def expire_cache(key)\n end",
"def expire(key, seconds)\n call(key, [:expire, key, seconds], transform: Redis::Boolify)\n end",
"def ttl(key); end",
"def ttl(key); end",
"def cache_store(key, value, options = {})\n options[:expires] = options.delete(:ttl) || @options[:expires_in]\n @moneta.store(key, value, options)\n end",
"def put(key, value, expiry=0, replace=1, gen_count=0) \n return Nvmkv::kv_put(@kv_id, @pool_id, key, value, expiry, replace, gen_count)\n end",
"def expire(key, expires_in)\n namespace(key) { |key| super(key, expires_in) }\n end",
"def set(key, value, options={})\n body = {:value => value}\n if ttl = options[:ttl]\n body[:ttl] = ttl\n end\n response = request(:post, uri(key), body: body)\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n end",
"def hmset(key, values, timeout = nil)\n begin\n @redis.hmset(key, *values.to_a.flatten)\n @redis.expire(key, timeout) unless timeout.nil?\n rescue Redis::CannotConnectError => e\n $logger.error \"[Redis]Cannot set key #{key}\"\n $logger.error \"[Redis]Cannot connect to Redis: #{e.message}\"\n return false\n end\n end",
"def store(key, value, opts = {})\n opts = {:ttl => opts} if opts.is_a?(Integer)\n @cache[\"#{@cache_name}:#{key}\"] = {\n :expires => opts[:ttl] ? Time.now + opts[:ttl].to_i : nil,\n :value => value\n }\n value\n end",
"def expire(key, seconds, nx: nil, xx: nil, gt: nil, lt: nil)\n args = [:expire, key, Integer(seconds)]\n args << \"NX\" if nx\n args << \"XX\" if xx\n args << \"GT\" if gt\n args << \"LT\" if lt\n\n send_command(args, &Boolify)\n end",
"def set_keycache(key,encoded_key,expires = 3600)\n @keycache = {\n :expires => Time.now.to_i + expires,\n :key => key,\n :encoded_key => encoded_key\n }\n write_settings\n end",
"def pexpire(key, milliseconds)\n call(key, [:pexpire, key, milliseconds], transform: Redis::Boolify)\n end",
"def cache_store(key, value, options = {})\n ttl = options[:ttl] || @options[:expires_in]\n\n @client.setex(key, ttl, ::Marshal.dump(value))\n\n return value\n end",
"def pexpireat(key, ms_unix_time, **kwarg); end",
"def pexpire(key, milliseconds, **kwarg)\n node_for(key).pexpire(key, milliseconds, **kwarg)\n end",
"def stop_timeout\n @expire_time = nil\n end",
"def event_expiry=(value)\n @event_expiry = coerce_time_milli(value)\n cleanup_expired_events\n end",
"def set(k, v, ttl = nil, ignored_options = nil)\n handle_fork\n _set k, v, extract_ttl(ttl)\n end",
"def expires_in\n Gitlab::Redis::SharedState.with do |redis|\n redis.ttl(key)\n end\n end",
"def expires_at=(value)\n self[:expires_at] = value\n end",
"def expires=(value)\n @expires = value\n @expires_in = nil\n end",
"def set_expires_at\n self[:expires_at] = case self.expiry_option \n when :in then Time.now.utc + (self.expiry_days || 3).days\n when :on then self[:expires_at]\n else self[:expires_at]\n end\n end",
"def expiry\n @expiry ||= 60 * 10\n end",
"def expiry\n @expiry ||= 60 * 10\n end",
"def ttl_in_seconds= value\n @ttl_in_seconds = value\n refresh_rates_expiration! if ttl_in_seconds\n end",
"def refresh_expiry\n self.expires_at = Time.now + ttl\n end",
"def []=(key, value=nil) \n\n # If we are assigning something to nil, let's remove it\n if value.nil?\n delete(key)\n sleep @key_sleep.to_f\n nil\n else\n\t persistent = (value[:persistent].nil? ? 0 : (value[:persistent] ? 1 : 0))\n\t \n Klass.addKey(@handle, key.to_s, value[:value].to_s, persistent)\n sleep @key_sleep.to_f\n value[:value].to_s\n end\n end",
"def evict_timeout(timeout)\n @evict_timeout = timeout.to_i\n self\n end",
"def process_expire(command)\n key = command[0]\n seconds = command[1]\n options = {:expiration => seconds }\n @connection.touch(as_key(key), options)? 0 : 1 # return 1 when result is OK = 0\n rescue ::Aerospike::Exceptions::Aerospike => e\n if (e.result_code == ::Aerospike::ResultCode::KEY_NOT_FOUND_ERROR)\n return 0\n else\n raise\n end\n end",
"def expires_in=(value)\n @expires_in = value\n @expires = nil\n end",
"def password_expiration_set(handle:,\n password_expiry_duration:,\n password_history: 0,\n password_notification_period: 15,\n password_grace_period: 0)\n\n mo = AaaUserPasswordExpiration.new(parent_mo_or_dn: \"sys/user-ext\")\n args = {\n :password_expiry_duration => password_expiry_duration.to_s,\n :password_history => password_history.to_s,\n :password_notification_period => password_notification_period.to_s,\n :password_grace_period => password_grace_period.to_s\n }\n mo.set_prop_multiple(**args)\n handle.set_mo(mo: mo)\n return handle.query_dn(dn: mo.dn)\nend",
"def idle_timeout=(timeout); end",
"def expireat(key, unix_time, nx: T.unsafe(nil), xx: T.unsafe(nil), gt: T.unsafe(nil), lt: T.unsafe(nil)); end",
"def key_expiration_time(rnp_key)\n Time.at(key_creation_time(rnp_key) + key_validity_seconds(rnp_key))\n end",
"def set(key, value, opts = {})\n key = add_namespace(key) unless opts[:no_namespace]\n\n opts[:key] = key\n\n result = @redis.set(key, encode(value), ex: opts[:expire_seconds])\n\n boolify(result)\n end",
"def store(key, value, options = {})\n # todo What's the best way to run these two calls at once, given that it's very much one-at-a-time\n exp = options[:expires_in] ? (Time.now + options[:expires_in]) : nil\n @mongo_collection.update({ '_id' => key }, { '_id' => key, 'data' => value, 'expires' => exp }, { :upsert => true }) # upsert is the best technical term ever.\n \n unless options.has_key?(:bypass_memcache)\n args = [key, value, options[:expires_in] || @options[:memcache_default_expire]].compact\n @memcache.set(*args)\n end\n \n value\n end",
"def timeout=(value)\n @transfer[:timeout] = value\n end",
"def auth_expires=(value)\n @children['auth-expires'][:value] = value\n end",
"def ttl=(seconds)\n self.shared_max_age = age + seconds\n end",
"def process_setex(command)\n key = command[0]\n seconds = command[1]\n val = command[2]\n options = {:expiration => seconds }\n @connection.put(as_key(key), {@bin => val}, options)\n return 'OK'\n end",
"def set(key: nil, value: nil, ttl: nil, whitespace: 0, flags: 0)\n ttl ||= @memory[key].ttl if @memory[key]\n @memory[key] = Item.new(value: value, ttl: ttl, casToken: @@casTokenCount += 1, whitespace: whitespace, flags: flags)\n ResponseConstants::STORED\n end"
] |
[
"0.7437024",
"0.7267534",
"0.7267534",
"0.71853137",
"0.71056145",
"0.7064739",
"0.6906304",
"0.6899647",
"0.68369937",
"0.67862463",
"0.67700803",
"0.67484677",
"0.6729623",
"0.6716706",
"0.6664775",
"0.665613",
"0.66462934",
"0.66319704",
"0.6624713",
"0.6591006",
"0.65388745",
"0.6535306",
"0.6513329",
"0.6513329",
"0.64109606",
"0.6386777",
"0.6371209",
"0.6361833",
"0.63511676",
"0.63339967",
"0.6321512",
"0.6304313",
"0.6302777",
"0.6277011",
"0.62602115",
"0.6226733",
"0.6223798",
"0.6214757",
"0.6214549",
"0.61580765",
"0.61520165",
"0.615095",
"0.6132172",
"0.61154264",
"0.6114975",
"0.6098055",
"0.6094402",
"0.60751075",
"0.6036851",
"0.60362625",
"0.6035919",
"0.60316396",
"0.60301614",
"0.60209674",
"0.6018002",
"0.6016245",
"0.6002109",
"0.5989178",
"0.5982732",
"0.5977327",
"0.5967552",
"0.5967552",
"0.59588224",
"0.59253496",
"0.5916253",
"0.58931744",
"0.58782005",
"0.5863233",
"0.58615583",
"0.58608",
"0.5826803",
"0.5804931",
"0.57998824",
"0.5771216",
"0.5759202",
"0.5757768",
"0.575453",
"0.5747416",
"0.57464045",
"0.57286465",
"0.57273495",
"0.5708656",
"0.5708656",
"0.5693061",
"0.5681344",
"0.5670848",
"0.56593907",
"0.56554365",
"0.5654093",
"0.56509215",
"0.564655",
"0.5639331",
"0.56387347",
"0.5637395",
"0.5636761",
"0.5611327",
"0.5607808",
"0.5605785",
"0.56046504",
"0.5602349"
] |
0.5866262
|
67
|
end of play method
|
def exit_jukebox
puts "Goodbye"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def play; end",
"def play\n \n end",
"def play \n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n\tend",
"def play\n end",
"def after_play\n\n end",
"def get_play() \n # \n end",
"def play\n self\n end",
"def play\n #calls to all the methods that produce game!\n end",
"def play_as_master_second\r\n \r\n end",
"def run \n Engine::play(Beginning)\nend",
"def play()\n @ole.Play()\n end",
"def play()\n @ole.Play()\n end",
"def play\r\n\t\t[FOLD]\r\n\tend",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def play\r\n return if self.finished?\r\n self.update\r\n end",
"def play\n greeting\n get_tiles\n move_sequence\n end",
"def play socket\n end",
"def play\n @hungry = true\n #p \"play method called\" #print notification to console\n end",
"def play\n puts 'Playing'\n end",
"def play\n @@plays += 1\n end",
"def play\n\t\tgame_loop\n\tend",
"def main_audio ; end",
"def process_ok\n Sound.play_ok\n super\n end",
"def play\n \"We're rockiinnggg\"\n end",
"def play\n #tho I am sure there is a better way to define a virtual method... just gonna throw something\n raise 'Method play cannot be called directly. It must be overridden in a child class first.'\n end",
"def show_play_complete_player\n\t\t# nothing\n\tend",
"def startPlayback\n end",
"def play\n synchronize do\n @starved = false\n @source.play\n end\n end",
"def show_play_complete_player\n # nothing\n end",
"def play\n\t\t\"playing #{title}\"\n\tend",
"def audio; end",
"def play_sports\n end",
"def play\n puts \"buzz\"\n end",
"def play\n render layout: 'player'\n end",
"def next_player!\n end",
"def sound; end",
"def main_audio\r\n super\r\n # Stop BGM and BGS\r\n $game_system.bgm_play(nil)\r\n $game_system.bgs_play(nil)\r\n # Play game over ME\r\n $game_system.me_play($data_system.gameover_me)\r\n end",
"def playAction _obj, _args\n \"_obj playAction _args;\" \n end",
"def playlist_end playlist\n end",
"def set_player\n\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def main_audio\r\n super\r\n # Play title BGM\r\n $game_system.bgm_play($data_system.title_bgm)\r\n # Stop playing ME and BGS\r\n Audio.me_stop\r\n Audio.bgs_stop\r\n end",
"def play_title_music\r\n\r\n$data_system.title_bgm.play\r\n\r\nRPG::BGS.stop\r\n\r\nRPG::ME.stop\r\n\r\nend",
"def on_play(track)\n end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def song; end",
"def buz; Sound.play_buzzer; end",
"def play!\n @playlist.shift\n end",
"def change_player\n\n end",
"def play\n puts \"#{name} got zoomies playing fetch!\"\n @hungry = true\n end",
"def show\n\n \t\t\trespond_with @play\n\n \t\tend",
"def play\n @play_mode = true\n session[:cards] = @tarot.cards.map(&:id).shuffle\n @tname = @tarot.name\n @tauthor = @tarot.author\n @draw_path = draw_one_tarot_cards_path(@tarot)\n @shuffle_path = play_tarot_cards_path(@tarot)\n # シャッフルでは画面リドローした方がいいので描画しなおす\n # respond_to do |format|\n # format.html\n # format.js\n # end\n end",
"def play\n wake\n puts \"You play fetch with #{@name}.\"\n time_passed\n end",
"def play\n each do |playable|\n if playable.respond_to?(:play)\n playable.play\n end\n end\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def play\r\n puts @recordings.last\r\n end",
"def play_as_master_first\r\n \r\n end",
"def play(&blk)\n start_playing\n blk.call\n ensure\n stop_playing\n end",
"def play\n\temulate do |emulator|\n\t\temulator.play(self)\n\tend\nend",
"def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend",
"def main\n rounds = Game.start\n game = Game.new(rounds)\n roshambo = Roshambo.new(game)\n Roshambo.play(roshambo)\nend",
"def gameflow\n \n end",
"def playMoveNow _obj, _args\n \"_obj playMoveNow _args;\" \n end",
"def playActionNow _obj, _args\n \"_obj playActionNow _args;\" \n end",
"def run() end",
"def playMove _obj, _args\n \"_obj playMove _args;\" \n end",
"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 abort %(None from #{@user}. Fuck off.).magenta if @recordings.empty?\n stdout = preface\n @recordings.each do |r|\n stdout += \"\\n#{r[:time]} : \".cyan + \"@#{r[:user]}\".yellow\n stdout += \"\\n#{r[:message]}\\n\\n\"\n end\n puts stdout\n stdout\n end",
"def play\n Audio::Out.add @cpg\n @is_playing = true\n #Audio::Out.add @actuator\n end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def teardown\n @play = nil\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 play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end",
"def play(cmd)\n play_game(cmd)\n end",
"def pause; end",
"def play_action\n @status.playback_state = :playing\n update_status\n end"
] |
[
"0.8445035",
"0.8348472",
"0.82470936",
"0.8150902",
"0.8150902",
"0.8150902",
"0.8150902",
"0.81472355",
"0.8138188",
"0.7579214",
"0.75363344",
"0.73412687",
"0.7304116",
"0.7091379",
"0.7061106",
"0.7026526",
"0.7026526",
"0.6999948",
"0.6960647",
"0.6960647",
"0.6960647",
"0.6960647",
"0.6960647",
"0.6960647",
"0.6960647",
"0.69347787",
"0.690902",
"0.68903023",
"0.68679947",
"0.6846933",
"0.68454176",
"0.68397856",
"0.67910236",
"0.6712474",
"0.6710792",
"0.67064923",
"0.6702124",
"0.6679995",
"0.6647994",
"0.663297",
"0.66311073",
"0.6617854",
"0.661647",
"0.65842634",
"0.6583236",
"0.657803",
"0.6561382",
"0.6553334",
"0.6526323",
"0.65064526",
"0.64992523",
"0.64756364",
"0.64756364",
"0.64756364",
"0.6418596",
"0.6403351",
"0.6397525",
"0.6387587",
"0.6387587",
"0.6387587",
"0.6387587",
"0.6387587",
"0.6387587",
"0.6387587",
"0.6387587",
"0.6333415",
"0.63245845",
"0.6321667",
"0.6308581",
"0.6295021",
"0.6293642",
"0.6262975",
"0.62547404",
"0.6249771",
"0.6240277",
"0.62249124",
"0.6215934",
"0.6203041",
"0.61683136",
"0.6160805",
"0.616072",
"0.61532706",
"0.61494213",
"0.61490464",
"0.6148916",
"0.61467195",
"0.61432624",
"0.61385584",
"0.61326563",
"0.61326563",
"0.61323863",
"0.61323863",
"0.61323863",
"0.61323863",
"0.61323863",
"0.6128933",
"0.6125767",
"0.6117376",
"0.6116926",
"0.6113706",
"0.6112572"
] |
0.0
|
-1
|
takes first optional argument as array of column names second optional argument as array of data arrays
|
def initialize cols=nil, *args, &block
@chash = [] # hash of column info, not used
@_skip_columns = {} # internal, which columns not to calc width of since user has specified
@separ = @columns = @numbering = nil
@y = '|'
@x = '+'
@use_separator = false
@_hidden_columns_flag = false
self.columns = cols if cols
if !args.empty?
self.data = args
end
yield_or_eval(&block) if block_given?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_column_data_array\n\ttable_id = create_table_id('../data/census_column_metadata.csv')\n\tcolumn_id = create_column_id('../data/census_column_metadata.csv')\n\t\n\t[title_processor,table_id,column_id].transpose\n\nend",
"def bound_variable_arg(arg, conn)\n case arg\n when ArrayRow\n \"(#{arg.map{|v| bound_variable_array(v) if v}.join(',')})\"\n when HashRow\n arg.check_columns!\n \"(#{arg.values_at(*arg.columns).map{|v| bound_variable_array(v) if v}.join(',')})\"\n else\n super\n end\n end",
"def columns(*args)\n @columns = @columns | args.map(&:to_sym)\n end",
"def select_columns_by_kv_as_arrays *args\n map_to_keys(\n map_to_keys(\n map_to_keys(\n (select_columns_by_kv(*args)),\n :to_a\n ),\n :transpose\n ),\n :last\n )\n end",
"def columns(*array)\n unless array.empty?\n if (array.class == Array)\n options[:columns] = array\n else\n raise \"Report columns must be specified.\"\n end\n else\n options[:columns]\n end\n end",
"def datarows=(array)\n self[:datarows] = array.join(\",\")\n end",
"def convert_columns(arr)\n if ccs = @column_converters\n arr.zip(ccs).map{|v, pr| (v && pr) ? pr.call(v) : v}\n else\n arr \n end\n end",
"def concatenate_data_arrays(array_name, array_type)\n query = {\n name: array_name, array_type: array_type, linear_data_type: 'CellMetadatum', linear_data_id: self.id,\n study_id: self.study_id, study_file_id: self.study_file_id\n }\n DataArray.concatenate_arrays(query)\n end",
"def is_multiple?(name)\n columns[name.to_s]\n end",
"def values_sql_for_column_names_and_attributes( columns, array_of_attributes ) # :nodoc:\n values = []\n array_of_attributes.each do |arr|\n my_values = []\n arr.each_with_index do |val,j|\n my_values << quote( val, columns[j] )\n end\n values << my_values\n end \n values_arr = values.map{ |arr| '(' + arr.join( ',' ) + ')' }\n end",
"def columns_param(column_names)\n column_names.map! { |name| escape(name) }\n \"columns:!(#{column_names.join(',')})\"\n end",
"def concatenate_data_arrays(array_name, array_type)\n data_arrays = DataArray.where(name: array_name, array_type: array_type, linear_data_type: 'CellMetadatum',\n linear_data_id: self.id).order(:array_index => 'asc')\n all_values = []\n data_arrays.each do |array|\n all_values += array.values\n end\n all_values\n end",
"def to_data_array(data_set)\n case\n when data_set.is_a?(Daru::DataFrame)\n return ArgumentError unless data_set.index.is_a?(Daru::Index)\n data_set.access_row_tuples_by_indexs(*data_set.index.to_a)\n when data_set.is_a?(Daru::Vector)\n rows = []\n data_set.to_a.each { |a| rows << [a] }\n rows\n when data_set.is_a?(Array)\n data_set\n else\n raise ArgumentError # TODO: error msg\n end\n end",
"def method_missing(name, *args)\n @columns[args[0]] = [name, args[1]]\n end",
"def pick_a_column(board, *coords)\n\t\tcolumn_array = []\n \tcolumn_array << coords.map { |coord| board[coord.first][coord.last]}\n\tend",
"def concatenate_data_arrays(array_name, array_type)\n data_arrays = DataArray.where(name: array_name, array_type: array_type, linear_data_type: 'Gene',\n linear_data_id: self.id).order(:array_index => 'asc')\n all_values = []\n data_arrays.each do |array|\n all_values += array.values\n end\n all_values\n end",
"def insert_array(column, value)\n @columns << column\n @values << Translate.escape_array(value)\n end",
"def _select_map_multiple(ret_cols)\n rows = []\n clone(:_sequel_pg_type=>:array).fetch_rows(sql){|s| rows << s}\n rows\n end",
"def columns(cols, options = {})\n if cols.is_a? Array\n cols.each.map{|c| columns(c.first, c.count >= 2 ? c.second : {}) if c.is_a? Array }\n return\n end\n cols.split(/,\\s/).each do |col|\n n = col.split(':')\n id = n.first\n name = n.count > 1 ? n.second : nil\n search = col_by_id id\n tmp = search.nil? ? Flexigrid::Column.new(self, id, name) : search\n options.map{|key,value| tmp.send(key.to_s + \"=\",value)}\n tmp.update!\n @columns << tmp\n @columns_hash[tmp.id] = tmp\n end\n end",
"def table_data(objects, *arguments)\n rows = [[*arguments]]\n\n rows += flatten_uniq(objects).map do |obj|\n arguments.map do |argument|\n begin\n obj = obj.query if obj.respond_to?(:query)\n if argument.respond_to?(:call)\n obj.instance_eval(&argument)\n else\n obj.instance_eval(argument.to_s)\n end\n rescue => e\n 'error'\n end\n end\n end\n\n rows\n end",
"def from_array_of_arrays(rows, hlines: false, **types)\n headers = []\n if !hlines\n # Take the first row as headers\n # Second row et seq as data\n headers = rows[0].map(&:to_s).map(&:as_sym)\n first_data_row = 1\n elsif rows[1].nil?\n # Use first row 0 as headers\n # Row 1 is an hline\n # Row 2 et seq are data\n headers = rows[0].map(&:to_s).map(&:as_sym)\n first_data_row = 2\n else\n # Synthesize headers\n # Row 0 et seq are data\n headers = (1..rows[0].size).to_a.map { |k| \"col_#{k}\".as_sym }\n first_data_row = 0\n end\n result = new(*headers, **types)\n rows[first_data_row..-1].each do |row|\n if row.nil?\n unless hlines\n msg = 'found an hline in input: try setting hlines true'\n raise UserError, msg\n end\n result.mark_boundary\n next\n end\n row = row.map { |s| s.to_s.strip }\n hash_row = Hash[headers.zip(row)]\n result << hash_row\n end\n result.normalize_boundaries\n result\n end",
"def getColumn arr, col\n arr2 = [] \n for row in arr do\n arr2.push row[col]\n end \n return arr2\nend",
"def parseColumns(arg)\n if arg =~ /^(\\d+)-(\\d+)$/ # Range of column indices (e.g., 3-5)\n return (Integer($1)..Integer($2)).to_a\n elsif arg =~ /^([\\d,]+)$/ # Just a set of columns\n return arg.split(/,/).map{|x| Integer(x)}\n elsif arg =~ /^:(.*)$/ # Search to find the column\n query, rest = $1, $2\n result = nil\n @data.each { |row|\n (0...row.size).each { |col|\n if row[col].to_s =~ /#{query}/\n result = col\n break\n end\n }\n }\n return [result] if result\n raise \"Can't identify column from #{arg}\"\n else\n # Comma-separated list of names\n matches = []\n arg.split(/,/).each { |a|\n @header.each_with_index { |name,i|\n matches << i if name =~ /^#{a}$/\n }\n }\n raise \"Not valid header: #{arg}, possible headers: #{@header.inspect}\" if matches.size == 0\n return matches\n end\n end",
"def create_data_frame_for_returns(column_names_array)\n command = \"return_data=data.frame(\"\n\n column_names_array.each {|name| command << \"#{name.downcase}=#{name},\"}\n\n command.chomp!(\",\")\n command << \")\"\n\n @con.eval(\"#{command};Data = as.timeSeries(return_data)\")\n end",
"def add_column(col)\n if col.is_a?(Array)\n self.columns += col\n else\n self.columns << col\n end\n end",
"def argument_rows\n rows[1..rows.count] || []\n end",
"def update_columns=(column_names)\n @update_columns = Array(column_names)\n end",
"def get_columns!( *headers )\n data.get_columns!( *headers ); self\n end",
"def column(name, *args)\n define_method name do\n instance_variable_get(\"@_#{name}\")\n end\n define_method \"#{name}=\" do |val|\n instance_variable_set(\"@_#{name}\", val)\n end\n self.columns = columns.concat([[name].concat(args)])\n end",
"def columns(table_name, name = nil) end",
"def load_data(row, columns, headers)\n #// HEADER EXCLUSION LIST:\n #// ----------------------\n exclusion_list = [\n 'Option_Types'\n ]\n attr_hash = {}\n exception_hash = {}\n sanitized_headers_array = []\n header_return_array = []\n \n for i in columns[0]..columns[1]\n exclusion_list.each do |exclusion|\n if headers[i] =~ /#{exclusion}/i\n exception_hash[exclusion] = row[i]\n elsif headers[i] == exclusion\n exception_hash[exclusion] = row[i]\n else\n attr_hash[headers[i]] = row[i] unless row[i].nil?\n sanitized_headers_array << headers[i]\n end\n end\n \n end\n header_return_array[0] = attr_hash\n header_return_array[1] = exception_hash\n header_return_array[2] = sanitized_headers_array\n return header_return_array\n end",
"def sql_array(array)\n Arel.sql(ActiveRecord::Base.sanitize_sql([\"ARRAY[?]\", array]))\n end",
"def columns\n @columns ||= @csv_data[0].zip(*@csv_data[1..])\n end",
"def data_with_head(columnheader)\r\n Array(raw_data_sheet.column(columnheaders_raw.index(columnheader)))\r\n end",
"def isin(*cols)\n if cols.size == 1 && cols.first.is_a?(Array)\n cols = cols.first\n end\n\n cols = cols.map do |col|\n Column.from_literal(col)\n end\n\n new_jcolumn = jcolumn.isin(Spark.jb.to_seq(cols))\n Column.new(new_jcolumn)\n end",
"def concatenate_data_arrays(array_name, array_type, subsample_threshold = nil, subsample_annotation = nil)\n if subsample_threshold.blank?\n subsample_threshold = nil\n subsample_annotation = nil\n end\n query = {\n name: array_name, array_type: array_type, subsample_threshold: subsample_threshold,\n subsample_annotation: subsample_annotation, user_annotation_id: self.id\n }\n UserDataArray.concatenate_arrays(query)\n end",
"def convertArray(df, column_number)\n df.map(:row) { |row| row[column_number] }\n end",
"def convert_dataset(ds)\n if dimensions == 2\n # valid inputs include:\n # an array of >=2 arrays, or an array of >=2 hashes\n ds = ds.map do |d|\n d.is_a?(Hash) ? d : {:data => d}\n end\n elsif dimensions == 1\n # valid inputs include:\n # a hash, an array of data, an array of >=1 array, or an array of >=1 hash\n if ds.is_a?(Hash)\n ds = [ds]\n elsif not ds.first.is_a?(Hash)\n ds = [{:data => ds}]\n end\n end\n ds\n end",
"def select(*args); dataset.select(*args); end",
"def create_column_data\n\tcolumn_hash = {}\n\t\n\tcreate_column_data_array.map do |array|\n\tcolumn_hash = {title: array[0], table_id: array[1], \n\t\tcol_id: array[2]}\n\tend\nend",
"def raw cols\n ret = get_values [*cols]\n\n case cols\n when Array\n ret\n else\n ret.first\n end\n end",
"def columns=(arr)\n @columns = arr\n update_height\n end",
"def initialize(columns, size_or_array=nil)\n size_or_array ||= columns.size \n\n case size_or_array\n when Integer\n @arr = Array.new(size_or_array)\n when Array\n @arr = size_or_array\n else\n raise TypeError, \"parameter must be either Integer or Array\"\n end\n\n # The '@column_map' is used to map column names to integer values so\n # that users can reference row values by name or number.\n\n @column_map = {}\n @column_names = columns\n columns.each_with_index { |c,i| @column_map[c] = i }\n super(@arr)\n end",
"def column(name, type = nil, options = {})\n super\n column = self[name]\n # NOTE: <= 3.1 no #new_column_definition hard-coded ColumnDef.new :\n # column = self[name] || ColumnDefinition.new(@base, name, type)\n # thus we simply do not support array column definitions on <= 3.1\n column.array = options[:array] if column.is_a?(ColumnDefinition)\n self\n end",
"def build_array_of_cols_and_vals( num )\n cols = [:my_name, :description]\n value_sets = []\n num.times { |i| value_sets << [\"My Name #{i}\", \"My Description #{i}\"] }\n [cols, value_sets]\n end",
"def append!(column_name, value=nil)\n raise ArgumentError, \"Can't have duplicate column names\" if self.labels.include?(column_name)\n self.labels << column_name.to_underscore_sym\n if value.is_a?(Array)\n self.items.each_with_index do |item, i|\n item << value[i]\n end\n else\n self.items.each do |item|\n item << value\n end\n end\n self.columns(true)\n # Because we are tainting the sub arrays, the TaintableArray doesn't know it's been changed.\n self.items.taint\n end",
"def set_data_type_and_array\n column_schema = SearchFacet.get_table_schema(column_name: big_query_id_column)\n detected_type = column_schema[:data_type]\n self.is_array_based = detected_type.include?('ARRAY')\n item_type = BQ_DATA_TYPES.detect { |d| detected_type.match(d).present? }\n self.data_type = BQ_TO_FACET_TYPES[item_type]\n end",
"def timeSeriesMultipleDataSource(time1,time2,dataSources)\n @result = nil\n if(dataSources != nil)\n sourceList = \"\"\n dataSources.each do |x|\n if sourceList != \"\"\n sourceList = sourceList << \",\"\n end\n sourceList = sourceList << x \n end\n if(time1 && time2 && sourceList != \"\")\n @result = @table.scan(start_row: time1, stop_row: time2, columns:dataSources) \n end \n end\n return @result\n end",
"def load(arg)\n index = 0\n @mat.each do | _ ,row|\n (0..row.length-1).each do |i|\n row[i] = arg[index]\n index += 1\n end\n end\n end",
"def parse_columns(columns)\n pairs = []\n raise TypeError, Ajaila::Messager.warning(\"Your table should include columns. Add something like this: name:String age:Integer and etc.\") if columns == []\n columns.each do |key_string|\n params = key_string.split(':')\n raise TypeError, Ajaila::Messager.warning(\"Wrong format of table parameters (name:String/Integer/Date/etc)\") if KNOWN_CLASSES.include?(params[1].capitalize) == false\n pairs << [params[0].downcase, params[1].capitalize]\n end\n return pairs\n end",
"def set_data_type_and_array\n column_schema = SearchFacet.get_table_schema(column_name: self.big_query_id_column)\n detected_type = column_schema[:data_type]\n self.is_array_based = detected_type.include?('ARRAY')\n item_type = BQ_DATA_TYPES.detect {|d| detected_type.match(d).present?}\n self.data_type = BQ_TO_FACET_TYPES[item_type]\n end",
"def performArgs(args)\n proj = [] # new column index -> list of original column indices\n projNames = [] # new column index -> name to show\n # In the following, columns refer to the new column index\n sort = nil # Which column to sort by (only support one)\n aggregate = [] # Which columns to aggregate (rest of columns are used as the key)\n sortReverse = false\n selectTransforms = [] # Select / transform subset of the columns\n hist = [] # Array of columns to compute the histogram key over\n histMaxExemplars = 1 # For each key, how many to print\n\n # No arguments means we want to select everything\n addAllCols = lambda {\n proj += (0...numCols).map { |col| [col] }\n projNames += (0...numCols).map { |col| @header[col] }\n }\n\n # Default: if no arguments, then add all columns\n addAllCols.call if args.size == 0\n\n ensureProjExists = lambda { throw \"No column specified before #{arg}\" if proj.size == 0 }\n\n args.each { |arg|\n if arg == '.sort'\n sort = proj.size-1\n elsif arg == '.sort-'\n sort = proj.size-1\n sortReverse = true\n elsif arg == '.all'\n addAllCols.call\n elsif arg =~ /^\\.hist(\\d*)$/\n histMaxExemplars = Integer($1) if $1 != ''\n ensureProjExists.call\n hist << proj.size-1\n elsif arg == '.agg'\n ensureProjExists.call\n aggregate << proj.size-1\n elsif arg =~ /^\\?(.+)$/ # Select: general (e.g., '?_>5')\n ensureProjExists.call\n query = $1\n selectTransforms << ['select', proj.size-1, eval(\"lambda { |_,_i| #{query} }\")]\n elsif arg =~ /^[\\/=](.*)$/ # Select: search (e.g., /5)\n ensureProjExists.call\n query = $1\n if query == ''\n selectTransforms << ['select', proj.size-1, lambda { |x,i| x == nil }]\n else\n if arg =~ /^=/\n selectTransforms << ['select', proj.size-1, lambda { |x,i| x.to_s == query }]\n else\n selectTransforms << ['select', proj.size-1, lambda { |x,i| x.to_s =~ /#{query}/ }]\n end\n end\n elsif arg =~ /^%(.+)$/ # Transform: general (e.g., %_*2)\n ensureProjExists.call\n body = $1\n selectTransforms << ['transform', proj.size-1, eval(\"lambda { |_,_i| #{body} }\")]\n elsif arg =~ /^s\\/(.+)\\/(.*)\\/g?$/ # Transform: search and replace (e.g., s/a/b/)\n ensureProjExists.call\n search, replace, global = $1, $2, $3\n if global\n func = lambda{|x,i| x.sub(/#{search}/, replace)}\n else\n func = lambda{|x,i| x.gsub(/#{search}/, replace)}\n end\n selectTransforms << ['transform', proj.size-1, func]\n elsif arg =~ /^.split=(.+)$/ # Transform: split using a particular delimiter (generates two columns, one before delimiter and one after)\n ensureProjExists.call\n delim = $1\n selectTransforms << ['transform', proj.size-1, lambda { |x,i| x.split(/#{delim}/, 2)[0] }] # Pick out stuff before a delimiter\n proj << proj.last\n selectTransforms << ['transform', proj.size-1, lambda { |x,i| x.split(/#{delim}/, 2)[1] }] # Pick out after after a delimiter\n else\n # Specify a new column\n proj << parseColumns(arg)\n projNames << arg\n end\n }\n\n # Canonicalize only when we need to use the row\n canonicalized = {}\n canonicalizeColumn = lambda { |cols|\n cols.each { |col|\n next if canonicalized[col] # Already canonicalized\n $stderr.puts \"Canonicalize #{col}\" if $verbose\n @data.each { |row|\n row[col] = canonicalizeValue(row[col])\n }\n }\n }\n\n # proj is a sequence of cols (e.g., [[0,1], [2]]\n # Project onto the specified columns.\n # Perform aggregation within each group of columns.\n @header = proj.map_with_index { |cols,j|\n cols.size == 1 ? @header[cols[0]] : projNames[j]\n }\n @data = @data.map { |row|\n proj.map_with_index { |cols,j|\n if cols.size == 1\n value = row[cols[0]] # No need to aggregate\n else\n if cols.all?{|col| row[col] == nil} # Aggregate nils into nil\n value = nil\n else # Concatenate non-numerical values\n value = cols.map{|col| row[col]}.join(' ')\n end\n end\n value\n }\n }\n\n # Select and transform\n selectTransforms.each { |mode,col,func|\n canonicalizeColumn.call([col])\n canonicalized[col] = true\n if mode == 'select'\n i = -1\n @data = @data.select { |row| i += 1; func.call(row[col], i) }\n elsif mode == 'transform'\n @data.each_with_index { |row,i| row[col] = func.call(row[col], i) }\n else\n raise \"Internal error: bad mode #{mode}\"\n end\n }\n\n # Sort rows by some column\n if sort\n canonicalizeColumn.call([sort])\n canonicalized[sort] = true\n # Ensure stable sort\n indices = (0...@data.size).sort { |i,j|\n a = @data[i][sort] || 0\n b = @data[j][sort] || 0\n a != b ? a <=> b : i <=> j\n }\n @data = indices.map {|i| @data[i]}\n @data.reverse! if sortReverse\n end\n\n # Create histogram (hist specifies columns that determine the key)\n if hist.size > 0\n counts = {}\n exemplars = {} # key => list of rows\n keys = []\n @data.each { |row|\n key = hist.map { |col| row[col] }\n if not counts[key]\n keys << key\n counts[key] = 1\n exemplars[key] = [row]\n else\n counts[key] += 1\n list = exemplars[key]\n list << row if list.size < histMaxExemplars\n end\n }\n @data = []\n # Preserve order if we want to actually get multiple views\n keys = keys.sort{|a,b| counts[a] <=> counts[b]} if histMaxExemplars == 1\n keys.each { |key|\n exemplars[key].each { |row|\n @data << row + [counts[key]]\n }\n }\n @header << 'count'\n end\n\n if aggregate.size > 0\n # |aggregate| specifies the columns that we will do aggregation over.\n # The rest of the columns serve to form the key.\n # For each key, stats[key][j] will be a list of numbers for the j-th\n # column that we're aggregating over.\n aggregate.each { |col|\n canonicalizeColumn.call([col])\n canonicalized[col] = true\n }\n keyCols = (0...numCols).select { |col| not aggregate.index(col) }\n stats = {}\n keys = []\n @data.each { |row|\n key = keyCols.map { |col| row[col] }\n keyStats = stats[key]\n if not keyStats\n keyStats = stats[key] = aggregate.map { [] }\n keys << key\n end\n aggregate.each_with_index { |col,j|\n keyStats[j] << row[col]\n }\n }\n\n # Change header: remove aggregated fields with statistics\n newHeader = @header.map_with_index {|name,col|\n aggregate.index(col) ? nil : name\n }.compact\n aggregate.each_with_index { |col,j|\n newHeader << @header[col] + \".min\"\n newHeader << @header[col] + \".mean\"\n newHeader << @header[col] + \".stddev\"\n newHeader << @header[col] + \".max\"\n newHeader << @header[col] + \".sum\"\n }\n @header = newHeader\n\n @data = keys.map { |key|\n row = key\n keyStats = stats[key]\n aggregate.each_with_index { |col,j|\n numbers = keyStats[j].compact\n row << numbers.min\n row << numbers.mean\n row << numbers.stddev\n row << numbers.max\n row << numbers.sum\n }\n row\n }\n end\n\n # Use custom header\n if $Fields\n @header = $Fields\n end\n end",
"def column_list(columns)\n if columns.empty?\n WILDCARD\n else\n m = columns.map do |i|\n i.is_a?(Hash) ? i.map{|kv| \"#{literal(kv[0])} AS #{quote_identifier(kv[1])}\"} : literal(i)\n end\n m.join(COMMA_SEPARATOR)\n end\n end",
"def expected_columns; end",
"def timeSeriesMultipleSourceMultipleAttributes(time1,time2,dataSources,inverters)\n @result = nil\n if inverters != nil\n invList = \"MultipleColumnPrefixFilter(\"\n inverters.each do |x|\n if invList != \"MultipleColumnPrefixFilter(\"\n invList = invList << \",\"\n end\n invList = invList << \"'\" << x << \"'\"\n end\n invList = invList << ')\"'\n puts invList\n if(time1 && time2 && dataSources)\n @result = @table.scan(start_row: time1, stop_row: time2, columns:dataSources,filter_String:invList) \n end\n end \n return @result \n end",
"def insert_by_data data, table\n sql = \"insert into #{table} \"\n case data\n when Array\n data.each do |d|\n insert_by_data(d, table)\n end\n when Hash\n columns = data.keys.to_s.gsub('[','(').gsub(']',')').gsub('\"','')\n values = data.values.to_s.gsub('[','(').gsub(']',')').gsub('nil','NULL')\n sql = sql + columns + \" values \" + values\n query(sql)\n end\n end",
"def raws cols\n ret = get_values [*cols], true\n\n case cols\n when Array\n ret\n else\n ret.first\n end\n end",
"def lookup(*args)\n return nil unless dataset # Dataset is not established, unable to lookup\n # options = args.extract_options!\n case args.first\n when :first then dataset.send(table_name.to_sym).find{|m| m}\n when :last then dataset.send(table_name.to_sym).compact[-1]\n when :all then dataset.send(table_name.to_sym).compact\n else dataset.send(table_name.to_sym)[*args]\n end\n end",
"def generate_array_query(accessions: [])\n \"SELECT DISTINCT id, name FROM(SELECT id_col AS id, name_col as name FROM #{CellMetadatum::BIGQUERY_TABLE}, \" \\\n \"UNNEST(#{big_query_id_column}) AS id_col WITH OFFSET id_pos, UNNEST(#{big_query_name_column}) AS name_col \" \\\n \"WITH OFFSET name_pos WHERE id_pos = name_pos #{accessions.any? ? \"AND #{format_accession_list(accessions)}\" : nil}) \" \\\n 'WHERE id IS NOT NULL ORDER BY LOWER(name)'\n end",
"def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n end",
"def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n end",
"def print_arrays(data, cols)\n formatted_list = cli.list(data, :uneven_columns_across, cols)\n cli.say(formatted_list)\n end",
"def columns(names, options=nil)\n names.each do |name|\n column name, options\n end\n end",
"def columns *args\n if args.size > 0 && configurable?\n raise 'please call %s only inside #model block' % __method__ if model_defined?\n return @columns_opted = false if args.first == false\n @columns_opted = args\n end\n end",
"def multiple(sql, values = [])\n r = $db.exec_params(sql, values)\n return [] if r.ntuples == 0\n r.map { |row| convert_to_ruby_types(row) }\nend",
"def data\n datacolumns.reduce({}) do |t, col|\n t[col.name] = col.data; t\n end\n end",
"def import_array(rows)\n raise ArgumentError, \"Can only work with arrays\" unless rows.is_a?(Array)\n if self.labels.size > 1 and rows.dimensions == 1\n self.add_item(rows)\n else\n # self.items = self.items + rows\n rows.each do |row|\n self.add_item(row)\n end\n end\n end",
"def many!(assoc_rows, target_attr, assoc_attr)\n begin\n assoc_rows_by_attr = assoc_rows.group_by(&assoc_attr.to_sym)\n rescue NoMethodError => e\n raise MissingColumnError.new(assoc_rows[0], e.name)\n end\n\n target_rows.each do |row|\n begin\n pkey = row.send target_attr\n rescue NoMethodError => e\n raise MissingColumnError.new(row, e.name)\n end\n row.send @assign, assoc_rows_by_attr[pkey] || []\n end\n end",
"def array_query(sql, name, binds)\n query(sql, name, binds)[0]\n end",
"def columns=(array)\n #$log.debug \"tabular got columns #{array.count} #{array.inspect} \" if $log\n @columns = array\n @columns.each_with_index { |e,i| \n #@chash[i] = ColumnInfo.new(c, c.to_s.length) \n c = get_column(i)\n c.name = e\n c.width = e.to_s.length\n #@chash[i] = c\n #@cw[i] ||= c.to_s.length\n #@calign[i] ||= :left # 2011-09-27 prevent setting later on\n }\n end",
"def update!(**args)\n @column_items = args[:column_items] if args.key?(:column_items)\n end",
"def quote_with_array(value, column = nil)\n if value && column && column.sql_type =~ /\\[\\]$/\n raise ArrayTypeMismatch, \"#{column.name} must be an Array or have a valid array value (#{value})\" unless value.kind_of?(Array) || value.valid_postgres_array?\n return value.to_postgres_array\n end\n quote_without_array(value,column)\n end",
"def cols_array\n arr = Array.new\n @columns_hash.each{|k,v| arr << k}\n return arr\n end",
"def prepared_columns(cols)\n RUBY_VERSION >= '1.9' ? cols.sort : cols.sort_by(&:to_s)\n end",
"def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n @invalid_values_allowed = args[:invalid_values_allowed] if args.key?(:invalid_values_allowed)\n end",
"def get_data_colnames(d)\n if d == nil or d.empty?\n return []\n end\n return d.first().keys()\n end",
"def by_col column, row = nil\n column = column_name_to_id column\n raise ArgumentError, \"column must not be nil.\" if column.nil?\n row.nil? ? @rows.map {|v| v[column] } : (@rows[row.to_i].nil? ? nil : @rows[row.to_i][column])\n end",
"def column_deltas=(_arg0); end",
"def add(column, value)\n \n # If we see a column we don't recognize, stop everything\n if (@params[column] == \"\")\n puts(\"Unrecognized column\")\n else\n # We have a hash of arrays for when we have multiple criteria for one column\n @params[column].push(value)\n end\n\n end",
"def generate_column_data(params=Hash.new)\n self.class.column_details.keys.each do |k|\n if column_default(k)\n if column_default(k).is_a?(Proc)\n @column_values[k] = column_default(k).call\n else\n @column_values[k] = column_default(k)\n end\n else\n @column_values[k] = generate_value(column_detail(k))\n end\n end\n normalised_params = internalize_column_params(params)\n validate_columns(normalised_params)\n @column_values.merge! normalised_params\n end",
"def set_column(*args)\n data = args\n cell = data[0]\n\n # Check for a cell reference in A1 notation and substitute row and column\n if cell =~ /^\\D/\n data = substitute_cellref(*args)\n\n # Returned values $row1 and $row2 aren't required here. Remove them.\n data.shift # $row1\n data.delete_at(1) # $row2\n end\n\n return if data.size < 3 # Ensure at least $firstcol, $lastcol and $width\n return if data[0].nil? # Columns must be defined.\n return if data[1].nil?\n\n # Assume second column is the same as first if 0. Avoids KB918419 bug.\n data[1] = data[0] if data[1] == 0\n\n # Ensure 2nd col is larger than first. Also for KB918419 bug.\n data[0], data[1] = data[1], data[0] if data[0] > data[1]\n\n # Limit columns to Excel max of 255.\n data[0] = ColMax - 1 if data[0] > ColMax - 1\n data[1] = ColMax - 1 if data[1] > ColMax - 1\n\n @colinfo.push(data)\n\n # Store the col sizes for use when calculating image vertices taking\n # hidden columns into account. Also store the column formats.\n #\n firstcol, lastcol, width, format, hidden = data\n\n width ||= 0 # Ensure width isn't undef.\n hidden ||= 0\n width = 0 if hidden > 1 # Set width to zero if col is hidden\n\n (firstcol .. lastcol).each do |col|\n @col_sizes[col] = width\n @col_formats[col] = format unless format.nil?\n end\n end",
"def values_at(arg0, arg1, *rest)\n end",
"def update!(**args)\n @columns = args[:columns] if args.key?(:columns)\n @columns_int16 = args[:columns_int16] if args.key?(:columns_int16)\n @columns_int32 = args[:columns_int32] if args.key?(:columns_int32)\n @columns_int64 = args[:columns_int64] if args.key?(:columns_int64)\n @columns_int8 = args[:columns_int8] if args.key?(:columns_int8)\n @values = args[:values] if args.key?(:values)\n end",
"def query_return_array(sql, *binds)\n mysql.fetch(sql, *binds).all\n end",
"def permitted_params\n columns.map { |name,multiple| multiple ? { name => [] } : name }\n end",
"def sql_function_args(args)\n \"(#{Array(args).map{|a| Array(a).reverse.join(' ')}.join(', ')})\"\n end",
"def create_query_hash(array)\n names = array.shift\n rval = []\n array.each do |r|\n row = {}\n names.each_with_index { |column, idx| row[column] = r[idx] }\n rval << row\n end\n rval\nend",
"def insert_multi(tablename, arr_hashes, args = {})\n sql = \"INSERT INTO `#{tablename}` (\"\n\n first = true\n if args && args[:keys]\n keys = args[:keys]\n elsif arr_hashes.first.is_a?(Hash)\n keys = arr_hashes.first.keys\n else\n raise \"Could not figure out keys.\"\n end\n\n keys.each do |col_name|\n sql << \",\" unless first\n first = false if first\n sql << quote_column(col_name)\n end\n\n sql << \") VALUES (\"\n\n first = true\n arr_hashes.each do |hash|\n if first\n first = false\n else\n sql << \"),(\"\n end\n\n first_key = true\n if hash.is_a?(Array)\n hash.each do |val|\n if first_key\n first_key = false\n else\n sql << \",\"\n end\n\n sql << @db.quote_value(val)\n end\n else\n hash.each do |_key, val|\n if first_key\n first_key = false\n else\n sql << \",\"\n end\n\n sql << @db.quote_value(val)\n end\n end\n end\n\n sql << \")\"\n\n return sql if args && args[:return_sql]\n\n query(sql)\n\n if args && args[:return_id]\n first_id = last_id\n raise \"Invalid ID: #{first_id}\" if first_id.to_i <= 0\n ids = [first_id]\n 1.upto(arr_hashes.length - 1) do |count|\n ids << first_id + count\n end\n\n ids_length = ids.length\n arr_hashes_length = arr_hashes.length\n raise \"Invalid length (#{ids_length}, #{arr_hashes_length}).\" unless ids_length == arr_hashes_length\n\n return ids\n else\n return nil\n end\n end",
"def compose_sql_array(ary)\n statement, *values = ary\n if values.first.is_a?(Hash) and statement =~ /:\\w+/\n replace_named_bind_variables(statement, values.first)\n elsif statement.include?('?')\n replace_bind_variables(statement, values)\n else\n statement % values.collect { |value| client.escape(value.to_s) }\n end\n end",
"def get_data_column(d, colname)\n dc = []\n\n if (d == nil or d.stuffing_data == nil)\n log_and_print 'WARN: Request for document data column with either a nil document or nil stuffing data'\n return []\n end\n\n d.stuffing_data.find_all do |item| \n if item[colname] != nil \n dc << item[colname] \n end\n end\n return dc\n end",
"def insert_multi(tablename, arr_hashes, args = {})\n sql = \"INSERT INTO `#{tablename}` (\"\n\n first = true\n if args && args[:keys]\n keys = args[:keys]\n elsif arr_hashes.first.is_a?(Hash)\n keys = arr_hashes.first.keys\n else\n raise \"Could not figure out keys.\"\n end\n\n keys.each do |col_name|\n sql << \",\" unless first\n first = false if first\n sql << quote_column(col_name)\n end\n\n sql << \") VALUES (\"\n\n first = true\n arr_hashes.each do |hash|\n if first\n first = false\n else\n sql << \"),(\"\n end\n\n first_key = true\n if hash.is_a?(Array)\n hash.each do |val|\n if first_key\n first_key = false\n else\n sql << \",\"\n end\n\n sql << @db.quote_value(val)\n end\n else\n hash.each do |_key, val|\n if first_key\n first_key = false\n else\n sql << \",\"\n end\n\n sql << @db.quote_value(val)\n end\n end\n end\n\n sql << \")\"\n\n return sql if args && args[:return_sql]\n\n query_no_result_set(sql)\n\n if args && args[:return_id]\n first_id = last_id\n raise \"Invalid ID: #{first_id}\" if first_id.to_i <= 0\n ids = [first_id]\n 1.upto(arr_hashes.length - 1) do |count|\n ids << first_id + count\n end\n\n ids_length = ids.length\n arr_hashes_length = arr_hashes.length\n raise \"Invalid length (#{ids_length}, #{arr_hashes_length}).\" if ids_length != arr_hashes_length\n\n return ids\n else\n return nil\n end\n end",
"def process_select_columns(select_columns)\n select_columns.map do |column|\n if column.is_a?(String) or column.is_a?(Symbol)\n as_table[column]\n else\n column\n end\n end\n end",
"def named_columns( names )\n @columns.values_at( *names )\n end",
"def in_step_args arg\n if arg[:type] == :DataTable\n res = []\n arg[:rows].each_with_index do |row, i|\n sep = i == 0 ? '||' : '|'\n res << surround(row[:cells].map {|hsh| jira_monospace(jira_blank_pad hsh[:value])}, sep)\n end\n return res\n elsif arg[:type] == :DocString\n # todo: handle if needed\n @log.warn \"Docstrings found in '#{arg}' found in file @ #{@file_path}\"\n else\n @log.warn \"Unknown type '#{arg[:type]}' found in file @ #{@file_path}\"\n end\n []\n end",
"def extract_data(args = {})\n sheet_data.rows.map { |row|\n row.cells.map { |c| c && c.value(args) } unless row.nil?\n }\n end",
"def update!(**args)\n @cols = args[:cols] if args.key?(:cols)\n @data = args[:data] if args.key?(:data)\n @rows = args[:rows] if args.key?(:rows)\n @type = args[:type] if args.key?(:type)\n end",
"def merge_data(array1, array2)\n keys.collect do |name|\n name.merge(data[0][name[:first_name]])\n end\nend",
"def get_columns!( *headers )\n headers = headers.flatten\n hrow = sheet.header_rows - 1\n ensure_shape\n @data = @data.transpose.select{ |col| col[0..hrow].any?{ |val| headers.include?( val ) } }\n @data = @data.sort_by{ |col| headers.index( col[0..hrow].select { |val| headers.include?( val ) }.first ) || headers.length }.transpose\n calc_dimensions\n end",
"def merge_data(argu, argu2)\n names = argu[0]\n names2 = argu[1]\n\n argu2.each do |nested_hash|\n nested_hash.each do |name, hash|\n hash.each do |key, value|\n if name == \"blake\"\n names[key] = value\n elsif name == \"ashley\"\n names2[key] = value\n end\n end\n end\n end\n\n new_array = []\n new_array << names\n new_array << names2\n new_array\nend"
] |
[
"0.6135704",
"0.61350346",
"0.6114321",
"0.5990158",
"0.5811916",
"0.5702721",
"0.5654487",
"0.5623366",
"0.5587993",
"0.5566014",
"0.55366254",
"0.5523478",
"0.55062604",
"0.5484118",
"0.54664457",
"0.544343",
"0.5434125",
"0.54301643",
"0.54062504",
"0.5404279",
"0.5353882",
"0.5351758",
"0.5344071",
"0.53358436",
"0.5330574",
"0.532445",
"0.532127",
"0.5271108",
"0.5255476",
"0.523838",
"0.5224223",
"0.5209815",
"0.52034163",
"0.5191406",
"0.5188815",
"0.51810133",
"0.5167538",
"0.51643896",
"0.5145151",
"0.51218456",
"0.5118248",
"0.50972724",
"0.5091025",
"0.50890946",
"0.5075245",
"0.5063876",
"0.505516",
"0.5053593",
"0.50379515",
"0.50377685",
"0.5026075",
"0.5024826",
"0.5021656",
"0.5016679",
"0.501037",
"0.49999237",
"0.4984527",
"0.49795148",
"0.49757618",
"0.49752334",
"0.49752334",
"0.49715725",
"0.49672866",
"0.49664629",
"0.495947",
"0.49503195",
"0.49406043",
"0.49386263",
"0.4930594",
"0.49282986",
"0.49243444",
"0.4908228",
"0.49067295",
"0.490103",
"0.48951134",
"0.489116",
"0.489116",
"0.48820335",
"0.48741832",
"0.48622814",
"0.48559526",
"0.48530838",
"0.4849074",
"0.48410603",
"0.4840946",
"0.48274213",
"0.48170283",
"0.48163286",
"0.48151088",
"0.48149",
"0.48092628",
"0.4804884",
"0.48028913",
"0.47976083",
"0.47944698",
"0.4785997",
"0.47810805",
"0.47788757",
"0.47760683",
"0.477018",
"0.47674036"
] |
0.0
|
-1
|
set columns names . NOTE that we are not clearing chash here. In case, someone changes table and columns.
|
def columns=(array)
#$log.debug "tabular got columns #{array.count} #{array.inspect} " if $log
@columns = array
@columns.each_with_index { |e,i|
#@chash[i] = ColumnInfo.new(c, c.to_s.length)
c = get_column(i)
c.name = e
c.width = e.to_s.length
#@chash[i] = c
#@cw[i] ||= c.to_s.length
#@calign[i] ||= :left # 2011-09-27 prevent setting later on
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def columns= columns\n columns.each { |c| c.table = self }\n @columns = columns\n end",
"def columns(table_name, name = nil) end",
"def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end",
"def columns(*cs)\n if cs.empty?\n super\n else\n self.columns = cs\n self\n end\n end",
"def modify_columns(columns)\n columns\n end",
"def columns=(value)\n @columns = value\n end",
"def set_columns(new_columns)\n @columns = new_columns\n def_column_accessor(*new_columns) if new_columns\n @columns\n end",
"def set_columns(new_columns)\n @columns = new_columns\n def_column_accessor(*new_columns) if new_columns\n @columns\n end",
"def column_names\n @column_names = columns_hash.keys\n end",
"def columns=(v)\n cache_set(:_columns, v)\n end",
"def columns(*args)\n @columns = @columns | args.map(&:to_sym)\n end",
"def columns!\n @columns = nil\n columns\n end",
"def set_grid_columns(columns)\n TSApi.tsapi_setDefinedColumnsOnDisplay(columns, 0)\n end",
"def reset_column_information\n generated_methods.each { |name| undef_method(name) }\n @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = nil\n end",
"def columns(table_name, name = nil)#:nodoc:\n # Each table always has a row key called 'ROW'\n columns = [\n Column.new('ROW', '')\n ]\n schema = describe_table(table_name)\n doc = REXML::Document.new(schema)\n column_families = doc.elements['Schema/AccessGroup[@name=\"default\"]'].elements.to_a\n\n @hypertable_column_names[table_name] ||= {}\n for cf in column_families\n column_name = cf.elements['Name'].text\n rubified_name = rubify_column_name(column_name)\n @hypertable_column_names[table_name][rubified_name] = column_name\n columns << new_column(rubified_name, '')\n end\n\n columns\n end",
"def update_columns=(column_names)\n @update_columns = Array(column_names)\n end",
"def column_names\n @column_names ||= @columns.keys\n end",
"def clear_columns\n @columns = []\n end",
"def columns=(value)\n return if @columns == value\n @columns = value\n refresh\n end",
"def columns\n @columns = columns_hash.values\n end",
"def columns(table = nil)\n if table\n @columns[table]\n else\n ActiveSupport::Deprecation.warn('call columns with a table name!')\n @columns.dup\n end\n end",
"def columns=(cols)\n if cols && cols.uniq.size != cols.size\n handle_duplicate_columns(cols)\n end\n super\n end",
"def set_raw_columns(cols)\n @columns = cols.collect { |args| Column.new(*args) }\n end",
"def method_missing(name, *args)\n @columns[args[0]] = [name, args[1]]\n end",
"def column(name, *args)\n define_method name do\n instance_variable_get(\"@_#{name}\")\n end\n define_method \"#{name}=\" do |val|\n instance_variable_set(\"@_#{name}\", val)\n end\n self.columns = columns.concat([[name].concat(args)])\n end",
"def set_to_column_name(value=nil, &block)\n define_attr_method :to_column_name, value, &block\n end",
"def columns; end",
"def columns_hash\n @columns_hash ||= columns.inject({}){|r,c| r.merge(c[:name].to_sym => c)}\n end",
"def _columns\n cache_get(:_columns)\n end",
"def column_names(table)\n self.table_column_names ||= {}\n unless table_column_names.include? table\n table_column_names[table] = columns(table).map {|c| c.name}\n end\n table_column_names[table]\n end",
"def reset_column_information\n @column = find_column(column_name)\n end",
"def column_names\n @column_names ||= columns.collect(&:name)\n end",
"def save_columns!\n # NetzkeFieldList.update_list_for_current_authority(global_id, columns(false), original_data_class.name) if persistent_config_enabled?\n end",
"def columns(table_name)\n table_name = table_name.to_s\n\n @columns ||= {}\n @columns[table_name] ||= if @registration[:columns].present?\n @registration[:columns].call(@connection, table_name)\n else\n @connection.columns(table_name)\n end\n end",
"def get_columns!( *headers )\n data.get_columns!( *headers ); self\n end",
"def write_column_headers\n\n # Get the column headings\n @column_names = {}\n # Access the schema\n @document.xpath('//element').each do |elem|\n # Extract the column name and the column heading\n column = elem.attributes[\"name\"].value\n table_name = elem.attributes[\"tableHeading\"].value\n column_name = elem.attributes[\"columnHeading\"].value\n full_column_name = table_name + \".\" + column_name\n # Get the output csv header name\n # If the column has no equivalent,\n # try the table name appended to the column name,\n # then just use the current heading\n output_column_name = column_mappings[column_name] || column_mappings[full_column_name] || column_name\n\n # Make a column mapping\n @column_names[column] = output_column_name\n end\n\n # Add the headers to the csv file\n CSV.open(csv_file_path, 'w') do |csv|\n csv << @column_names.values\n end\n\n end",
"def method_missing(table, *columns)\n table_settings[table] = columns\n end",
"def add_columns(list)\n list.each { |obj| add_column(obj) }\n self\n end",
"def print_column_names(table_name)\r\n if table_exists?(table_name)\r\n puts \"Your table \\\"#{table_name}\\\" has columns named:\"\r\n columns = get_column_names(table_name)\r\n columns.each_with_index do |name, i|\r\n print \"\\\"#{name}\\\" \"\r\n print \"& \" unless i == (columns.size - 1)\r\n end\r\n puts \"\"\r\n end\r\n end",
"def semanticize_table_headers!\n @document.tree.search('table tr:first td').each { |node| node.node_name = 'th' }\n end",
"def addColumn(name)\r\n if not name == nil or name.empty?\r\n if @columns == nil\r\n @columns=Array.new\r\n end\r\n \r\n @columns.push(name)\r\n end\r\n end",
"def column_names(table_name)\n columns(table_name).map(&:name)\n end",
"def remember_index_columns_inside_table(node)\n table_name = @table_name\n index_column = node.arguments.all.first.to_object\n\n @index_columns[table_name] ||= []\n @index_columns[table_name] << index_column\n end",
"def columns=(n)\n @columns = n\n end",
"def named_columns( names )\n @columns.values_at( *names )\n end",
"def columns\n self.columns = @core.columns._inheritable unless @columns # lazy evaluation\n @columns\n end",
"def columns\n self.columns = @core.columns._inheritable unless @columns # lazy evaluation\n @columns\n end",
"def columns(table_name, *rest)\n @table.fields.map {|s| ::ActiveRecord::ConnectionAdapters::Column.new(s.to_s, nil, String)}\n end",
"def set_converted_headers\n header_conversion_chart = @import_rows_to_class.const_get(:RECORD_HEADERS).invert\n @converted_headers = importable_columns.map { |col| header_conversion_chart[col] }\n end",
"def columns(table_name)\n column_definitions(table_name.to_s).map do |column_name, type, default, notnull, oid, fmod|\n default_value = extract_value_from_default(default)\n type_metadata = fetch_type_metadata(column_name, type, oid, fmod)\n default_function = extract_default_function(default_value, default)\n new_column(column_name, default_value, type_metadata, notnull == 'f', table_name, default_function)\n end\n end",
"def col_names_for_insert\n self.class.column_names.delete_if {|column| column == \"id\"}.join(\", \")\n end",
"def clear_columns_cache\n @cache.delete(:_columns)\n end",
"def column=(_); end",
"def columns()\n cols = {}\n prefix = \"#{@opts[:pname]}_\"\n fspec = @opts[:fspec]\n\n fspec.params.each do |name, opts|\n cols[prefix + name] = opts\n end\n cols \n end",
"def sortable_columns\n @sortable_columns ||= ['Passport.name']\n end",
"def columns\n\t\t\t@columns ||= Txtboard::Column.columns.sort_by(&:order)\n\t\tend",
"def columns; @columns; end",
"def column_names\n columns_in_order.map { |c| c.name }\n end",
"def default_columns\n#\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t%w( id case_icf_master_id mother_icf_master_id icf_master_id \n\t\t\tsubject_type vital_status sex dob \n\t\t\tfirst_name last_name)\n\tend",
"def columns(table_name, name = nil)\n # Limit, precision, and scale are all handled by the superclass.\n column_definitions(table_name).collect do |name, type, default, notnull|\n VerticaColumn.new(name, default, type, notnull == 'false')\n end\n end",
"def columns(table_name, name = nil)\n # Limit, precision, and scale are all handled by the superclass.\n column_definitions(table_name).collect do |name, type, default, notnull|\n notnull = [false, true][notnull]\n Column.new(name, default, type, notnull)\n end\n end",
"def column_names\n keys = COLUMN_NAMES\n keys.map{|key| [Person.field_name(key), key]}\n end",
"def get_column_names(table_name)\r\n column_names = get_info(table_name, 'name')\r\n end",
"def revert_columns(object)\n self.class.column_names.each do |col|\n next unless self.class.clone_column?(col)\n value = self.send(\"#{col}_changed?\") ? self.send(\"#{col}_was\") : self.send(col)\n object.send(\"#{col}=\", value)\n end\n end",
"def remember_index_columns_outside_table(node)\n table_name = node.arguments.all.first.to_s\n index_column = node.arguments.all[1].to_object\n\n @index_columns[table_name] ||= []\n @index_columns[table_name] << index_column\n end",
"def columns_hash(connection, table_name)\n @columns_hash.fetch(table_name) do\n @columns_hash[deep_deduplicate(table_name)] = columns(connection, table_name).index_by(&:name).freeze\n end\n end",
"def columns(model, options)\n if cols = options[:columns]\n cols\n else\n cols = model.keys.collect do |k|\n { :key => k.to_sym, :label => \"#{k.capitalize}\" }\n end\n end\n end",
"def columns(names, options=nil)\n names.each do |name|\n column name, options\n end\n end",
"def add_pseudo_columns(sql_for_columns)\n @sql_for_columns.merge! sql_for_columns\n @pseudo_column_names.merge sql_for_columns.keys.map(&:to_s)\n end",
"def columns( table )\n sanity_check\n @handle.columns( table ).collect {|col| ColumnInfo.new(col) }\n end",
"def write_headers\n @sheet.row(0).replace [header]\n @sheet.row(3).replace name_header_row(@player.longs.first.ticker_name, @player.shorts.first.ticker_name, @player.calls.first.ticker_name)\n @sheet.row(4).replace data_header_row(long_short_headers, long_short_headers, call_put_headers)\n\n @sheet.row(17).replace name_header_row(@player.futures.first.ticker_name, 'Total P&L', @player.puts.first.ticker_name)\n @sheet.row(18).replace data_header_row(long_short_headers, overall_headers, call_put_headers)\n end",
"def fixup_columns\n @columns.each_index do |idx| \n\n if @columns[idx][:searchable].nil? then\n @columns[idx][:searchable] = @model_class.column_methods_hash[@columns[idx][:id].intern] ? true : false\n end\n @columns[idx][:query] = @columns[idx][:id] if @columns[idx][:query].nil?\n \n if @columns[idx][:sortable].nil? then\n @columns[idx][:sortable] = @columns[idx][:query] == false ? false : true\n end\n \n end\n end",
"def flushCol(colname)\n\t\t@mx.each do |row|\n\t\t\tself.setValue(row, colname, '')\n\t\tend\n\t\treturn self\n\tend",
"def get_table_column_names(table)\r\n @db[table].columns\r\n end",
"def columns!\n ds = clone(opts.merge(:sql => \"SELECT TOP 1 [T1].* FROM (#{opts[:sql]}) \\\"T1\\\"\"))\n ds.each{break}\n\n if cols = ds.cache[:_columns]\n self.columns = cols\n else\n []\n end\n end",
"def column_definitions(table_name)\r\n query <<-end_sql\r\n SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, c.consrc\r\n FROM pg_attribute a LEFT JOIN pg_attrdef d\r\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\r\n LEFT JOIN pg_constraint c ON a.attrelid = c.conrelid AND \r\n c.contype = 'c' AND c.conkey[1] = a.attnum\r\n WHERE a.attrelid = '#{table_name}'::regclass\r\n AND a.attnum > 0 AND NOT a.attisdropped\r\n ORDER BY a.attnum\r\n end_sql\r\n end",
"def set_column_comments(table_name, comments)\n\n end",
"def col_names_for_insert\n self.class.column_names.delete_if {|col| col == \"id\"}.join(\", \")\n #\n end",
"def columns(connection, table_name)\n if ignored_table?(table_name)\n raise ActiveRecord::StatementInvalid, \"Table '#{table_name}' doesn't exist\"\n end\n\n @columns.fetch(table_name) do\n @columns[deep_deduplicate(table_name)] = deep_deduplicate(connection.columns(table_name))\n end\n end",
"def column_names\n columns.map(&:name)\n end",
"def column_names\n @column_names || owner.column_names\n end",
"def columns\r\n unless @columns\r\n @columns = connection.columns(table_name, \"#{name} Columns\")\r\n @columns.each {|column| column.primary = primary_keys.include?(column.name.to_sym)}\r\n end\r\n @columns\r\n end",
"def build_update_set_cols(key)\n \"#{quote_column_name(key)} = updated_values.#{quote_column_name(key)}\"\n end",
"def columns_with_redhillonrails_core\n unless @columns\n columns_without_redhillonrails_core\n cols = columns_hash\n indexes.each do |index|\n next if index.columns.blank?\n column_name = index.columns.reverse.detect { |name| name !~ /_id$/ } || index.columns.last\n column = cols[column_name]\n column.case_sensitive = index.case_sensitive?\n column.unique_scope = index.columns.reject { |name| name == column_name } if index.unique\n end\n end\n @columns\n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def audit_columns(*columns)\n cattr_accessor :_audit_columns\n self._audit_columns = columns.map(&:to_s) & valid_column_names\n end",
"def columns=(arr)\n @columns = arr\n update_height\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end",
"def update!(**args)\n @column_name = args[:column_name] if args.key?(:column_name)\n end"
] |
[
"0.68806785",
"0.6714919",
"0.66101706",
"0.6537603",
"0.65074956",
"0.6458233",
"0.6431775",
"0.6431775",
"0.6371532",
"0.6305882",
"0.6231081",
"0.6224894",
"0.61524403",
"0.61167276",
"0.61036533",
"0.6091803",
"0.6084889",
"0.60723287",
"0.60540897",
"0.6042492",
"0.6039466",
"0.60363406",
"0.603556",
"0.6035139",
"0.60068727",
"0.59903246",
"0.5969365",
"0.5935399",
"0.5933744",
"0.59275264",
"0.5913472",
"0.59070545",
"0.58954585",
"0.58899987",
"0.58581907",
"0.5857238",
"0.58359337",
"0.58318806",
"0.5826314",
"0.58161235",
"0.58066577",
"0.5799366",
"0.579287",
"0.5779839",
"0.57667696",
"0.57654476",
"0.57654476",
"0.5756072",
"0.57521594",
"0.5730477",
"0.57257354",
"0.5712777",
"0.5707907",
"0.570217",
"0.57012945",
"0.57012683",
"0.56999665",
"0.5698431",
"0.5698352",
"0.5675793",
"0.56741905",
"0.5668747",
"0.5664194",
"0.5662677",
"0.5662613",
"0.5660442",
"0.5656221",
"0.56553936",
"0.5652811",
"0.5652635",
"0.56513524",
"0.56494904",
"0.564563",
"0.56451213",
"0.5636471",
"0.563345",
"0.562306",
"0.56192297",
"0.56136125",
"0.5611714",
"0.5609173",
"0.5608374",
"0.56053615",
"0.56041086",
"0.5602521",
"0.5601807",
"0.560008",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468",
"0.5579468"
] |
0.67733675
|
1
|
set data as an array of arrays
|
def data=(list)
#puts "got data: #{list.size} " if !$log
#puts list if !$log
@list = list
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_data_array(data_set)\n case\n when data_set.is_a?(Daru::DataFrame)\n return ArgumentError unless data_set.index.is_a?(Daru::Index)\n data_set.access_row_tuples_by_indexs(*data_set.index.to_a)\n when data_set.is_a?(Daru::Vector)\n rows = []\n data_set.to_a.each { |a| rows << [a] }\n rows\n when data_set.is_a?(Array)\n data_set\n else\n raise ArgumentError # TODO: error msg\n end\n end",
"def to_ary\n\t\t@data.flatten\n\tend",
"def data=(series)\n @data = []\n series.each do |d|\n @data << [[0,d]]\n end\n end",
"def converted_arrays; end",
"def to_a\n @data.inject([]) { |array, h| array.push(h.values)}\n end",
"def to_array(dataset)\n dataset.map do |row|\n entity_class.new row\n end\n end",
"def datasets\n datasets = []\n dataset.each do |d|\n if d[:data].first.is_a?(Array)\n datasets += d[:data]\n else\n datasets << d[:data]\n end\n end\n datasets\n end",
"def to_a; [Array]; end",
"def generate_data_values\n data_array = Array.new()\n @data.repository.each { |dataset|\n data_array << create_data_hash(dataset)\n }\n return data_array\n end",
"def get_data\n @data = []\n end",
"def as_array\n @fm.dup\n end",
"def to_a\n array\n end",
"def data_values\n if bare_data_set?\n [data]\n else\n data.map{ |set| set.is_a?(Hash) ? set[:values] : set }\n end\n end",
"def to_a; Array(force) end",
"def set_data(array_of_hashes)\n @values = array_of_hashes\n @metadata = {\n rows: @values.size,\n }\n end",
"def Array(p0) end",
"def set_array!(values)\n @objects = []\n @memory = FFI::MemoryPointer.new(MsgObject,values.length)\n\n values.each_with_index do |value,index|\n @objects << MsgObject.new_object(value,@memory[index])\n end\n\n self[:type] = :array\n\n array = self[:values][:array]\n array[:size] = values.length\n array[:ptr] = @memory\n end",
"def parse_attribute_as_array_of(name, data, klass)\n value = data.class != Array || data.empty? ? [] : data.collect { |i| klass.new(i) }\n instance_variable_set(\"@#{name.to_s.underscore}\", value)\n end",
"def initialize\n @data = []\n end",
"def yale_nd_row_as_array i\n yale_nd_row(i, :array)\n end",
"def set_values(array)\n @row = array\n end",
"def _array(obj)\n obj.map { |v| _renc(v) }\n end",
"def to_a\n Array.wrap(self)\n end",
"def parse_raw_data\n data_slices.to_a\n end",
"def arrays\n @vectors\n end",
"def build_array\n arr = []\n yield(arr)\n arr \n end",
"def to_a #:nodoc:\n data.to_a\n end",
"def to_a \n return @data\n end",
"def array\n @array\n end",
"def to_a\n @arr\n end",
"def to_a\n data.all\n end",
"def to_a\n array.map do |item|\n if item.is_a?(SpecViewArray)\n item.to_a\n else\n item\n end\n end\n end",
"def array\n\t\t#create an array of\n\t\tarray = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\tend",
"def build_data_array\n table = helper_class.new(@file_upload.file.path).to_table # # load data to array of hashes\n errors = []\n data = table.map do |item_hash|\n process_item(attributes(item_hash), errors)\n end\n [data, errors]\n end",
"def tsv2array( data )\n return_data = [] \n data_by_line = data.split(\"\\n\")\n \n data_by_line.each do |d|\n intermediate = {}\n data_by_item = d.split(\"\\t\")\n for i in 0 .. ( data_by_item.size() - 1 )\n intermediate[ self.attributes[i] ] = data_by_item[i]\n end\n return_data.push( intermediate )\n end\n \n return return_data\n end",
"def array()\n\t\t@array\n\tend",
"def to_a\n array = all\n array.each_with_index do |value, i|\n array[i] = value.to_a if value.is_a?(RedisArray)\n end\n end",
"def append_data_array(raw_data)\n $test_logger.log(\"Append data array #{raw_data}\")\n raw_array = []\n raw_data.each_with_index{|x, i| raw_array[i] = BioPacket.swap_dword(x) }\n @data.concat(raw_array)\n build_cmd\n end",
"def data\n data = (@transpose ? @data.transpose : @data).clone\n data.shift\n data\n end",
"def to_a\n array = []\n rows.times do |row|\n col_array = []\n cols.times do |col|\n col_array << self.value_at(row,col)\n end\n array << col_array\n end\n\n return array\n end",
"def data=(data)\n self.shape = data.shape\n\n unless @_data\n unless @_deferred_init.empty?\n @_deferred_init[2] = data\n else\n raise RuntimeError, \"Parameter '#{@name}' has not been initialized.\"\n end\n end\n\n list_data.each do |arr|\n arr[0..-1] = data\n end\n end",
"def concatenate_data_arrays(array_name, array_type)\n data_arrays = DataArray.where(name: array_name, array_type: array_type, linear_data_type: 'CellMetadatum',\n linear_data_id: self.id).order(:array_index => 'asc')\n all_values = []\n data_arrays.each do |array|\n all_values += array.values\n end\n all_values\n end",
"def to_a ; data.dup ;end",
"def make_array\n [@name, @author, @deviation_url, @views, @favs, @comments]\n end",
"def from_arrays(array2d)\n @bandwidth = BandMatrixFactory.calculate_bandwidth(array2d)\n @row_size = array2d.size\n @column_size = array2d.first.size\n \n @data = Array.new(@row_size){Array.new(@bandwidth*2+1,0)}\n \n DelegateMatrix.iterate_matrix(array2d, Proc.new do |x,y,v|\n self.[]=(x,y,v)\n end)\n end",
"def as_array(thing)\n [ thing ].flatten\n end",
"def to_a\n @data\n end",
"def set_data(data)\n @preset_data = data || []\n refresh\n end",
"def to_a\n\t\tarr = []\n\t\teach {|valor| arr << valor}\n\t\tarr\n\tend",
"def q1_read_to_array(data_file_name)\r\n array2d = []\r\n \r\n read_file(\"data/\"+data_file_name).each{ |line|\r\n array1d = line.split(\",\").map(&:strip).map(&:to_s)\r\n array2d << array1d\r\n }\r\n return array2d\r\nend",
"def datarows=(array)\n self[:datarows] = array.join(\",\")\n end",
"def to_flex_array\n self\n end",
"def to_array\n array = []\n self.each { |x| array.push x }\n return array\n end",
"def array(*args)\n args_ = (args.size == 1) && (args[0].is_a? ::Array) ? args[0] : args\n args_.each_with_object(newObject('Array')) do |val, obj|\n obj.add val\n end\n end",
"def to_a\n Array(each)\n end",
"def to_a\n map { |e| e.data}\n end",
"def get_data\n $test_logger.log(\"Get data\")\n\n if @data.is_a?(Array) \n data_copy = Array.new(@data.size)\n @data.each_with_index{|d, i|\n if !d.to_s.include? CmdManager::DONT_CARE\n data_copy[i] = BioPacket.swap_dword(d)\n else\n data_copy[i] = d\n end \n } \n else\n data_copy = Common.get_obj_copy(@data)\n end \n data_copy\n end",
"def yale_nd_row_as_set i\n require 'set'\n yale_nd_row(i, :array).to_set\n end",
"def convert_dataset(ds)\n if dimensions == 2\n # valid inputs include:\n # an array of >=2 arrays, or an array of >=2 hashes\n ds = ds.map do |d|\n d.is_a?(Hash) ? d : {:data => d}\n end\n elsif dimensions == 1\n # valid inputs include:\n # a hash, an array of data, an array of >=1 array, or an array of >=1 hash\n if ds.is_a?(Hash)\n ds = [ds]\n elsif not ds.first.is_a?(Hash)\n ds = [{:data => ds}]\n end\n end\n ds\n end",
"def data_array\n completed_array = []\n slugs.each_with_index do |slug, index|\n completed_array << {slug: slug, content: contents[index]}\n end\n completed_array\n end",
"def to_flat_array\n ary = Array.new(self.size)\n self.each.with_index { |v,i| ary[i] = v }\n ary\n end",
"def array(before: Pass.instance, each: Pass.instance, after: Pass.instance)\n ArrayV.new before: before, each: each, after: after\n end",
"def rows\n Array.new self\n end",
"def data y_values\n super(Array.new(y_values.to_a.size) { |i| i }, y_values.to_a)\n end",
"def concatenate_data_arrays(array_name, array_type)\n data_arrays = DataArray.where(name: array_name, array_type: array_type, linear_data_type: 'Gene',\n linear_data_id: self.id).order(:array_index => 'asc')\n all_values = []\n data_arrays.each do |array|\n all_values += array.values\n end\n all_values\n end",
"def arrays_to_hashes\n end",
"def to_a\n [x, y, z]\n end",
"def rows\n @array\n end",
"def import_array(rows)\n raise ArgumentError, \"Can only work with arrays\" unless rows.is_a?(Array)\n if self.labels.size > 1 and rows.dimensions == 1\n self.add_item(rows)\n else\n # self.items = self.items + rows\n rows.each do |row|\n self.add_item(row)\n end\n end\n end",
"def values\n @data.values\n end",
"def create_column_data_array\n\ttable_id = create_table_id('../data/census_column_metadata.csv')\n\tcolumn_id = create_column_id('../data/census_column_metadata.csv')\n\t\n\t[title_processor,table_id,column_id].transpose\n\nend",
"def arr\n @custom_cells.each do |c|\n set_custom_cell_val(c)\n end\n @arr.map! { |x| (x == nil) ? 0 : x }\n @arr\n end",
"def array\n @@array\n end",
"def concatenate_data_arrays(array_name, array_type)\n query = {\n name: array_name, array_type: array_type, linear_data_type: 'CellMetadatum', linear_data_id: self.id,\n study_id: self.study_id, study_file_id: self.study_file_id\n }\n DataArray.concatenate_arrays(query)\n end",
"def to_array(data, legislators, filter = nil)\n array = []\n filters = filter ? filter.split(/\\s+/) : []\n \n sources = sort_by_ref(data.keys, source_keys)\n header = []\n header << 'Bioguide ID'\n sources.each do |source|\n sort_fields(data[source].keys, source).each do |column|\n header << (data[source][column][:header] ? data[source][column][:header] : column.to_s.titleize)\n end\n end\n \n array << header\n \n legislators.each do |legislator|\n row = []\n row_filters = filters.dup\n \n row << legislator.bioguide_id\n \n sources.each do |source|\n sort_fields(@data[source].keys, source).each do |column|\n cell = data[source][column][legislator.bioguide_id]\n if cell.is_a?(Hash)\n raw_data = cell[:data]\n searchable = cell[:searchable]\n else\n raw_data = cell\n searchable = nil\n end\n \n if row_filters and row_filters.any?\n row_filters.reject! {|f| (raw_data =~ /#{f}/i) || (searchable and searchable =~ /#{f}/i)}\n end\n \n row << raw_data\n end\n end\n \n array << row unless filter and row_filters.any?\n end\n \n array\n end",
"def array(value)\n value.respond_to?(:to_ary) ? value : [value]\n end",
"def to_a\n @rep.map { |l| l }\n end",
"def to_a\n @rep.map { |l| l }\n end",
"def to_a\n\t\t\tflat = []\n\t\t\t\n\t\t\tflatten_to_array(flat)\n\t\t\t\n\t\t\treturn flat\n\t\tend",
"def get_items\r\n @arr.to_a\r\n end",
"def push_array(arr_t, arr_v)\n arr_data = arr_t.zip(arr_v)\n @data.concat(arr_data)\n @data.sort_by! { |d| d[0] }\n end",
"def data=(val)\n list(val)\n end",
"def user_data_as_array(key)\n val = ec2_user_data(key)\n if !val || val.empty?\n val = []\n elsif !val.is_a?(Array)\n val = [val]\n end\n\n val\n end",
"def to_ary\n self.map{|result| result}\n end",
"def table_to_array_of_arrays(table=@table)\n array = []\n table.rows.each do |row|\n row_array = []\n row.data.each_with_index do |column, index|\n data = {:text => column}\n if row.cell_format.is_a? Hash\n data.reverse_merge! row.cell_format\n elsif row.cell_format.is_a? Array\n data.reverse_merge! row.cell_format[index]\n end\n row_array << Prawn::Table::Cell.new(data)\n end\n array << row_array\n end\n array\n end",
"def to_a\n res = []\n each_row do |ts, val|\n res << [ts, val]\n end\n res\n end",
"def load_data(*args)\n init_data_arrays # wipes all preexisting data in @data_collections and @data_objects\n \n args[0].each.with_index do |array_or_variable, i|\n if i < data_collection_names.count\n @data_collections[i] += array_or_variable \n else\n j = i - data_collection_names.count\n @data_objects[j] = array_or_variable # if array_or_variable.class != Array\n end\n end\n self\n end",
"def get_data(dimensions)\n data = []\n (0...@m).each do |row_idx|\n row = []\n col_idx = 1\n while col_idx <= dimensions\n row << @x_matrix[row_idx, col_idx]\n col_idx += 1\n end\n row << @y_vector[row_idx, 0]\n data << row\n end\n data\n end",
"def make_matrixarray\n\t\tmatrix = []\n\t\t@speakers.each do |this_speaker|\n\t\t\tmatrix << row(this_speaker)\n\t\tend\n\t\t#return matrix array\n\t\treturn matrix\n\tend",
"def make_item_array(data_hash)\n data_hash[\"items\"][\"item\"].map do |item_hash|\n Item.new(item_hash)\n end\nend",
"def set_data_type_and_array\n column_schema = SearchFacet.get_table_schema(column_name: self.big_query_id_column)\n detected_type = column_schema[:data_type]\n self.is_array_based = detected_type.include?('ARRAY')\n item_type = BQ_DATA_TYPES.detect {|d| detected_type.match(d).present?}\n self.data_type = BQ_TO_FACET_TYPES[item_type]\n end",
"def to_a\n [ x, y, z ]\n end",
"def array\n raise \"Not implemented\"\n end",
"def array_result\n [@result['results']].flatten\n end",
"def +(data)\n DataArray.new(x_name: @x_name, y_axis: @y_axis, data: super(normalize(data)))\n end",
"def to_a(dimen=nil)\n if self.dim == 2\n\n return self.to_flat_a if self.shape[0] == 1\n\n ary = []\n begin\n self.each_row do |row|\n ary << row.to_flat_a\n end\n #rescue NotImplementedError # Oops. Try copying instead\n # self.each_row(:copy) do |row|\n # ary << row.to_a.flatten\n # end\n end\n ary\n else\n to_a_rec(0)\n end\n end",
"def to_a\n # @rows.collect{|row| row.collect{|e| e}} \n my_rows = @rows\n r_size = my_rows.size\n res = Array.new(r_size)\n for i in 0..r_size-1 do\n res[i] = my_rows[i].dup\n end\n res\n end",
"def prepare_source_array data\n return [] if data.empty?\n if (leading_2_bytes = (leading_bytes = (first = data[0]).unpack 'C3').slice 0, 2) == BOM_BYTES_UTF_16LE\n data[0] = first.byteslice 2, first.bytesize\n # NOTE you can't split a UTF-16LE string using .lines when encoding is UTF-8; doing so will cause this line to fail\n return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16LE).rstrip}\n elsif leading_2_bytes == BOM_BYTES_UTF_16BE\n data[0] = first.byteslice 2, first.bytesize\n return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16BE).rstrip}\n elsif leading_bytes == BOM_BYTES_UTF_8\n data[0] = first.byteslice 3, first.bytesize\n end\n if first.encoding == ::Encoding::UTF_8\n data.map {|line| line.rstrip}\n else\n data.map {|line| (line.encode ::Encoding::UTF_8).rstrip}\n end\n end",
"def initialize array\n @array = array\n end",
"def to_ary\n [@x, @y, @z]\n end",
"def to_array\n return [@filename,\n @timestamp,\n @source,\n @rmr_number,\n @series_description,\n @gender,\n @slice_thickness,\n @slice_spacing,\n @reconstruction_diameter, \n @acquisition_matrix_x,\n @acquisition_matrix_y]\n end"
] |
[
"0.68242866",
"0.6756915",
"0.66845435",
"0.6625737",
"0.64005864",
"0.6362649",
"0.6320675",
"0.6297889",
"0.6229435",
"0.6210775",
"0.6188046",
"0.61304575",
"0.6110629",
"0.61034673",
"0.6095829",
"0.60781205",
"0.6006571",
"0.6002479",
"0.5990009",
"0.5987814",
"0.5964601",
"0.5963717",
"0.5954334",
"0.59370774",
"0.5932189",
"0.5929298",
"0.591223",
"0.5902816",
"0.5901086",
"0.5899122",
"0.58872336",
"0.5881988",
"0.5879904",
"0.5878488",
"0.5875143",
"0.5866017",
"0.58582044",
"0.58551276",
"0.5831172",
"0.5806476",
"0.5796727",
"0.5788462",
"0.578237",
"0.5782291",
"0.5779544",
"0.5779099",
"0.57759273",
"0.5769718",
"0.57624525",
"0.576026",
"0.5758579",
"0.57535815",
"0.5748492",
"0.572993",
"0.57225513",
"0.5722503",
"0.5721751",
"0.5713948",
"0.57096785",
"0.56630707",
"0.56545246",
"0.56538796",
"0.5649781",
"0.564021",
"0.5632459",
"0.56266695",
"0.56178683",
"0.561686",
"0.561353",
"0.56067085",
"0.56027174",
"0.5601153",
"0.55803764",
"0.5573367",
"0.5572264",
"0.5568883",
"0.55651766",
"0.55651766",
"0.55565965",
"0.5551507",
"0.55427927",
"0.55363154",
"0.55317426",
"0.55279315",
"0.5514401",
"0.5514238",
"0.55081666",
"0.5504882",
"0.55030984",
"0.5499728",
"0.54979",
"0.548441",
"0.5484005",
"0.5483073",
"0.5481419",
"0.54814124",
"0.5478888",
"0.5473543",
"0.54703206",
"0.54674506",
"0.54666233"
] |
0.0
|
-1
|
add a row of data
|
def add array
#$log.debug "tabular got add #{array.count} #{array.inspect} " if $log
@list ||= []
@list << array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add(row)\n @data << row\n end",
"def add_row(row)\n size = row.size\n raise ArgumentError.new(\"Given a row of data with #{size} entries, but there are only #{@table_columns.size} columns in the table\") unless size == @table_columns.size\n @data << row\n end",
"def addrow(data, opts=DEF_ADD_ROW_OPTS)\n\t\t#opts=DEF_ADD_ROW_OPTS.merge(opts)\n\t\tvalidate_row(data)\n\t\t@rows << data\n\tend",
"def add_row( new_row, pos=@table.size)\n @table.insert(pos, new_row)\n end",
"def append_row!(*args)\r\n insert_row!(*args)\r\n end",
"def addRow\n\t\tnew_row = @vars.values\n\t\tcsvrow = new_row.to_csv\n\t\t@arrayOfRows.push(csvrow)\n\tend",
"def add_rows(rows)\n sizes = rows.collect {|r| r.size }.uniq\n expected_size = @table_columns.size\n errors = sizes.select {|s| s != expected_size }\n raise ArgumentError.new(\"Given a row of data with #{errors.to_sentence} entries, but there are only #{expected_size} columns in the table\") if errors.any?\n @data += rows\n end",
"def <<(row)\n add_row(row)\n end",
"def add_row(obj)\n obj = DataRow.new(obj) unless obj.is_a?(DataRow)\n raise(StandardError, \"wrong row size #{obj.cells_count}, should be #{columns_count})\") if obj.cells_count != columns_count\n obj.close\n @rows << obj\n self\n end",
"def add_row(encrypted_row_data)\n @encrypted_rows << encrypted_row_data\n end",
"def add_row(row)\n case\n when row.is_a?(Array)\n @rows << Hash[@parameters.zip(row.collect { |value| value.strip })]\n @row_elements << Row.new(\"|#{row.join('|')}|\")\n when row.is_a?(Hash)\n @rows << row.each_value { |value| value.strip! }\n @row_elements << Row.new(\"|#{ordered_row_values(row).join('|')}|\")\n else\n raise(ArgumentError, \"Can only add row from a Hash or an Array but received #{row.class}\")\n end\n end",
"def <<(row)\n @rows << row\n end",
"def append_row(*args)\n begin_row\n args.each do |arg|\n append(arg)\n end\n end_row\n end",
"def add_row\n unless @current_row.nil?\n # Add the row to the puzzle.\n @puzzle << @current_row\n # And clear the row.\n @current_row = nil\n end\n end",
"def new_row(data=[], options ={})\n @rows << self.class::ROW_CLASS.new(self, data, options)\n @rows.last\n end",
"def add_row(row)\n raise('Cannot add a row. No parameters have been set.') if rows.empty?\n\n # A quick 'deep clone' so that the input isn't modified\n row = Marshal.load(Marshal.dump(row))\n\n values = if row.is_a?(Array) # rubocop:disable Style/CaseLikeIf # False positive\n row\n elsif row.is_a?(Hash)\n # There is no guarantee that the user built up their hash with the keys in the same order as\n # the parameter row and so the values have to be ordered by us. Additionally, the hash needs\n # to have string keys in order for #order_row_values to work\n ordered_row_values(stringify_keys(row))\n else\n raise(ArgumentError, \"Can only add row from a Hash or an Array but received #{row.class}\")\n end\n\n @rows << Row.new(\"|#{values.join('|')}|\")\n end",
"def <<(row)\n @rows << row\n self\n end",
"def append_row row, row_type\n send(row_type) << row\n end",
"def add_row\n @rows += 1\n @current_cards.push [@deck.removeAny, @deck.removeAny, @deck.removeAny]\n end",
"def add_row(row)\n if row.size < @size\n row.fill('', row.size...@size)\n elsif row.size > @size\n @heading.fill('', @size...row.size)\n @body.each { |r| r.fill('', @size...row.size) }\n @size = row.size\n end\n @body << row\n end",
"def add_row(hash = {})\n row = vr_row(model.append)\n hash.each_pair { |key, val| row[key] = val }\n return row\n end",
"def add_row( group_id, row, number_to_transpose = 0 )\n @groups[group_id - 1] ||= []\n @groups[group_id - 1] << MiltonsMachine::Core::ForteSet.new(row).transpose_mod12(number_to_transpose)\n @max_group_index = @groups.length - 1\n @max_column_index = @groups[0][0].length - 1\n end",
"def insert_row(row, index=@rows.length)\n @rows.insert(index, row)\n end",
"def add_new_record(h, ws)\n row_array = []\n @excel_row.each do |a|\n row_array.push(h[a])\n end\n ws.add_row row_array\nend",
"def lnbAddRow _args\n \"lnbAddRow _args;\" \n end",
"def add_rows! *rows\r\n matrix_new = add_rows *rows\r\n @rows = matrix_new.to_a\r\n end",
"def <<(fields)\n add_row(fields)\n end",
"def add_cell(cell)\n # If there is no row yet, create a blank array for it.\n @current_row ||= []\n # Add the cell to the end of the row.\n @current_row << cell\n end",
"def add(type, *data)\n df = DataFrame.new({x: data[0], y: data[1], z: data[2]})\n return add_with_df(df, type, :x, :y, :z)\n end",
"def write_row(row)\n end",
"def add_row(pos)\n start = pos[:at].to_i\n count = pos[:count].to_i\n rows.each do |row|\n row.position += count if row.position >= start\n end\n count.times { rows.new(position: pos[:at]) }\n saved = rows.collect {|row| row.save }\n saved.all?\n end",
"def write_row(row)\n @data_stream << row.to_a\n end",
"def insert_row!(*args)\r\n after, before = nil, nil\r\n opts = (Hash === args.last || Numeric === args.last) ? args.pop : {}\r\n case opts\r\n when Numeric\r\n before = opts\r\n when Hash\r\n after = opts[:after]\r\n before = opts[:before]\r\n end\r\n input = args.flatten\r\n \r\n # get input column count and assign default headers\r\n init_blank_headers!(input.size) if headers.empty?\r\n \r\n # pad or truncate row based on headers\r\n input = normalized_columns(input)\r\n unless after or before\r\n @data += input\r\n else\r\n if after\r\n after = [after, row_count].min\r\n @data.insert( [index_of_next_row_start(after), @data.size].min, *input)\r\n end\r\n if before\r\n before = [before, row_count].min\r\n @data.insert(index_of_row_start(before), *input)\r\n end\r\n end\r\n \r\n init_caches!\r\n self\r\n end",
"def append(data)\n begin\n # convert old data to array\n old_data_array = CSV.read(@file, headers: true, header_converters: :symbol).to_a\n\n # extend the headers by the ones for new testcases\n data.each do |result|\n old_data_array[0] << result[:identifier] if not old_data_array[0].include?(result[:identifier].to_sym)\n end unless data.empty?\n\n # create the new line column by column in the right order\n line = []\n old_data_array[0].each do |header|\n line << (data.detect{ |field| field[:identifier] == header.to_s }[:runtime] rescue nil)\n end unless old_data_array[0].empty?\n\n # append the new line of data to existing data\n old_data_array << line\n\n # write the CSV\n file = File.open(@file, \"w\")\n CSV(file, col_sep: \",\") do |csv|\n old_data_array.each do |line|\n csv << line\n end\n end\n file.close\n rescue\n create(data)\n end\n end",
"def row\n new_row = RowBuilder.new\n\n yield new_row\n\n @rows << new_row\n end",
"def add_row(row)\n\n # Delete row if it already exists\n $rows.delete_if { |r| r['file_path'] == row['file_path'] }\n $rows << row\n\n # rewrite csv:\n update_csv($rows)\nend",
"def add_row(row, mark: false)\n row.transform_keys!(&:as_sym)\n # Make sure there is a column for each known header and each new key\n # present in row.\n new_heads = row.keys - headers\n new_heads.each do |h|\n # This column is new, so it needs nil items for all prior rows lest\n # the value be added to a prior row.\n items = Array.new(size, nil)\n columns << Column.new(header: h, items: items, tolerant: tolerant_col?(h))\n end\n headers.each do |h|\n # NB: This adds a nil if h is not in row.\n column(h) << row[h]\n end\n self\n end",
"def add_entry entry\n @data << entry\n end",
"def add_rows(list)\n list.each { |obj| add_row(obj) }\n self\n end",
"def <<(row)\n CSV.generate_row(row, row.size, @dev, @fs, @rs)\n self\n end",
"def push_row(other_row)\n\t\t# initialize the new array\n\t\tnew_row = Array.new(@headers.length)\n\t\t\n\t\t# Iterate headers, building our new row\n\t\t0.upto @headers.length-1 do |index|\t\t\n\t\t\t\n\t\t\t# Put the value into the corresponding column in our CSV\n\t\t\tnew_row[index] = other_row[ @headers[index] ]\n\t\tend\n\t\t\n\t\t# Add this row into our matrix\n\t\t@matrix<< new_row\n\tend",
"def append(row,text)\n\t\t@text[row] = @text[row].dup\n\t\t@text[row] += text\n\tend",
"def push(sdata)\n row = Hash.new\n @columns.each do |column,value|\n nvalue = sdata.shift()\n row.store(column,nvalue)\n row.store(column,value) if row[column].nil?\n end\n @data.push(row)\n end",
"def row; end",
"def add_row(label)\n @components << row = QueryFacetRow.new(label, @setup)\n row\n end",
"def add array\n $log.debug \"tabular got add #{array.count} #{array.inspect} \" if $log\n @list ||= []\n @list << array\n end",
"def add_row(parent, hash = {})\n row = vr_row(model.append(parent))\n hash.each_pair { |key, val| row[key] = val }\n return row\n end",
"def create_row(params)\n\t\tself.google_doc.restart_session_if_necessary\n\t\treset_worksheet_obj if @worksheet_obj == nil\n\t\t# add the keys if they don't exist\n\t\tparams.each do | key, value |\n\t\t\tif(!@worksheet_obj.list.keys.include?(key))\n\t\t\t\tadd_column_key(key)\n\t\t\tend\n\t\tend\n\t\t# save key changes\n\t\tif(@worksheet_obj.dirty?)\n\t\t\t@worksheet_obj.synchronize\n\t\tend\n\t\t#push the new row\n\t\tnew_row = @worksheet_obj.list.push(params)\n\t\t@worksheet_obj.save\n\t\treturn new_row\n\tend",
"def insert_rows( before, number=1 )\n @data = @data.insert( ( col_index( before ) - 1 ), *Array.new( number, [nil] ) )\n calc_dimensions\n end",
"def insert row_ind, count=1\n @row_refs.insert(row_ind,count)\n end",
"def write(data)\n @output_row << data\n end",
"def row(row)\n Row.new(@data, row)\n end",
"def << (val)\n\t\t# if this is first row set the width based on size of first array to be pushed\n\t\tif @h == 0 \n\t\t\t@w = val.size\n\t\telsif val.size != @w or val.class.to_s != 'Array'\n\t\t\traise \"Only add rows/arrays the same size as the width(#{@w})\"\n\t\tend\t\n\n\t\t@data[@h] = val\n\t\t@h += 1\n\tend",
"def add_rows *rows\r\n matrix_a = self.to_a\r\n\r\n rows.each {|m|\r\n if m.column_size != self.column_size\r\n raise ArgumentError, \"number of columns should be identical\"\r\n end\r\n\r\n matrix_a += m.to_a\r\n }\r\n\r\n Matrix.rows(matrix_a)\r\n end",
"def addrow(collist)\n grid = OutputGrid.new(@colset)\n collist.each do |colname|\n grid.addcol(colname)\n end\n @grids << grid\n end",
"def insert(data) \n set data, 1\n end",
"def insert(data) \n set data, 1\n end",
"def add_data(dataset, worksheet, columns)\r\n dataset.rows.each_with_index do |row, rindex|\r\n columns.each_with_index do |col, cindex|\r\n # set column formatting\r\n f = nil\r\n cell_value = nil\r\n col_length = row[col].to_s.length < 20 ? 20 : row[col].to_s.length\r\n if row[col].kind_of? Fixnum or row[col].kind_of? Float\r\n f = @formats[:number_column]\r\n cell_value = [row[col]]\r\n else\r\n f = @formats[:column_format] \r\n cell_value = row[col].to_s\r\n end\r\n \r\n worksheet.write(rindex + STARTING_DATA_ROW, cindex, cell_value, @formats[:column_format])\r\n worksheet.format_column(cindex, col_length, f)\r\n end\r\n end\r\n end",
"def next_row\n @current_row += 1\n end",
"def add_row(table_name, column_values)\n options = {\n :query => {\n 'ZOHO_ACTION' => 'ADDROW',\n },\n :body => column_values\n }\n\n send_request get_uri(table_name), 'post', options\n end",
"def add_rows(sheet)\n # Do nothing\n end",
"def add_column(obj)\n raise(StandardError, \"can't add columns after adding rows\") if rows_count > 0\n obj = DataColumn.new(obj) unless obj.is_a?(DataColumn)\n obj.close\n @columns << obj\n self\n end",
"def add(data)\n create(data)\n end",
"def add(data)\n create(data)\n end",
"def insert(row, values)\n values = Array(values)\n unless values.empty?\n @data.expand(row, values.count)\n @data.values.insert row, Array.new([@data.columns_count, values.count].max) { |index| values[index] }\n end\n self\n end",
"def build_row(data = self.data)\n values = data.to_a\n keys = self.data.column_names.to_a\n hash = {}\n values.each_with_index do |val, i|\n key = (keys[i] || i).to_s\n hash[key] = val\n end\n line = hash.to_json.to_s\n output << \" #{line}\"\n end",
"def increase_rows(row)\n @sheet_data.size.upto(row) do\n @sheet_data << Array.new(@sheet_data[0].size)\n end\n end",
"def write_line(arr)\n @sheet.row(@current_row).concat arr\n next_row\n end",
"def create_row(params)\n # add the keys if they don't exist\n params.each do | key, value |\n if(!@worksheet_obj.list.keys.include?(key))\n add_key(key)\n end\n end\n # save key changes\n if(@worksheet_obj.dirty?)\n @worksheet_obj.synchronize\n end\n #push the new row\n @worksheet_obj.list.push(params)\n @worksheet_obj.save\n end",
"def +(other)\n if columns != columns.union(other.columns)\n raise ArgumentError, \"can't added two sets of rows with different columns\"\n end\n\n rows = @rows + other.rows_data\n self.class.new(rows, columns, pre_built_rows: true)\n end",
"def add(rows, columns, character=\"O\")\n raise ArgumentError.new(\"rows and columns should be greater than 0\") if rows < 1 || columns < 1\n raise ArgumentError.new(\"rows and columns should be less than or equal to 250\") if rows > 250 || columns > 250\n # TODO : to change the size of the bitmap(matrix) by calling this method multiple times comment the following line.\n raise ArgumentError.new(\"rows and columns should be less than or equal to 250\") if self.data.is_a?(Matrix) && (rows > self.data.row_count || columns > self.data.column_count)\n @data = Matrix.build(rows, columns) {character}\n end",
"def feed_rows(rows)\n write_bytes(27, 74, rows)\n end",
"def add_row_vector(row_vector)\n AddRowVector.new(\n first_row_vector: self,\n second_row_vector: row_vector\n ).call\n end",
"def add_cells (row_key, cells)\r\n cells.each{|item|\r\n @table.put(row_key, {(item[\"col_family\"]+':'+item[\"col_name\"]) => item[\"value\"]})\r\n } \r\n end",
"def add_data_in_table(data_set)\n case\n when data_set.is_a?(Daru::DataFrame)\n return ArgumentError unless data_set.index.is_a?(Daru::Index)\n\n rows = add_dataframe_data(data_set)\n when data_set.is_a?(Daru::Vector)\n rows = add_vector_data(data_set)\n when data_set.is_a?(Array)\n return GoogleVisualr::DataTable.new if data_set.empty?\n\n rows = add_array_data(data_set)\n when data_set.is_a?(Hash)\n @table = GoogleVisualr::DataTable.new(data_set)\n return\n else\n raise ArgumentError # TODO: error msg\n end\n @table.add_rows(rows)\n @table\n end",
"def create_row(hash)\n raise ORM::TableError, \"Something went wrong.\" unless hash[:id].present?\n\n update_counter(hash[:id])\n result_table = table << hash\n File.write(@table_path, JSON.generate(result_table))\n end",
"def add_recipe(new_recipe)\n @recipearray << new_recipe\n update_csv\n end",
"def write_row(row)\n @csv << row\n\n self\n end",
"def add_row(pixels)\n @width = pixels.length if @width.nil?\n @rows << pixels.map { |c| @color_map[c] } # TODO: truncate & fill to force width?\n end",
"def push(*rows)\n rows.each { |row| self << row }\n self\n end",
"def append(new_data)\n end",
"def addrowcol row,col\n return if @col.nil? or @col == -1 # contradicts comment on top\n return if @row.nil? or @row == -1\n @col += col\n @row += row\n @window.wmove @row, @col\n \n end",
"def header_row data\n data = get_cells data unless data.is_a?(Array)\n add_row data, \"!\"\n end",
"def append_rows(reader, table_schemas_lookup, row_transformer, validator = nil, copy_options = [])\n add_rows(reader, table_schemas_lookup, row_transformer, validator, copy_options, AddNewData.new('append'))\n end",
"def append_rows(reader, table_schemas_lookup, row_transformer, validator = nil, copy_options = [])\n add_rows(reader, table_schemas_lookup, row_transformer, validator, copy_options, AddNewData.new('append'))\n end",
"def push(*args)\n args.each do |obj|\n if obj.is_a?(String) || obj.is_a?(Integer)\n td = Table::Row::Data.new(obj.to_s)\n super(td)\n next\n else\n expect(obj, [Data, Header])\n end\n super(obj)\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 add_row(fields = [])\n if fields.length != self.columns.length\n raise RuntimeError, 'Invalid number of columns!'\n end\n formatted_fields = fields.map.with_index { |field, idx|\n # Remove whitespace and ensure String format\n field = format_table_field(field.to_s.strip, idx)\n\n if (colprops[idx]['MaxWidth'] < field.to_s.length)\n old = colprops[idx]['MaxWidth']\n colprops[idx]['MaxWidth'] = field.to_s.length\n end\n\n field\n }\n\n rows << formatted_fields\n end",
"def add(data)\n params = self.params\n data['add']['parameters'].each { |k,v|\n params[k] = v\n }\n write(params)\n data['add']['parameters']\n end",
"def add_data_elements\n \n end",
"def add_row( task )\n unless self.tasks.include?( task )\n timesheet_row = TimesheetRow.new\n timesheet_row.task = task\n\n self.timesheet_rows.push( timesheet_row )\n\n return timesheet_row\n else\n return nil\n end\n end",
"def add_payment_entry_row\n @ac = ApplicationController.new\n \n @day = params[:payment_date][3..4]\n @month = params[:payment_date][0..1]\n @year = params[:payment_date][6..9]\n \n @total_payment = params[:amount].to_s\n 3.times do\n @total_payment.sub!(\",\", \"\")\n end\n @total_payment = @total_payment.to_f\n \n @pfd = PaymentFromDestination.create(:payment_date => \"#{@year}-#{@month}-#{@day}\", :payment_num => params[:payment_num], :destination_id => params[:destination_id], :job_id => params[:job_id], :tickets => params[:tickets], :net_mbf => params[:net_mbf], :tonnage => params[:tonnage], :total_payment => @total_payment, :wood_type => params[:wood_type])\n end",
"def add(column, value)\n \n # If we see a column we don't recognize, stop everything\n if (@params[column] == \"\")\n puts(\"Unrecognized column\")\n else\n # We have a hash of arrays for when we have multiple criteria for one column\n @params[column].push(value)\n end\n\n end",
"def addNewData(data)\n\t\tif(data.is_a?(Array))\n\t\t\t@availProofs = @availProofs + data\n\t\telse\n\t\t\t@availProofs.push(data)\n\t\tend\n\tend",
"def insert_row filename, lineno, text\n d = _read filename\n d.insert(lineno, text)\n _write filename, d\n 0\n end",
"def [](row, sdata=nil)\n @data = Array.new if @data.nil?\n @data.push(Hash.new()) if (@data.last()).nil?\n (@data.last())[row] = sdata if !stdata.nil?\n end",
"def insert(*args)\n dataset.insert(*args)\n self\n end",
"def add_row(numbers)\n row = []\n row.push(numbers.split(\" \").map!{|j| j.to_i})\n row.flatten!\n @arr << row \nend",
"def add_element (element, row_num, col_num)\n #puts \"adding element #{element} #{row_num} #{col_num}\"\n @rows[row_num].add element\n @columns[col_num].add element\n @blocks.block(row_num, col_num).add element\n end",
"def create_rows\n (row_count.to_i - rows.size).times { rows.create(position: rows.size) }\n end"
] |
[
"0.85498613",
"0.7993887",
"0.7834648",
"0.7552865",
"0.747617",
"0.74530756",
"0.7377337",
"0.72740483",
"0.7259757",
"0.7140334",
"0.7078779",
"0.7056619",
"0.6937684",
"0.69340885",
"0.69019437",
"0.6847979",
"0.6814924",
"0.6814072",
"0.67863846",
"0.6785863",
"0.6769066",
"0.66923225",
"0.66845435",
"0.6680262",
"0.6665022",
"0.66061753",
"0.65975606",
"0.6580024",
"0.6532433",
"0.6529301",
"0.6461033",
"0.6446919",
"0.6436201",
"0.64210886",
"0.6405626",
"0.63720304",
"0.63343686",
"0.63318187",
"0.6319794",
"0.6314319",
"0.62749904",
"0.6262969",
"0.62395525",
"0.62394893",
"0.623501",
"0.6205439",
"0.6176231",
"0.61289006",
"0.6127104",
"0.6115175",
"0.61013484",
"0.61004883",
"0.6090214",
"0.60882556",
"0.60854506",
"0.6083892",
"0.6083892",
"0.60731846",
"0.60725915",
"0.6068914",
"0.60672045",
"0.606555",
"0.6064829",
"0.6064829",
"0.60621",
"0.60613334",
"0.6057243",
"0.6047902",
"0.6041021",
"0.6020978",
"0.60146075",
"0.5979817",
"0.59794956",
"0.5930171",
"0.5924886",
"0.59073365",
"0.59017015",
"0.5893918",
"0.588498",
"0.58845454",
"0.588325",
"0.58723414",
"0.5859676",
"0.5837389",
"0.5837389",
"0.5829966",
"0.57646483",
"0.5750517",
"0.573103",
"0.5727465",
"0.5727069",
"0.5722679",
"0.571208",
"0.5711185",
"0.57077897",
"0.56903094",
"0.56838334",
"0.5670057",
"0.56346285",
"0.5634196"
] |
0.6086264
|
54
|
retrieve the column info structure for the given offset. The offset pertains to the visible offset not actual offset in data model. These two differ when we move a column.
|
def get_column index
return @chash[index] if @chash[index]
# create a new entry since none present
c = ColumnInfo.new
c.index = index
@chash[index] = c
return c
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_column\n @col_offset\n end",
"def column_for_position(position); end",
"def column_for_position(position); end",
"def column_for_position(position); end",
"def _calculate_column_offsets\n total = 0\n coffsets = []\n ctr = 0\n ## ix will have gaps in between for hidden fields\n each_column { | c, ix|\n v = c.width\n coffsets[ctr] = total\n ctr += 1\n total += v + 2 ## blank space plus separator\n }\n return coffsets\n end",
"def store_colinfo(firstcol=0, lastcol=0, width=8.43, format=nil, hidden=0, level=0, collapsed=0) #:nodoc:\n record = 0x007D # Record identifier\n length = 0x000B # Number of bytes to follow\n\n # Excel rounds the column width to the nearest pixel. Therefore we first\n # convert to pixels and then to the internal units. The pixel to users-units\n # relationship is different for values less than 1.\n #\n width ||= 8.43\n if width < 1\n pixels = width *12\n else\n pixels = width *7 +5\n end\n pixels = pixels.to_i\n\n coldx = (pixels *256/7).to_i # Col width in internal units\n grbit = 0x0000 # Option flags\n reserved = 0x00 # Reserved\n\n # Check for a format object\n if !format.nil? && format.kind_of?(Format)\n ixfe = format.get_xf_index\n else\n ixfe = 0x0F\n end\n\n # Set the limits for the outline levels (0 <= x <= 7).\n level = 0 if level < 0\n level = 7 if level > 7\n\n\n # Set the options flags. (See set_row() for more details).\n grbit |= 0x0001 if hidden != 0\n grbit |= level << 8\n grbit |= 0x1000 if collapsed != 0\n\n header = [record, length].pack(\"vv\")\n data = [firstcol, lastcol, coldx,\n ixfe, grbit, reserved].pack(\"vvvvvC\")\n\n prepend(header, data)\n end",
"def column_info(method)\n column = @object.column_for_attribute(method) if @object.respond_to?(:column_for_attribute)\n \n # translated attributes dont have a column info at this point\n # check the associated translation class\n if not column\n tx_info = translation_info(method)\n if tx_info\n column = tx_info[:column]\n end\n end\n \n column\n end",
"def get_column_for(tag_name, subfield_name)\n if options_config.include?(tag_name) and options_config[tag_name].include?(\"layout\")\n f = options_config[tag_name][\"layout\"][\"fields\"].assoc(subfield_name)\n return f if f\n end\n return [subfield_name, {\"cols\" => 1}]\n end",
"def get_line_and_column_from_chunk(offset)\n if offset.zero?\n return [@chunk_line, @chunk_column]\n end\n\n string =\n offset >= @chunk.size ? @chunk : @chunk[0..offset-1]\n\n line_count = string.count(\"\\n\")\n\n column = @chunk_column\n if line_count > 0\n lines = string.split(\"\\n\")\n column = lines.empty? ? 0 : lines[-1].size\n else\n column += string.size\n end\n\n [@chunk_line + line_count, column]\n end",
"def char_offset(offset)\n effective_line = @locator.line_for_offset(offset)\n locator.char_offset(offset) + (effective_line * @leading_line_offset) + @leading_offset\n end",
"def get_column_descriptors\n #skip past header to get to column information\n @data.seek(HEADER_LENGTH)\n \n # column names are the first 128 bytes and column info takes up the last 72 bytes. \n # byte 130 contains a 16-bit column type\n # byte 136 contains a 16-bit length field\n @columns = []\n @column_count.times do\n name, type, length = @data.read(200).unpack('A128 x S x4 S')\n if length > 0\n @columns << Column.new(name.strip, type, length)\n end\n end\n # Reset the column count in case any were skipped\n @column_count = @columns.size\n \n @columns\n end",
"def offset_info(reim_doc_id)\n #debugger\n RiemCpOffset.where(\"reim_doc_head_id=? and cp_doc_head_id=#{self.id}\",reim_doc_id).first\n end",
"def get_offset\n @offset\n end",
"def getCol\n return @col\n end",
"def column\n @__col\n end",
"def column\n location&.column\n end",
"def struct_offsets(definition, offset)\n padding = 0\n offsets = []\n definition.each do |mapping|\n key, data_type = mapping\n if sizeof_type(data_type) > padding\n offset = offset + padding\n end\n\n offsets.push(offset)\n\n offset = offset + sizeof_type(data_type)\n padding = calc_padding(offset)\n end\n\n offsets\n end",
"def metaDataFor(offset)\n previousMetadata = \"unknown\"\n @lineStateMachine.pages.sort_by(&:reverse).each do |metadata, wordOffset|\n if (wordOffset < offset) then\n previousMetadata = metadata\n else\n return previousMetadata\n end\n end\n return previousMetadata\n end",
"def to_col(pos)\n\t (1..@cols).include?(pos) ? pos - 1 : nil\n\tend",
"def xy(offset_x, offset_y)\n @board[3 * offset_y + offset_x - 4]\n end",
"def get_column(ordinal_number, split = true)\n column = @columns[ordinal_number.to_i]\n if split\n column = column.split \".\"\n column[0]\n else\n column\n end\n end",
"def columns\n get_metadata unless @columns\n return @columns\n end",
"def columns \n @c\n end",
"def columns\n @columns ||= begin\n column_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end",
"def column_for_attribute(attr)\n FauxColumnInfo.new(self.class.types[attr])\n end",
"def offset_changes\n changes(col_offset: @col_offset, row_offset: @row_offset)\n end",
"def columns; @columns; end",
"def char_offset(offset)\n raise \"Should not be called\"\n end",
"def hidden_tuple_from_col col, type\n\t\thidden_tuple get_col_cells(col), type\n\tend",
"def to_sql_query_info(offset)\n \"SELECT * FROM #{@model.quoted_table_name} WHERE \" +\n \" #{quote_column(@model.primary_key)} = (($id - #{offset}) / #{ThinkingSphinx.indexed_models.size})\"\n end",
"def record(offset)\n return nil unless offset\n return infimum if offset == pos_infimum\n return supremum if offset == pos_supremum\n\n cursor(offset).forward.name(\"record[#{offset}]\") do |c|\n # There is a header preceding the row itself, so back up and read it.\n header = c.peek { record_header(c) }\n\n this_record = UserRecord.new(\n format: page_header.format,\n offset: offset,\n header: header,\n next: header.next.zero? ? nil : header.next\n )\n\n if record_format\n this_record.type = record_format[:type]\n\n # Used to indicate whether a field is part of key/row/sys.\n # TODO: There's probably a better way to do this.\n fmap = %i[key row sys].each_with_object({}) do |k, h|\n this_record[k] = []\n record_format[k].each { |f| h[f.position] = k }\n end\n\n # Read the fields present in this record.\n record_fields.each do |f|\n p = fmap[f.position]\n c.name(\"#{p}[#{f.name}]\") do\n this_record[p] << FieldDescriptor.new(\n name: f.name,\n type: f.data_type.name,\n value: f.value(c, this_record),\n extern: f.extern(c, this_record)\n )\n end\n end\n\n # If this is a node (non-leaf) page, it will have a child page number\n # (or \"node pointer\") stored as the last field.\n this_record.child_page_number = c.name(\"child_page_number\") { c.read_uint32 } unless leaf?\n\n this_record.length = c.position - offset\n\n # Add system field accessors for convenience.\n this_record.sys.each do |f|\n case f[:name]\n when \"DB_TRX_ID\"\n this_record.transaction_id = f[:value]\n when \"DB_ROLL_PTR\"\n this_record.roll_pointer = f[:value]\n end\n end\n end\n\n Innodb::Record.new(self, this_record)\n end\n end",
"def columns\n single_record unless @columns\n @columns || []\n end",
"def offset()\n @offset__\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def get_col_from_index(idx)\n idx%cols\n end",
"def columns\n ColumnCollection.new(@data)\n end",
"def columns\n @header.to_a\n end",
"def get_column_metadata( table_name )\r\n sql=<<-SQL\r\n select column_name\r\n from information_schema.columns\r\n where\r\n table_schema = '#{ @schema || 'public' }' and\r\n table_catalog = '#{ @catalog }' and\r\n table_name = '#{ table_name }'\r\n order by ordinal_position;\r\n SQL\r\n column_names = []\r\n execute( sql.trim_tabs ).each do |record|\r\n column_names.push record.column_name\r\n end\r\n return column_names\r\n end",
"def data_column_info_for_columnheader(columnheader)\r\n method_index = method_index_for_columnheader(columnheader)\r\n\r\n data_header_ch = {}\r\n data_header_ch[:columnheader] = columnheader\r\n data_header_ch[:columnnr] = 1 + columnheaders_raw.index(columnheader)\r\n\r\n if method_index.nil? # columnheader does not appear in the method sheet\r\n data_header_ch[:definition] = columnheader\r\n else\r\n data_header_ch[:definition] = Array(data_description_sheet.column(*WBF[:column_definition_col]))[method_index].blank? ? columnheader : clean_string(Array(data_description_sheet.column(*WBF[:column_definition_col]))[method_index])\r\n data_header_ch[:unit] = clean_string(Array(data_description_sheet.column(*WBF[:column_unit_col]))[method_index])\r\n data_header_ch[:comment] = clean_string(Array(data_description_sheet.column(*WBF[:column_keywords_col]))[method_index])\r\n data_header_ch[:import_data_type] = clean_string(Array(data_description_sheet.column(*WBF[:group_methodvaluetype_col]))[method_index])\r\n end\r\n\r\n return data_header_ch\r\n\r\n end",
"def offset_of(member)\n self::MEMBERS_HASH[member].offset\n end",
"def to_find_offset\n @offset\n end",
"def columns()\n (cr=@records.get(GRT_COLROW)) ? cr[0] : nil\n end",
"def get_data_column(d, colname)\n dc = []\n\n if (d == nil or d.stuffing_data == nil)\n log_and_print 'WARN: Request for document data column with either a nil document or nil stuffing data'\n return []\n end\n\n d.stuffing_data.find_all do |item| \n if item[colname] != nil \n dc << item[colname] \n end\n end\n return dc\n end",
"def column(pos = T.unsafe(nil)); end",
"def cols\n @cols\n end",
"def columns\n @columns\n end",
"def columns\n @columns ||= @csv_data[0].zip(*@csv_data[1..])\n end",
"def get_columns\n return @columns\n end",
"def ListView_GetColumn(hwnd, iCol, pcol)\n send_listview_message(hwnd, :GETCOLUMN, wparam: iCol, lparam: pcol)\n end",
"def columns\n if @column_names\n columns = []\n\n # First match against fully named columns, e.g. 'attribute:name'\n @column_names.each{|cn| columns << owner.columns_hash[cn] if owner.columns_hash.has_key?(cn)}\n\n # Now match against aliases if the number of columns found previously do not\n # match the expected @columns_names size, i.e. there's still some missing.\n if columns.size != @column_names.size\n columns_left = @column_names - columns.map{|column| column.name}\n owner.columns_hash.each { |name,column| columns << column if columns_left.include?(column.alias) }\n end\n\n columns\n else\n owner.columns\n end\n end",
"def offset\n @object.send(:read_attribute,@startAttribute)\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def columns; end",
"def content_offset(offset, dimension)\n return 0 unless offset >= dimension\n\n offset - dimension\n end",
"def get_column(index)\n column = []\n self.rows.times do |i|\n column.push(@state[i][index])\n end\n\n column\n end",
"def columns\n end",
"def get_column(col_num)\n column = []\n @grid.each do |row|\n column << row[col_num]\n end\n column\n end",
"def offsetof(typ, membername)\n return typ.offset_of(membername)\n end",
"def get_schema_info(klass, options)\n info = []\n klass.columns.each do |col|\n attrs = []\n attrs << \"default(#{quote(col.default)})\" unless col.default.nil?\n attrs << \"not null\" unless col.null\n attrs << \"primary key\" if col.name == klass.primary_key\n\n col_type = col.type.to_s\n if col_type == \"decimal\"\n col_type << \"(#{col.precision}, #{col.scale})\"\n else\n col_type << \"(#{col.limit})\" if col.limit\n end\n\n # Check out if we got a geometric column\n # and print the type and SRID\n if col.respond_to?(:geometry_type)\n attrs << \"#{col.geometry_type}, #{col.srid}\"\n end\n\n # Check if the column has indices and print \"indexed\" if true\n # If the indice include another colum, print it too.\n if options[:simple_indexes] # Check out if this column is indexed\n indices = klass.connection.indexes(klass.table_name)\n if indices = indices.select { |ind| ind.columns.include? col.name }\n indices.each do |ind|\n ind = ind.columns.reject! { |i| i == col.name }\n attrs << (ind.length == 0 ? \"indexed\" : \"indexed => [#{ind.join(\", \")}]\")\n end\n end\n end\n info << { :name => col.name, :type => col_type, :attrs => attrs.join(\", \"), :human_name => klass.respond_to?(:human_attribute_name) ? klass.human_attribute_name(col.name) : col.name }\n end\n info\n end",
"def spatial_column_info(table_name)\n @spatial_column_info ||= {}\n @spatial_column_info[table_name.to_sym] ||= SpatialColumnInfo.new(self, table_name.to_s)\n end",
"def columns\n @cr[2] & 0x7f\n end",
"def offset(*) end",
"def columns\n @columns = @clazz.columns_hash.map do |name, column|\n [name, @columns[name] || Column.new(column, @dump)]\n end.to_h.with_indifferent_access\n end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def column; end",
"def col\r\n @lines[@line_num].cursor\r\n end",
"def list_columns\n columns\n end",
"def get_view_columns\n if @_view_columns.nil?\n set_default_view_columns\n end\n @_view_columns\n end",
"def spatial_column_info(table_name)\n @spatial_column_info ||= {}\n @spatial_column_info[table_name.to_sym] = SpatialColumnInfo.new(self, table_name.to_s)\n end",
"def column(name)\n @name_to_columns[name]\n end",
"def columns\n must_be_open!\n return @columns.map(&:first)\n end",
"def dig_column(klass, name_or_segments)\n segments = name_or_segments.is_a?(Array) ? name_or_segments : name_or_segments.to_s.split(\".\")\n column_name = segments.shift\n if( segments.empty? )\n return klass.columns_hash[column_name]\n else\n reflection = klass.reflect_on_association(column_name.to_sym)\n raise \"Can't find reflection for: #{klass}.#{column_name}\" unless reflection\n raise \"Can't fetch column from has_many association: #{klass}.#{column_name}\" if reflection.macro == :has_many\n return dig_column(reflection.klass, segments)\n end\n end",
"def chooseColumn\n @metadata.chooseColumn\n end",
"def col; end",
"def offset\n fil_header[:offset]\n end",
"def normalize_offset(offset); end",
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def columns(table_name, name = nil)#:nodoc:\n sql = \"SHOW FIELDS FROM #{quote_table_name(table_name)}\"\n columns = []\n result = execute(sql, name)\n result.each do |field|\n klass = field[1] =~ /geometry|point|linestring|polygon|multipoint|multilinestring|multipolygon|geometrycollection/i ? ActiveRecord::ConnectionAdapters::SpatialMysql2Column : ActiveRecord::ConnectionAdapters::Mysql2Column\n columns << klass.new(field[0], field[4], field[1], field[2] == \"YES\")\n end\n columns\n end",
"def get_hidden_columns\n @hidden_columns_cache = @columns - get_visible_columns if @hidden_columns_cache.nil?\n @hidden_columns_cache\n end",
"def get_col_from_index(index)\n index % 8 == 0 ? 8 : index % 8\n end",
"def columns()\n \t cols = {}\n cols['oml_sender_id'] = {:type => 'INTEGER'}\n cols['oml_seq'] = {:type => 'INTEGER'}\n cols['oml_ts_client'] = {:type => 'REAL'}\n cols['oml_ts_server'] = {:type => 'REAL'}\n \t if @filters.size > 0\n \t @filters.each do |f|\n cols.merge!(f.columns)\n \t end\n \t else\n #appDef = AppDefinition[@application.to_s]\n appDef = @application.appDefinition\n appDef.measurements[@mdef].metrics.each do |name, opts|\n #[name] = {:type => type, :description => description, :seqNo => @metrics.length}\n case (type = opts[:type])\n when 'xsd:string' then\n cols[name] = {:type => 'TEXT'}\n when 'xsd:long', 'xsd:float' then\n if @single_sample_mode\n cols[name] = {:type => Xsd2SqlType[type]}\n else\n cols[\"#{name}_avg\"] = cols[\"#{name}_min\"] = cols[\"#{name}_max\"] = {:type => 'REAL'}\n end\n else\n error \"Type '#{opts[:type]}' for '#{name}' not implemented\"\n end\n \t end\n \t end\n cols\n \tend",
"def columns\n self.class.instance_variable_get(:@columns)\n end",
"def fetch(name, offset=0)\n addr = pfa(name)\n @vm.fetch(addr + cells(offset))\n end",
"def column(id)\n @columns[id]\n end",
"def columns\n @pz.group_by.each_with_index { |val, n| column_id(n) }\n end",
"def col_by_id(id, raise_on_nil = false)\n c = @columns_hash[id.to_s]\n raise \"Column ID `#{id}` was requested, however it was not defined by method 'columns'\" if raise_on_nil and c.nil?\n return c\n end",
"def columns\n @columns_hash.values\n end",
"def get_header_info\n @data.rewind\n \n #column_count_offset = 33, record_count_offset = 24, record_length_offset = 36\n @record_count, @data_offset, @record_length = data.read(HEADER_LENGTH).unpack(\"@24 I x4 I I\")\n @column_count = (@data_offset-400)/200\n end",
"def offset; end",
"def offset; end",
"def offset; end",
"def _columns\n cache_get(:_columns)\n end",
"def columns\n return @columns\n end"
] |
[
"0.62186426",
"0.59655404",
"0.59655404",
"0.59655404",
"0.5828985",
"0.57704616",
"0.5598626",
"0.5578441",
"0.5573682",
"0.55598956",
"0.54008937",
"0.5389818",
"0.538439",
"0.53585845",
"0.5340063",
"0.53385663",
"0.5331531",
"0.5317543",
"0.530272",
"0.5270082",
"0.5217466",
"0.51535237",
"0.514375",
"0.51367646",
"0.5108695",
"0.5096561",
"0.50643307",
"0.5062631",
"0.5060948",
"0.505984",
"0.5048962",
"0.5045103",
"0.5033603",
"0.50256985",
"0.50256985",
"0.50253445",
"0.5013326",
"0.5010291",
"0.50100124",
"0.5009827",
"0.49981624",
"0.4994981",
"0.49939996",
"0.49922577",
"0.4990768",
"0.4986652",
"0.49760747",
"0.49702823",
"0.49681324",
"0.49419105",
"0.49333033",
"0.49313694",
"0.49234813",
"0.49234813",
"0.4919747",
"0.49132597",
"0.49121976",
"0.48994052",
"0.48939955",
"0.48901138",
"0.4876474",
"0.48737147",
"0.4871923",
"0.48699993",
"0.486733",
"0.48551384",
"0.48551384",
"0.48551384",
"0.48551384",
"0.48551384",
"0.48551384",
"0.48551384",
"0.4854899",
"0.48533136",
"0.48474002",
"0.48460433",
"0.4845999",
"0.48436424",
"0.4843418",
"0.48388025",
"0.48373067",
"0.48361433",
"0.48285058",
"0.48273808",
"0.4825243",
"0.4819829",
"0.48196867",
"0.48159954",
"0.48122263",
"0.48051834",
"0.48046646",
"0.48016307",
"0.47982964",
"0.47870204",
"0.4786927",
"0.47868204",
"0.47868204",
"0.47868204",
"0.47827968",
"0.4781716"
] |
0.49867812
|
45
|
set width of a given column, any data beyond this will be truncated at display time.
|
def column_width colindex, width=:NONE
if width == :NONE
#return @cw[colindex]
return get_column(colindex).width
end
@_skip_columns[colindex] = true ## don't calculate col width for this.
get_column(colindex).width = width
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def column_width=(value)\n @column_width = value\n end",
"def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)\n change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)\n end",
"def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)\n change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)\n end",
"def change_column_width_raw(column_index, width)\n validate_workbook\n ensure_cell_exists(0, column_index)\n range = cols.get_range(column_index)\n range.width = width\n range.custom_width = true\n end",
"def change_column_width_raw(column_index, width)\n validate_workbook\n ensure_cell_exists(0, column_index)\n range = cols.get_range(column_index)\n range.width = width\n range.custom_width = true\n end",
"def adjust(column, length)\n return nil unless column_exists?(column)\n @columns[column][:length] = length if length > @columns[column][:length]\n end",
"def ListView_SetColumnWidth(hwnd, iCol, cx)\n send_listview_message(hwnd, :SETCOLUMNWIDTH, wparam: iCol, lparam: MAKELPARAM(cx, 0))\n end",
"def adjust_column_width\n grouped_columns = group_by{|column| column.width == \"0%\" ? \"without\" : \"with\"};\n with = grouped_columns[\"with\"] || []\n without = grouped_columns[\"without\"] || []\n # origin 5% keeped for selection column width\n used = with.inject(5){|total, column| column.width =~ /(\\d+)%$/ ? total + $1.to_i : total}\n begin\n avg_width = (100 - used) / without.size\n left_width = (100 - used) % without.size\n without.each{|col| col.width = \"#{avg_width}%\"}\n without.last.width = \"#{avg_width + left_width}%\"\n end if not without.empty?\n end",
"def width(val); @width = val; self; end",
"def width\n @column_widths.inject(0) { |s,r| s + r }\n end",
"def column_width colindex, width\n @cw[colindex] ||= width\n if @chash[colindex].nil?\n @chash[colindex] = ColumnInfo.new(\"\", width) \n else\n @chash[colindex].w = width\n end\n @chash\n end",
"def shrink\n column_size = table.columns_size\n ratio = ((natural_width - renderer.width) / column_size.to_f).ceil\n\n widths = (0...column_size).reduce([]) do |lengths, col|\n width = (renderer.column_widths[col] - ratio)\n # basically ruby 2.4 Numeric#clamp\n width = width < minimum_width ? minimum_width : width\n width = width > renderer.width ? renderer.width : width\n lengths << width\n end\n distribute_extra_width(widths)\n end",
"def column_width\n return @column_width\n end",
"def width(value)\n model.width = proc { value }\n end",
"def setwidth(width)\n @width = width\n end",
"def return_a_string_to_max_column_width(string, column_width_as_integer)\n string + \" \" * (column_width_as_integer - string.length)\nend",
"def return_a_string_to_max_column_width(string, column_width_as_integer)\n string + \" \" * (column_width_as_integer - string.length)\nend",
"def return_a_string_to_max_column_width(string, column_width_as_integer)\n string + \" \" * (column_width_as_integer - string.length)\nend",
"def width= w\n\t\t\t@width = w\n\t\t\t@column_width = nil\n\t\t\t@margin_width = nil\n\t\tend",
"def setCellWidth(cellContent, width)\n numCharsTooShort = width - cellContent.length\n if numCharsTooShort < 0\n # cellContent is too long, so truncate\n return cellContent[0, [width - 3, 0].max] + '.' * [3, width].min\n else\n # cellContent is requested width or too short, so right-pad with zero or more spaces\n return cellContent + ' ' * numCharsTooShort\n end\n end",
"def column_width\n column_headings.values.collect {|l| l.to_s.length}.max + 2\n end",
"def expand_column_widths\n columns_count = table.columns_count\n max_width = renderer.width\n extra_column_width = ((max_width - natural_width) / columns_count.to_f).floor\n\n widths = (0...columns_count).reduce([]) do |lengths, col|\n lengths << renderer.column_widths[col] + extra_column_width\n end\n distribute_extra_width(widths)\n end",
"def max_width(table_data, col)\n table_data.map do |row|\n Strings.sanitize(row[col].join).lines.map(&:length).max || 0\n end.max\n end",
"def max_width(table_data, col)\n table_data.map do |row|\n Strings.sanitize(row[col].join).lines.map(&:length).max || 0\n end.max\n end",
"def auto_adjust_widths\n column_widths = []\n\n rows.each do |row|\n row.columns.each_with_index do |col, i|\n column_widths[i] = [col.required_width, (column_widths[i] || 0)].max\n end\n end\n\n rows.each do |row|\n row.columns.each_with_index do |col, i|\n col.width = column_widths[i]\n end\n end\n end",
"def width=(value)\n\t\t\t@width = value\n\t\tend",
"def width=(value)\n\t\t\t@width = value\n\t\tend",
"def width=(width)\n @width = width || 0\n end",
"def width=(width)\n @width = width || 0\n end",
"def column(c=0)\n percent_width(g_col_width, column_width(c))\n end",
"def width=(new_width)\n resize_width(new_width)\n end",
"def width=(value)\n @width = value\n end",
"def width(value)\n attributes[:width] = value\n end",
"def width(value)\n @ole.Width = value\n nil\n end",
"def width(value)\n @ole.Width = value\n nil\n end",
"def width=(w)\n @view__.width = w\n end",
"def width=(width)\n @width = width.to_s\n\n setOption('width', @width)\n end",
"def set_Width(value)\n set_input(\"Width\", value)\n end",
"def width=(width)\n end",
"def setWidth(width)\n # This exists to deal with an inconsistency in IE's implementation where\n # it won't accept negative numbers in length measurements\n # FIXME: assert extractLengthValue(width.trim().toLowerCase()) >= 0 : \"CSS widths should not be negative\";\n \n DOM.setStyleAttribute(@element, \"width\", width)\n end",
"def width=(val)\n super\n fire_dimension_changed :width\n end",
"def column_width n\n column_widths[n] || 0\n end",
"def column=(column)\n @column = Utility.clamp(column, 0, GRID_COLUMNS - 1)\n end",
"def get_column_width(column_index = 0)\n width = get_column_width_raw(column_index)\n return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?\n (width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round\n end",
"def width=(value)\n @style.width = value\n end",
"def width\n @columns * @block_size\n end",
"def append_width(required_col)\n diff = required_col - @screen_size[1] + 1\n @screen.each.with_index do |row, i|\n @screen[i] = row + Array.new(diff)\n end\n @screen_size[1] += diff\n end",
"def get_column_width_raw(column_index = 0)\n validate_workbook\n validate_nonnegative(column_index)\n\n range = cols.locate_range(column_index)\n range && range.width\n end",
"def width\n return 0 if columns.empty?\n\n columns.size\n end",
"def width=(width)\n if width.nil?\n fail ArgumentError, 'invalid value for \"width\", width cannot be nil.'\n end\n @width = width\n end",
"def width=(_); end",
"def width=(_); end",
"def width=(width)\n if width.nil?\n fail ArgumentError, 'invalid value for \"width\", width cannot be nil.'\n end\n if width < 0\n fail ArgumentError, 'invalid value for \"width\", must be greater than or equal to 0.'\n end\n @width = width\n end",
"def column_width(n=0)\n sg = 0\n if n.zero?\n n = g_total_cols\n sg = g_side_gutter_width\n end\n (n*g_col_width) + ((n - 1)*g_gutter_width).ceil + (sg*2)\n end",
"def width=(width)\n if !width.nil? && width < 0\n fail ArgumentError, 'invalid value for \"width\", must be greater than or equal to 0.'\n end\n\n @width = width\n end",
"def adjust_width\n self.width = [[text_size('O' * @max_characters).width + padding * 2,\n @title ? text_size(@title).width + padding * 2 : 0].max, Graphics.width].min\n end",
"def size_col(col) #:nodoc:\n # Look up the cell value to see if it has been changed\n unless @col_sizes[col].nil?\n width = @col_sizes[col]\n\n # The relationship is different for user units less than 1.\n if width < 1\n return (width *12).to_i\n else\n return (width *7 +5 ).to_i\n end\n else\n return 64\n end\n end",
"def column_widths\n []\n end",
"def enforce\n assert_minimum_width\n padding = renderer.padding\n\n if natural_width <= renderer.width\n if renderer.resize\n expand_column_widths\n else\n renderer.column_widths.map do |width|\n padding.left + width + padding.right\n end\n end\n else\n if renderer.resize\n shrink\n else\n rotate\n end\n end\n end",
"def width(input)\n process(:width, input)\n end",
"def autofit_table_to_fixed_column_widths()\n # Open the document\n doc = Rjb::import('com.aspose.words.Document').new(@data_dir + \"TestFile.doc\")\n \n node_type = Rjb::import('com.aspose.words.NodeType')\n table = doc.getChild(node_type.TABLE, 0, true)\n \n # Disable autofitting on this table.\n autofit_behavior = Rjb::import(\"com.aspose.words.AutoFitBehavior\")\n table.autoFit(autofit_behavior.AUTO_FIT_TO_CONTENTS)\n\n # Save the document to disk.\n doc.save(@data_dir + \"TestFile.FixedWidth Out.doc\")\n # ExEnd\n preferred_width_type = Rjb::import(\"com.aspose.words.PreferredWidthType\")\n\n if (doc.getFirstSection().getBody().getTables().get(0).getPreferredWidth().getType() == preferred_width_type.AUTO) then\n puts \"PreferredWidth type is not auto.\"\n end\n\n if (doc.getFirstSection().getBody().getTables().get(0).getPreferredWidth().getValue() == 0) then\n puts \"PreferredWidth value is not 0.\"\n end\n\n if (doc.getFirstSection().getBody().getTables().get(0).getFirstRow().getFirstCell().getCellFormat().getWidth() == 0) then\n puts \"Cell width is not correct.\"\n end\n end",
"def fill_col_widths(picklist_column_widths)\n # populate width of dropdown columns by the length of their contents\n @col_widths.each do |category, widths|\n sum = 0\n widths.each_with_index do |w, i|\n if w.nil?\n @col_widths[category][i] = picklist_column_widths.shift\n end\n sum += @col_widths[category][i]\n end\n if category.to_s.length + 2 > sum\n width_factor = (category.to_s.length + 2).to_f / sum.to_f\n widths.each_index do |i|\n @col_widths[category][i] *= width_factor\n end\n end\n end\n end",
"def ds_width=(width)\n list = (width.is_a?(String) ? ALLOWED_STRING_WIDTHS : ALLOWED_NUMERIC_WIDTHS)\n width = self.class.fetch_or_fallback(list, width, 'two_thirds') if width\n @ds_width_class = if width.is_a?(String)\n \"ds_input--fluid-#{width}\"\n elsif width\n \"ds_input--fixed-#{width}\"\n end\n end",
"def width(value)\n fail InvalidWidth if x_out_of_bounds?(value)\n\n attributes[:geometry][:width] = value\n end",
"def min_width=(min_width)\n @min_width = min_width\n end",
"def set_column(*args)\n data = args\n cell = data[0]\n\n # Check for a cell reference in A1 notation and substitute row and column\n if cell =~ /^\\D/\n data = substitute_cellref(*args)\n\n # Returned values $row1 and $row2 aren't required here. Remove them.\n data.shift # $row1\n data.delete_at(1) # $row2\n end\n\n return if data.size < 3 # Ensure at least $firstcol, $lastcol and $width\n return if data[0].nil? # Columns must be defined.\n return if data[1].nil?\n\n # Assume second column is the same as first if 0. Avoids KB918419 bug.\n data[1] = data[0] if data[1] == 0\n\n # Ensure 2nd col is larger than first. Also for KB918419 bug.\n data[0], data[1] = data[1], data[0] if data[0] > data[1]\n\n # Limit columns to Excel max of 255.\n data[0] = ColMax - 1 if data[0] > ColMax - 1\n data[1] = ColMax - 1 if data[1] > ColMax - 1\n\n @colinfo.push(data)\n\n # Store the col sizes for use when calculating image vertices taking\n # hidden columns into account. Also store the column formats.\n #\n firstcol, lastcol, width, format, hidden = data\n\n width ||= 0 # Ensure width isn't undef.\n hidden ||= 0\n width = 0 if hidden > 1 # Set width to zero if col is hidden\n\n (firstcol .. lastcol).each do |col|\n @col_sizes[col] = width\n @col_formats[col] = format unless format.nil?\n end\n end",
"def column_space=(val)\n @column_space = val\n update_xy\n end",
"def width\n @width ||= (cells.map(&:to_s) << to_s).map(&:size).max\n end",
"def width=(_arg0); end",
"def change_column_font_size(col=0, font_size=10)\n # Get style object\n xf_id = xf_id(get_col_style(col))\n # Get copy of font object with modified size\n font = deep_copy(@workbook.fonts[xf_id[:fontId].to_s][:font])\n font[:sz][:attributes][:val] = font_size\n # Update font and xf array\n change_column_font(col, Worksheet::SIZE, font_size, font, xf_id)\n end",
"def width\n cols\n end",
"def change_column(table_name, column_name, type, options = {})\n execute(\n \"ALTER TABLE #{quote_table_name(table_name)} \"+\n \"ALTER COLUMN #{quote_column_name(column_name)} \"+\n \"SET DATA TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\",\n SCHEMA_LOG_NAME\n )\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end",
"def border_width=(width)\n self.each {|cell| cell.border_width = width}\n end",
"def change_column(table_name, column_name, type, options = {})\n sql = \"ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n add_column_options!(sql, options)\n execute(sql)\n end",
"def full_width_column(options={}, &block)\n row(options) do\n column(12, &block)\n end\n end",
"def increase_columns(column)\n @sheet_data.each do |r|\n r.size.upto(column) do\n r << nil\n end\n end\n end",
"def chunk_col(col, width)\n words = col.split\n first_word = true\n len = 0\n chunks = []\n chunk = []\n words.each do |w|\n if first_word\n first_word = false\n len += w.length\n else\n len += w.length + 1\n end\n if len > width\n chunks << chunk\n len = w.length\n chunk = [w]\n else\n chunk << w\n end\n end\n chunks << chunk unless chunk.empty?\n chunks.map {|c| c.join(\" \")}\n end",
"def width\n ensure_complete!\n sum_width = cell_widths.reduce(&:+)\n [param(:width, 0), sum_width].max\n end",
"def admin_data_get_value_for_column(column, source, options = {})\n options.reverse_merge!(:limit => 400)\n if column.type == :datetime\n d = source.send(column.name)\n d.strftime('%m/%d/%Y %H:%M:%S %p') unless d.blank?\n else\n value = source.send(column.name)\n return value if options[:limit].blank?\n if column.type == :string || column.type == :text\n # truncate method fails in handling serialized array stored in string column\n begin\n truncate(value,:length => options[:limit])\n rescue\n '<actual data is not being shown because truncate method failed.>'\n end\n end\n end\n end",
"def text_column_width\n (width - (columns - 1) * gutter_width) / columns\n end",
"def fit_width; end",
"def length_within(table, column, options)\n within(table, \"length(#{table}.#{column})\", options)\n end",
"def width(accessoryWidth)\n return if accessoryWidth.nil?\n @dimensions[:width] = [accessoryWidth.to_f, MIN_WIDTH, MAX_WIDTH].sort[1]\n end",
"def column=(_); end",
"def column_space(); @column_space; end",
"def fix_row_widths\n\n fill_cells(@row_offset - 1, 0)\n\n max = 0\n\n @data.each_with_index do |row|\n max = row.length unless max >= row.length\n end\n\n @data.each_with_index do |row,idx|\n if row.length < max\n row = row + [ @base_cell_options.merge({content: ''}) ] * (max - row.length)\n @data[idx] = row\n end\n end\n\n end",
"def width(value=nil)\n make_constraint(:width, :equal, value)\n end",
"def calc_width(col, colspan, length, width)\n if @scale.empty?\n width = \"#{100*length/width}%\"\n else\n warr = @scale[col,colspan]\n if warr.length == 1\n if warr[0] == 'auto'\n return nil\n else\n return warr[0]\n end\n elsif warr.include?('auto') or warr.include?('')\n return nil # auto is html default \n else\n ws = 0\n apercentage = false\n afixedwidth = false\n warr.each do |w|\n ws += w.to_i\n if w[-1,1] == '%'\n apercentage = true\n else\n afixedwidth = true\n end\n end\n if apercentage and afixedwidth\n return nil # both kinds unreconcilable\n elsif apercentage and not afixedwidth\n return \"#{ws}%\"\n else\n return \"#{ws}\"\n end\n end\n end\n return nil # should never get here, but just in case\n end",
"def rejigger(w)\n @width = w if w > @width\n end",
"def minimum_width\n table.columns_size * MIN_WIDTH + border_size\n end",
"def natural_width\n renderer.column_widths.inject(0, &:+) + border_size + padding_size\n end",
"def set_tyre_width(tyre_width)\n\t\t@tyre_width = tyre_width\n\tend",
"def limit\n @column[:limit] if @column\n end",
"def ListView_GetColumnWidth(hwnd, iCol) send_listview_message(hwnd, :GETCOLUMNWIDTH, wparam: iCol) end",
"def width\n begin\n (@num_cols.to_i) * (@col_width.to_i + @gutter.to_i)\n rescue\n 0\n end\n end",
"def set_form_col col1=@curpos\n @curpos = col1 || 0 # NOTE we set the index of cursor here\n c = @col + @col_offset + @curpos - @pcol\n min = @col + @col_offset\n max = min + @width\n c = min if c < min\n c = max if c > max\n #$log.debug \" #{@name} FIELD set_form_col #{c}, curpos #{@curpos} , #{@col} + #{@col_offset} pcol:#{@pcol} \"\n setrowcol nil, c\n end",
"def columns=(integer); end",
"def autowidth(widtharray)\n return if value.nil?\n\n if styles.cellXfs[style].alignment && styles.cellXfs[style].alignment.wrap_text\n first = true\n value.to_s.split(/\\r?\\n/, -1).each do |line|\n if first\n first = false\n else\n widtharray << 0\n end\n widtharray[-1] += string_width(line, font_size)\n end\n else\n widtharray[-1] += string_width(value.to_s, font_size)\n end\n widtharray\n end",
"def pad(col, value)\n @sizes[col] = [value.try(&:size) || 0, @sizes[col] || 0].max\n end",
"def endCol; @col + @width - 1; end"
] |
[
"0.80435437",
"0.76471424",
"0.7587935",
"0.7513679",
"0.73899555",
"0.7049284",
"0.6824156",
"0.6741879",
"0.671783",
"0.6681531",
"0.6662315",
"0.66044116",
"0.65847903",
"0.6490916",
"0.64883727",
"0.64860964",
"0.64860964",
"0.64860964",
"0.64485145",
"0.63773966",
"0.6315832",
"0.63061386",
"0.62955743",
"0.62955743",
"0.629026",
"0.6285677",
"0.6285677",
"0.62508285",
"0.62508285",
"0.6240041",
"0.6192305",
"0.6189554",
"0.61846906",
"0.61584896",
"0.61584896",
"0.61527103",
"0.6152228",
"0.61362267",
"0.60840034",
"0.6082383",
"0.6061986",
"0.59648603",
"0.5935579",
"0.59332997",
"0.5930668",
"0.59290457",
"0.5879349",
"0.58384115",
"0.58369434",
"0.58291316",
"0.5807532",
"0.5807532",
"0.5785035",
"0.57484305",
"0.5739368",
"0.56994",
"0.5686515",
"0.5680653",
"0.5663582",
"0.5660303",
"0.5646417",
"0.56342256",
"0.5631557",
"0.56222284",
"0.5618985",
"0.5568845",
"0.5563075",
"0.55585456",
"0.5538881",
"0.55378056",
"0.5536653",
"0.5522392",
"0.5504909",
"0.55025554",
"0.5502025",
"0.54942596",
"0.5491543",
"0.54891837",
"0.5475895",
"0.5467491",
"0.5466393",
"0.5455711",
"0.5449362",
"0.54455906",
"0.54446864",
"0.5415549",
"0.54074854",
"0.5403715",
"0.53941625",
"0.53888077",
"0.538582",
"0.53773236",
"0.5368558",
"0.5362907",
"0.53411114",
"0.53396976",
"0.53296834",
"0.5328468",
"0.5321386",
"0.5304122"
] |
0.70229214
|
6
|
set alignment of given column offset
|
def column_align colindex, lrc=:NONE
if lrc == :NONE
return get_column(colindex).align
#return @calign[colindex]
end
raise ArgumentError, "wrong alignment value sent" if ![:right, :left, :center].include? lrc
get_column(colindex).align = lrc
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def align_column colindex, lrc\n raise ArgumentError, \"wrong alignment value sent\" if ![:right, :left, :center].include? lrc\n @calign[colindex] ||= lrc\n if @chash[colindex].nil?\n @chash[colindex] = ColumnInfo.new(\"\", nil, lrc)\n else\n @chash[colindex].align = lrc\n end\n @chash\n end",
"def align_column n, alignment\n r = rows\n column(n).each_with_index do |col, i|\n cell = r[i][n]\n cell.alignment = alignment unless cell.alignment?\n end\n end",
"def alignment= value\n raise unless ALIGNMENTS.any? {|a| a == value }\n @alignment = value\n end",
"def align_column n, alignment\n r = rows\n column(n).each_with_index do |col, i|\n r[i][n] = { :value => col, :alignment => alignment } unless Hash === col\n end\n end",
"def align; end",
"def align; end",
"def call(field, row, col)\n align_field(field, col)\n end",
"def call(field, row, col)\n align_field(field, col)\n end",
"def aligned_text_position=(pos)\n end",
"def align_field(field, col)\n column_width = widths[col]\n alignment = Alignment.new(field.align || self[col])\n field.value = alignment.format(field, column_width)\n end",
"def align\n [:owner, :group, :size].each do |field|\n current = @alignment[field]\n @buffer.each do |line|\n new = line[field].length\n current = new if current < new\n end\n @alignment[field] = current\n end\n end",
"def align(size)\n @pos = (@pos + size - 1) / size * size\n end",
"def settextalign(*)\n super\n end",
"def vertical_alignment=(value)\n @vertical_alignment = value\n end",
"def align=(_arg0); end",
"def horizontal_alignment=(value)\n @horizontal_alignment = value\n end",
"def align_field(field, col)\n column_width = widths[col]\n direction = field.alignment || alignments[col] || DEFAULT\n Strings.align(field.content, column_width, direction: direction)\n end",
"def align\n unless defined?(@align); parse_align; end\n @align\n end",
"def align\n unless defined?(@align); parse_align; end\n @align\n end",
"def align(align=nil)\n @options[:align] = align unless align.nil?\n @options[:align]\n end",
"def change_vertical_alignment(alignment='center')\n validate_worksheet\n validate_vertical_alignment(alignment)\n @style_index = modify_alignment(@workbook,@style_index,false,alignment)\n end",
"def align=(align)\n set_align(align)\n generate_buffers\n end",
"def set_alignment_with_action(toolbar_name, alignment)\n opera_desktop_action(\"Set alignment\", toolbar_name, alignment)\n sleep(0.1)\n end",
"def align_center\n self.center(LENGTH)\n end",
"def option_align\n @align = true\n end",
"def set_string(row: 0, string:, align: \"left\")\n column = 0\n str = case align\n when \"left\" then string[0, @max_column].ljust(@max_column)\n when \"right\" then string[0, @max_column].rjust(@max_column)\n when \"center\" then string[0, @max_column].center(@max_column)\n else string[0, @max_column].ljust(@max_column)\n end\n\n str.chars do |chr|\n set_character(row: row, column: column, character: chr)\n column += 1\n end\n end",
"def aligned_text_position\n end",
"def alignment_node(node); end",
"def set_alignment_with_action(toolbar_name, alignment)\n opera_desktop_action(\"Set alignment\", toolbar_name, alignment)\n sleep(0.1) \n end",
"def align(size)\n rem = pos % size\n adv(size - rem) if rem > 0\n end",
"def align \n return @raw.align \n end",
"def change_horizontal_alignment(alignment='center')\n validate_worksheet\n validate_horizontal_alignment(alignment)\n @style_index = modify_alignment(@workbook,@style_index,true,alignment)\n end",
"def left_align\n @align = nil\n end",
"def align\n @options[:align]\n end",
"def sub_alignment _value=0\n send_cmd(\"sub_alignment #{_value}\")\n end",
"def aligned\n case align\n when :right then text.rjust(width, ' ')\n when :centre then text.center(width, ' ')\n else text.ljust(width, ' ')\n end\n end",
"def set_offset(offset)\n @offset = offset\n self\n end",
"def alignment=(alignment)\n validator = EnumAttributeValidator.new('String', ['Center', 'Inset', 'NotDefined'])\n unless validator.valid?(alignment)\n fail ArgumentError, 'invalid value for \"alignment\", must be one of #{validator.allowable_values}.'\n end\n @alignment = alignment\n end",
"def align(addr, width)\n\treturn addr + pad_length(addr, width)\nend",
"def alignment_of(member)\n self::MEMBERS_HASH[member].alignment\n end",
"def alignment_of(member)\n self.class.alignment_of(member)\n end",
"def alignment=(alignment)\n validator = EnumAttributeValidator.new('String', ['left', 'center', 'right'])\n unless validator.valid?(alignment)\n fail ArgumentError, 'invalid value for \"alignment\", must be one of #{validator.allowable_values}.'\n end\n @alignment = alignment\n end",
"def effective_x_align(x_align, y_align)\n case x_align\n when :left, :middle, :right\n x_align\n else\n # Default horizontal alignment depends on vertical alignment\n # If vertical alignment is set to top or bottom, we assume it should be centered at top/bottom\n case y_align\n when :top, :bottom\n :middle\n else\n :left\n end\n end\n end",
"def align!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n type = ALIGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 362:8: 'align'\n match( \"align\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 32 )\n\n end",
"def set_position(row, col)\n if row.between?(0, 7) && col.between?(0, 7)\n @position[:row] = row\n\t @position[:col] = col\n\tend\n end",
"def v_alignment=(v_alignment)\n validator = EnumAttributeValidator.new('String', ['bottom', 'center', 'top'])\n unless validator.valid?(v_alignment)\n fail ArgumentError, 'invalid value for \"v_alignment\", must be one of #{validator.allowable_values}.'\n end\n @v_alignment = v_alignment\n end",
"def offset_on_line(offset)\n end",
"def alignments_reset\n @valign = GroupLayout::CENTER\n @halign = GroupLayout::CENTER\n end",
"def wrap_at=(setting)\n @wrap_at = setting == :auto ? output_cols : setting\n end",
"def write_xfrm_offset\n x = 0\n y = 0\n\n attributes = [\n ['x', x],\n ['y', y]\n ]\n\n @writer.empty_tag('a:off', attributes)\n end",
"def calc_padding(offset)\n align = required_alignment\n\n # If offset is not aligned...\n if (offset % align) != 0\n # Calculate padding needed to be aligned\n align - (offset & (align - 1))\n else\n 0\n end\n end",
"def ljust(p0, padstr=\"\") end",
"def modify_alignment(workbook, style_index, is_horizontal, alignment)\n old_xf_obj = workbook.get_style(style_index)\n\n xf_obj = deep_copy(old_xf_obj)\n\n if xf_obj[:alignment].nil? || xf_obj[:alignment][:attributes].nil?\n xf_obj[:alignment] = {:attributes=>{:horizontal=>nil, :vertical=>nil}}\n end\n\n if is_horizontal\n xf_obj[:alignment][:attributes][:horizontal] = alignment.to_s\n else\n xf_obj[:alignment][:attributes][:vertical] = alignment.to_s\n end\n\n if workbook.cell_xfs[:xf].is_a?Array\n workbook.cell_xfs[:xf] << deep_copy(xf_obj)\n else\n workbook.cell_xfs[:xf] = [workbook.cell_xfs[:xf], deep_copy(xf_obj)]\n end\n\n xf = workbook.get_style_attributes(workbook.cell_xfs[:xf].last)\n xf[:applyAlignment] = '1'\n workbook.cell_xfs[:attributes][:count] += 1\n workbook.cell_xfs[:xf].size-1\n end",
"def normalize_offset(offset); end",
"def move_by(row_delta, col_delta)\n @row, @col = wrap(@row + row_delta, @col + col_delta)\n end",
"def alignment(name)\n {\n \"left\" => -1,\n \"center\" => 0,\n \"right\" => 1\n }[name.to_s]\n end",
"def text_align(alignment)\n Kernel.raise ArgumentError, \"Unknown alignment constant: #{alignment}\" unless ALIGN_TYPE_NAMES.key?(alignment.to_i)\n primitive \"text-align #{ALIGN_TYPE_NAMES[alignment.to_i]}\"\n end",
"def offset= offset\n @value = nil\n @offset = offset\n end",
"def textalignment=(textAlignment)\n @elementHash[:textalignment] = textAlignment\n end",
"def padded_aligned_data(data)\n string_repr = @data_to_s.call(data)\n\n string_repr = case @alignment\n when :left\n string_repr.ljust(@width)\n when :center\n string_repr.center(@width)\n when :right\n string_repr.rjust(@width)\n else\n string_repr\n end\n\n @padding ? @padding + string_repr + @padding : string_repr\n end",
"def offset_vector=(offset_vector)\n end",
"def offset!(offset)\n @offset = offset || 0\n self\n end",
"def alignment\n fetch('dnd.alignments')\n end",
"def refresh_window_alignment\n self.x = case @@alignment\n when 0 then 0\n when 1 then Graphics.width/2-(width/2)\n when 2 then Graphics.width-width\n end\n end",
"def lnbsetColumnsPos _args\n \"lnbsetColumnsPos _args;\" \n end",
"def fix_row_alignment!(row)\n log \"#{row['IFSC']}: Using State = '#{row['CITY2']}' STD_CODE=#{row['STATE']}, PHONE=#{row['STD CODE']} and discarding PHONE=#{row['PHONE']}\", :info\n row['STATE'],row['STD CODE'], row['PHONE'] = row['CITY2'], row['STATE'], row['STD CODE']\nend",
"def align(num)\n if num < 10\n \" #{num}\"\n else\n \" #{num}\"\n end\n end",
"def v_text_align(vta=nil)\n cur_page.v_text_align(vta)\n end",
"def center(size)\n (@raw_columns - size) / 2\n end",
"def align\n i = @max_cell_row\n j = @max_cell_column\n @first_result = \"\" \n @second_result = \"\" \n gaps_in_first = 0 # count of gaps in each sequence\n gaps_in_second = 0\n\n while true\n\n # end local alignment at 0 cell\n if @traceback_matrix[i, j] == 0\n break\n end\n\n # match/mismatch\n if @traceback_matrix[i, j] == 1\n @first_result << @first_string[i-1]\n @second_result << @second_string[j-1]\n i -= 1\n j -= 1\n end\n\n # deletion -> gap in S1\n if @traceback_matrix[i, j] == 2\n @first_result << \"-\"\n @second_result << @second_string[j-1]\n j -= 1\n gaps_in_first += 1\n end\n\n # insertion -> gap in S2\n if @traceback_matrix[i, j] == 3\n @first_result << @first_string[i-1]\n @second_result << \"-\"\n i -= 1\n gaps_in_second += 1\n end\n\n end\n # set variables to make writing to file prettier\n set_variables(gaps_in_first, gaps_in_second)\n end",
"def reset_table_cell\n mixin({\n text_align: 'left',\n font_weight: 'normal',\n vertical_align: 'middle'\n })\n end",
"def set_lines(lines:, align: \"left\")\n if lines.length >= @max_row\n set_string(row: 0, string: lines[0].to_s, align: align)\n set_string(row: 1, string: lines[1].to_s, align: align)\n else\n set_string(row: 0, string: lines[0].to_s, align: align)\n end\n end",
"def aligner(infile, justification = :Left)\n fieldsbyrow = infile.map {|line| line.strip.split('$')}\n # pad to same number of fields per record\n maxfields = fieldsbyrow.map(&:length).max\n fieldsbyrow.map! {|row| row + ['']*(maxfields - row.length)}\n # calculate max fieldwidth per column\n colwidths = fieldsbyrow.transpose.map {|column|\n column.map(&:length).max\n }\n # pad fields in columns to colwidth with spaces\n justifier = J2justifier[justification]\n fieldsbyrow.map {|row|\n row.zip(colwidths).map {|field, width|\n field.send(justifier, width)\n }.join(\" \")\n }.join(\"\\n\")\nend",
"def offset_on_line(offset)\n @locator.offset_on_line + @leading_line_offset\n end",
"def move_to_column(x); puts \"\\e[#{x}F\" end",
"def center(p0, padstr=\"\") end",
"def render(target)\n align_right? ? Justifier.rjust(target, width) : Justifier.ljust(target, width)\n rescue StandardError => e\n raise \"Column #{name} failed: #{e.message}\"\n end",
"def padding=(pad); end",
"def char_offset(offset)\n effective_line = @locator.line_for_offset(offset)\n locator.char_offset(offset) + (effective_line * @leading_line_offset) + @leading_offset\n end",
"def parse_alignment_options(options = {})\n return unless options[:alignment]\n\n CellAlignment.new options[:alignment]\n end",
"def alignments\n map { |alignment| alignment }\n end",
"def place(x, y, orientation)\n position(x, y, @table.size)\n self.direction = orientation.to_sym\n end",
"def align(indexes, type)\n [*indexes].each do |index|\n index = parse_index(index)\n raise Exception::new \"Undefined column #{index}\" unless index\n @align[index] = type\n end\n end",
"def update!(**args)\n @alignment = args[:alignment] if args.key?(:alignment)\n @width = args[:width] if args.key?(:width)\n end",
"def char_offset(offset)\n raise \"Should not be called\"\n end",
"def align_row sself, sother, row_index\n asd = 0\n if sself[row_index] && sother[row_index]\n asd = sself[row_index].key <=> sother[row_index].key\n elsif sself[row_index]\n asd = -1\n elsif sother[row_index]\n asd = 1\n end\n if (asd == -1) && insert_placeholder?(sother, sself, row_index)\n sother.insert row_index, placeholder_row\n row_index -= 1\n elsif (asd == 1) && insert_placeholder?(sother, sself, row_index)\n sself.insert row_index, placeholder_row\n row_index -= 1\n end\n\n row_index + 1\n end",
"def offset_changes\n changes(col_offset: @col_offset, row_offset: @row_offset)\n end",
"def cells_per_row_offset offset\n @grpc.cells_per_row_offset_filter = offset\n self\n end",
"def set_form_col col1=@curpos\n @curpos = col1 || 0 # NOTE we set the index of cursor here\n c = @col + @col_offset + @curpos - @pcol\n min = @col + @col_offset\n max = min + @width\n c = min if c < min\n c = max if c > max\n #$log.debug \" #{@name} FIELD set_form_col #{c}, curpos #{@curpos} , #{@col} + #{@col_offset} pcol:#{@pcol} \"\n setrowcol nil, c\n end",
"def setrowcol r, c\n # 2010-02-07 21:32 is this where i should add ext_offsets\n #$log.debug \" #{@name} w.setrowcol #{r} + #{@ext_row_offset}, #{c} + #{@ext_col_offset} \"\n # commented off 2010-02-15 18:22 \n #r += @ext_row_offset unless r.nil?\n #c += @ext_col_offset unless c.nil?\n if @form\n @form.setrowcol r, c\n #elsif @parent_component\n else\n raise \"Parent component not defined for #{self}, #{self.class} \" unless @parent_component\n @parent_component.setrowcol r, c\n end\n #setformrowcol r,c \n end",
"def move(marker)\n column = 0\n until column > 0 && column < 8\n column = play_column.to_i\n end\n @position = place_marker(marker, column)\n end",
"def move_to(row, col)\n @row, @col = wrap(row, col)\n end",
"def effective_y_align(x_align, y_align)\n case y_align\n when :top, :center, :bottom\n y_align\n else\n # Default vertical alignment depends on horizontal alignment\n # If horizontal alignment is set to left or right, we assume it should be centered at left/right\n case x_align\n when :left, :right\n :center\n else\n :top\n end\n end\n end",
"def aligned_position \n \n cigar_line = \"#{self.cigar_line}\"\n \n x = cigar_line.slice!(/^[0-9]*/)\n char = cigar_line.slice!(/^[A-Z]/)\n \n x.nil? ? x = 1 : x = x.to_i\n char == \"X\" ? start = x : start = 0\n \n char = cigar_line.slice!(/[A-Z]$/)\n y = cigar_line.slice!(/[0-9]*$/)\n \n if y.nil?\n y = 1\n else\n y = y.to_i\n end\n \n if char == \"X\"\n stop = self.genomic_align_block.length - y\n else\n stop = self.genomic_align_block.length\n end\n answer = Array.new\n answer.push(start)\n answer.push(stop)\n return answer\n \n end",
"def xref_offset=(offset)\n check_is_a!(offset, Integer)\n check_gt!(offset, 0)\n @xref_offset = offset\n end",
"def mix_text_align element, opt, ctx\n\n align = detect(opt[:align] || opt[TEXT_ALIGN])\n element.style[TEXT_ALIGN] = align unless none?(align)\n\n end",
"def set_mark(pos, mark)\n\t row, col = to_row_col(pos)\n\t return if row.nil? || col.nil?\n\t @grid[row][col] = mark\n\tend",
"def get_alignment\n @halign = CP::CMS::DEFAULT_ALIGNMENT # Sets alignment to default\n @halign = 2 if @text.include?(\"\\\\alir\") # Sets alignment to right\n @halign = 2 if @text.include?(\"\\\\ar\")\n @halign = 1 if @text.include?(\"\\\\alic\") # Sets alignment to center\n @halign = 1 if @text.include?(\"\\\\ac\")\n @halign = 0 if @text.include?(\"\\\\alil\") # Sets alignment to left\n @halign = 0 if @text.include?(\"\\\\al\")\n @text.gsub!(/\\\\(?:alil|alic|alir|ar|ac|al)/){\"\"}# Clears alignment modifiers\n end",
"def set_Offset(value)\n set_input(\"Offset\", value)\n end",
"def set_Offset(value)\n set_input(\"Offset\", value)\n end"
] |
[
"0.6934832",
"0.67424357",
"0.6686975",
"0.6625456",
"0.6587735",
"0.6587735",
"0.6460359",
"0.6460359",
"0.6433331",
"0.63598865",
"0.62720424",
"0.62634814",
"0.62217283",
"0.6138361",
"0.611345",
"0.60497516",
"0.6049009",
"0.6045546",
"0.6045546",
"0.6001273",
"0.5967639",
"0.59338814",
"0.58790404",
"0.58775264",
"0.5873337",
"0.58553565",
"0.5848263",
"0.5831922",
"0.58048594",
"0.57808673",
"0.57481873",
"0.5731376",
"0.5720296",
"0.5711519",
"0.56878173",
"0.5628855",
"0.56167084",
"0.56036836",
"0.5592329",
"0.5542194",
"0.55362767",
"0.55235434",
"0.5516463",
"0.5515264",
"0.54679734",
"0.5451529",
"0.54445255",
"0.5391159",
"0.5360982",
"0.5349914",
"0.5339618",
"0.5329508",
"0.5311141",
"0.5266457",
"0.52606446",
"0.52568287",
"0.52516425",
"0.5230668",
"0.5227848",
"0.52150095",
"0.5207276",
"0.5202092",
"0.518598",
"0.51536936",
"0.515122",
"0.51414543",
"0.51382697",
"0.51345646",
"0.511599",
"0.5109897",
"0.51076365",
"0.51065195",
"0.5106295",
"0.5089161",
"0.5088834",
"0.5084984",
"0.5084014",
"0.5076475",
"0.5065545",
"0.5063505",
"0.5043489",
"0.5036639",
"0.5035368",
"0.5032229",
"0.50084627",
"0.50066775",
"0.4999038",
"0.49910563",
"0.49855497",
"0.49788952",
"0.49774393",
"0.49736172",
"0.49624956",
"0.49478582",
"0.49422613",
"0.4941469",
"0.4932843",
"0.4930982",
"0.49137026",
"0.49137026"
] |
0.6835414
|
1
|
return an array of visible columns names
|
def visible_column_names
visible = []
@chash.each_with_index do |c, ix|
if !c.hidden
if block_given?
yield c.name, ix
else
visible << c.name
end
end
end
return visible unless block_given?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def get_columns_visible\n columns_visible ? JSON.parse(columns_visible) : []\n end",
"def get_visible_columns\n return @visible_columns_cache unless @visible_columns_cache.nil?\n if get_cookie('columns').nil? or @reload\n visible = ''\n @columns.each do |c|\n next if c.hidden?\n c.visible = true\n visible << c.id.to_s << (c != @columns.last ? ', ' : '')\n end\n set_cookie('columns', visible)\n end\n colstr = get_cookie('columns')\n ret = Array.new\n col_s = colstr.split(/,\\s/)\n col_s.each do |c|\n t = col_by_id c\n next if t.blank?\n t.visible = true\n ret << t\n end\n @visible_columns_cache = ret\n return ret\n end",
"def get_columns_visible_sql\n if self.columns_visible.blank?\n return ' * '\n else\n return (JSON.parse self.columns_visible).join(', ')\n end\n end",
"def visible_columns\n @visible_columns ||= (request_columns.empty? ? columns : columns.select { |column| visible_column?(column) })\n end",
"def column_names\n columns.map(&:name)\n end",
"def column_names\n @columns.keys\n end",
"def columns_visible_sql\n if columns_visible.blank?\n ' * '\n else\n JSON.parse(columns_visible).join(', ')\n end\n end",
"def list_columns\n columns\n end",
"def get_columns_name\r\n columns = []\r\n if @columns != nil\r\n @columns.each do |column|\r\n columns.push column\r\n end\r\n end\r\n \r\n if @stats != nil and @stats.length > 0\r\n @stats.each do |stat|\r\n columns.push stat.to_column_name\r\n end\r\n end\r\n \r\n return columns\r\n end",
"def column_names\n @column_names ||= columns.collect(&:name)\n end",
"def get_hidden_columns\n @hidden_columns_cache = @columns - get_visible_columns if @hidden_columns_cache.nil?\n @hidden_columns_cache\n end",
"def columns()\n return @columns.keys\n end",
"def showable_columns\n showable_attributes.keys\n end",
"def column_names\n @column_names ||= @columns.keys\n end",
"def show_columns_for_model(klass, klass_ui, controller) \n results = current_show_columns(klass, klass_ui, controller).collect {|c| klass_ui.all_columns.find {|col| col.name == c}}\n results.reject! {|c| c == nil}\n return results\n # return klass.columns.select {|c| current_show_columns(klass, klass_ui, controller).include?(c.name)}\n end",
"def all\n __getobj__.column_names\n end",
"def column_names\n self[0].keys\n end",
"def column_names\n columns_in_order.map { |c| c.name }\n end",
"def column_names\n @entity_columns.map(&:name).map(&:to_s)\n end",
"def column_names\n klass.properties.keys\n end",
"def columns\n @model.columns.map{|c| c.name}\n end",
"def get_all_sorted_columns\n @all_cols_cache = get_visible_columns + get_hidden_columns if @all_cols_cache.nil?\n return @all_cols_cache\n end",
"def column_names(table_name)\n columns(table_name).map(&:name)\n end",
"def column_header_names\r\n column_headers.collect {|header| header.name }\r\n end",
"def headers\n columns.map(&:header)\n end",
"def column_names\n @column_names || owner.column_names\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n else\n \"\"\n end\n }.compact\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def column_names\n @column_names = columns_hash.keys\n end",
"def column_count\n visible_column_names().count\n end",
"def columns\n @header.to_a\n end",
"def column_names\n keys = COLUMN_NAMES\n keys.map{|key| [Person.field_name(key), key]}\n end",
"def columns \n @c\n end",
"def columns; @columns; end",
"def wanted_column_names\n nil # nil => select all columns\n end",
"def columns\n if @column_names\n columns = []\n\n # First match against fully named columns, e.g. 'attribute:name'\n @column_names.each{|cn| columns << owner.columns_hash[cn] if owner.columns_hash.has_key?(cn)}\n\n # Now match against aliases if the number of columns found previously do not\n # match the expected @columns_names size, i.e. there's still some missing.\n if columns.size != @column_names.size\n columns_left = @column_names - columns.map{|column| column.name}\n owner.columns_hash.each { |name,column| columns << column if columns_left.include?(column.alias) }\n end\n\n columns\n else\n owner.columns\n end\n end",
"def retrieve_name_columns\n fetch_columns.grep /name/\n end",
"def columns\n @columns ||= @stats.values.flatten.map { |a| a.column_name }\n end",
"def columns\n @columns\n end",
"def cols\n @cols\n end",
"def show_banded_columns\n return @show_banded_columns\n end",
"def column_names\n klass.attributes\n end",
"def columns \n []\n end",
"def column_names\n klass.new.attributes.keys\n end",
"def get_columns\n return @columns\n end",
"def columns\n @columns_hash.values\n end",
"def columns\n @columns\n end",
"def column_headers\n use_column_headers ? columns.map(&:heading) : true\n end",
"def columns\n return [{:id=>\"one\", :display =>'One', :searchable=>false}, {:id=>'two', :display => 'three'}]\n end",
"def names\n @column_families.keys\n end",
"def columns\n return @columns\n end",
"def visible_columns(row)\n visible = []\n row.each_with_index do |e, ix|\n hid = @chash[ix].hidden\n if !hid\n if block_given?\n yield e, ix\n else\n visible << e \n end\n end\n end\n return visible if !block_given?\n end",
"def get_column_names(table_name)\r\n column_names = get_info(table_name, 'name')\r\n end",
"def columns\n # we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?\n unless defined? @columns\n self.columns = @core.columns.collect { |c| c.name if @core.columns._inheritable.include?(c.name) && c.searchable? && c.association.nil? && c.text? }.compact\n end\n @columns\n end",
"def field_names\n @field_names ||= (columns_hash.keys.map(&:to_sym) rescue [])\n end",
"def columns\n @columns ||= [];\n end",
"def columns_title\n self.columns.collect{|c|c.label}\n end",
"def columns\n end",
"def columns; end",
"def columns\n @columns ||= []\n end",
"def get_data_colnames(d)\n if d == nil or d.empty?\n return []\n end\n return d.first().keys()\n end",
"def columns\n @columns ||= ControllerAction.columns.map(&:name).map(&:to_sym).reject{|c|c==:id}\n end",
"def columns; @columns_hash.values; end",
"def columns\n get_metadata unless @columns\n return @columns\n end",
"def grid_row_undisplayed_columns\n []\n end",
"def table_columns\n klass.column_names\n end",
"def columns\n\t\t\t@columns ||= Txtboard::Column.columns.sort_by(&:order)\n\t\tend",
"def keys\n @klass.column_names\n end",
"def list_columns\n self.entity_columns.where(\"list_rank > 0\").order(\"list_rank asc\")\n end",
"def columns\n orig_dataset.columns\n end",
"def columns\n self.class.instance_variable_get(:@columns)\n end",
"def columns\n must_be_open!\n return @columns.map(&:first)\n end",
"def columnheaders_raw\r\n columns = Array(raw_data_sheet.row(0)).compact\r\n columns = columns.collect!{ |col| clean_string(col) } unless columns.nil?\r\n columns\r\n end",
"def columns\n _columns || columns!\n end",
"def column_names(table)\n self.table_column_names ||= {}\n unless table_column_names.include? table\n table_column_names[table] = columns(table).map {|c| c.name}\n end\n table_column_names[table]\n end",
"def columns\n single_record unless @columns\n @columns || []\n end",
"def columns\n @pz.group_by.each_with_index { |val, n| column_id(n) }\n end",
"def readable_columns\n readable_attributes.keys\n end",
"def columns(sql)\n return self.dbh.execute(sql).column_names\n end",
"def columns_for(table)\n db_connection.select_values(\"show columns from `#{ table }`\")\n end",
"def columns\n self.class.columns\n end",
"def columns\n self.class.columns\n end",
"def columns\n self.class.const_get(:COLUMNS) rescue []\n end",
"def get_table_column_names(table)\r\n @db[table].columns\r\n end",
"def columns\n map.keys\n end",
"def columns_in_list\n css_select('table.list thead th:not(.checkbox)').map(&:text).select(&:present?)\n end",
"def query_part_column_names\n remote_query_column_types.map{|name, type| name}.join(\"\\n , \")\n end",
"def get_view_columns\n if @_view_columns.nil?\n set_default_view_columns\n end\n @_view_columns\n end",
"def columns!\n ds = clone(opts.merge(:sql => \"SELECT TOP 1 [T1].* FROM (#{opts[:sql]}) \\\"T1\\\"\"))\n ds.each{break}\n\n if cols = ds.cache[:_columns]\n self.columns = cols\n else\n []\n end\n end",
"def fetch_columns\n raise \"Model name can't be blank\" if @model_name.nil?\n\n @model_name.attribute_names\n end",
"def getQuestionMatrixColNames(ridx)\n nmatrix = getNumQuestionMatrixConfig(ridx)\n nfields = getNumQuestionFieldConfig(ridx)\n colnames = Array.new\n if nmatrix > 0\n qrnames = getQuestionMatrixRowsConfig(ridx)\n qcnames = getQuestionMatrixColsConfig(ridx)\n cqfidx = 0\n qcnames.each do |colname|\n showcol = getQuestionMatrixColFlag(ridx,cqfidx)\n if showcol.to_s == \"1\"\n colnames << colname \n end\n cqfidx = cqfidx + 1\n end\n end\n return colnames\n end",
"def columns_for_search\n self.entity_columns.select(\"name, ref_type, ref_name, col_type\")\n end",
"def importable_columns\n @column_names ||= self.class.spreadsheet_columns\n end",
"def columns()\n (cr=@records.get(GRT_COLROW)) ? cr[0] : nil\n end",
"def columns(table_name)\n @db.table_info(table_name).map { |info| info[\"name\"].to_sym }\n end",
"def columns\n restrictions - exclude\n end"
] |
[
"0.79247165",
"0.7845815",
"0.78433377",
"0.7817416",
"0.765696",
"0.7655768",
"0.75953966",
"0.7585849",
"0.7460832",
"0.72860515",
"0.72471976",
"0.72181123",
"0.7210697",
"0.7187838",
"0.717872",
"0.7132154",
"0.70969605",
"0.70618695",
"0.70578426",
"0.7038825",
"0.7036948",
"0.7025341",
"0.70060325",
"0.6950463",
"0.6936028",
"0.6931497",
"0.69259614",
"0.68863374",
"0.68863374",
"0.68857855",
"0.68839544",
"0.68839544",
"0.6879363",
"0.6876017",
"0.68602777",
"0.6852707",
"0.6838898",
"0.6832375",
"0.6831441",
"0.6820547",
"0.68185055",
"0.67831784",
"0.67820525",
"0.6775548",
"0.6767908",
"0.6757617",
"0.67559075",
"0.6749684",
"0.6747762",
"0.67170596",
"0.6710936",
"0.67080486",
"0.67015785",
"0.66972977",
"0.66632634",
"0.66576284",
"0.6653829",
"0.6638007",
"0.66329956",
"0.66207856",
"0.6615055",
"0.6614756",
"0.6609465",
"0.66084564",
"0.6590969",
"0.6580681",
"0.6556926",
"0.6536412",
"0.65356493",
"0.6523273",
"0.6511759",
"0.6502377",
"0.64920765",
"0.6491883",
"0.64702547",
"0.6463872",
"0.64514524",
"0.643266",
"0.6429569",
"0.6413604",
"0.64064187",
"0.64043456",
"0.6401091",
"0.63971764",
"0.63896245",
"0.63896245",
"0.63868207",
"0.6384652",
"0.6382642",
"0.6358177",
"0.63550854",
"0.6354572",
"0.63490283",
"0.6348619",
"0.6347424",
"0.63465863",
"0.6319901",
"0.6319531",
"0.63186044",
"0.6305621"
] |
0.8338983
|
0
|
returns the count of visible columns based on column names. NOTE: what if no column names gives ???
|
def column_count
visible_column_names().count
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ncols\n @colnames.length\n end",
"def count_columns\n fields.size\n end",
"def column_count\r\n assert_exists\r\n arr_cells = cells\r\n return arr_cells.length\r\n end",
"def columns_count\n @columns.size\n end",
"def columns_count\n @values.empty? ? 0 : @values.first.count\n end",
"def column_count\r\n assert_exists\r\n arr_rows = rows\r\n return arr_rows[0].column_count\r\n end",
"def visible_columns\n @visible_columns ||= (request_columns.empty? ? columns : columns.select { |column| visible_column?(column) })\n end",
"def visible_column_names\n visible = []\n @chash.each_with_index do |c, ix|\n if !c.hidden\n if block_given?\n yield c.name, ix \n else\n visible << c.name\n end\n end\n end\n return visible unless block_given?\n end",
"def num_cols\n col_labels.length\n end",
"def num_columns\n score_numbers.count\n end",
"def header_cols\n @row_dims.count\n end",
"def column_count\n @stmt_api.column_count\n end",
"def get_columns_visible\n columns_visible ? JSON.parse(columns_visible) : []\n end",
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def columns_visible_sql\n if columns_visible.blank?\n ' * '\n else\n JSON.parse(columns_visible).join(', ')\n end\n end",
"def available_columns(heaps)\n x = 0\n\n results = heaps.each_index.select{|i| heaps[i] > 0}\n\n results\n end",
"def visible_tabs\n count = 0\n @tab_names.each { |x| count += 1 if x.visible? }\n count\n end",
"def get_columns_visible_sql\n if self.columns_visible.blank?\n return ' * '\n else\n return (JSON.parse self.columns_visible).join(', ')\n end\n end",
"def header_rows\n @col_dims.count\n end",
"def available_columns\n available_cols = []\n #Transpose the grid so sub arrays are now columns instead of rows\n t = grid.transpose\n t.each_with_index do |col, index|\n available_cols << index if col.any? {|cell| cell == BLANK }\n end\n available_cols\n end",
"def number_of_columns\n headings_with_rows.map { |r| r.number_of_columns }.max || 0\n end",
"def num_cols()\n return self[0].length\n end",
"def set_cols(visible, list)\n @rows = 1 if visible\n @cols = (depends_on & list).find_all { |u| u.visible }.inject(0) { |s, v| s + (v.cols || 0) }\n @cols = 1 if @cols == 0 and visible\n end",
"def column_count\n is_container? ? get_content_param_by_key( :model_count_in_row ) : 0\n end",
"def get_visible_columns\n return @visible_columns_cache unless @visible_columns_cache.nil?\n if get_cookie('columns').nil? or @reload\n visible = ''\n @columns.each do |c|\n next if c.hidden?\n c.visible = true\n visible << c.id.to_s << (c != @columns.last ? ', ' : '')\n end\n set_cookie('columns', visible)\n end\n colstr = get_cookie('columns')\n ret = Array.new\n col_s = colstr.split(/,\\s/)\n col_s.each do |c|\n t = col_by_id c\n next if t.blank?\n t.visible = true\n ret << t\n end\n @visible_columns_cache = ret\n return ret\n end",
"def column_count_upper_bound(strings)\n column_count = 0\n length = 0\n\n sorted_by_length = strings.sort {|x, y| x.length <=> y.length }\n\n sorted_by_length.each do |e|\n length += e.length\n break unless length < $curwin.width\n\n column_count += 1\n length += @@COLUMN_SEPARATOR.length\n end\n\n return column_count\n end",
"def columns?\n @columns_on\n end",
"def length\n columns.length\n end",
"def get_hidden_columns\n @hidden_columns_cache = @columns - get_visible_columns if @hidden_columns_cache.nil?\n @hidden_columns_cache\n end",
"def column_count\n @stkw_config[:max_col]\n end",
"def pages_count_column?\n expected_column = default_pages_count_column\n @attachment.instance.class.columns.detect do |column|\n column.name.to_s == expected_column\n end\n end",
"def show_columns_for_model(klass, klass_ui, controller) \n results = current_show_columns(klass, klass_ui, controller).collect {|c| klass_ui.all_columns.find {|col| col.name == c}}\n results.reject! {|c| c == nil}\n return results\n # return klass.columns.select {|c| current_show_columns(klass, klass_ui, controller).include?(c.name)}\n end",
"def header_cells_count\n header_cells.count\n end",
"def count_records(params, columns)\n 0\n end",
"def count_records(params, columns)\n 0\n end",
"def count_field_names\n count_fields.map(&:to_s)\n end",
"def columns\n @columns || 150\n end",
"def columns\n if @column_names\n columns = []\n\n # First match against fully named columns, e.g. 'attribute:name'\n @column_names.each{|cn| columns << owner.columns_hash[cn] if owner.columns_hash.has_key?(cn)}\n\n # Now match against aliases if the number of columns found previously do not\n # match the expected @columns_names size, i.e. there's still some missing.\n if columns.size != @column_names.size\n columns_left = @column_names - columns.map{|column| column.name}\n owner.columns_hash.each { |name,column| columns << column if columns_left.include?(column.alias) }\n end\n\n columns\n else\n owner.columns\n end\n end",
"def column_size\n @delegate.getColSize\n end",
"def columns\n 1\n end",
"def getTotalNumDesignDetailCols()\n @designdetailsids.each do |dd_id|\n totalcols = totalcols + getNumDesignDetailCols(dd_id)\n end\n return totalcols\n end",
"def columns_incdec howmany\n @gviscols += howmany.to_i\n @gviscols = 1 if @gviscols < 1\n @gviscols = 6 if @gviscols > 6\n @pagesize = @grows * @gviscols\nend",
"def columns; end",
"def columns_in_list\n css_select('table.list thead th:not(.checkbox)').map(&:text).select(&:present?)\n end",
"def find_number_of_columns\n column_array = []\n CSV.foreach('testdata.csv', {headers: true}) {|row| column_array << row[0]}\n column_array.uniq.size\nend",
"def column_size\n first_row = @rows[0]\n if first_row._equal?(nil)\n return 0\n end\n first_row.size\n end",
"def _calculate_column_offsets\n total = 0\n coffsets = []\n ctr = 0\n ## ix will have gaps in between for hidden fields\n each_column { | c, ix|\n v = c.width\n coffsets[ctr] = total\n ctr += 1\n total += v + 2 ## blank space plus separator\n }\n return coffsets\n end",
"def column_nils(input_query, key)\n input_query.count - input_query.count(key)\n end",
"def get_all_sorted_columns\n @all_cols_cache = get_visible_columns + get_hidden_columns if @all_cols_cache.nil?\n return @all_cols_cache\n end",
"def number_of_columns\n return rows.first.length unless rows.empty?\n raise Error, 'your table needs some rows'\n end",
"def getCols\n return @grid.getCols\n end",
"def column_count(string)\n Math.sqrt(string.length).ceil\nend",
"def fields_match_columns?\n fields = all_implementation_fields(only_real: true)\n # fields.reject! { |f| f.index(/^embedded_report_|^placeholder_/) }\n\n (fields.sort - table_columns.map { |c| c.name.to_s }.sort).empty?\n end",
"def get_columns!( *headers )\n headers = headers.flatten\n hrow = sheet.header_rows - 1\n ensure_shape\n @data = @data.transpose.select{ |col| col[0..hrow].any?{ |val| headers.include?( val ) } }\n @data = @data.sort_by{ |col| headers.index( col[0..hrow].select { |val| headers.include?( val ) }.first ) || headers.length }.transpose\n calc_dimensions\n end",
"def getTotalNumOutcomeDetailCols()\n totalcols = 0;\n @outcomedetailsids.each do |outd_id|\n totalcols = totalcols + getNumOutcomeDetailCols(outd_id)\n end\n return totalcols\n end",
"def too_many_cols?; cols.count >= MAX_COL_COUNT; end",
"def wanted_column_names\n nil # nil => select all columns\n end",
"def list_columns\n columns\n end",
"def cols\n directions.count('r') + 1\n end",
"def visible_columns(row)\n visible = []\n row.each_with_index do |e, ix|\n hid = @chash[ix].hidden\n if !hid\n if block_given?\n yield e, ix\n else\n visible << e \n end\n end\n end\n return visible if !block_given?\n end",
"def get_columns\n require 'io/console'\n n = ENV[\"COLUMNS\"]\n if n.nil? or n == \"\"\n rows, n = IO.console.winsize\t\n else\n n = n.to_i\n end\n return n\nend",
"def table_counts(tables)\r\n\ttables.each do |table|\r\n\t\tputs \"\"\r\n\t\tputs table['name']\r\n\t\tputs \"column count = #{table['cols'].length}\"\r\n\t\tputs \"type count = #{table['type'].length}\"\r\n\t\ti = 0\r\n\t\ttable['data'].each do |row|\r\n\t\t\tputs \"row #{i} = #{row.length}\"\r\n\t\t\ti += 1\r\n\t\tend\r\n\t\tputs \"\"\r\n\tend\r\nend",
"def get_columns_name\r\n columns = []\r\n if @columns != nil\r\n @columns.each do |column|\r\n columns.push column\r\n end\r\n end\r\n \r\n if @stats != nil and @stats.length > 0\r\n @stats.each do |stat|\r\n columns.push stat.to_column_name\r\n end\r\n end\r\n \r\n return columns\r\n end",
"def columnIsFiltered?(header)\n return @options[:filteredColumns] &&\n @options[:filteredColumns].is_a?(Array) &&\n @options[:filteredColumns].include?(header)\n end",
"def showable_columns\n showable_attributes.keys\n end",
"def columns; @columns; end",
"def cols\n count == 0 ? Array.new(@order) :\n first.inject([]) { |arr, item| \n arr << map { |row| row[arr.count] }; arr }\n end",
"def retrieve_name_columns\n fetch_columns.grep /name/\n end",
"def columns\n end",
"def columns \n @c\n end",
"def cols\n @cols\n end",
"def columnCount(parent)\n return 1\n end",
"def columns\n @pz.group_by.each_with_index { |val, n| column_id(n) }\n end",
"def check_columns\n\t @board.columns.each do |column|\n\t first = column.first\n\t return first unless column.any? { |value| value != first }\n\t end\n\t nil\n\tend",
"def columns()\n return @columns.keys\n end",
"def columns\n map.keys\n end",
"def count_visible(x, y)\n sum = 0\n h.times do |oy|\n w.times do |ox|\n sum += 1 if visible?(x, y, ox, oy)\n end\n end\n sum\n end",
"def allow_more_cols?\n !cols_enum_empty? && cols_enum_ready? && !(cols.values.include?('') || cols.values.include?(nil)) && cols.values.count < MAX_COL_COUNT\n end",
"def check_columns_for_winner\n # TODO\n end",
"def has_datacolumns? (record)\n record.datacolumns.size > 0 ? true : false\n end",
"def column_headers\n use_column_headers ? columns.map(&:heading) : true\n end",
"def size\n return 0 if columns.empty?\n\n columns.first.size\n end",
"def column_display param, column_name\n defined?(param[:searchable][:col]).nil? ? true : param[:searchable][:col].include?(column_name) ? true : false\n end",
"def column_names\n @columns.keys\n end",
"def columns\n layout_text.blank? ? 12 : layout[0].size\n end",
"def width\n return 0 if columns.empty?\n\n columns.size\n end",
"def columnheaders_unique?\r\n columnheaders_raw.length == columnheaders_raw.uniq.length\r\n end",
"def columns\n @columns ||= @stats.values.flatten.map { |a| a.column_name }\n end",
"def column_names\n @column_names ||= @columns.keys\n end",
"def num_datasources\n Network.columns.select {|col| col.name.include? \"ds_score\"}.size\n end",
"def cols\n # remove the nils\n cols = (Array.new(@size) { Array.new(@size) }).map { |col| col.select { |el| el != nil} }\n \n @rows.each do |row|\n row.each_with_index do |mark, col_idx|\n cols[col_idx] << mark\n end\n end\n \n cols\n end",
"def columns!\n @columns = nil\n columns\n end",
"def columns\n # we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?\n unless defined? @columns\n self.columns = @core.columns.collect { |c| c.name if @core.columns._inheritable.include?(c.name) && c.searchable? && c.association.nil? && c.text? }.compact\n end\n @columns\n end",
"def column_names\n @column_names ||= columns.collect(&:name)\n end",
"def grid_row_columns\n grid_row_fields.keys - grid_row_skipped_columns\n end",
"def columns_len(index)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.SplitComponentState_columns_len(@handle.ptr, index)\n result\n end",
"def filtered_column_positions columns\n columns = columns.flatten\n @filtered_column_positions ||= register.select {|field, pos| columns.include? field }.values\n end",
"def cols\n\t\treturn self[0].length if(self.matrix? && self.length>0)\n\tend",
"def column_width\n @level_order.inject(0) do |width_, level_|\n w_ = level_.name.size\n w_ > width_ ? w_ : width_\n end\n end",
"def table_has_header?(columns)\n columns.any? { |column| !column[:title].nil? }\n end"
] |
[
"0.73080254",
"0.7107904",
"0.6898772",
"0.6886108",
"0.6841604",
"0.6790589",
"0.67589843",
"0.6656489",
"0.65630984",
"0.6552611",
"0.6425674",
"0.63371474",
"0.6336136",
"0.619328",
"0.61428595",
"0.61328506",
"0.6115696",
"0.61093533",
"0.6105659",
"0.6075087",
"0.6045279",
"0.60424584",
"0.60133165",
"0.5960989",
"0.59581405",
"0.5930807",
"0.5916847",
"0.58992916",
"0.588736",
"0.58612555",
"0.5855539",
"0.5844605",
"0.58019817",
"0.5788389",
"0.5788389",
"0.576847",
"0.5764636",
"0.57534355",
"0.5741146",
"0.57359993",
"0.5707756",
"0.57071835",
"0.56953067",
"0.5690059",
"0.56703246",
"0.5663398",
"0.56522214",
"0.56517833",
"0.5646675",
"0.56457675",
"0.56396973",
"0.5631281",
"0.56298184",
"0.5624231",
"0.56194544",
"0.5613382",
"0.5612626",
"0.55982965",
"0.559454",
"0.559444",
"0.55702806",
"0.5563531",
"0.5551988",
"0.5548126",
"0.5530114",
"0.5523737",
"0.55228114",
"0.55221325",
"0.5514426",
"0.55088997",
"0.550618",
"0.5504888",
"0.5504403",
"0.55021834",
"0.55000025",
"0.5499643",
"0.5498758",
"0.5497505",
"0.54882306",
"0.54729754",
"0.54692143",
"0.5439352",
"0.5434665",
"0.54257256",
"0.54179305",
"0.5415624",
"0.5414262",
"0.54118574",
"0.5411719",
"0.54071563",
"0.54019684",
"0.53928196",
"0.53919387",
"0.5391311",
"0.53894913",
"0.538929",
"0.53795195",
"0.5369871",
"0.5368327",
"0.536243"
] |
0.85858935
|
0
|
yields nonhidden columns (ColumnInfo) and the offset/index This is the order in which columns are to be printed
|
def each_column
@chash.each_with_index { |c, i|
next if c.hidden
yield c,i if block_given?
}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def visible_column_names\n visible = []\n @chash.each_with_index do |c, ix|\n if !c.hidden\n if block_given?\n yield c.name, ix \n else\n visible << c.name\n end\n end\n end\n return visible unless block_given?\n end",
"def _calculate_column_offsets\n total = 0\n coffsets = []\n ctr = 0\n ## ix will have gaps in between for hidden fields\n each_column { | c, ix|\n v = c.width\n coffsets[ctr] = total\n ctr += 1\n total += v + 2 ## blank space plus separator\n }\n return coffsets\n end",
"def columns; end",
"def column_for_position(position); end",
"def column_for_position(position); end",
"def column_for_position(position); end",
"def columns; @columns; end",
"def column_order\n [:line_count, :loc_count, :file_count, :class_length]\n end",
"def visible_columns(row)\n visible = []\n row.each_with_index do |e, ix|\n hid = @chash[ix].hidden\n if !hid\n if block_given?\n yield e, ix\n else\n visible << e \n end\n end\n end\n return visible if !block_given?\n end",
"def content\n number_to_skip = 0 # Keeps track of the # of columns to skip\n \n html = ''\n table.header.column_names.each do |column|\n number_to_skip -= 1 and next if number_to_skip > 0\n \n if cell = @cells[column]\n number_to_skip = (cell[:colspan] || 1) - 1\n else\n cell = Cell.new(column, nil)\n end\n \n html << cell.html\n end\n \n html\n end",
"def columns\n end",
"def render\n @board_array.each_with_index do |row, row_index|\n row.each_with_index do |cell, col_index|\n if @position_hash[[row_index, col_index]].hidden\n print '______'\n else\n print cell.to_s\n end\n end\n print \"\\n\"\n end\n end",
"def columns \n @c\n end",
"def draw_columns\n @sections[:body][:fields].each do |field, settings|\n settings = [settings[0], @posY, (@defaults.merge (settings[1] || { }).symbolize_keys!)]\n settings[2][:style] = settings[2][:style].to_sym\n set_options settings[2]\n draw_line(@posY + @sections[:body][:settings][:height]/2)\n field = settings[2][:column] || field.to_s.split('_').inject('') do |str, part|\n str << part.camelize << \" \"\n end\n draw_text field, settings\n end\n draw_line(@posY - @sections[:body][:settings][:height]/2)\n set_pos_y @sections[:body][:settings][:height]\n end",
"def display\n positions_with_tokens.each_slice(3) do |row|\n print_row row.map{ |cell_id, token| token || cell_id }\n end\n end",
"def cols\n count == 0 ? Array.new(@order) :\n first.inject([]) { |arr, item| \n arr << map { |row| row[arr.count] }; arr }\n end",
"def display_print\n @grid.each_with_index do |row, row_idx|\n row.each_with_index do |element, column_idx|\n separator = (column_idx % 3 == 2) ? \" \" : \" \"\n print element.to_s + separator\n end\n puts\n puts if (row_idx % 3 == 2)\n end\n nil\n end",
"def get_hidden_columns\n @hidden_columns_cache = @columns - get_visible_columns if @hidden_columns_cache.nil?\n @hidden_columns_cache\n end",
"def columns\n _columns || columns!\n end",
"def print_filter(columns)\n lines = filter(columns)\n output = []\n lines.each_with_index do |line, i|\n row = \"#{i}.\".ljust(6)\n line.each do |k,v|\n row << \"#{v}\\t\"\n end\n output << row\n end\n puts output.join(\"\\n\")\n end",
"def columns\n\t\t\t@columns ||= Txtboard::Column.columns.sort_by(&:order)\n\t\tend",
"def grid_row_undisplayed_columns\n []\n end",
"def columns \n []\n end",
"def columns\n @pz.group_by.each_with_index { |val, n| column_id(n) }\n end",
"def get_columns\n column_lines = []\n 0.upto(@@width - 1) do |column|\n column_line = \"\"\n 0.upto(@@height - 1) do |row|\n column_line << @board[row][column]\n end\n column_lines << column_line\n end\n column_lines\n end",
"def probe\n name_pad = columns.map { |c| c.name.length }.max + 1\n type_pad = columns.map { |c| c.type.length }.max + 2\n sql_type_pad = columns.map { |c| c.sql_type.length }.max + 1\n\n columns.sort { |a, b| a.name <=> b.name }.map do |column|\n name = column.name\n name = \"* #{name}\" if primary_key_column?(column)\n print yellow(name.to_s.rjust(name_pad))\n print \" \"\n print blue(column.type.to_s.ljust(type_pad, \".\"))\n print magenta(column.sql_type.to_s.ljust(sql_type_pad))\n column.null ? print(red(\"NULL\")) : print(\" \")\n print \" [#{column.default}]\" if column.default\n print \" #{gray column.comment}\" if column.comment\n puts\n end\n nil\n end",
"def render\n\t\tprint \"cl1 cl2 cl3 cl4 cl5 cl6 cl7 cl8 cl9 c10\\n\"\n\t\t(0..9).each do |row|\n\t\t\t(0..9).each do |col|\n\t\t\t\tif @grid[row][col].is_flagged\n\t\t\t\t\tprint \"FLG\"\n\t\t\t\telsif @grid[row][col].is_hidden\n\t\t\t\t\tprint \" \"\n\t\t\t\telsif @grid[row][col].surrounding_bombs > 0\n\t\t\t\t\tprint \" #{@grid[row][col].surrounding_bombs} \"\n\t\t\t\telsif @grid[row][col].has_bomb\n\t\t\t\t\tprint \"POW\"\t\t\t\t\t\n\t\t\t\telse print \"xxx\"\n\t\t\t\tend\n\t\t\t\tprint \"|\" unless col == 9\n\t\t\t\tprint \"row#{row + 1}\\n\" if col == 9\n\t\t\tend\n\t\tend\n\tend",
"def current_column\n @col_offset\n end",
"def display_col(col)\r\n\r\n print \"Column #{col}: \"\r\n @bingo_board[@cols.index(col)].each {|num| print \"#{num} \"}\r\n puts\r\n\r\n end",
"def cols\n # remove the nils\n cols = (Array.new(@size) { Array.new(@size) }).map { |col| col.select { |el| el != nil} }\n \n @rows.each do |row|\n row.each_with_index do |mark, col_idx|\n cols[col_idx] << mark\n end\n end\n \n cols\n end",
"def columns_incdec howmany\n @gviscols += howmany.to_i\n @gviscols = 1 if @gviscols < 1\n @gviscols = 6 if @gviscols > 6\n @pagesize = @grows * @gviscols\nend",
"def get_column_descriptors\n #skip past header to get to column information\n @data.seek(HEADER_LENGTH)\n \n # column names are the first 128 bytes and column info takes up the last 72 bytes. \n # byte 130 contains a 16-bit column type\n # byte 136 contains a 16-bit length field\n @columns = []\n @column_count.times do\n name, type, length = @data.read(200).unpack('A128 x S x4 S')\n if length > 0\n @columns << Column.new(name.strip, type, length)\n end\n end\n # Reset the column count in case any were skipped\n @column_count = @columns.size\n \n @columns\n end",
"def columns!\n @columns = nil\n columns\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def each_column\n end",
"def columns\n 1\n end",
"def display_columns(input)\n output = \"\"\n input.each_with_index do |element, index|\n # spaces to add inbetween = column.length - word.length\n output += \"#{element.capitalize + (\" \" * (15 - element.to_s.chars.count))}\"\n if index % 4 == 0 && index != 0\n output += \"\\n\"\n end\n end\n puts \"\"\n puts ColorizedString[output].bold\n end",
"def columns\n @columns ||= begin\n column_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end",
"def column_print(things, color=:white)\n # return unless things.any?\n # sizes = things.map{|x|x.size}\n # col_width = sizes.max\n # cols = 80 / (col_width+3)\n # cols = 4 if cols > 4\n \n # if things.size % cols != 0\n # things += [''] * (cols - (things.size % cols))\n # end\n \n # things.map!{|thing| thing.ljust(col_width)}\n \n # things.each_slice(cols) do |slice|\n # puts slice.join(' | ').send(color)\n # end\n puts Term::Table.new(things).to_s.send(color)\n end",
"def display_board\n col_separator = ' | '\n row_separator = '--+---+--'\n\n @rows.each_with_index do |row, row_number|\n row.each_with_index do |col, col_number|\n print col.to_s\n print col_separator unless col_number + 1 >= row.length\n end\n puts ''\n puts row_separator unless row_number + 1 >= @rows.length\n end\n end",
"def unfilled_columns\n @cells[0].each_with_object([]).with_index do |(cell, nonFull_columns), idx|\n nonFull_columns << idx if cell.eql?(' ')\n end\n end",
"def columns\n @header.to_a\n end",
"def move_to_column(x); puts \"\\e[#{x}F\" end",
"def line_and_column(pos); end",
"def displayframecolumnvalues\r\n\t\t\ttitle = \" 1 2 3 4 5 6 7\"\r\n\t\t\t@output.puts(\"#{title}\")\r\n\t\t\t@matrix.each do |row|\r\n\t\t\t\tnew_row='|'+row.join('|')+'|'\r\n\t\t\t\t@output.puts(new_row)\r\n\t\t\tend\r\n\t\tend",
"def list_columns\n columns\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def columns\n collect = []\n recursive_columns(@base, collect)\n end",
"def columns\n @columns || 150\n end",
"def cols\n @cols\n end",
"def columnate_with_indexing ary, sz\n buff=Array.new\n $log.warn \"columnate_with_indexing got nil list \" unless ary\n return buff if ary.nil? || ary.size == 0\n \n # determine width based on number of files to show\n # if less than sz then 1 col and full width\n #\n wid = 30\n ars = ary.size\n ars = [$pagesize, ary.size].min\n # 2 maybe for borders also\n d = 0\n if ars <= sz\n wid = $gcols - d\n else\n tmp = (ars * 1.000/ sz).ceil\n wid = $gcols / tmp - d\n end\n\n # ix refers to the index in the complete file list, wherease we only show 60 at a time\n ix=0\n while true\n ## ctr refers to the index in the column\n ctr=0\n while ctr < sz\n\n cur=SPACE\n cur = CURMARK if ix + $sta == $cursor\n f = ary[ix]\n\n if $long_listing\n begin\n # one of zsh's flags adds not just / but @ * and a space, so the a FNF error comes\n unless File.exist? f\n last = f[-1]\n if last == \" \" || last == \"@\" || last == '*'\n stat = File.stat(f.chop)\n end\n else\n stat = File.stat(f)\n end\n f = \"%10s %s %s\" % [readable_file_size(stat.size,1), date_format(stat.mtime), f]\n rescue Exception => e\n f = \"%10s %s %s\" % [\"?\", \"??????????\", f]\n end\n end\n\n # be careful of modifying f or original array gets modified XXX\n k = get_shortcut ix\n isdir = f[-1] == \"/\"\n fsz = f.size + k.to_s.size + 0\n fsz = f.size + 1\n if fsz > wid\n # truncated since longer\n f = f[0, wid-2]+\"$ \"\n ## we do the coloring after trunc so ANSI escpe seq does not get get\n #if ix + $sta == $cursor\n #f = \"#{CURSOR_COLOR}#{f}#{CLEAR}\"\n #end\n else\n ## we do the coloring before padding so the entire line does not get padded, only file name\n #if ix + $sta == $cursor\n #f = \"#{CURSOR_COLOR}#{f}#{CLEAR}\"\n #end\n f = f.ljust(wid)\n # pad with spaces\n #f << \" \" * (wid-fsz)\n #f = f + \" \" * (wid-fsz)\n end\n # now we add the shortcut with the coloring (we need to adjust the space of the shortcut)\n #\n colr = \"white\"\n colr = \"blue, bold\" if isdir\n # this directly modified the damned index resulting in searches failing\n #k << \" \" if k.length == 1\n k = k + \" \" if k.length == 1\n\n f = \"#{cur}#[fg=yellow, bold]#{k}#[end] #[fg=#{colr}]#{f}#[end]\" \n\n if buff[ctr]\n buff[ctr] += f\n else\n buff[ctr] = f\n end\n\n ctr+=1\n ix+=1\n break if ix >= ary.size\n end\n break if ix >= ary.size\n end\n return buff\nend",
"def print_out_column_v1(board, number)\n\n\t\tcolumn_array = []\n\n\t\tnum_of_rows = board.length - 1\n\t\tcolumn_num_choosen = number - 1\n\n\t\tfor num in (0..num_of_rows)\n\t\t\trow_array = board[num]\n\t\t\tcolumn_array << row_array[column_num_choosen]\n\t\tend\n\t\tprint column_array\n\t\treturn column_array\n\tend",
"def crawl\n #cols.map do |col|\n # let's grab each column and the data for that column\n # heading = (document/col.heading_selector).inner_html\n # data = (document/col.column_selector).map { |row| row.inner_html }\n # [heading, data]\n #end.transpose.tap do |dm|\n # let's transpose the matrix and grab the headers\n # @headers = dm.slice(0)\n #end.slice(1..-1).each do |row|\n # and the we take all the data and we yield each row as\n # a hash of headers matched with their column value for this row\n # yield Hash[*@headers.zip(row)]\n #end\n end",
"def print_in_cols a, noc=nil\n unless noc\n noc = 3\n if a.size < 7\n noc = 1\n elsif a.size < 15\n noc = 2\n end\n end\n\n x = noc - 1\n cols = a.each_slice((a.size+x)/noc).to_a\n # todo width should be determined based on COLS of screen, and width of data\n cols.first.zip( *cols[1..-1] ).each{|row| puts row.map{|e| e ? '%-30s' % e : ' '}.join(\" \") }\nend",
"def columns\n @columns\n end",
"def printIndice\n\t\tafficherIndices(@indicesLigne)\n\t\tprint \"\\n\\n\"\n\t\tafficherIndices(@indicesColonne)\n\tend",
"def printIndice\n\t\tafficherIndices(@indicesLigne)\n\t\tprint \"\\n\\n\"\n\t\tafficherIndices(@indicesColonne)\n\tend",
"def expected_columns; end",
"def display(line, column = T.unsafe(nil)); end",
"def display(line, column = T.unsafe(nil)); end",
"def display(line, column = T.unsafe(nil)); end",
"def position\n [row.position, column.position]\n end",
"def print_column_names(table_name)\r\n if table_exists?(table_name)\r\n puts \"Your table \\\"#{table_name}\\\" has columns named:\"\r\n columns = get_column_names(table_name)\r\n columns.each_with_index do |name, i|\r\n print \"\\\"#{name}\\\" \"\r\n print \"& \" unless i == (columns.size - 1)\r\n end\r\n puts \"\"\r\n end\r\n end",
"def list_columns\n self.entity_columns.where(\"list_rank > 0\").order(\"list_rank asc\")\n end",
"def display\n i=0\n print \" \"\n 0.upto(9) do |x|\n print\" #{x} \"\n end\n 10.upto(@cols-1) do |x|\n print\" #{x}\"\n end\n print \"\\n\"\n print \" \"\n 0.upto(@cols-1) do\n print\"---\"\n end\n print \"\\n\"\n 0.upto(9) do |x|\n\t\t\tprint\" #{x}\"\n\t\t\t0.upto(@rows-1) do |y|\n \t\t \tprint @map[x][y].value\n\t\t\tend\n\t\t\t\tprint \"\\n\"\n \t\tend\n 10.upto(@rows-1) do |x|\n\t\t\tprint\"#{x}\"\n\t\t\t0.upto(@rows-1) do |y|\n \t\t \tprint @map[x][y].value\n\t\t\tend\n\t\t\t\tprint \"\\n\"\n end\n return nil\n\tend",
"def print_board\n BOARD_POSITIONS.each_slice(3) do |cells|\n print_row cells\n end\n end",
"def columns\n get_metadata unless @columns\n return @columns\n end",
"def columns\n raise NotImplementedError\n end",
"def col; end",
"def columns\r\n # TODO: transpose possibly doesn't work for rectangular (non-square) maps\r\n @all_columns ||= rows.transpose\r\n end",
"def visible_columns\n @visible_columns ||= (request_columns.empty? ? columns : columns.select { |column| visible_column?(column) })\n end",
"def report\n yield \"#{table.x},#{table.y},#{Direction::DIRECTIONS[direction.current]}\"\n end",
"def columns\n @cr[2] & 0x7f\n end",
"def columns\n @columns ||= []\n end",
"def offset_returns_row_number_column?\n true\n end",
"def each\n 0.upto(@row_count-1) do |row|\n fields = []\n 0.upto(@col_count-1) do |col|\n fields << self[row, col]\n end\n yield fields\n end\n end",
"def columns\n return @columns\n end",
"def get_all_sorted_columns\n @all_cols_cache = get_visible_columns + get_hidden_columns if @all_cols_cache.nil?\n return @all_cols_cache\n end",
"def render()\n print \" \"\n (0...@size).each do |col|\n print (col).to_s + \" \"\n end\n puts\n\n (0...@size).each do |row|\n (-1...@size).each do |col|\n print col == -1 ? row : card([row, col]).display\n print \" \"\n end\n puts\n end\n end",
"def columns!\n ds = clone(opts.merge(:sql => \"SELECT TOP 1 [T1].* FROM (#{opts[:sql]}) \\\"T1\\\"\"))\n ds.each{break}\n\n if cols = ds.cache[:_columns]\n self.columns = cols\n else\n []\n end\n end",
"def print_row(num)\n puts \" \" # Gives row margin\n\n @position_of_pieces.each do |piece|\n current_piece = piece[num]\n print make_piece(current_piece)\n end\n end",
"def header_footer(width, col_1, col_2)\n print col_1.to_s + leader(width, \" \", col_1.to_s, col_2.to_s) + col_2.to_s + \"\\n\"\nend",
"def pretty_print(mask, table, special_pos)\n for i in 0..table.size-1 do\n for j in 0..mask.size-1 do\n puts(mask[j] + \": \" + (if j==special_pos then \"\\n\" else \"\" end) + table[i][j])\n end\n puts(\"----------------------------\")\n end\nend",
"def pretty_print(mask, table, special_pos)\n for i in 0..table.size-1 do\n for j in 0..mask.size-1 do\n puts(mask[j] + \": \" + (if j==special_pos then \"\\n\" else \"\" end) + table[i][j])\n end\n puts(\"----------------------------\")\n end\nend",
"def hide_other_columns\n\t\t\n\t\t\t# Hide all other columns\n\t\t\t(@model.columnCount - 1).times do |i|\n\t\t\t\tself.setColumnHidden(i + 1, true)\n\t\t\tend\n\t\t\t \n\t\t\t# Resize first column to fit whole width\n\t\t\tself.resizeColumnToContents(0)\n\t\t\tself.setUniformRowHeights(true)\t\t\t\t\t\n\t\tend",
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def columns\n @columns ||= @csv_data[0].zip(*@csv_data[1..])\n end",
"def export_columns\n self.entity_columns.select(\"name, description, ref_type, ref_name, col_type\").where(\"list_rank > 0 and name not in ('domain_id', 'creator_id', 'updater_id', 'created_at', 'updated_at')\").order(\"list_rank asc\")\n end",
"def column(index)\n end",
"def columns(&block)\n yield @columns\n return self\n end",
"def column(pos = T.unsafe(nil)); end",
"def display\n puts\n puts \" 1 2 3 4 5 6 7 8\"\n puts\n $board.each_with_index do |line, index|\n unless line == []\n print index + 1\n print \" \"\n line.each do |cell|\n if cell == -1\n print \"- \"\n elsif cell == 0\n print \"X \"\n else\n print \"O \"\n end\n end\n print \" \"\n print index + 1\n puts\n end\n end\n puts\n puts \" 1 2 3 4 5 6 7 8\"\n puts\nend",
"def opx_pp(items, col, start_col, fill_col)\n return print(\"\\n\") if (items.length == 0)\n item = items.shift\n print (item = item + (items.length == 0 ? \"\" : \", \"))\n col += item.length\n if ((items.length > 0) && (fill_col <= (col + items[0].length)))\n print \"\\n\"\n start_col.times { |x| print(\" \") }\n col = start_col\n end\n opx_pp(items, col, start_col, fill_col)\n rescue => e\n opx_err(\"Fatal failure while pretty-printing Tabulator data\", e)\n end",
"def col\r\n @lines[@line_num].cursor\r\n end",
"def column_with_headings n\n headings_with_rows.map { |row| row_with_hash(row)[n] }.compact\n end",
"def pretty_print(mask, table, special_pos)\n for i in 0..table.size-1 do\n for j in 0..mask.size-1 do\n puts(mask[j] + \": \" + (if j==special_pos then \"\\n\" else \"\" end) + table[i][j].to_s)\n end\n puts(\"----------------------------\")\n end\nend",
"def pos_header\n @position - 2\n end"
] |
[
"0.66282904",
"0.64667326",
"0.6226126",
"0.6144539",
"0.6144539",
"0.6144539",
"0.6051335",
"0.604972",
"0.60314804",
"0.5972126",
"0.5948847",
"0.59092015",
"0.58611375",
"0.58564484",
"0.585576",
"0.58543706",
"0.58256406",
"0.58035064",
"0.57957774",
"0.5789821",
"0.57829016",
"0.5750981",
"0.57034826",
"0.56872153",
"0.5679808",
"0.56744695",
"0.5669008",
"0.5651297",
"0.56467676",
"0.56411105",
"0.5638347",
"0.563623",
"0.561853",
"0.5598645",
"0.5598645",
"0.55880886",
"0.55850506",
"0.5575742",
"0.55691797",
"0.55628055",
"0.5562461",
"0.5551835",
"0.5537553",
"0.55241257",
"0.55129546",
"0.5507467",
"0.5505959",
"0.5504676",
"0.5503065",
"0.5503065",
"0.5502449",
"0.54999495",
"0.54986835",
"0.5494669",
"0.5491622",
"0.5481335",
"0.5472353",
"0.547073",
"0.5469404",
"0.5469404",
"0.54640424",
"0.54533",
"0.54533",
"0.54533",
"0.5443378",
"0.5439051",
"0.5427613",
"0.5419601",
"0.5410795",
"0.5409147",
"0.54072624",
"0.5407244",
"0.5400588",
"0.5391779",
"0.5385695",
"0.53792596",
"0.5376216",
"0.5374221",
"0.5373445",
"0.5371415",
"0.5366371",
"0.53559184",
"0.5340292",
"0.53376126",
"0.533516",
"0.5333887",
"0.5333887",
"0.5325463",
"0.53230554",
"0.53150207",
"0.5311286",
"0.53108984",
"0.5302464",
"0.5296725",
"0.52939785",
"0.52893096",
"0.5289258",
"0.5285453",
"0.5283935",
"0.5283664"
] |
0.6988101
|
0
|
for the given row, return visible columns as an array
|
def visible_columns(row)
visible = []
row.each_with_index do |e, ix|
hid = @chash[ix].hidden
if !hid
if block_given?
yield e, ix
else
visible << e
end
end
end
return visible if !block_given?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def get_columns_visible\n columns_visible ? JSON.parse(columns_visible) : []\n end",
"def get_array_by_col()\n\t\tprepare(@dim_i,@dim_j)\n\t\ttmpTab = Array.new\n\t\tfor j in 0..@dim_j-1\n\t\t\ttmpTab.push get_col(j)\n\t\tend\n\t\treturn tmpTab\n\tend",
"def get_row_elements(row)\n @cells[row]\n end",
"def cols\n # remove the nils\n cols = (Array.new(@size) { Array.new(@size) }).map { |col| col.select { |el| el != nil} }\n \n @rows.each do |row|\n row.each_with_index do |mark, col_idx|\n cols[col_idx] << mark\n end\n end\n \n cols\n end",
"def get_row_cells row\n\t\treturn (row * 9...row * 9 + 9).to_a\n\tend",
"def visible_column_names\n visible = []\n @chash.each_with_index do |c, ix|\n if !c.hidden\n if block_given?\n yield c.name, ix \n else\n visible << c.name\n end\n end\n end\n return visible unless block_given?\n end",
"def columns\r\n # TODO: transpose possibly doesn't work for rectangular (non-square) maps\r\n @all_columns ||= rows.transpose\r\n end",
"def get_col_cells col\n\t\treturn (col...9 ** 2).step(9).to_a\n\tend",
"def get_row_contents(row)\n @board.slice(row*9,9)\n end",
"def get_visible_columns\n return @visible_columns_cache unless @visible_columns_cache.nil?\n if get_cookie('columns').nil? or @reload\n visible = ''\n @columns.each do |c|\n next if c.hidden?\n c.visible = true\n visible << c.id.to_s << (c != @columns.last ? ', ' : '')\n end\n set_cookie('columns', visible)\n end\n colstr = get_cookie('columns')\n ret = Array.new\n col_s = colstr.split(/,\\s/)\n col_s.each do |c|\n t = col_by_id c\n next if t.blank?\n t.visible = true\n ret << t\n end\n @visible_columns_cache = ret\n return ret\n end",
"def columns\n @board.transpose\n end",
"def get_col(n)\n\t\tprepare(@dim_i,@dim_j)\n\t\ttmpCol = Array.new\n\t\t@myTab.each do |row|\n\t\t\ttmpCol.push row[n]\n\t\tend\n\t\treturn tmpCol\n\tend",
"def get_col(board, col)\n \n col_array = []\n board.each do |row|\n col_array << row[col]\n end\n col_array\nend",
"def getColumn arr, col\n arr2 = [] \n for row in arr do\n arr2.push row[col]\n end \n return arr2\nend",
"def get_columns\n column_lines = []\n 0.upto(@@width - 1) do |column|\n column_line = \"\"\n 0.upto(@@height - 1) do |row|\n column_line << @board[row][column]\n end\n column_lines << column_line\n end\n column_lines\n end",
"def cols\n @cols\n end",
"def cols\n cols = [[], [], []]\n @rows.each do |row| # row = conents of [0][0], [0][1], [0][2]\n row.each_with_index do |mark, col| #:x, 0 ; :o, 1, :x, 0\n #ex: [[:x, :o, :x], [:x, nil, :o], [:x, nil, :x]]\n cols[col] << mark #cols[0] = the three marks in column 0\n end\n end\n\n cols\n end",
"def visible_array(ary)\n new_array = Array.new\n ary.each do |t|\n if check_visible(t)\n new_array << t\n end\n end\n return new_array\n end",
"def row_visible(row)\n return true if self.scterm.nil?\n row_to_s(row).match(self.scterm)\n end",
"def cols\n count == 0 ? Array.new(@order) :\n first.inject([]) { |arr, item| \n arr << map { |row| row[arr.count] }; arr }\n end",
"def col_arrays\n #puts self.inspect\n cols = []\n (MIN_ROW_POSITION..MAX_ROW_POSITION).each do |i|\n cols[i] = []\n (MIN_COL_POSITION..MAX_COL_POSITION).each do |j|\n cols[i].push(@board[j][i])\n end\n end \n cols\n end",
"def available_columns\n available_cols = []\n #Transpose the grid so sub arrays are now columns instead of rows\n t = grid.transpose\n t.each_with_index do |col, index|\n available_cols << index if col.any? {|cell| cell == BLANK }\n end\n available_cols\n end",
"def get_col(col)\n\tcol_array = []\n\t$boggle_board.length.times do |row|\n\t\tcol_array << $boggle_board[row][col]\n\t\trow+=1\n\tend\n\tcol_array\nend",
"def getCols\n return @grid.getCols\n end",
"def get_cells(rows, columns)\n cells = []\n rows.each do |r|\n columns.each do |c|\n cells << @fields[r][c]\n end\n end\n cells\n end",
"def grid_row_undisplayed_columns\n []\n end",
"def covered_cols_at(indications, t_row)\n covered_cols = []\n indications.each do |indication|\n s = indication.sensor\n b = indication.beacon\n dist = (s.row - b.row).abs + (s.col - b.col).abs\n start_range = (s.row - t_row).abs + s.col - dist\n end_range = dist - (s.row - t_row).abs + s.col\n for t_col in start_range..end_range do\n covered_cols.push(t_col) unless b.row == t_row and b.col == t_col\n end\n end\n\n covered_cols.uniq.length\nend",
"def visibility(grid, row, column)\n n = grid.size # dimensionality\n c = 0 # counter\n \n # tmp values (row/column)\n tr, tc = row, column\n \n # go top\n while (tr-=1) >= 0\n break if grid[tr][column] <= 0\n c += 1\n end\n \n # go right\n while (tc+=1) < n\n break if grid[row][tc] <= 0\n c += 1\n end\n \n # go down\n tr = row # reset\n while (tr+=1) < n\n break if grid[tr][column] <= 0\n c += 1\n end\n \n # go left\n tc = column # reset\n while (tc-=1) >= 0\n break if grid[row][tc] <= 0\n c += 1\n end\n \n c # sum\nend",
"def cols_array\n arr = Array.new\n @columns_hash.each{|k,v| arr << k}\n return arr\n end",
"def _get_board_columns()\n column_index = 0\n array_of_columns = []\n until column_index == 9\n row_index = 0\n until row_index == 9\n array_of_columns << sudoku_board[row_index][column_index]\n row_index += 1\n end\n column_index += 1\n end\n array_of_columns.each_slice(9).to_a\n end",
"def get_col(col)\n board = $boggle_board\n board.map{|array| array[col]}\nend",
"def cells_for_row row, offset, maxcol\n cells = cells_in_row row\n cells = cells[1 .. maxcol]\n cells.select_with_index { |cell, cidx| (cidx % data_cell_span) == offset }\n end",
"def visible\n\t\tres = []\n\t\ti = 0\n\t\twhile i < @lines.size\n\t\t\tres << i\n\t\t\ti += @lines[i].folded_lines + 1\n\t\tend\n\t\tres\n\tend",
"def rows\n rows_and_cols.first\n end",
"def get_hidden_columns\n @hidden_columns_cache = @columns - get_visible_columns if @hidden_columns_cache.nil?\n @hidden_columns_cache\n end",
"def columns \n @c\n end",
"def get_col(board,col)\n\tboard.map { |row| row[col] }\nend",
"def show\n @row_columns = @container_row.row_columns\n end",
"def collection_cards_by_row_and_col(rows:, cols:)\n table = CollectionCard.arel_table\n all_collection_cards.where(\n table[:row].gteq(rows[0])\n .and(\n table[:row].lteq(rows[1]),\n )\n .and(\n table[:col].gteq(cols[0]),\n )\n .and(\n table[:col].lteq(cols[1]),\n ),\n ).ordered_row_col\n end",
"def to_ary_cols\n ary = Array.new\n cola = Array.new\n coli = 0\n each_index_by_cols do |row, col|\n if coli != col\n coli = col\n ary << cola\n cola = Array.new\n end\n\n cola << self[row, col]\n end\n\n ary << cola\n ary\n end",
"def get\n return [@row, @col]\n end",
"def cols\n @dimension\n end",
"def get_col(board, col)\n column = []\n board.each_with_index { |obj,i| column.push(board[i][col])}\n return column\nend",
"def get_col(col_index)\n @boggle_board.map {|row| row[col_index]}\n end",
"def colrow() @records.get_data(GRT_COLROW); end",
"def get_column_elements(column)\n @cells.each_with_object([]) do |row, queried_column|\n queried_column << row[column]\n end\n end",
"def columns\n @cr[2] & 0x7f\n end",
"def get_col(col)\n $boggle_board.transpose[col]\nend",
"def columns; @columns; end",
"def get_col(game,col)\n\tcolumn = []\n game.each do |x|\n column.push(x[col])\n end\n column\nend",
"def get_col(board, col)\n board.map {|x| x[col]}\nend",
"def get_array_by_row()\n\t\tprepare(@dim_i,@dim_j)\n\t\treturn @myTab\n\tend",
"def get_column(col_num)\n column = []\n @grid.each do |row|\n column << row[col_num]\n end\n column\n end",
"def get_col(board, col)\n column = []\n board.each { |row| column.push(row[col])}\n return column\nend",
"def aggregate_col_data(row)\n\t\tdata_cols = (1..NUM_COL).reject{|i| REJECT.include?(i)}.compact\n\n\t\tformat_first_col(row)\n\t\t\t.concat(\n\t\t\t\tdata_cols.collect do |col|\n\t\t\t\t\ttext = doc.css('div.games-fullcol').css('table').css('tr')[row].css('td')[col].text\n\t\t\t\t\tcol == 2 ? format_team_owner(text) : text \n\t\t\t\tend).join(\",\")\n\tend",
"def columns\n cols = []\n (0...size).each do |i|\n vals = []\n (0...size).each do |j|\n vals.push(get_square({:column => i, :row => j}))\n end\n cols.push(Row.new(size, {:vals => vals}))\n end\n cols\n end",
"def visible_columns\n @visible_columns ||= (request_columns.empty? ? columns : columns.select { |column| visible_column?(column) })\n end",
"def get_col(board, col)\n column = []\n board.each do |x|\n column.push(x[col])\n\tend\n return column\nend",
"def rows\n @array\n end",
"def columns; @columns_hash.values; end",
"def make_columns(rows)\n columns = Array.new(rows.size) { [] }\n # make an empty nested array to represent columns.\n # iterate through the rows, for each row...\n # place the number into the new nested array evenly across the subarrays\n rows.each do |row|\n row.each_with_index do |num, col_idx|\n columns[col_idx] << num\n end\n end\n columns\nend",
"def to_a\n columns\n end",
"def hidden_tuple_from_row row, type\n\t\thidden_tuple get_row_cells(row), type\n\tend",
"def board_row_values(board, row_number)\n start_value = row_number == 1 ? 0 : (row_number * BOARD_WIDTH) - BOARD_WIDTH\n board.values.slice(start_value, BOARD_WIDTH)\nend",
"def get_col(board, column)\n\tboard.map {|col| col[column]}\nend",
"def column_vectors\n # (0 .. column_size - 1).collect { |i| column(i) }\n my_rows = @rows\n r_size = my_rows.size\n col_size = my_rows[0].size\n vector_cls = Vector\n array_cls = Array\n res = array_cls.new(col_size)\n for j in 0..col_size-1 do\n a_col = array_cls.new(r_size)\n for i in 0..r_size-1 do\n a_col[i] = my_rows[i][j]\n end\n res[j] = Vector.elements(a_col, false)\n end\n res\n end",
"def row_values(row)\r\n assert_exists\r\n arr_rows = rows\r\n cells = arr_rows[row - 1].cells\r\n values = Array.new(cells.length)\r\n for i in 0..cells.length - 1 do\r\n values[i] = cells[i].to_s\r\n end\r\n return values\r\n end",
"def get_diagonal_elements(row, column)\n queried_diagonals = [1,-1].each_with_object([]) do |slope, diagonals|\n diagonal = get_points(column, row, slope).each_with_object([]) do |point, elements|\n elements << @cells[point[1]][point[0]]\n end\n\n diagonals << diagonal\n end\n\n queried_diagonals.reject {|diagonal| diagonal.size == 1 }\n end",
"def get_col(game,col)\n\tcolumn = []\n game.each do |x|\n column.push(x[col])\n end\ncolumn\nend",
"def get_column(index)\n column = []\n self.rows.times do |i|\n column.push(@state[i][index])\n end\n\n column\n end",
"def columns()\n (cr=@records.get(GRT_COLROW)) ? cr[0] : nil\n end",
"def cells\n rows.flatten\n end",
"def split_rows\n\t\t@board.values.each_slice(15).to_a\n\tend",
"def columns\n puzzle.transpose\n end",
"def cols\n shape[1]\n end",
"def neighbours(line, column)\n min_col, max_col, min_line, max_line = bound_check(line, column)\n neighbourhood = []\n\n # Iterate 3x3 block\n (min_line..max_line).each do |l|\n (min_col..max_col).each do |c|\n next if l == line && c == column # Skip itself\n\n @grid[l][c].position(line: l, column: c)\n neighbourhood << @grid[l][c]\n end\n end\n\n neighbourhood\n end",
"def columns\n @columns\n end",
"def columns\n @columns\n end",
"def column_at(column_idx)\n (0..@height-1).map do |row_idx|\n element_at(row_idx, column_idx)\n end\n end",
"def column_values(column)\r\n assert_exists\r\n arr_rows = rows\r\n values = Array.new(arr_rows.length)\r\n for i in 0..arr_rows.length - 1 do\r\n values[i] = arr_rows[i][column].to_s \r\n end\r\n return values\r\n end",
"def _get_board_rows()\n array_of_rows = []\n sudoku_board.each { |row| array_of_rows << row }\n end",
"def rowcol\n return self.row+@row_offset, self.col+@col_offset\n end",
"def columns \n []\n end",
"def rows\n @dimension\n end",
"def neighbors(row, col, arr)\n height = arr.size\n width = arr[0].size\n neighbors = []\n neighbors << [row, col + 1] if col + 1 < width && arr[row][col + 1] >= 1\n neighbors << [row, col - 1] if col - 1 >= 0 && arr[row][col - 1] >= 1\n neighbors << [row + 1, col] if row + 1 < height && arr[row + 1][col] >= 1\n neighbors << [row - 1, col] if row - 1 >= 0 && arr[row - 1][col] >= 1\n\n neighbors\nend",
"def board_column_values(board, column_number)\n column_values = []\n\n BOARD_HEIGHT.times do |i|\n column_values << board.values[column_number - 1 + BOARD_WIDTH * i]\n end\n column_values\nend",
"def columns\n c = []\n cells.group_by {|cell| cell.coordinate.y}.each_pair do |key,value|\n c << Column.new(position: key, cells: value)\n end\n c\n end",
"def get_col(board, col)\n board.transpose[col]\nend",
"def set_cols(visible, list)\n @rows = 1 if visible\n @cols = (depends_on & list).find_all { |u| u.visible }.inject(0) { |s, v| s + (v.cols || 0) }\n @cols = 1 if @cols == 0 and visible\n end",
"def columns\n @header.to_a\n end",
"def data\n vertical? ? columns : rows\n end",
"def grid_row_columns\n grid_row_fields.keys - grid_row_skipped_columns\n end",
"def columns; end",
"def column(n)\n column = []\n each_row do |row|\n column << row[n]\n end\n return column\n end",
"def columns\n @columns\n end",
"def pick_a_column(board, *coords)\n\t\tcolumn_array = []\n \tcolumn_array << coords.map { |coord| board[coord.first][coord.last]}\n\tend",
"def get_col(col, boggle_board)\n\tboggle_board.map {|x| x.fetch(col)} # so the .fetch method calls the index of each sub-array.\n\t\n end",
"def visible\n lines.map { |line| line[ox...(ox + bordered_width)] || '' }\n end",
"def get_all_sorted_columns\n @all_cols_cache = get_visible_columns + get_hidden_columns if @all_cols_cache.nil?\n return @all_cols_cache\n end"
] |
[
"0.6800079",
"0.67770416",
"0.64326525",
"0.63399136",
"0.6281308",
"0.6272814",
"0.62722653",
"0.6207757",
"0.6197278",
"0.61805534",
"0.6173692",
"0.61454064",
"0.6128624",
"0.61245334",
"0.61191356",
"0.6100184",
"0.60742474",
"0.60221314",
"0.60187423",
"0.599238",
"0.5982238",
"0.5962962",
"0.59555924",
"0.59401315",
"0.59236014",
"0.59217316",
"0.58905154",
"0.588477",
"0.58678275",
"0.58562136",
"0.58138806",
"0.58098817",
"0.57972205",
"0.57950956",
"0.57886165",
"0.57816625",
"0.5776522",
"0.57668054",
"0.57614005",
"0.5753719",
"0.57528377",
"0.57509327",
"0.57345784",
"0.57324713",
"0.57249063",
"0.5722712",
"0.5721803",
"0.571966",
"0.5709626",
"0.57080525",
"0.5706948",
"0.5698795",
"0.5696614",
"0.5692093",
"0.56888515",
"0.56840676",
"0.5675585",
"0.5673644",
"0.5672927",
"0.5670326",
"0.56693166",
"0.56640124",
"0.56508636",
"0.56446",
"0.5637718",
"0.56363446",
"0.56350476",
"0.5632992",
"0.5616228",
"0.5609328",
"0.5603833",
"0.5594558",
"0.5560569",
"0.5551312",
"0.55469865",
"0.55411196",
"0.55406344",
"0.5540294",
"0.5540294",
"0.55324626",
"0.55321205",
"0.55265856",
"0.5525451",
"0.55153847",
"0.55124104",
"0.55123705",
"0.5509765",
"0.5498448",
"0.5492567",
"0.5477265",
"0.5476076",
"0.5474403",
"0.54673123",
"0.5464664",
"0.5457654",
"0.54538256",
"0.5442046",
"0.54404527",
"0.5436227",
"0.5432426"
] |
0.8342887
|
0
|
Now returns an array with formatted data
|
def render
raise "tabular:: list is nil " unless @list
$log.debug " render list:: #{@list.size} "
#$log.debug " render list:1: #{@list} "
raise "tabular:: columns is nil " unless @columns
buffer = []
@separ = nil
_guess_col_widths
rows = @list.size.to_s.length
#@rows = rows
fmstr = _prepare_format
$log.debug "tabular: fmstr:: #{fmstr}"
$log.debug "tabular: cols: #{@columns}"
#$log.debug "tabular: data: #{@list}"
str = ""
if @numbering
str = " "*(rows+1)+@y
end
#str << fmstr % visible_column_names()
str << convert_heading_to_text(visible_column_names(), fmstr)
buffer << str
#puts "-" * str.length
buffer << separator if @use_separator
if @list ## XXX why wasn't numbering done in _prepare_format ???? FIXME
if @numbering
fmstr = "%#{rows}d "+ @y + fmstr
end
#@list.each { |e| puts e.join(@y) }
count = 0
@list.each_with_index { |r,i|
if r == :separator
buffer << separator
next
end
if @_hidden_columns_flag
r = visible_columns(r)
end
if @numbering
r.insert 0, count+1
end
#value = convert_value_to_text r, count
value = convert_value_to_text r, fmstr, i
buffer << value
count += 1
}
end
buffer
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format data\n data\n end",
"def to_ary\n [\"#{id}: #{description}\", @raw_data]\n end",
"def parse_raw_data\n data_slices.to_a\n end",
"def convert(data_array, format)\n formated_text_and_coordinates=[]\n for i in 0 ... format.items.size\n formated_text_current = format.items[i][2].clone\n for j in 0 ... data_array.size\n if formated_text_current =~ /__#{j}__/\n if ! data_array[j] then data_array[j]=\"\" end\n eval \"formated_text_current.gsub!(/__#{j}__/,data_array[j])\"\n end\n end\n formated_text_and_coordinates.push([format.items[i][0], format.items[i][1], formated_text_current])\n end\n return formated_text_and_coordinates\nend",
"def convert(data_array, format)\n formated_text_and_coordinates=[]\n for i in 0 ... format.items.size\n formated_text_current = format.items[i][2].clone\n for j in 0 ... data_array.size\n if formated_text_current =~ /__#{j}__/\n if ! data_array[j] then data_array[j]=\"\" end\n eval \"formated_text_current.gsub!(/__#{j}__/,data_array[j])\"\n end\n end\n formated_text_and_coordinates.push([format.items[i][0], format.items[i][1], formated_text_current])\n end\n return formated_text_and_coordinates\nend",
"def to_output_format(data)\n records = []\n data.each do |arr|\n records << {\n last_name: arr[0],\n first_name: arr[1],\n gender: arr[2],\n favorite_color: arr[3],\n birthdate: arr[4]\n } \n end\n records\n end",
"def formatted_data\n self.data['bids'] = adjusted('bids')\n self.data['asks'] = adjusted('asks')\n data\n end",
"def to_array\n return [@filename,\n @timestamp,\n @source,\n @rmr_number,\n @series_description,\n @gender,\n @slice_thickness,\n @slice_spacing,\n @reconstruction_diameter, \n @acquisition_matrix_x,\n @acquisition_matrix_y]\n end",
"def lines; [to_s]; end",
"def format_data\n formatted_rows = []\n @data.each do |row|\n values = []\n row.each_with_index do |entry,index|\n # Format/escape individual values for javascript, checking column types, and the ruby value as a failsafe\n safe_val = if @column_types[index] == \"date\" || entry.is_a?(Date)\n # Format a date object as a javascript date\n entry.is_a?(String) ? entry : \"new Date (#{entry.year},#{entry.month - 1},#{entry.day})\"\n elsif @column_types[index] == \"datetime\" || entry.is_a?(Time)\n # Format a Time (datetime) as a javascript date object down to seconds\n entry.is_a?(String) ? entry : \"new Date (#{entry.year},#{entry.month - 1},#{entry.day},#{entry.hour},#{entry.min},#{entry.sec})\"\n else\n # Non date/time values can be JS escaped/formatted safely with # to_json\n entry.to_json\n end\n values << safe_val\n end\n rowstring = \"[#{values.join(\", \")}]\"\n formatted_rows << rowstring\n end\n \"[#{formatted_rows.join(', ')}]\"\n end",
"def get\n to_array.join(\"\\r\\n\")\n end",
"def format_data data\r\n\tresult = []\r\n\t#split entry to array\r\n\tarr = data.read.split '>'\r\n\tarr.each do |item|\r\n\t\tname = item.split('|')[0]\r\n\t\tnext if !name\r\n\r\n\t\tprotein = []\r\n\t\t#format name\r\n\t\tname.delete! ' '\r\n\t\tname.tr! '|', ''\r\n\r\n\t\t#format sequence\r\n\t\ttmp = item.split \"\\n\"\r\n\t\ttmp.shift\r\n\t\tsequence = tmp.join\r\n\r\n\t\tprotein.push name, sequence\r\n\r\n\t\tresult.push protein\r\n\tend\t\r\n\tresult\r\n\r\nend",
"def to_a \n return @data\n end",
"def to_a #:nodoc:\n data.to_a\n end",
"def to_a\n map { |e| e.data}\n end",
"def get_data_as_text()\n get_data_as_array().join(\", \")\n end",
"def to_array\n [ self.company.name,\n self.invoice_num,\n self.invoice_date,\n self.operation_date,\n self.reporter,\n self.notes,\n self.status,\n self.categories.pluck(:name).join(\";\")\n ]\n end",
"def as_content_array\n as_array[1]\n end",
"def converted_arrays; end",
"def format\n collect { |a| a.format }\n end",
"def to_a; Array(force) end",
"def to_ary\n\t\t@data.flatten\n\tend",
"def to_a\n @data\n end",
"def formatData(data)\n data.keys.each{|key| data}\n end",
"def to_a\n return [] unless @ready\n\n case @data\n when String\n case @mode\n when :default\n @data.each_codepoint.to_a.collect{|p| PETSCII[p]}\n when :screen\n @data.upcase.each_codepoint.to_a.collect{|p| CHAR_MAP[p]}\n end\n when Array\n case @mode\n when :default\n @data.dup\n when :word\n @data.collect{|e| [e.ls_byte, e.ms_byte]}.flatten\n end\n end\n end",
"def make_array\n [@name, @author, @deviation_url, @views, @favs, @comments]\n end",
"def to_s\n array = []\n array << @header.to_s if @header\n # add a blank line after header\n array << \"\"\n @entries.each do |entry|\n array << entry.to_s\n end\n array.join(\"\\n\")\n end",
"def format_trending\n @formatted_arr = []\n @data.each do |data| \n hash = {}\n # Check for edge case of trending developers without a repository\n if data.include? 'repo'\n hash = { \n name: data['name'], \n username: data['username'], \n avatar: data['avatar'],\n repo: { name: data['repo']['name'] }, \n description: data['repo']['description'],\n url: data['repo']['url']\n }\n else \n hash = { \n name: data['name'],\n username: data['username'],\n avatar: data['avatar'],\n }\n end\n @formatted_arr << hash\n end\n @formatted_arr\n end",
"def get_formatting_data\n format = @data[country][:format]\n prefix = @data[country][Core::NATIONAL_PREFIX]\n rule = (format[Core::NATIONAL_PREFIX_RULE] ||\n @data[country][Core::NATIONAL_PREFIX_RULE] || '$1')\n\n [format, prefix, rule]\n end",
"def to_array\n\n [\n @seconds,\n @minutes,\n @hours,\n @days,\n @months,\n @weekdays,\n @monthdays,\n @timezone ? @timezone.name : nil\n ]\n end",
"def format_to_array(value)\n case value\n when Array then value\n when String then value.split(separator)\n else raise InvalidTagFormat\n end\n end",
"def to_s\n @data.map(&:to_s).join(\"\\n\")\n end",
"def to_s\n data.map { |ar| ar.map { |v| v.to_s.gsub(/\\t|\\n|\\r/,' ') }.join \"\\t\" }.join( $/ )\n end",
"def to_a\n docnumb = self.number\n docdate = self.date ? self.date.oris_format : Date.today.oris_format\n currency = self.currency ? self.currency : 'GEL'\n project = self.project ? self.project.to_geo : ' მთ.წიგნი'.to_geo\n sysdate = self.sysdate ? self.sysdate.oris_format : Date.today.oris_format\n unit = self.unit ? self.unit.to_geo : 'ერთეული'.to_geo\n quant = self.quantity || 0\n quant2 = self.quantity_normal || quant\n user = self.user ? self.user.to_geo : ''\n ['', '', '', docnumb, '0', docdate, ORIS.oris_acc_code(self.acc_debit), ORIS.oris_acc_code(self.acc_credit),\n '0', self.calc_amount, currency, self.description, '0', '1', unit, quant, quant2, project, user,\n '0', '9', '0', '', '0', sysdate, self.related_to, '0', '1', '3', '', '0', '', '']\n end",
"def summary_array\n row = []\n column = [DueText.minutes, till_or_since, calc_mins_till.round(2), DueText.minutes_suffix]\n row << column\n column = [DueText.hours, till_or_since, calc_hours_till.round(2), DueText.hours_suffix]\n row << column\n column = [DueText.days, till_or_since, calc_days_till.round(2), DueText.days_suffix]\n row << column\n column = [DueText.weeks, till_or_since, calc_weeks_till.round(2), DueText.weeks_suffix]\n row << column\n column = [DueText.months, till_or_since, calc_months_till.round(2), DueText.months_suffix]\n row << column\n column = [DueText.years, till_or_since, calc_years_till.round(2), DueText.years_suffix]\n row << column\n end",
"def formats; end",
"def formats; end",
"def data_format\n object.content\n end",
"def to_ary() end",
"def to_a\n data.all\n end",
"def predict_format_converter usages\r\n @date = []\r\n @total = []\r\n @lines = []\r\n @labels = []\r\n @table_array = []\r\n usages[:daily_usage].each do |usage|\r\n @date.append(usage[:date].to_s)\r\n\r\n @total.append(usage[:usage])\r\n end\r\n @table_array.append(\"date[i]\")\r\n @table_array.append(\"total[i]\")\r\n usages[:daily_time_periods].each_with_index do |period, index|\r\n @name =\"lines[#{index.to_s}][i]\"\r\n @table_array.append(@name)\r\n @lines.append([])\r\n @labels.append(period[:label])\r\n period[:daily_usage].each do |usage|\r\n @lines[index].append(usage[:usage])\r\n\r\n end\r\n end\r\n end",
"def to_a\n\t\tarr = []\n\t\teach {|valor| arr << valor}\n\t\tarr\n\tend",
"def get_records_format_data(class_name, fields, condition = nil)\n ret = []\n ret.push([\"\",\"\"])\n class_name.find(:all).each do |rec|\n tmp = \"\"\n fields[1..fields.size-1].each do |field|\n tmp += \" \" if tmp.length > 0\n tmp += rec[field]\n end\n ret.push([rec[fields[0]], tmp])\n end\n return ret\n end",
"def to_a\n [@pid, @code, @data]\n end",
"def to_a\n [@year,@month,@day]\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def to_a\n array\n end",
"def to_a\n [status.to_i, headers.to_h, body.to_s]\n end",
"def to_a\n [@trd, @sld, @tld]\n end",
"def to_s\n to_ary\n end",
"def prepare_source_array data\n return [] if data.empty?\n if (leading_2_bytes = (leading_bytes = (first = data[0]).unpack 'C3').slice 0, 2) == BOM_BYTES_UTF_16LE\n data[0] = first.byteslice 2, first.bytesize\n # NOTE you can't split a UTF-16LE string using .lines when encoding is UTF-8; doing so will cause this line to fail\n return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16LE).rstrip}\n elsif leading_2_bytes == BOM_BYTES_UTF_16BE\n data[0] = first.byteslice 2, first.bytesize\n return data.map {|line| (line.encode ::Encoding::UTF_8, ::Encoding::UTF_16BE).rstrip}\n elsif leading_bytes == BOM_BYTES_UTF_8\n data[0] = first.byteslice 3, first.bytesize\n end\n if first.encoding == ::Encoding::UTF_8\n data.map {|line| line.rstrip}\n else\n data.map {|line| (line.encode ::Encoding::UTF_8).rstrip}\n end\n end",
"def array()\n\t\t@array\n\tend",
"def build_data_array\n table = helper_class.new(@file_upload.file.path).to_table # # load data to array of hashes\n errors = []\n data = table.map do |item_hash|\n process_item(attributes(item_hash), errors)\n end\n [data, errors]\n end",
"def to_a\n [\"#{status_code} #{reason_phrase}\", headers, entity_body]\n end",
"def to_array\n\t\t\tm_color = self.color.delete(' ')\n\t\t\tm_color.delete!('cielab(')\n\t\t\tm_color.delete!(')')\n\n\t\t\tm_color = m_color.split(',')\n\t\t\tm_color[0] = m_color[0].to_f / 100\n\t\t\tm_color[1] = m_color[1].to_f.round(4) \n\t\t\tm_color[2] = m_color[2].to_f.round(4)\n\t\t\tm_color \n\t\tend",
"def to_a\n notes.map(&:to_h)\n end",
"def return_arr_txts\r\n IO.write(\"./DEBUG\", \"docclass=\"+@doc.to_s+\" andinfoclass= \"+@@info_past.class.to_s+\"=\"+@@info_past.to_s)\r\n @doc = @@info_past[1]\r\n if @doc[\"doc\"].empty?\r\n return [\"0\"]\r\n else\r\n return @doc[\"doc\"] #retorna os nomes dentro de um Array\r\n end\r\n end",
"def to_a\n [\n \"Auto Restart: #{automatic_restart}\",\n \"Case Sensitivity: #{case_sensitive_matching}\",\n \"Hashtag TTL: #{tag_time_to_live_in_seconds}\",\n \"Storage Type: #{hashtag_storage_class}\",\n \"Streaming Endpoint: #{streaming_endpoint}\",\n \"Valid Keys: #{is_valid?}\",\n \"Log Device: #{log_capture_device == STDOUT ? 'console' : log_capture_device}\"\n ]\n end",
"def to_flex_array\n self\n end",
"def to_a\n @data.inject([]) { |array, h| array.push(h.values)}\n end",
"def to_a\n @content.collect { |item| assemble(item) }\n end",
"def format(result)\n result.values.join(\"\\n\")\n end",
"def table_to_array_of_arrays(table=@table)\n array = []\n table.rows.each do |row|\n row_array = []\n row.data.each_with_index do |column, index|\n data = {:text => column}\n if row.cell_format.is_a? Hash\n data.reverse_merge! row.cell_format\n elsif row.cell_format.is_a? Array\n data.reverse_merge! row.cell_format[index]\n end\n row_array << Prawn::Table::Cell.new(data)\n end\n array << row_array\n end\n array\n end",
"def data\n to_h\n end",
"def to_a; [Array]; end",
"def to_s\n to_data.map(&:to_s).join(\"\\n\")\n end",
"def getArrMeses\n m = Array.new\n \n m[1] = \"Enero\"\n m[2] = \"Febrero\"\n m[3] = \"Marzo\"\n m[4] = \"Abril\"\n m[5] = \"Mayo\"\n m[6] = \"Junio\"\n m[7] = \"Julio\"\n m[8] = \"Agosto\"\n m[9] = \"Septiembre\"\n m[10] = \"Octubre\"\n m[11] = \"Noviembre\"\n m[12] = \"Diciembre\"\n \n return m\n end",
"def convert_to_string\n @data.join(\"\\n\")\n end",
"def q1_read_to_array(data_file_name)\r\n array2d = []\r\n \r\n read_file(\"data/\"+data_file_name).each{ |line|\r\n array1d = line.split(\",\").map(&:strip).map(&:to_s)\r\n array2d << array1d\r\n }\r\n return array2d\r\nend",
"def helper_for_parsing_sprint_info obj, arr\n arr.map do |field_num|\n \"#{obj[0].split(',')[field_num].split(\"=\")[1]}\" if obj\n end\n end",
"def data\n [@name, @format, @entry, @processors]\n end",
"def field_to_array(field)\n final = []\n field.each do |value|\n final << value.to_s\n end\n final\n end",
"def to_a\n each.to_a\n end",
"def to_a\n each.to_a\n end",
"def formatter; end",
"def formatter; end",
"def formatter; end",
"def value_as_array(item, format: \"YMDhms\")\n value = raw_value(item)\n return nil if value.nil?\n\n defaults = {}\n format.each_char { |c| defaults[c] = \"\" }\n defaults.map do |key, default_value|\n value[key] || default_value\n end\n end",
"def to_r() end",
"def to_array str\n array = []\n str.split().each do |i|\n entry = i.split(\",\")\n\n width = entry[0].to_i\n height = entry[1].to_i\n\n if entry.length == 2\n array << [width, height]\n else\n ALL_MACROS[entry[2]].call(width, height, array)\n end\n end\n\n array\nend",
"def to_a\n [year, month, day, hour, minute, second, zone]\n end",
"def to_ary; []; end",
"def to_a\n return [@t_year, @t_month, @t_day, @t_hour, @t_min, @t_sec, @t_usec]\n end",
"def to_a\n self.to_s.split(' ', 6)\n end",
"def to_json\n JSON.pretty_generate(@data)\n end",
"def to_json\n i = 0\n datas = Array.new\n td = Array.new\n\n ds = @data\n ds.each_with_index do |row,index|\n data = \"{\"\n td.clear\n row.each_pair do |key,value|\n td.push(\"#{format(key)}: #{format(value)}\")\n end\n\n data +=td.join(\",\")\n data += \"}\"\n datas.push(data)\n end\n data = \"[#{datas.join(\",\")}]\"\n data\n end",
"def to_s\n \"[ Date: \" + @date.to_s + \", Precipitation: \" + @precipitation.to_s + \", Temperature: \" + @temp.to_s + \" ]\"\n end",
"def as_array\n @fm.dup\n end",
"def to_a()\n end",
"def to_a\n a = []\n \n @collection.each do |e|\n a << e.style \n end\n \n return a\n end",
"def prepare_source_array data\n return [] if data.empty?\n if (leading_2_bytes = (leading_bytes = (first = data[0]).unpack 'C3').slice 0, 2) == BOM_BYTES_UTF_16LE\n data[0] = first.byteslice 2, first.bytesize\n # NOTE you can't split a UTF-16LE string using .lines when encoding is UTF-8; doing so will cause this line to fail\n return data.map {|line| (line.encode UTF_8, ::Encoding::UTF_16LE).rstrip }\n elsif leading_2_bytes == BOM_BYTES_UTF_16BE\n data[0] = first.byteslice 2, first.bytesize\n return data.map {|line| (line.encode UTF_8, ::Encoding::UTF_16BE).rstrip }\n elsif leading_bytes == BOM_BYTES_UTF_8\n data[0] = first.byteslice 3, first.bytesize\n end\n if first.encoding == UTF_8\n data.map {|line| line.rstrip }\n else\n data.map {|line| (line.encode UTF_8).rstrip }\n end\n end",
"def record_to_array(r, attrs)\n []\n end",
"def to_a\n #convert to array\n [@id, @name, @address, @city, @county, @state, @zip]\n end",
"def email_record_to_array(db_record)\n retval = []\n\n retval << db_record.character_count\n retval << db_record.alpha_numeric_count\n retval << db_record.alpha_numeric_ratio\n retval << db_record.digit_count\n retval << db_record.whitespace_count\n\n ('a'..'z').each do |letter|\n retval << db_record.send(\"#{letter}_count\")\n end\n\n retval << db_record.asterisk_count\n retval << db_record.underscore_count\n retval << db_record.plus_count\n retval << db_record.equals_count\n retval << db_record.percent_count\n retval << db_record.dollar_sign_count\n retval << db_record.at_count\n retval << db_record.minus_count\n retval << db_record.backslash_count\n retval << db_record.slash_count\n retval << db_record.word_count\n retval << db_record.short_word_count\n retval << db_record.average_word_length\n retval << db_record.average_sentence_character_length\n retval << db_record.average_sentence_word_length\n\n (1..15).each do |length| \n retval << db_record.send(\"words_of_length_#{length}_ratio\")\n end\n\n retval << db_record.number_of_unique_words\n retval << db_record.once_occuring_words_freq\n retval << db_record.twice_occuring_words_freq\n\n retval << db_record.period_count\n retval << db_record.tick_count\n retval << db_record.semicolon_count\n retval << db_record.question_mark_count\n retval << db_record.exclamation_mark_count\n retval << db_record.colon_count\n retval << db_record.left_paren_count\n retval << db_record.right_paren_count\n retval << db_record.dash_count\n retval << db_record.quotation_mark_count\n retval << db_record.left_double_arrow_count\n retval << db_record.right_double_arrow_count\n retval << db_record.less_than_count\n retval << db_record.greater_than_count\n retval << db_record.left_bracket_count\n retval << db_record.right_bracket_count\n retval << db_record.left_brace_count\n retval << db_record.right_brace_count\n\n retval\n end",
"def prettyify_array(gemspec_ruby, array_name); end",
"def array\n\t\t#create an array of\n\t\tarray = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\tend",
"def to_a\n [value, timestamp]\n end",
"def line_style_to_array(data)\n return default_line_style if data.nil?\n thickness = data[:thickness] || default_line_style.first\n style = data[:style]\n style_arr = style.is_a?(Hash) ? [style[:solid], style[:blank]] :\n line_style_definition(style, thickness)\n [thickness] + style_arr\n end",
"def to_ordered_array\n [self.test_execution_date, self.full_name, self.test_names,\n self.total_amount, self.sum_of_doctor_commission, self.doctor_received_paymet]\n end",
"def values\n @data.values\n end",
"def to_s\n return \"[\" + @id.to_s + \" , \" + @name +\" , \" + @age.to_s + \" , \" + @wage.to_s + \" , \" \\\n + @active.to_s + \"]\"\n end"
] |
[
"0.70158577",
"0.69932467",
"0.6614158",
"0.64066076",
"0.6406329",
"0.63066924",
"0.6252737",
"0.62265384",
"0.6216922",
"0.62026376",
"0.61905193",
"0.6176119",
"0.61705196",
"0.61339253",
"0.6120145",
"0.6102318",
"0.60958934",
"0.6079461",
"0.60642844",
"0.60520196",
"0.60499716",
"0.6037381",
"0.5997378",
"0.59739316",
"0.5971317",
"0.5970383",
"0.5957753",
"0.59552175",
"0.5946903",
"0.5916194",
"0.5900985",
"0.58986807",
"0.58904",
"0.58798665",
"0.58753145",
"0.58542025",
"0.58542025",
"0.58540475",
"0.5848077",
"0.5845217",
"0.5829559",
"0.58138067",
"0.5804607",
"0.58040434",
"0.58033377",
"0.57975006",
"0.5796312",
"0.5789456",
"0.57874477",
"0.5785774",
"0.5779524",
"0.5772001",
"0.5768754",
"0.57632196",
"0.5758423",
"0.57561",
"0.575072",
"0.57482904",
"0.5747009",
"0.5745042",
"0.57442653",
"0.5740888",
"0.57326835",
"0.57239026",
"0.57218385",
"0.5719053",
"0.570934",
"0.5706561",
"0.5694384",
"0.56923944",
"0.5686451",
"0.56835145",
"0.56741846",
"0.56741846",
"0.567246",
"0.567246",
"0.567246",
"0.56623495",
"0.56588304",
"0.5657945",
"0.56560355",
"0.5655356",
"0.5654566",
"0.564634",
"0.5637873",
"0.5629619",
"0.5627072",
"0.5624262",
"0.5619311",
"0.5613621",
"0.5610482",
"0.5607806",
"0.55987525",
"0.55920553",
"0.5587586",
"0.55870956",
"0.5586607",
"0.5581734",
"0.5576179",
"0.5570208",
"0.556737"
] |
0.0
|
-1
|
use this for printing out on terminal NOTE: Do not name this to_s as it will print the entire content in many places in debug statements
|
def to_string
render().join "\n"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s\n Printer.instance.print(self)\n end",
"def print\n puts to_s\n end",
"def to_s\r\n pretty_output\r\n end",
"def to_s\n render().join \"\\n\"\n end",
"def to_s\r\n self.each do |r|\r\n puts r.each { |p| p }.join(\" \")\r\n end\r\n end",
"def print_temp\n print to_string\n end",
"def to_s\n \n each {|x| puts x}\n \n end",
"def to_s\n output || content || \"\"\n end",
"def to_s\r\n dump\r\n end",
"def to_s() @out.to_s end",
"def to_s\n rv = ''\n write rv\n rv\n end",
"def to_s\n Array(render).map(&:to_s).join(\"\\n\")\n end",
"def to_s()\n prettify()\n end",
"def print\n Kernel.print(self)\n end",
"def print(to = $stdout)\n to.print to_s\n end",
"def to_s\n \"#{@text}: #{@context}\"\n end",
"def to_s\n PrettyPrinter.new.process(to_sexp)\n end",
"def display\n to_s.split(\"\\n\")\n .map { |line| line.split('').join(' ') }\n .join(\"\\n\")\n end",
"def print\n puts @text\n end",
"def to_s\n\t\tputs \"{#{@nombre} => Proteínas: #{@proteinas} Carbohidratos: #{@carbohidratos} Lípidos: #{@lipidos} GEI: #{@gei} Terreno usado: #{@terrenousado}}\"\n\tend",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def to_s\n to_text\n end",
"def to_s\n @output.inject('') { |r, entry| r << entry.to_s }\n end",
"def to_s\n content.to_s\n end",
"def to_s\n content.to_s\n end",
"def to_s\n soup = @@boards_templates[1].to_s.scan(/...../)\n soup.each {|x| puts \"#{x}\\n\"} \n end",
"def to_s\n #\"\\#<#{self.class}-#{@name} - #{@top_dir}>\"\n \"\\#<#{self.class}-#{@name}>\"\n end",
"def to_s\n Alf::Renderer.text(self).execute(\"\")\n end",
"def to_s\n io = StringIO.new\n write io\n io.string\n end",
"def outtoconsole(things)\n\tsep = \" -> \"\n\tprint things.join(sep).to_s + \"\\n\"\nend",
"def to_s\n join(\"\\n\")\n end",
"def to_s\n text = ''\n\n text << \"#{@keyword}:#{name_output_string}\"\n text << \"\\n#{description_output_string}\" unless no_description_to_output?\n text << \"\\n\" unless steps.empty? || no_description_to_output?\n text << \"\\n#{steps_output_string}\" unless steps.empty?\n\n text\n end",
"def to_s\n text.to_s\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n inspect\n end",
"def to_s\n \"#{get_titulo} #{get_porcentaje}\\n#{get_conjunto_platos}\\nV.C.T. | % #{get_vct} | #{get_proteinas} - #{get_grasas} - #{get_hidratos}\" \n end",
"def print\n return ''\n end",
"def to_s\n @out.join\n end",
"def to_s\n text = ''\n\n text << tag_output_string + \"\\n\" unless tags.empty?\n text << \"#{@keyword}:#{name_output_string}\"\n text << \"\\n\" + description_output_string unless (description.nil? || description.empty?)\n text << \"\\n\" unless (steps.empty? || description.nil? || description.empty?)\n text << \"\\n\" + steps_output_string unless steps.empty?\n text << \"\\n\\n\" + examples_output_string unless examples.empty?\n\n text\n end",
"def dump_to_s\n output = \"\\r\\n---- Factory dump: ----\"\n @context_list.each do |context_key, context|\n if context.parent_context.instance_of?( V3::ContextDAO )\n output << \"\\r\\n(#{context.parent_context.id}) => '#{context_key}': #{ context }\"\n else\n output << \"\\r\\n'#{context_key}': #{ context }\"\n end\n end\n output << \"\\r\\n\"\n @entity_list.each do |entity_key, entity|\n output << \"\\r\\n'#{entity_key}': #{ entity }\"\n end\n output << \"\\r\\n-----------------------\\r\\n\"\n output\n end",
"def inspect\n to_s.inspect\n end",
"def raw_output(s)\n s\n end",
"def to_s\n \"[#{@type}]#{@content}\"\n end",
"def to_s\n inspect.to_s\n end",
"def to_s\n to_data.map(&:to_s).join(\"\\n\")\n end",
"def out(*args); to_s(*args); end",
"def to_s\n r = \"##### ##### ##### ##### #####\\n\"\n (0..2).each { |y|\n (0..2).each { |x|\n r += get_print_char(x,y, '.') + \" \"\n }\n r += (\" \" * 5)\n (0..2).each { |x|\n r += get_print_char(x,y, nil, \" \", \" \") + \" \"\n }\n r += \"\\n\"\n }\n r += '##### ##### ##### ##### #####'\n end",
"def inspect\n redacted_string(:inspect)\n end",
"def inspect\n redacted_string(:inspect)\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n to_buffer.to_s\n end",
"def to_s\n inspect\n end",
"def to_s\n inspect\n end",
"def inspect\n to_s\n end",
"def to_s\n\t\tout = \"\";\n\t\t# title\n\t\tout += \"# #{@title[:name].gsub!(/_/,'\\_')}: #{@title[:title]}\\n\\n\"\n\t\t# environment\n\t\tout += \"## Environment:\\n\" if @environment.size > 0\n\t\t@environment.each { |pk,pv|\n\t\t\tout += \"### #{pk}\\n```\\n#{pv}\\n```\\n\"\t\n\t\t}\n\t\t# prerequisites\n\t\tout += \"## Prerequisites:\\n\" if @prerequisites.size > 0\n\t\t@prerequisites.each { |pk,pv|\n\t\t\tout += \"### #{pk}\\n```\\n#{pv}\\n```\\n\"\t\n\t\t}\n\t\t# execution\n\t\tout += \"## Execution:\\n\" if @execution.size > 0\n\t\t# p execution.size, execution\n\t\t@execution.each { |pk,pv|\n\t\t\tout += \"### #{pk}\\n```\\n#{pv}\\n```\\n\"\t\n\t\t}\n\t\t# appLog\n\t\tout += \"### Application logs:\\n\" if @appLog.size > 0\n\t\t@appLog.each { |pk,pv|\n\t\t\tout += \"#### #{pk}\\n```\\n#{pv}\\n```\\n\"\t\n\t\t}\n\t\treturn out\n\tend",
"def to_s\n to_a.join(\"\\n\")\n end",
"def debug_str(inspect_method = :inspect)\n \"Current Date: #{self.input_date.readable}\\nCurrent Time: #{self.input_time.readable}\\n\\nQuery: #{self.query}\\nStandardized Query: #{self.nlp_query}\\nQuery changed in: #{self.nlp_query.changed_in.inspect}\\n\\nConstructs Found: #{s = \"\\n\"; self.construct_finder.constructs.each{|x| s << x.send(inspect_method) + \"\\n\"}; s}\\n\\n@construct_interpreter: #{self.construct_interpreter.send(inspect_method)}\"\n end",
"def stringOutput\n\t\tend",
"def stringOutput\n\t\tend",
"def inspect\n original_inspect = super\n original_inspect.split( ' ' ).first << '>'\n end",
"def inspect\n original_inspect = super\n original_inspect.split( ' ' ).first << '>'\n end",
"def inspect\n original_inspect = super\n original_inspect.split( ' ' ).first << '>'\n end",
"def to_s\n super\n @out << \"\\nTalla\\tPeso\\tCintura\\tCadera\\tBicipital\\tTricipital\\tSubescapular\\tSuprailiaco\\tBrazo\\n\"\n @out << @talla.to_s\n @out << \"\\t\"\n @out << @peso.to_s\n @out << \"\\t\"\n @out << @cintura.to_s\n @out << \"\\t\"\n @out << @cadera.to_s\n @out << \"\\t\"\n @out << @bicipital.to_s\n @out << \"\\t\"\n @out << @tricipital.to_s\n @out << \"\\t\"\n @out << @subescapular.to_s\n @out << \"\\t\"\n @out << @suprailiaco.to_s\n @out << \"\\t\"\n @out << @brazo.to_s\n @out << \"\\n\"\n @out\n end",
"def to_s\n \"\\n\\tTitle: #{@title}\\n\n \\tAuthor: #{@author}\\n\n \\tUrl: #{@url}\\n\\n\"\n end",
"def to_s\n @content.inspect\n end",
"def to_s\n contents.to_s\n end",
"def to_s\n text = ''\n\n text << \"#{tag_output_string}\\n\" unless tags.empty?\n text << \"#{@keyword}:#{name_output_string}\"\n text << \"\\n#{description_output_string}\" unless no_description_to_output?\n text << \"\\n\\n#{background_output_string}\" if background\n text << \"\\n\\n#{tests_output_string}\" unless tests.empty?\n\n text\n end",
"def to_s\n text\n end",
"def to_s\n self.inspect\n end",
"def to_s\n @to_s ||= traite_to_text\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def to_s\n toString()\n end",
"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 to_s\n text\n end",
"def to_s\n puts \"#{name} is a #{species} and plays with #{toys.join(\" \")}: \"\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def dump\r\n super + to_s\r\n end",
"def to_s\n self.inspect\n end",
"def to_s\n text\n end",
"def to_s\n text\n end",
"def to_s\n print \"[ \"\n\n each do |node|\n print \"#{node.data}\"\n print \", \" unless node.next_node == nil\n end\n\n print \" ]\\n\"\n end",
"def to_s\n print \"[ \"\n\n each do |node|\n print \"#{node.data}\"\n print \", \" unless node.next_node == nil\n end\n\n print \" ]\\n\"\n end",
"def pretty_print_me\n sio = PP.pp(self, \"\")\n\n # aber bitte ohne die ids und ohne @\n sio.gsub(/0x[^\\s]*/,'').gsub(/@/,'')\n end",
"def to_s\n pretty.uncolor.gsub(/(\\s*\\n)+/, \" \").gsub(/\\s{2,}/, \" \")\n end",
"def to_s\n string=\"\"\n each { |value| string+=value.to_s + \"\\n\" } # Funciona también entre do-end\n return string\n end",
"def debug_out()\n return JSON.pretty_generate(self).gsub(\"\\\": \", \"\\\" => \").gsub(\" => null\", \" => nil\")\n end",
"def print\n result = \"\"\n messages.each do |message|\n result += Thimbl::Utils.parse_time( message['time'] ).strftime( '%Y-%m-%d %H:%M:%S' )\n result += \" #{message['address']}\"\n result += \" > #{message['text']}\"\n result += \"\\n\"\n end\n \n return result\n end",
"def inspect\n \"\"\n end"
] |
[
"0.7424938",
"0.7352448",
"0.7339749",
"0.7282939",
"0.72734314",
"0.72063947",
"0.7173819",
"0.70856524",
"0.70621943",
"0.6977064",
"0.6933766",
"0.6931118",
"0.69023156",
"0.6887039",
"0.68830633",
"0.68762255",
"0.6872572",
"0.68509907",
"0.682394",
"0.68021905",
"0.6796641",
"0.6796641",
"0.6796641",
"0.6796641",
"0.6796641",
"0.6764008",
"0.675784",
"0.6719648",
"0.67191064",
"0.6716878",
"0.671378",
"0.67015254",
"0.6701522",
"0.6699522",
"0.6682306",
"0.6674181",
"0.6670228",
"0.66702014",
"0.6666335",
"0.66652846",
"0.66579884",
"0.6644008",
"0.66372305",
"0.66363454",
"0.6633699",
"0.66312885",
"0.6630973",
"0.66294324",
"0.6629312",
"0.66235083",
"0.6619688",
"0.66193974",
"0.66193974",
"0.661927",
"0.661927",
"0.661927",
"0.661927",
"0.661927",
"0.661927",
"0.661927",
"0.6618573",
"0.6614352",
"0.6614352",
"0.66046435",
"0.6602995",
"0.6598095",
"0.6596003",
"0.65885586",
"0.65885586",
"0.65842515",
"0.65842515",
"0.65842515",
"0.6576159",
"0.65735215",
"0.65719444",
"0.6571574",
"0.65709996",
"0.65636224",
"0.6561881",
"0.6561686",
"0.655802",
"0.655802",
"0.6556669",
"0.6554473",
"0.6554357",
"0.6548617",
"0.654764",
"0.654764",
"0.6546322",
"0.654293",
"0.65395343",
"0.65395343",
"0.65372676",
"0.65372676",
"0.6528692",
"0.65227646",
"0.65074587",
"0.6498838",
"0.64983624",
"0.6480815"
] |
0.70152366
|
9
|
This refers to a separator line after the heading and not a field separator. Badly named !
|
def separator
return @separ if @separ
str = ""
if @numbering
str = "-"*(rows+1)+@x
end
each_column { | c, ix|
v = c.width
next if v == 0 ## hidden column
str << "-" * (v+1) + @x
}
@separ = str.chop
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def separator; end",
"def lsep\n \"==================================================================================\"\n end",
"def line_divider \n puts @header.light_blue\n end",
"def separator\n nil\n end",
"def separator(type); end",
"def sep; end",
"def sep; end",
"def default_separator; end",
"def line_sep(title=nil); print \"\\n#{title} ----\\n\\n\"; end",
"def line_sep(title=nil); print \"\\n#{title} ----\\n\\n\"; end",
"def separator\n puts \" \"\n puts pastel.bright_magenta(\"======================================================\")\n puts \" \"\n end",
"def separator\n puts \" \"\n puts pastel.bright_magenta(\"======================================================\")\n puts \" \"\n end",
"def separator\n puts \" \"\n puts pastel.bright_magenta(\"======================================================\")\n puts \" \"\n end",
"def divider_line\n lines - 2\n end",
"def delimiter\n \" \"\n end",
"def delimiter\n \" \"\n end",
"def lineBreak \n \"lineBreak\" \n end",
"def separator\n @parts.push(separator: true)\n end",
"def middle_line\n border_options.separator ? \"\" : super\n end",
"def section_seperator\n puts <<EOF\n\n\n\n=========================\n=========================\nEOF\nend",
"def print_divider\n\t\tputs \"------------------------------------------------------------\"\n\tend",
"def separator\n \":\"\n end",
"def table_separation\n line = \"#{TABLE_COLUMN_LINE}|#{TABLE_COLUMN_LINE}\".dup\n line << \"|#{TABLE_COLUMN_LINE}\" if header_line_rate?\n line << \"|#{TABLE_COLUMN_LINE}\" if header_branch_rate?\n line << \"\\n\"\n end",
"def parse_line_break; end",
"def empty_line\n end",
"def separator\n return @separator\n end",
"def default_separator=(separator); end",
"def delim!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n\n\n type = DELIM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 305:3: '|'\n match( 0x7c )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n\n\n end",
"def p_blankline_hr\n p :class => \"underline\" do\n nbsp\n end\n end",
"def default_line_separator\n @def_line_sep ||= infer_line_separator\n end",
"def separator(text)\n puts '--%s' % text\nend",
"def add_divider_row_to_table\n table << \" -\"\n size.times { table << '-----' }\n table << \"\\n\"\n end",
"def header_format; self.underline end",
"def delimiter(col)\n gmu(\"# \", col)\n end",
"def field_value_separator\n tag(:br)\n end",
"def display_bottom_separator(width = HOLE_SIZE, new_line = true, tab = true)\n\t\tdisplay_separator_row(SEPARATOR[:sw_corner], SEPARATOR[:s_divide], \n\t\t\t SEPARATOR[:se_corner], width, new_line, tab)\n\tend",
"def sequence_separator; end",
"def _FrontmatterSeparator\n\n _save = self.pos\n while true # sequence\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = match_string(\"---\")\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:__hyphen_)\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:_Nl)\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_FrontmatterSeparator unless _tmp\n return _tmp\n end",
"def p_blankline\n p do\n nbsp\n end\n end",
"def end_line(kind); end",
"def skip?(line)\n line[0] == '#' || !line.include?(@delimeter) || line.split(@delimeter).size < 2\n end",
"def excerpt_separator; end",
"def end_line kind\n end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def normal_line(text)\n end",
"def line_to_wrap; end",
"def left_delimiter\n @left_delimiter || World.left_delimiter\n end",
"def end_field; end",
"def print_separator_line\nline = \"\"\n3.times do\n3.times { line << SEPARATOR[:horizontal] }\nline << SEPARATOR[:cross]\nend\nputs line[0...line.length - 1]\nprint \"\\t\"\nend",
"def determine_field_delimiter(l)\n if l =~ /[\\,\\|]/ \n /\\s*[\\,\\|]\\s*/\n else\n /\\s/\n end\n end",
"def separator\n \"-\" * (COLUMN_NUM * COLUMN_SIZE)\nend",
"def empty_header_lines(txt)\n txt.gsub(/^\\[\\|[^\\]\\n]+\\](?=\\n)/, '')\n end",
"def break_to_newline\n end",
"def non_standardized_header(row)\n @header=row.split(/\\s{2}+/).reject{|a|a.empty?} \n @header[1].insert(8,'--')\n @header[1]=@header[1].split(/--/)\n @header.insert(1,'Incep Date')\n @header=@header.flatten\n end",
"def separator = '********************' * 8",
"def hr\n \"<hr />\"\n end",
"def draw_eol\n print \"\\r\\e[#{columns - 1}C#{V_SEP}\\n\"\n end",
"def begin_line kind\n end",
"def delimiter\n @view_column[:delimiter] || '-'\n end",
"def print_empty_line\n print_in_same_line(\" \")\n end",
"def good_divider(lines,i)\n above_and_below = lines.rows(0...i)+lines.rows((i+1)..-1)\n segments(lines[i]).all? { |text,range|\n text =~ /^( +|---+)$/ or above_and_below.columns(range).blank?\n }\n end",
"def li_blankline\n li do\n nbsp\n end\n end",
"def h_line\n puts \"-\" * 80\n nil\nend",
"def line_after\n line[column..-1].to_s\n end",
"def newline; end",
"def ti_delete_line\n\ttictl(\"dl\")\n end",
"def original_line; end",
"def divider(text, color: nil)\n raise NotImplementedError\n end",
"def delimiter_never_precedes_last!\n options[:'delimiter-precedes-last'] = :never\n self\n end",
"def line\n end",
"def line\n end",
"def break_to_newline\n end",
"def begin_line(kind); end",
"def begin_line(kind); end",
"def h_line\n puts \"-\" * 50\n nil\nend",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def first_line; end",
"def separator\n columns_dashes = @widths.map { |w| '-' * (w + 2) }\n \"+#{columns_dashes.join('+')}+\"\n end"
] |
[
"0.7266506",
"0.7061372",
"0.70447874",
"0.6834164",
"0.6719125",
"0.66833764",
"0.66833764",
"0.6677838",
"0.66188836",
"0.66188836",
"0.6590353",
"0.6590353",
"0.6590353",
"0.65376014",
"0.6436418",
"0.6436418",
"0.6331948",
"0.6315255",
"0.62589073",
"0.6207433",
"0.6197585",
"0.6160098",
"0.6140632",
"0.61358786",
"0.60975456",
"0.60974973",
"0.6018269",
"0.5988503",
"0.5986648",
"0.5976794",
"0.5970612",
"0.5961545",
"0.5941351",
"0.5933181",
"0.59307015",
"0.5909089",
"0.586158",
"0.5861477",
"0.58470494",
"0.58316475",
"0.58312726",
"0.5814107",
"0.5809203",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.5801882",
"0.58018494",
"0.5792519",
"0.57705235",
"0.5767463",
"0.57652324",
"0.57598585",
"0.57584196",
"0.5750089",
"0.5746419",
"0.5741189",
"0.571842",
"0.5711397",
"0.56951004",
"0.56938326",
"0.5689964",
"0.56874686",
"0.56770384",
"0.5669745",
"0.5663708",
"0.5662655",
"0.5650987",
"0.5650253",
"0.5643515",
"0.5624697",
"0.56205446",
"0.5614338",
"0.5614338",
"0.5609776",
"0.56036913",
"0.56036913",
"0.5599172",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.559887",
"0.5596453"
] |
0.60345525
|
26
|
This calculates and stores the offset at which each column starts. Used when going to next column or doing a find for a string in the table.
|
def _calculate_column_offsets
total = 0
coffsets = []
ctr = 0
## ix will have gaps in between for hidden fields
each_column { | c, ix|
v = c.width
coffsets[ctr] = total
ctr += 1
total += v + 2 ## blank space plus separator
}
return coffsets
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_column\n @col_offset\n end",
"def column\n old_pos - start_of_current_line_pos\n end",
"def column\n old_pos - start_of_current_line_pos\n end",
"def column_index(col)\n col.each_codepoint.reduce(0) do |sum, n|\n break sum - 1 if n < A_CODEPOINT # reached a number\n\n sum * 26 + (n - A_CODEPOINT + 1)\n end\n end",
"def current_line_pos\n pos - col\n end",
"def col\r\n @lines[@line_num].cursor\r\n end",
"def column_for_position(position); end",
"def column_for_position(position); end",
"def column_for_position(position); end",
"def lines_offset\n @starting_line - 1\n end",
"def next_tab\n @tab_stops.sort.each do |stop|\n if @col < stop\n return stop\n end\n end\n\n return @cols\n end",
"def to_col(pos)\n\t (1..@cols).include?(pos) ? pos - 1 : nil\n\tend",
"def column_deltas; end",
"def col_positions(pos, cols)\n if pos.nil? || pos.empty?\n pos = []\n cols.each { |c| pos << Array.new(c.size) { |c| c } }\n pos\n else\n pos.split(';').collect { |p| p.split(',').collect { |p| p.to_i } }\n end\n end",
"def b_offset\n @last_4[1].to_i\n end",
"def column_next direction=0\n # right movement or panning cycles back to first column\n # leftward movement stops at first column.\n if direction == 0\n @stact += @grows\n @stact = 0 if @stact >= @vps\n @cursor += @grows\n # 2019-03-18 - zero loses offset. we need to maintain it\n # @cursor = 0 if @cursor >= @vps\n if @cursor - @sta >= @vps\n @cursor -= @grows while @cursor > @sta\n @stact -= @grows while @stact > 0\n @cursor += @grows if @cursor < @sta\n @stact += @grows if @stact < 0\n end\n else\n @stact -= @grows\n @cursor -= @grows\n @stact = 0 if @stact < 0\n # setting cursor as zero loses the position or offset\n # We are trying to maintain offset\n @cursor += @grows if @cursor < 0\n end\nend",
"def offset\n\t\t\t@position + @offset\n\t\tend",
"def offset_changes\n changes(col_offset: @col_offset, row_offset: @row_offset)\n end",
"def first_offset; end",
"def first_offset; end",
"def columns\n left...(left + bordered_width)\n end",
"def offset()\n @offset__\n end",
"def current_offset; end",
"def get_offset\n @offset\n end",
"def part_of_col_up(starting, ending)\n col(starting[0])[(starting[1] + 1)..(ending[1] - 1)]\n end",
"def column_delta; end",
"def cells_per_row_offset offset\n @grpc.cells_per_row_offset_filter = offset\n self\n end",
"def column\n\t return -1 if @inputStack.empty? # only if initialize() arg is bogus\n\n\t input = @inputStack[0] # not @inputStack.last\n\t currLineStart = input.string.rindex(\"\\n\", input.pos)\n\t return input.pos + 1 if currLineStart.nil?\n\t return input.pos - currLineStart + 1\n\tend",
"def get_cols_index(col)\n i = @cols.size - 1\n\n @cols.reverse_each do |column|\n if col >= (Integer(column[:attributes][:min])-1)\n if col <= (Integer(column[:attributes][:max])-1)\n break\n end\n end\n i -= 1\n end\n if i < 0\n i = @cols.size #effectively nil\n end\n i\n end",
"def endCol; @col + @width - 1; end",
"def calculate_pos_from_cpos_lpos(reset = true)\n set_line_and_column_pos(nil, nil)\n end",
"def position\n [ @row_offset, @col_offset ]\n end",
"def offset_returns_row_number_column?\n true\n end",
"def column_deltas=(_arg0); end",
"def get_current_offset\n @offset < 0 ? 0 : @offset\n end",
"def offset; end",
"def offset; end",
"def offset; end",
"def part_of_col_down(starting, ending)\n col(starting[0])[(ending[1] + 1)..(starting[1] - 1)]\n end",
"def rowcol\n return self.row+@row_offset, self.col+@col_offset\n end",
"def column_order\n [:line_count, :loc_count, :file_count, :class_length]\n end",
"def line_and_column(pos); end",
"def last_column_position\n columns.maximum(:position)\n end",
"def to_find_offset\n @offset\n end",
"def offset(*) end",
"def column_at(x, y, y_is_line = false)\n x = @text.x if x < x-@text.x\n line = @newline_data.dig(row_at(y)) unless y_is_line\n line = @newline_data.dig(y) if y_is_line\n column= 0\n return unless line\n\n text = line[:text]\n buffer= \"\"\n local_x=0\n\n text.size.times do |i|\n local_x = @text.font.text_width(buffer)\n\n break if local_x >= x\n column+=1\n buffer+=text.chars[i]\n end\n\n return column\n end",
"def offset\n @offset ||= (position.unitless? || position.unit_str == \"px\") ? position.value : 0\n end",
"def offset\n 1\n end",
"def recompute_offsets()\n @header.resource_index.number_of_records = @records.length\n # @header.resource_index.next_index = 0 # TODO: How is this determined?\n\n curr_offset = PDB::Header.round_byte_length\n\n # Compute length of index...\n unless @index == []\n @index.each do |i|\n curr_offset += i.length()\n end\n end\n\n unless @appinfo.nil?\n @header.appinfo_offset = curr_offset\n curr_offset += @appinfo.length()\n end\n\n unless @sortinfo.nil?\n @header.sortinfo_offset = curr_offset\n curr_offset += @sortinfo.length()\n end\n\n ## And here's the mysterious two-byte filler.\n #curr_offset += 2\n\n unless @index.length == 0\n @index.each do |i|\n rec = @records[i.r_id]\n i.offset = curr_offset\n curr_offset += rec.length\n end\n end\n end",
"def columns\n @columns ||= begin\n column_indexes.map do |e|\n e.map do |e|\n @input[e]\n end\n end\n end\n end",
"def last_column; end",
"def last_column; end",
"def last_column; end",
"def last_column; end",
"def calc_input_offset\n if input_count.zero?\n 0\n else\n buffer.abs_offset\n end\n end",
"def offset\n execute['offset']\n end",
"def position\n [row.position, column.position]\n end",
"def column_peers(i)\n column_number = i % 9\n digits_on_positions(\n (0...9).map { |p| p * 9 + column_number },\n i\n )\n end",
"def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend",
"def current_row\n @row_offset\n end",
"def get_col_cells col\n\t\treturn (col...9 ** 2).step(9).to_a\n\tend",
"def previous_offset\n @previous_offset ||= if after\n offset_from_cursor(after)\n elsif before\n offset_from_cursor(before) - (last ? last : 0) - 1\n else\n 0\n end\n end",
"def line_column(string, offset)\n return 1,1 if string.length==0 || offset==0\n lines = (string[0..offset-1] + \" \").split(\"\\n\")\n return lines.length, lines[-1].length\n end",
"def char_offset(offset)\n effective_line = @locator.line_for_offset(offset)\n locator.char_offset(offset) + (effective_line * @leading_line_offset) + @leading_offset\n end",
"def cursor_home\n @curpos = 0\n @pcol = 0\n set_col_offset 0\n end",
"def get_line_and_col_pos(pos)\n pos = self.size if pos > self.size\n pos = 0 if pos < 0\n\n lpos = get_line_pos(pos)\n\n lpos = @line_ends.size if lpos == nil\n cpos = pos\n cpos -= @line_ends[lpos - 1] + 1 if lpos > 0\n\n return [lpos, cpos]\n end",
"def columns\n @cr[2] & 0x7f\n end",
"def first_column\n @first_column ||= first_last_row_col[:first_column]\n end",
"def column_space(); @column_space; end",
"def rowcol #:nodoc:\n return @row+@row_offset, @col+@col_offset\n end",
"def column_of(range); end",
"def to_find_offset\n @conditions.to_find_offset\n end",
"def line_and_column(position = T.unsafe(nil)); end",
"def x_offset; end",
"def column(pos = T.unsafe(nil)); end",
"def find_start_and_finish\n grid.each_with_index do |row, row_idx|\n row.each_with_index do |spot, col_idx|\n if spot == START_MARK\n @start = [row_idx, col_idx]\n elsif spot == END_MARK\n @finish = [row_idx, col_idx]\n end\n end\n end\n end",
"def line_offset(pos=pos())\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end",
"def line_offset(pos=pos)\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end",
"def cols\n # remove the nils\n cols = (Array.new(@size) { Array.new(@size) }).map { |col| col.select { |el| el != nil} }\n \n @rows.each do |row|\n row.each_with_index do |mark, col_idx|\n cols[col_idx] << mark\n end\n end\n \n cols\n end",
"def calculate_columns!\n\n\n\n span_count = columns_span_count\n\n\n\n columns_count = children.size\n\n\n\n\n\n\n\n all_margins_width = margin_size * (span_count - 1)\n\n\n\n column_width = (100.00 - all_margins_width) / span_count\n\n\n\n\n\n\n\n columns.each_with_index do |column, i|\n\n\n\n is_last_column = i == (columns_count - 1)\n\n\n\n column.set_column_styles(column_width, margin_size, is_last_column)\n\n\n\n end\n\n\n\n end",
"def calculate_column(index)\n index % 9\n end",
"def columns_incdec howmany\n @gviscols += howmany.to_i\n @gviscols = 1 if @gviscols < 1\n @gviscols = 6 if @gviscols > 6\n @pagesize = @grows * @gviscols\nend",
"def columns\n @columns ||= @csv_data[0].zip(*@csv_data[1..])\n end",
"def excel_col()\n ( ( ( (self - 1)/26>=1) ? ( (self - 1)/26+64).chr: '') + ((self - 1)%26+65).chr)\n end",
"def set_current_row_col(array)\r\n current_s_index = array.locate2d(' ')\r\n @current_row = current_s_index.flatten.first\r\n @current_col = current_s_index.flatten.last\r\n end",
"def get_line_and_column_from_chunk(offset)\n if offset.zero?\n return [@chunk_line, @chunk_column]\n end\n\n string =\n offset >= @chunk.size ? @chunk : @chunk[0..offset-1]\n\n line_count = string.count(\"\\n\")\n\n column = @chunk_column\n if line_count > 0\n lines = string.split(\"\\n\")\n column = lines.empty? ? 0 : lines[-1].size\n else\n column += string.size\n end\n\n [@chunk_line + line_count, column]\n end",
"def elmt_offset_at token_index\n # Defaults to the character position BEYOND the last text element\n (self[token_index]&.last if token_index) || (last.last + self.last.first.to_s.length)\n end",
"def byte_offset(loc) loc.y * line_byte_size + loc.x * pixel_byte_size; end",
"def column_indexes(get_at = nil)\n @@column_indexes[@length] ||= begin\n @length.times.map do |count|\n @length.times.map do |inner_count|\n inner_count * @length + count\n end\n end\n end\n if get_at\n @@column_indexes[@length][get_at]\n else\n @@column_indexes[@length]\n end\n end",
"def expected_columns; end",
"def offset\n (page - 1) * PER_PAGE\n end",
"def get_vacant_pos col\n vacant_position = nil\n\n @row.times do |idx|\n if @grid[idx][col-1] == \"O\"\n vacant_position = idx + 1\n else\n break\n end\n end\n\n vacant_position\n end",
"def offset\n @object.send(:read_attribute,@startAttribute)\n end",
"def columns(line)\n line[ox...(ox + width)] || ''\n end",
"def start_columns(size = 2, gutter = 10)\n # Start from the current y-position; make the set number of columns.\n return false if @columns_on\n\n @columns = {\n :current => 1,\n :bot_y => @y\n }\n @columns_on = true\n # store the current margins\n @columns[:left] = @left_margin\n @columns[:right] = @right_margin\n @columns[:top] = @top_margin\n @columns[:bottom] = @bottom_margin\n # Reset the margins to suit the new columns. Safe enough to assume the\n # first column here, but start from the current y-position.\n @top_margin = @page_height - @y\n @columns[:size] = size || 2\n @columns[:gutter] = gutter || 10\n w = absolute_right_margin - absolute_left_margin\n @columns[:width] = (w - ((size - 1) * gutter)) / size.to_f\n @right_margin = @page_width - (@left_margin + @columns[:width])\n end",
"def columns\n @columns || 150\n end",
"def columns; end",
"def standard_offset\n return @standard_offset\n end",
"def insert_columns( before, number=1 )\n a = Array.new( number, nil )\n before = col_index( before ) - 1\n @data.map! { |row| row.insert( before, *a ) }\n calc_dimensions\n end",
"def offset\n loffset + 6\n end"
] |
[
"0.72847974",
"0.69097686",
"0.69097686",
"0.63683105",
"0.6299307",
"0.622816",
"0.6216673",
"0.6216673",
"0.6216673",
"0.6213201",
"0.612637",
"0.6073526",
"0.60015225",
"0.59757733",
"0.5975064",
"0.59747994",
"0.5966612",
"0.5953448",
"0.59420145",
"0.59420145",
"0.5907612",
"0.5906624",
"0.58930314",
"0.58888006",
"0.5865923",
"0.58560205",
"0.5854122",
"0.58126646",
"0.5809059",
"0.5801976",
"0.57883245",
"0.57797873",
"0.5759652",
"0.57573533",
"0.57433",
"0.57425535",
"0.57425535",
"0.57425535",
"0.57366914",
"0.57250774",
"0.57225597",
"0.5719552",
"0.5714413",
"0.56681216",
"0.5667056",
"0.5662849",
"0.5640437",
"0.56305593",
"0.5628133",
"0.5624585",
"0.562342",
"0.562342",
"0.562342",
"0.562342",
"0.5622454",
"0.5618959",
"0.56170994",
"0.5606514",
"0.5592387",
"0.5586773",
"0.55846363",
"0.5570053",
"0.55500925",
"0.5546234",
"0.5502155",
"0.55019903",
"0.5498632",
"0.54944515",
"0.5491878",
"0.5491499",
"0.5481138",
"0.5478522",
"0.5477508",
"0.5467543",
"0.5458129",
"0.5440118",
"0.5437484",
"0.5425503",
"0.5415397",
"0.5400668",
"0.5391652",
"0.53831434",
"0.5380888",
"0.5377818",
"0.5376858",
"0.53765917",
"0.53734195",
"0.5363105",
"0.53606623",
"0.53568786",
"0.53532076",
"0.53439784",
"0.5343041",
"0.53400797",
"0.53332525",
"0.5332782",
"0.53104466",
"0.5303461",
"0.5300537",
"0.5293777"
] |
0.79618025
|
0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.