query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
Description Deletes definitively an element. found: removes the element and reloads the whole page compact: removes the element and reloads the whole page expanded: removes the element and reloads the whole page Mode Json Specific filters ApplicationControllerinitialize_media_element_with_owner ApplicationControllerinitialize_media_element_destination | def destroy
if @ok
if !@media_element.check_and_destroy
@ok = false
@error = @media_element.get_base_error
end
else
@error = I18n.t('activerecord.errors.models.media_element.problem_destroying')
end
render :json => {:ok => @ok, :msg => @error}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove\n @ok_msg = t('other_popup_messages.correct.remove.media_element')\n if @ok\n bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).first\n if bookmark.nil?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')\n else\n bookmark.destroy\n if Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).any?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')\n end\n end\n else\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')\n end\n if @destination == ButtonDestinations::FOUND_MEDIA_ELEMENT\n prepare_media_element_for_js\n render 'media_elements/reload.js'\n else\n render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}\n end\n end",
"def destroy\n @element = @page.all_elements.find(params[:id])\n # Start by removing the element from the page\n page_element = Fe::PageElement.where(:element_id => @element.id, :page_id => @page.id).first\n page_element.destroy if page_element\n\n # If this element is not on any other pages, is not a question or has no answers, Destroy it\n if @element.reuseable? && (Fe::PageElement.where(:element_id => params[:id]).present? || @element.has_response?)\n @element.update_attributes(:question_grid_id => nil, :conditional_id => nil)\n else\n @element.destroy\n end\n\n respond_to do |format|\n format.js\n end\n end",
"def delete(element); end",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def delete_element(element); end",
"def destroy\n run_callbacks :destroy do\n connection.delete(element_path, encode, self.class.headers)\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to elements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @page_element.destroy\n respond_to do |format|\n format.html { redirect_to council_page_page_elements_path(@council) }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize Element\n @element.is_valid=false;\n respond_to do |format|\n if @element.save\n format.html { redirect_to elements_url, notice: 'Element je bil označen kot neveljaven.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @inner_page = Embeddable::InnerPage.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(inner_pages_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @inner_page.page_elements.each do |pe|\n pe.destroy\n end\n @inner_page.destroy\n end",
"def remove_elem\n elem =eval(params[:type]).find(params[:elem])\n elem.position= 0\n case params[:type]\n when \"Activity\"\n elem.model_id = -1\n when \"Action\"\n elem.activity_id = -1\n when 'PfTask'\n elem.action_id = -1\n end\n elem.update_attributes(elem.attributes)\n redirect_to :action => 'show_subs', :parent_id =>params[:parent_id], :parent_type =>eval(params[:type]).get_parent_name\n end",
"def delete_media_action(_browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n item = wait.until { _browser.find_element(:xpath => @galmgr.action) }\n if not item.displayed?\n Log.logger.info(\"Select bar is not visible...you haven't checked any content to delete!\")\n return\n end\n wait.until { _browser.find_element(:xpath => \"#{@galmgr.action}/option[contains(@value,'delete')]\") }.click\n JQuery.wait_for_events_to_finish(@browser)\n Log.logger.info(\"Clicking delete button.\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.confirm_delete) }\n wait.until { temp.displayed? }\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n next_body_text = wait.until { _browser.find_element(:xpath => \"//body\") }.text\n if next_body_text.include?(\"Error 503 Service Unavailable\")\n raise \"Got an error while trying to delete media items.\"\n end\n\n #are you sure?\n Log.logger.info(\"Waiting for and consuming confirmation.\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.confirm_delete) }\n wait.until { temp.displayed? }\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @home_element = HomeElement.find(params[:id])\n @home_element.destroy\n\n respond_to do |format|\n format.html { redirect_to home_elements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scraping_html_element.destroy\n respond_to do |format|\n format.html { redirect_to scraping_html_elements_url, notice: 'Scraping html element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @element = @account.elements.find(params[:id])\n @element.destroy\n respond_to do |format|\n format.html { redirect_to(elements_url, :notice => 'Element was sucessfully destroyed.') }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @observation_home_element = ObservationHomeElement.find(params[:id])\n @observation_home_element.destroy\n\n respond_to do |format|\n format.html { redirect_to observation_home_elements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @inform = @slide.inform\n if @slide.slide_tag[-1] != \"*\"\n\n @blocks = @inform.blocks.where(slide_tag: @slide.slide_tag) #Saco una coleccion de blocks asociadas al slide que voy a borrar\n\n @block = @blocks.first #Es para pasarla al render en JS\n\n @samples = @inform.samples.where(slide_tag: @slide.slide_tag, name: \"Extendido\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @sample = @samples.first #Es para pasarla al render en JS\n # @recipient = Recipient.where(inform_id: @sample.inform_id, tag: @sample.recipient_tag).first #Es para pasarla al render en JS\n @recipient = nil\n\n \n\n \n @samples.each do |sample|\n sample.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n @blocks.each do |block|\n block.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n end\n @samplesc = @inform.samples.where(name: \"Cassette\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @blocks = @inform.blocks #Recargo todos los block para renderizado\n @slide.destroy\n end",
"def destroy\n @pm_element = PmElement.find(params[:id])\n @pm_element.destroy\n redirect_to pm_element_path(@pm_element.parent)\n \n end",
"def delete_elem\n elem = eval(params[:type]).find(params[:elem])\n eval(params[:type]).delete(params[:elem])\n elems = nil\n case params[:type]\n when \"ProcessModel\"\n elems = elem.activities\n for e in elems\n e.model_id =-1\n e.update_attributes(e.attributes)\n end\n when \"Activity\"\n elems = elem.actions\n for e in elems\n e.activity_id =-1\n e.update_attributes(e.attributes)\n end\n when \"Action\"\n elems = elem.pf_tasks\n for e in elems\n e.action_id =-1\n e.update_attributes(e.attributes)\n end\n end\n redirect_to :action => 'index', :tab =>params[:type]\n rescue\n flash[:error] = l(:error_can_not_delete_custom_field)\n redirect_to :action => 'index',:tab =>params[:type]\n end",
"def destroy\n @dataelement = Dataelement.find(params[:id])\n @dataelement.destroy\n\n respond_to do |format|\n format.html { redirect_to dataelements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @content_group_element = ContentGroupElement.find(params[:id])\n @content_group_element.destroy\n\n respond_to do |format|\n format.html { redirect_to content_group_elements_url }\n format.json { head :ok }\n end\n end",
"def remove_media\n @media = Media.find_by_id(params[:media_id])\n remove_media_update\n end",
"def destroy\n @open_response = Embeddable::OpenResponse.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(open_responses_url) }\n format.xml { head :ok }\n format.js\n end\n # TODO: We should move this logic into the model!\n @open_response.page_elements.each do |pe|\n pe.destroy\n end\n @open_response.destroy\n\n end",
"def destroy\n @elemento = Elemento.find(params[:id])\n @elemento.destroy\n\n respond_to do |format|\n format.html { redirect_to(elementos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @documentary.remove_thumbnail = true\n @documentary.save!\n head :no_content\n end",
"def destroy\n @sound_grapher = Embeddable::SoundGrapher.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(sound_graphers_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @sound_grapher.page_elements.each do |pe|\n pe.destroy\n end\n @sound_grapher.destroy\n end",
"def destroy\n @elemento.destroy\n respond_to do |format|\n format.html { redirect_to elementos_url, notice: 'Elemento fue eliminado con exito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_element.destroy\n respond_to do |format|\n format.html { redirect_to list_elements_url, notice: 'List element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(element_key)\n parameter = { basic_auth: @auth }\n response = self.class.delete(\"/elements/#{element_key}\", parameter)\n unless response.success?\n puts \"Could not save element: #{response.headers['x-errordescription']}\"\n end\n response\n end",
"def destroy\n @video_player = Embeddable::VideoPlayer.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(video_players_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @video_player.page_elements.each do |pe|\n pe.destroy\n end\n @video_player.destroy\n end",
"def destroy\n institution = @element.institution\n begin\n @element.destroy!\n rescue ActiveRecord::InvalidForeignKey\n flash['error'] = \"The #{@element.name} element cannot be deleted, as \"\\\n \"it is in use by one or more items.\"\n rescue => e\n flash['error'] = \"#{e}\"\n else\n toast!(title: \"Element deleted\",\n message: \"The element \\\"#{@element.name}\\\" has been deleted.\")\n ensure\n if current_user.sysadmin?\n if institution\n redirect_to institution_path(institution)\n else\n redirect_to template_elements_path\n end\n else\n redirect_to registered_elements_path\n end\n end\n end",
"def destroy\n @biologica_breed_offspring = Embeddable::Biologica::BreedOffspring.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(biologica_breed_offsprings_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @biologica_breed_offspring.page_elements.each do |pe|\n pe.destroy\n end\n @biologica_breed_offspring.destroy\n end",
"def js_remove_element(element)\n rjs_method :remove_element, element\n end",
"def destroy\n @config_element.destroy\n respond_to do |format|\n format.html { redirect_to config_elements_url, notice: 'Config element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @custom_media_entry.destroy\n respond_to do |format|\n format.html { redirect_to custom_media_entries_url, notice: 'Custom media entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @feed_element = FeedElement.find(params[:id])\n @feed_element.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_elements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @extra.destroy\n\n head :no_content\n end",
"def destroy\n @web_car_gallery.destroy\n\n head :no_content\n end",
"def destroy\n @condominium.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def actualizarElementosContenido\n\n\n contenido_id = params[:contenido][:id]\n \n # Se borran elementos originales del contenido\n @elementos_asociados = Elemento.find(:all, :conditions => \"contenido_id = #{params[:contenido][:id]}\")\n \n for elemento in @elementos_asociados\n elemento.destroy\n end\n \n\n @elementos = params[:elemento]\n logger.debug(\"Esta es la cantidad de elementos para grabar nuevos: #{@elementos.size()}\" )\n if (!@elementos.nil? && @elementos.size() > 0 )\n \n # Guardando los nuevos elementos\n @elementos.each do |elemento|\n\n campos = elemento[1] # 1 corresponde al hash de campos / 0 es el id del elemento actual\n \n elemento_nuevo = Elemento.new()\n elemento_nuevo.id = campos[:id]\n elemento_nuevo.ubicacion = campos[:ubicacion] \n elemento_nuevo.contenido_id = contenido_id\n elemento_nuevo.valor = campos[:valor]\n elemento_nuevo.tipo_id = campos[:tipo_id]\n \n # Salvo\n elemento_nuevo.save!\n \n end\n end \n end",
"def documentremove\n if self.documents.attached?\n document_urls = self.documents.map do |adoc| \n Rails.application.routes.url_helpers.delete_document_attachment_tbl_quality_issue_url(adoc, only_path: true)\n end \n else\n nil\n end \n end",
"def clear\n assert_exists\n @element.clear\n end",
"def destroy\n @event_element.destroy\n respond_to do |format|\n format.html { redirect_to event_elements_url, notice: 'Event element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_attribute = MediaAttribute.find(params[:id])\n @media_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_attributes_url) }\n format.xml { head :ok }\n end\n end",
"def delete_media_by_id id\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/media/{id}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"id\" => id,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"APIMATIC 2.0\",\r\n \"accept\" => \"application/json\",\r\n \"Content-Type\" => Configuration.content_type\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params headers\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.delete query_url, headers:headers\r\n\r\n #Error handling using HTTP status codes\r\n if !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n else \r\n puts \"Media ID Deleted\"\r\n end\r\n\r\n response.body\r\n end",
"def destroy\n @spoiler.destroy\n\n head :no_content\n end",
"def destroy\n @web_display_car_image.destroy\n\n head :no_content\n end",
"def destroy\n @multimedia = find_media\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to @multimedia }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reflection.destroy\n head :no_content\n end",
"def destroy\n @media_path = MediaPath.find(params[:id])\n @media_path.destroy\n\n respond_to do |format|\n format.html { redirect_to({:controller=>:rmedial_settings, :action=>:index}) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n \n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end",
"def delete element\n element.perform :delete\n end",
"def destroy\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to profile_media_path(current_member) }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @custom_medium.destroy\n respond_to do |format|\n format.html { redirect_to custom_media_url, notice: 'Custom medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @structure_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end",
"def destroy\n @resource = @media_file.resource\n\n @media_file.destroy\n respond_to do |format|\n format.html { redirect_to edit_resource_path(@resource), notice: 'Media was removed.' }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @medusa_premis_representation_object = MedusaPremis::RepresentationObject.find(params[:id])\n @medusa_premis_representation_object.destroy\n\n respond_to do |format|\n format.html {\n query_params = session[:search] ? session[:search].dup : {}\n query_params.delete :counter\n query_params.delete :total\n link_url = url_for(query_params)\n redirect_to(link_url, notice: 'Representation object was successfully deleted.') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article.remove_thumbnail = true\n @article.save!\n head :no_content\n end",
"def destroy\n @media_type = MediaType.find(params[:id])\n @media_type.destroy\n\n respond_to do |format|\n format.html { redirect_to media_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pop_element.destroy\n respond_to do |format|\n format.html { redirect_to pop_elements_url, notice: 'Pop element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_interest.destroy\n\n respond_to do |format|\n format.html { redirect_to media_interests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts \"------------------------\"\n document_item = ActiveStorage::Attachment.find(@document.doc.id)\n p document_item.purge\n puts \"------------------------\"\n\n @document.destroy\n respond_to do |format|\n\n\n\n\n format.html { redirect_to property_property_unit_documents_path(@property, @property_unit), notice: 'Dokumentet ble slettet.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @medium = Medium.find_by_local_key(params[:local_key])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { render json: @medium.item }\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @webextra = Webextra.find(params[:id])\n @webextra.destroy\n\n respond_to do |format|\n format.html { redirect_to(webextras_url) }\n format.xml { head :ok }\n end\n end",
"def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end",
"def delete_image\n @page.first('span[data-vh-id=\"remove\"]').click\n end",
"def remove\n model_id = params[:id]\n @dom_id = \"ar_\" << model_id\n @model_access_right = convert_id_to_model(model_id)\n \n @valid = true\n begin\n @model_access_right.destroy\n rescue Exception => e\n logger.debug \"Exception: #{e.class}: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n @valid = false\n end\n\n \n #fixme, do destroy here also\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium = Media.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @microfilm_reel = MicrofilmReel.find(params[:id])\n @microfilm_reel.destroy\n\n respond_to do |format|\n format.html { redirect_to microfilm_reels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @click_data.destroy\n\n head :no_content\n end",
"def remove_old_media\n (@old_media || []).each do |medium|\n medium.destroy if medium\n end\n end",
"def destroy\n @uranium_j.destroy\n respond_to do |format|\n format.html { redirect_to uranium_js_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t# Desttroy the particular case media with all the attachment files\n\t\t@case_medium.destroy\n\t\t# Redirect to the case media index page after destroy case medium\n\t\tredirect_to case_case_media_path(@surgery_case)\n\tend",
"def destroy\n @social_media_link.destroy\n\n head :no_content\n end",
"def destroy\n druid=params[:id]\n gallery_id=params[:gallery_id]\n \n @document=SolrDocument.find(druid)\n @gallery=gallery_id ? Gallery.find(gallery_id) : current_user.favorites_list\n if @gallery \n @saved_item=SavedItem.where(:gallery_id=>@gallery.id,:druid=>druid).first\n authorize! :destroy, @saved_item\n @saved_item.destroy\n @message=t('revs.favorites.removed',:list_type=>list_type_interpolator(@gallery.gallery_type))\n end\n\n respond_to do |format|\n format.html { flash[:success]=@message\n redirect_to previous_page}\n format.js { render }\n end\n\n end",
"def destroy\n @entry = Entry.find(params[:id])\n img_choices = @entry.optional_images\n @entry.destroy\n @json_response = {\"response\" => \"success\", \"img_choices\" => img_choices}\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { render json: @json_response }\n #format.js\n end\n end",
"def destroy\n @mapping_data_tindakan_medi = MappingDataTindakanMedi.find(params[:id])\n #@mapping_data_tindakan_medi.destroy\n\n @id = params[:id]\n\n respond_to do |format|\n if request.xhr?\n format.js do\n render :update do |page|\n page[\"list#{params[:id]}\"].fade()\n end\n end\n else\n if @mapping_data_tindakan_medi.destroy\n format.html { redirect_to(mapping_data_tindakan_medis_url) }\n else\n format.html { redirect_to(:action => \"edit\", :id => @id, :error => DELETE_CASCADE_ERROR_MSG) }\n end\n\n #format.xml { head :ok }\n end\n end\n end",
"def destroy\n @demo_song.destroy\n respond_to do |format|\n format.html { redirect_to(admin_product_attachment_url(@demo_song.product_attachment)) }\n format.xml { head :ok }\n format.js \n end\n website.add_log(user: current_user, action: \"Deleted a demo song\")\n end",
"def remove_large_html_chunks\n page.execute_script(\"$('#{user_info_fields_container_selector}').remove()\")\n page.execute_script(\"$('#{rig_fields_container_selector}').remove()\")\nend",
"def destroy\n @comment = BrandComment.find(params[:id])\n @comment.destroy\n\n render :update do |page|\n page.visual_effect :highlight, @comment.dom_id\n page.remove @comment.dom_id\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :ok }\n end\n end",
"def delete_media(n=1, ascending = true, _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Deleting the last #{n} media items\")\n _browser.get(\"#{$config[\"sut_url\"]}/#{self.content_media_url}\")\n self.sort_content\n 1.upto(n) do |i|\n Log.logger.info(\"Selecting Element #{i}\")\n wait.until { _browser.find_element(:xpath => \"//*[@id='media-admin']//tbody/tr[#{i}]//input\") }.click\n end\n self.delete_media_action(_browser)\n\n # Check for any warnings, if any file is in use.\n\n warning_message = \"\"\n if (_browser.find_elements(:xpath => @galmgr.warning_message).size > 0)\n i = 1\n if (_browser.find_elements(:xpath => @galmgr.warning_message + \"/ul/li\").size < 1)\n warning_ct = 1\n warning_message = warning_message + _browser.find_element(:xpath => @galmgr.warning_message).text\n else\n warning_ct = Integer(_browser.find_elements(:xpath => \"#{@galmgr.warning_message}/ul/li\").size)\n while i < (warning_ct+1)\n warning_message = warning_message + _browser.find_element(:xpath => \"#{@galmgr.warning_message}/ul/li[#{i}]\").text\n i += 1\n end\n end\n else\n warning_ct = 0\n warning_message = \"No Warnings\"\n end\n # Check for any status messages, whether the media has been deleted.\n\n confirm_message = \"\"\n if (_browser.find_elements(:xpath => @galmgr.confirmation_message).size > 0)\n i = 1\n if (_browser.find_elements(:xpath => \"#{@galmgr.confirmation_message}/ul/li\").size < 1)\n confirm_msg_ct = 1\n confirm_message = confirm_message + _browser.find_element(:xpath => @galmgr.confirmation_message).text\n else\n confirm_msg_ct = Integer(_browser.find_elements(:xpath => \"#{@galmgr.confirmation_message}/ul/li\").size)\n while i < confirm_msg_ct+1\n confirm_message = confirm_message + _browser.find_element(:xpath => \"#{@galmgr.confirmation_message}/ul/li[#{i}]\").text\n i += 1\n end\n end\n else\n confirm_msg_ct = 0\n confirm_message = \"No Media deleted\"\n end\n\n _browser.switch_to.default_content\n self.return_to_home_page\n return warning_ct, warning_message, confirm_msg_ct, confirm_message\n end",
"def destroy\n @description.destroy!\n head :no_content\n end",
"def destroy\n @site_element.destroy\n respond_to do |format|\n format.html {\n if params[:return_to]\n return_to = URI.parse(params[:return_to]).path\n redirect_to(return_to, notice: \"#{@site_element.long_name} was successfully deleted.\")\n else\n redirect_to(admin_site_elements_url)\n end\n }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted a site element: #{@site_element.long_name}\")\n end",
"def destroy\n @device_sub_content.destroy\n respond_to do |format|\n format.html { redirect_to device_sub_contents_url, notice: 'Device sub content was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy_file\n \n if params[:type] == \"File\"\n\t @file = GalleryFiles.find(params[:file_id])\n elsif params[:type] == \"Media\"\n @file = GalleryMedia.find(params[:file_id])\n end\n @file.destroy\n\n respond_to do |format|\n format.html { redirect_to(edit_setup_path(params[:id])) }\n format.js {\n\t\trender :update do |page|\n\t\t\tif params[:type] == \"File\"\n\t\t\t page.visual_effect :blind_up, \"File_#{params[:file_id].to_s}\"\n\t\t\telsif params[:type] == \"Media\"\n\t\t\t page.visual_effect :blind_up, \"Media_#{params[:file_id].to_s}\"\n \t\t\t page.visual_effect :blind_up, \"Media_Attributes_#{params[:file_id].to_s}\"\n\t\t\tend\n\t\tend\n \t\t}\n end\n end",
"def destroy\n @medio = Medio.find(params[:id])\n @medio.destroy\n\n respond_to do |format|\n format.html { redirect_to medios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media = Media.find(params[:id])\n @media.destroy\n\n respond_to do |format|\n format.html { redirect_to(medias_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @condominium_child.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_element_content(element_id, id)\n delete_content(Voog::API::Contents::ParentKind::Element, element_id, id)\n end",
"def destroy\n @admin_media_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_media_types_url, notice: 'Media type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@document = current_user.documents.find(params[:document_id])\n @document_photo = @document.document_photos.find(params[:id])\n if @document_photo\n \n @document_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to document_itemimages_url(@document) }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @media_item = MediaItem.find(params[:id])\n @media_item.destroy\n\n respond_to do |format|\n format.html { redirect_to media_items_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.6986065",
"0.6622753",
"0.6012976",
"0.6008559",
"0.6001347",
"0.59929854",
"0.5971298",
"0.5967435",
"0.5856683",
"0.58267295",
"0.5814241",
"0.58061194",
"0.5748924",
"0.5748924",
"0.57301205",
"0.5723308",
"0.57088876",
"0.5666997",
"0.56562436",
"0.5640187",
"0.563349",
"0.55932873",
"0.557914",
"0.5568225",
"0.5550024",
"0.55305713",
"0.55275434",
"0.5501832",
"0.54888827",
"0.54799336",
"0.545238",
"0.5447428",
"0.5428674",
"0.54250884",
"0.5421453",
"0.5397512",
"0.53958195",
"0.53593063",
"0.535576",
"0.5350138",
"0.53387225",
"0.5333155",
"0.53289324",
"0.53229576",
"0.53187245",
"0.5317017",
"0.5306868",
"0.53002244",
"0.5295245",
"0.5293637",
"0.5275886",
"0.52711165",
"0.52635294",
"0.5260655",
"0.5251383",
"0.52471864",
"0.52448845",
"0.52448165",
"0.5242196",
"0.52322906",
"0.5231947",
"0.5230392",
"0.5212258",
"0.52072424",
"0.52017164",
"0.51999855",
"0.5198017",
"0.51971656",
"0.51964414",
"0.5191861",
"0.5190878",
"0.5176863",
"0.51764613",
"0.51731634",
"0.5172304",
"0.5171656",
"0.516969",
"0.5161243",
"0.5160834",
"0.5159021",
"0.51588833",
"0.51572204",
"0.51568395",
"0.51562124",
"0.51526856",
"0.5140461",
"0.51399267",
"0.51302516",
"0.5125451",
"0.5123496",
"0.5118022",
"0.51071125",
"0.5105546",
"0.5102936",
"0.5100061",
"0.5097909",
"0.50948286",
"0.50863",
"0.5084056",
"0.5080627"
] | 0.6529948 | 2 |
Description Removes the link of this element from your section. found: reloads the element in compact mode compact: removes the element and reloads the whole page expanded: removes the element and reloads the whole page Mode Ajax + Json Specific filters ApplicationControllerinitialize_media_element ApplicationControllerinitialize_media_element_destination | def remove
@ok_msg = t('other_popup_messages.correct.remove.media_element')
if @ok
bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).first
if bookmark.nil?
@ok = false
@error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')
else
bookmark.destroy
if Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).any?
@ok = false
@error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')
end
end
else
@error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')
end
if @destination == ButtonDestinations::FOUND_MEDIA_ELEMENT
prepare_media_element_for_js
render 'media_elements/reload.js'
else
render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @element = @page.all_elements.find(params[:id])\n # Start by removing the element from the page\n page_element = Fe::PageElement.where(:element_id => @element.id, :page_id => @page.id).first\n page_element.destroy if page_element\n\n # If this element is not on any other pages, is not a question or has no answers, Destroy it\n if @element.reuseable? && (Fe::PageElement.where(:element_id => params[:id]).present? || @element.has_response?)\n @element.update_attributes(:question_grid_id => nil, :conditional_id => nil)\n else\n @element.destroy\n end\n\n respond_to do |format|\n format.js\n end\n end",
"def remove_link\n # cocoon JS needs class specifically remove_fields.dynamic, just treat em all\n # like dynamic, it seems okay.\n template.link_to(I18n.t(\"kithe.repeatable_input.remove\"), '#', class: \"remove_fields dynamic btn btn-secondary\")\n end",
"def remove_medium_link(opts)\n opts[:text] ||= I18n.t('remove_link', :scope => [:has_media, :form])\n link_to opts[:text], medium_url(opts[:medium]), :remote => true, :method => :delete\n end",
"def js_remove_element(element)\n rjs_method :remove_element, element\n end",
"def remove_elem\n elem =eval(params[:type]).find(params[:elem])\n elem.position= 0\n case params[:type]\n when \"Activity\"\n elem.model_id = -1\n when \"Action\"\n elem.activity_id = -1\n when 'PfTask'\n elem.action_id = -1\n end\n elem.update_attributes(elem.attributes)\n redirect_to :action => 'show_subs', :parent_id =>params[:parent_id], :parent_type =>eval(params[:type]).get_parent_name\n end",
"def destroy\n if @ok\n if !@media_element.check_and_destroy\n @ok = false\n @error = @media_element.get_base_error\n end\n else\n @error = I18n.t('activerecord.errors.models.media_element.problem_destroying')\n end\n render :json => {:ok => @ok, :msg => @error}\n end",
"def link_to_remove_section(linktext, form, class_of_section_to_remove=\"removeme\")\n form.hidden_field(:_destroy) + \"\\n\" +\n link_to_function(linktext, \"remove_section(this, \\\"#{class_of_section_to_remove}\\\")\")\n end",
"def cleared_linked_display\n h.content_tag(:div, linked_display, class:'images single clear').html_safe\n end",
"def cleared_linked_display\n h.content_tag(:div, linked_display, class: 'images single clear').html_safe\n end",
"def clear_link\n @link = nil\n @autolink = false\n end",
"def destroy\n run_callbacks :destroy do\n connection.delete(element_path, encode, self.class.headers)\n end\n end",
"def clear_link(skip_requesting = false)\n link.skip_requesting = skip_requesting\n self.link = nil\n end",
"def remove_media\n @media = Media.find_by_id(params[:media_id])\n remove_media_update\n end",
"def destroy\n @inform = @slide.inform\n if @slide.slide_tag[-1] != \"*\"\n\n @blocks = @inform.blocks.where(slide_tag: @slide.slide_tag) #Saco una coleccion de blocks asociadas al slide que voy a borrar\n\n @block = @blocks.first #Es para pasarla al render en JS\n\n @samples = @inform.samples.where(slide_tag: @slide.slide_tag, name: \"Extendido\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @sample = @samples.first #Es para pasarla al render en JS\n # @recipient = Recipient.where(inform_id: @sample.inform_id, tag: @sample.recipient_tag).first #Es para pasarla al render en JS\n @recipient = nil\n\n \n\n \n @samples.each do |sample|\n sample.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n @blocks.each do |block|\n block.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n end\n @samplesc = @inform.samples.where(name: \"Cassette\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @blocks = @inform.blocks #Recargo todos los block para renderizado\n @slide.destroy\n end",
"def destroy\n @page_element.destroy\n respond_to do |format|\n format.html { redirect_to council_page_page_elements_path(@council) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scraping_html_element.destroy\n respond_to do |format|\n format.html { redirect_to scraping_html_elements_url, notice: 'Scraping html element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(element); end",
"def delete_element(element); end",
"def destroy\n @recommended_link.destroy\n\n head :no_content\n end",
"def clear_links ()\n\nend",
"def destroy\n @social_media_link.destroy\n\n head :no_content\n end",
"def remove\n\t\t\tself.make_request!({uri: self.to_uri, method: :delete})\n\t\tend",
"def destroy\n @pending_recommended_link.destroy\n\n head :no_content\n end",
"def api_remove_link(name, model, association, object, confirm, html_options = nil, &block)\n name, model, association, object, html_options = block, name, model, association, object if block_given?\n html_options ||= {}\n id, url, i18n_key = get_api_relationship_info(model, association, :remove)\n new_options = {\n title: t(i18n_key % 'button'),\n data: {\n remote: true, method: :delete, type: :jsonapi,\n params: [type: object.model_name.route_key, id: object.id],\n 'success-message': t((i18n_key % 'message') + 'Success',\n model: get_name_for(model), association: get_name_for(object))\n }\n }\n new_options[:data][:confirm] = t('general.message.confirmRemoveLong', subject: get_name_for(object)) if confirm\n render_button(name, :remove, i18n_key, url, html_options.deep_merge(new_options))\n end",
"def delete\n self.class.delete self.href\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def remove_link\n\t\tfname = \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.info(\"#{self.class.name}.#{__method__}\") { \"params=#{params}\" }\n\t\t@link = Link.find(params[:id])\n\t\t@link.destroy\n\t\trespond_to do |format|\n\t\t LOG.debug(fname) {\"session[:tree_object] =#{session[:tree_object]}\"}\n\t\t\tformat.html { redirect_to(session[:tree_object].nil? ? links_url : session[:tree_object]) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend",
"def remove_dimension_editor\n dimension_id = params[:id]\n render :update do |page| \n page.replace_html(\"div_dimension_extra_#{dimension_id}\", \"\")\n end\n end",
"def destroy\n authorize Element\n @element.is_valid=false;\n respond_to do |format|\n if @element.save\n format.html { redirect_to elements_url, notice: 'Element je bil označen kot neveljaven.' }\n format.json { head :no_content }\n end\n end\n end",
"def remove_usage_editor\n usage_id = params[:id]\n render :update do |page|\n page.replace_html(\"div_usage_extra_#{usage_id}\", \"\")\n end\n end",
"def remove_item(remove_options)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n JQuery.wait_for_events_to_finish(@browser)\n\n regular_options = \"//a[@href='#' and contains(text(),'Options')]\"\n expanded_options = \"//a[@href='#' and @aria-expanded='true' and contains(text(),'Options')]\"\n unexpanded_options = \"//a[@href='#' and @aria-expanded='false' and contains(text(),'Options')]\"\n\n Log.logger.info(\"Waiting for the unexpanded 'Options' tab.\")\n unexpanded_opts = wait.until { @browser.find_element(:xpath => unexpanded_options) }\n Log.logger.info(\"Clicking on the unexpanded 'Options' tab.\")\n unexpanded_opts.click\n JQuery.wait_for_events_to_finish(@browser)\n Log.logger.info(\"Waiting for the expanded 'Options' tab.\")\n expanded_opts = wait.until { @browser.find_element(:xpath => expanded_options) }\n\n JQuery.wait_for_events_to_finish(@browser)\n remove_options.each {|remove_option|\n temp = wait.until { @browser.find_element(:xpath =>\n \"//input[contains(@class, 'form-radio option-default') and @value = '#{remove_option}']/../../td[3]/a[contains(@class, 'remove')]\") }\n puts \"Found element to remove\"\n wait.until {temp.displayed?}\n puts \"Element is visible now, clicking\"\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n wait.until { @browser.find_elements(:xpath => \"//input[contains(@class, 'form-radio option-default') and @value = '#{remove_option}']\").empty? }\n }\n end",
"def _remove_iframe_edit()\n @parent.render(partial: 'dc_common/iframe_edit', formats: [:html])\nend",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to elements_url }\n format.json { head :ok }\n end\n end",
"def user_clear (element)\r\n begin\r\n key_processor(element)\r\n ****_clear(@selector, @locator)\r\n rescue Exception => e\r\n raise e.message\r\n raise e.backtrace.inspect\r\n end\r\n end",
"def add\n @ok_msg = t('other_popup_messages.correct.add.media_element')\n if @ok\n if !current_user.bookmark('MediaElement', @media_element_id)\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_creating_for_media_element')\n end\n else\n @error = I18n.t('activerecord.errors.models.bookmark.problem_creating_for_media_element')\n end\n if @destination == ButtonDestinations::FOUND_MEDIA_ELEMENT\n prepare_media_element_for_js\n @ok_msg = nil\n render 'media_elements/reload.js'\n else\n render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}\n end\n end",
"def destroy\n @pm_element = PmElement.find(params[:id])\n @pm_element.destroy\n redirect_to pm_element_path(@pm_element.parent)\n \n end",
"def remove(el)\n raise NotImplementedError\n end",
"def clear\n assert_exists\n @element.clear\n end",
"def destroy\n @home_element = HomeElement.find(params[:id])\n @home_element.destroy\n\n respond_to do |format|\n format.html { redirect_to home_elements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @content_group_element = ContentGroupElement.find(params[:id])\n @content_group_element.destroy\n\n respond_to do |format|\n format.html { redirect_to content_group_elements_url }\n format.json { head :ok }\n end\n end",
"def remove\n super\n update_tabs\n end",
"def destroy\n @inner_page = Embeddable::InnerPage.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(inner_pages_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @inner_page.page_elements.each do |pe|\n pe.destroy\n end\n @inner_page.destroy\n end",
"def destroy\n @comment = BrandComment.find(params[:id])\n @comment.destroy\n\n render :update do |page|\n page.visual_effect :highlight, @comment.dom_id\n page.remove @comment.dom_id\n end\n end",
"def remove\n @ok_msg = t('other_popup_messages.correct.remove.lesson')\n if @ok\n bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'Lesson', :bookmarkable_id => @lesson_id).first\n if bookmark.nil?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_lesson')\n else\n bookmark.destroy\n if Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'Lesson', :bookmarkable_id => @lesson_id).any?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_lesson')\n end\n end\n else\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_lesson')\n end\n if @destination == ButtonDestinations::FOUND_LESSON\n prepare_lesson_for_js\n render 'lessons/reload_compact.js'\n else\n render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}\n end\n end",
"def remove_element\n @app.dom_on_sockets.remove_element @id\n end",
"def link_to_remove_fields(name, f, div)\n f.hidden_field(:_delete) + link_to_function(name, \"remove_fields(this,'#{div}')\")\n end",
"def delete_image\n @page.first('span[data-vh-id=\"remove\"]').click\n end",
"def tradeoff_product_remove\n choice = Choice.find(params[:id]) \n choice.tips.clear\n render :update do |page|\n page.replace_html(\"dropzone_choice_#{choice.id}\", \"\")\n end\n end",
"def documentremove\n if self.documents.attached?\n document_urls = self.documents.map do |adoc| \n Rails.application.routes.url_helpers.delete_document_attachment_tbl_quality_issue_url(adoc, only_path: true)\n end \n else\n nil\n end \n end",
"def depopulate\n @video = Video.find params[:video_id]\n @collection.videos.delete(@video)\n\n respond_to do |format|\n format.html { redirect_to :back, :notice => \"Video removed from your reel.\" }\n format.js\n end\n end",
"def remove_attachment\n @user.assegnazione.purge if @user.assegnazione.attached?\n render :show\n end",
"def destroy\n @article.remove_thumbnail = true\n @article.save!\n head :no_content\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def delete_media_action(_browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n item = wait.until { _browser.find_element(:xpath => @galmgr.action) }\n if not item.displayed?\n Log.logger.info(\"Select bar is not visible...you haven't checked any content to delete!\")\n return\n end\n wait.until { _browser.find_element(:xpath => \"#{@galmgr.action}/option[contains(@value,'delete')]\") }.click\n JQuery.wait_for_events_to_finish(@browser)\n Log.logger.info(\"Clicking delete button.\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.confirm_delete) }\n wait.until { temp.displayed? }\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n next_body_text = wait.until { _browser.find_element(:xpath => \"//body\") }.text\n if next_body_text.include?(\"Error 503 Service Unavailable\")\n raise \"Got an error while trying to delete media items.\"\n end\n\n #are you sure?\n Log.logger.info(\"Waiting for and consuming confirmation.\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.confirm_delete) }\n wait.until { temp.displayed? }\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n end",
"def destroy\n destroy_and_respond(@link)\n end",
"def cleanup\n wait_for_ajax\n page.driver.reset!\n end",
"def destroy\n @biologica_breed_offspring = Embeddable::Biologica::BreedOffspring.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(biologica_breed_offsprings_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @biologica_breed_offspring.page_elements.each do |pe|\n pe.destroy\n end\n @biologica_breed_offspring.destroy\n end",
"def remove_large_html_chunks\n page.execute_script(\"$('#{user_info_fields_container_selector}').remove()\")\n page.execute_script(\"$('#{rig_fields_container_selector}').remove()\")\nend",
"def invalidate_link link\n @links.delete(link.condition)\n \n end",
"def destroy\n @observation_home_element = ObservationHomeElement.find(params[:id])\n @observation_home_element.destroy\n\n respond_to do |format|\n format.html { redirect_to observation_home_elements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spoiler.destroy\n\n head :no_content\n end",
"def clear\n page.main_frame.html = \"\"\n fragments.clear\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def invalidate_link link\r\n @links.delete(link.condition)\r\n link.detach_and_revert\r\n end",
"def remove_cq_question_link(form_builder)\n \n if form_builder.object.new_record?\n # If the task is a new record, we can just remove the div from the dom\n link_to_function(\"Usuń pytanie\", \"disableCQValidation(this);(this).up('.question').remove();\"\t\t\t \t\n \t);\n else\n # However if it's a \"real\" record it has to be deleted from the database,\n # for this reason the new fields_for, accept_nested_attributes helpers give us _delete,\n # a virtual attribute that tells rails to delete the child record.\n form_builder.hidden_field(:_delete) +\n link_to_function(\"Usuń pytanie\", \"$(this).up('.question').hide(); $(this).previous().value = '1';\")\n end\n end",
"def js_remove_element_by_dom_id(element)\n js_remove_element(element)\n end",
"def remove_widget\n # JQuery\n jq_remove = %|$(\"#context_remove\").trigger(\"mousedown\");|\n \n # watir-webdriver\n self.edit_page\n self.open_widget_menu\n self.execute_script(jq_remove)\n wait_for_ajax\n end",
"def clear\n playlist_control :delete\n end",
"def destroy\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n \n file_list_item_id = @file_list_item.id\n \n @page_section = @file_list.page_section\n @page = @page_section.page\n @site_section = @page.site_section\n \n @file_list_item.destroy\n\n respond_to do |format|\n format.html { redirect_to site_section_page_url(@site_section, @page) }\n format.js { render :js => \"$('#page_section_\" + @page_section.id.to_s + \"').replaceWith('\" + @template.escape_javascript(render_to_string(:partial => \"page_sections/show\")) + \"');$('#modal-content').html(\"\");$('#modal').jqmHide();\" }\n format.xml { head :ok }\n end\n end",
"def mtm_edit_remove(assoc, mc, obj, assoc_obj)\n t = String.new\n t << \"<li>\"\n t << association_link(mc, assoc_obj)\n form_attr = form_attributes(:action=>url_for(\"mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&remove%5b%5d=#{model.primary_key_value(assoc_obj)}&redir=edit\"), :method=>'post', :class => 'mtm_remove_associations', 'data-add'=>\"#add_#{assoc}\")\n t << Forme.form(form_attr, form_opts(form_attr[:action])) do |f|\n f.button(:value=>'Remove', :class=>'btn btn-xs btn-danger')\n end\n t << \"</li>\"\n end",
"def removal_link\n new_params = toggle_params\n\n h.content_tag(\n :li,\n h.link_to(\n h.html_escape(\"#{Documents::Category.model_name.human}: #{name}\") +\n close_icon,\n h.search_path(new_params)))\n end",
"def remove_image_link_tag\n @caption_node\n .children\n .first\n .content = @caption_node.content.sub(href_regexp, '').strip\n end",
"def destroy\n @documentary.remove_thumbnail = true\n @documentary.save!\n head :no_content\n end",
"def destroy\n institution = @element.institution\n begin\n @element.destroy!\n rescue ActiveRecord::InvalidForeignKey\n flash['error'] = \"The #{@element.name} element cannot be deleted, as \"\\\n \"it is in use by one or more items.\"\n rescue => e\n flash['error'] = \"#{e}\"\n else\n toast!(title: \"Element deleted\",\n message: \"The element \\\"#{@element.name}\\\" has been deleted.\")\n ensure\n if current_user.sysadmin?\n if institution\n redirect_to institution_path(institution)\n else\n redirect_to template_elements_path\n end\n else\n redirect_to registered_elements_path\n end\n end\n end",
"def remove_content(id)\n delete(\"/#{id}\")\n end",
"def delete_elem\n elem = eval(params[:type]).find(params[:elem])\n eval(params[:type]).delete(params[:elem])\n elems = nil\n case params[:type]\n when \"ProcessModel\"\n elems = elem.activities\n for e in elems\n e.model_id =-1\n e.update_attributes(e.attributes)\n end\n when \"Activity\"\n elems = elem.actions\n for e in elems\n e.activity_id =-1\n e.update_attributes(e.attributes)\n end\n when \"Action\"\n elems = elem.pf_tasks\n for e in elems\n e.action_id =-1\n e.update_attributes(e.attributes)\n end\n end\n redirect_to :action => 'index', :tab =>params[:type]\n rescue\n flash[:error] = l(:error_can_not_delete_custom_field)\n redirect_to :action => 'index',:tab =>params[:type]\n end",
"def remove_link(resource,tag)\n self.class.remove_link(self,resource,tag)\n end",
"def destroy\n @element = @account.elements.find(params[:id])\n @element.destroy\n respond_to do |format|\n format.html { redirect_to(elements_url, :notice => 'Element was sucessfully destroyed.') }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @config_element.destroy\n respond_to do |format|\n format.html { redirect_to config_elements_url, notice: 'Config element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_video\n\t\torder=Order.find(params[:id])\n\t\tx=order.custom_video.last\n\t\tif x.remove_path!\n\t\t\torder.clip_status=false\n\t\t\torder.save\n\t\t\ta=order.performer\n\t\t\tif a.white_label.id==1\n\t\t\t\ta.payment_to_be_done=a.payment_to_be_done-order.perf_cut.to_f\n\t\t\t\ta.save\n\t\t\telse\n\t\t\t\tb=a.white_label\n\t\t\t\tb.payment_to_be_done=b.payment_to_be_done-order.perf_cut.to_f\n\t\t\t\tb.save\n\t\t\tend\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to orders_path, notice: 'Video was successfully deleted' }\n\t\t\t\tformat.mobile { redirect_to orders_path, notice: 'Video was successfully deleted' }\n\t\t\tend\n\t\tend\n\tend",
"def remove_link f\n icon = image_tag 'subtract.gif', :class => 'icon'\n if f.object.new_record?\n link_to_function(icon, \"$(this).up('.#{f.object.class.name.underscore}').remove()\", :title => \"Remove\")\n else\n f.hidden_field(:_delete) + link_to_function(icon, \"$(this).up('.#{f.object.class.name.underscore}').hide(); $(this).previous().value = '1'\", :title => \"Remove\")\n end\n end",
"def remove\n __flag__ :remove\n end",
"def destroy\n @extra.destroy\n\n head :no_content\n end",
"def remove!; end",
"def remove\n\t\t#Clean up unused rtwork\n\t\tif Artwork.find_by_majorpost_uuid(params[:majorpost_uuid])\n\t\t\tResque.enqueue(Image::ArtworkCleanup, params[:majorpost_uuid])\n\t\tend\n\tend",
"def destroy\n @click_data.destroy\n\n head :no_content\n end",
"def destroy\n @sound_grapher = Embeddable::SoundGrapher.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(sound_graphers_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @sound_grapher.page_elements.each do |pe|\n pe.destroy\n end\n @sound_grapher.destroy\n end",
"def remove_offering\n @portal_clazz = Portal::Clazz.find(params[:id])\n dom_id = params[:dragged_dom_id]\n container = params[:dropped_dom_id]\n offering_id = params[:offering_id]\n @offering = Portal::Offering.find(offering_id)\n if (@offering && @offering.can_be_deleted?)\n @runnable = @offering.runnable\n @offering.destroy\n @portal_clazz.reload\n render :update do |page|\n page << \"var container = $('#{container}');\"\n page << \"var element = $('#{dom_id}');\"\n page << \"element.remove();\"\n page << \"$('flash').update('');\"\n page.insert_html :top, container, :partial => 'shared/runnable', :locals => {:runnable => @runnable}\n end\n else\n error_msg = \"Cannot delete offering with student data. Please deactivate instead.\"\n render :update do |page|\n page << \"var element = $('#{dom_id}');\"\n page << \"element.show();\"\n page << \"$('flash').update('#{error_msg}');\"\n page << \"alert('#{error_msg}');\"\n end\n end\n end",
"def destroy\n @web_display_car_image.destroy\n\n head :no_content\n end",
"def destroy\n @dataelement = Dataelement.find(params[:id])\n @dataelement.destroy\n\n respond_to do |format|\n format.html { redirect_to dataelements_url }\n format.json { head :no_content }\n end\n end",
"def unlink!\n parse \n @tags.each do |tag|\n @doc.xpath(\"//a[ends_with(@href,'#{tag}')]\", EndsWithFilter.new).each do |element|\n element.swap(element.children)\n end\n end\n output = @doc.xpath(\"/#{@wrap_tag}/body/p\").inner_html\n output = @doc.xpath(\"/#{@wrap_tag}/body\").inner_html if output == \"\"\n output\n end",
"def link_to_remove_ingest_association(f)\n label = I18n.t(\"ingest_form.#{f.object.group}.remove\", :default => \"Remove this #{f.object.group}\")\n html = %Q|<span class=\"sr-only\">#{label}</span><i class=\"icon-trash icon-white\"></i>|\n return link_to_remove_association(raw(html), f,\n :class => \"btn btn-danger\",\n :title => label\n )\n end",
"def unpublish\n @ok_msg = t('other_popup_messages.correct.unpublish')\n if @ok\n if !@lesson.unpublish\n @ok = false\n @error = @lesson.get_base_error\n end\n else\n @error = I18n.t('activerecord.errors.models.lesson.problem_unpublishing')\n end\n prepare_lesson_for_js\n if [ButtonDestinations::FOUND_LESSON, ButtonDestinations::COMPACT_LESSON].include? @destination\n render 'lessons/reload_compact.js'\n else\n render 'lessons/reload_expanded.js'\n end\n end",
"def reset\n @href = href # make sure we have the href\n @raw = nil\n end"
] | [
"0.6071593",
"0.57807547",
"0.5600696",
"0.55835575",
"0.5526149",
"0.55047345",
"0.543671",
"0.5432676",
"0.5417777",
"0.53990537",
"0.5340022",
"0.5313041",
"0.5259157",
"0.52519363",
"0.5238161",
"0.5231691",
"0.52297837",
"0.5223814",
"0.5210044",
"0.5190807",
"0.5190292",
"0.51851755",
"0.5153365",
"0.5152205",
"0.513441",
"0.5129547",
"0.5129547",
"0.51122904",
"0.5111043",
"0.50850147",
"0.5079566",
"0.50769943",
"0.5070827",
"0.5041908",
"0.5032344",
"0.5012369",
"0.50122225",
"0.4992518",
"0.49920753",
"0.49816722",
"0.4974483",
"0.4965853",
"0.4946857",
"0.49443865",
"0.49186915",
"0.49155998",
"0.4905692",
"0.4902369",
"0.4897559",
"0.4896213",
"0.48954785",
"0.48665354",
"0.48572925",
"0.48561385",
"0.48532385",
"0.48532385",
"0.48532385",
"0.48532385",
"0.48473686",
"0.4844569",
"0.48343176",
"0.4808607",
"0.48021054",
"0.479286",
"0.47924024",
"0.4791435",
"0.47855267",
"0.47779813",
"0.47779813",
"0.47744012",
"0.47696862",
"0.47664574",
"0.47651944",
"0.47525173",
"0.47479892",
"0.47334564",
"0.47262013",
"0.47228226",
"0.47213358",
"0.47172678",
"0.47157988",
"0.47130078",
"0.47024006",
"0.4700579",
"0.47004038",
"0.46972328",
"0.46958116",
"0.46877044",
"0.46793672",
"0.46723962",
"0.4672183",
"0.4660625",
"0.46562168",
"0.4655645",
"0.46545416",
"0.4652283",
"0.4651051",
"0.4644567",
"0.4643662",
"0.46298102"
] | 0.67451316 | 0 |
Description Updates the general information of the element (title, description and tags) Mode Ajax Specific filters ApplicationControllerinitialize_media_element_with_owner_and_private | def update
if @ok
@media_element.title = params[:title]
@media_element.description = params[:description]
@media_element.tags = params[:tags_value]
@media_element.save_tags = true
if !@media_element.save
@errors = convert_media_element_error_messages @media_element.errors
else
@media_element.set_status current_user.id
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_description\n self.div(:id=>\"contentmetadata_description_container\").fire_event \"onmouseover\"\n self.div(:id=>\"contentmetadata_description_container\").fire_event \"onclick\"\n end",
"def update\n params[:description][:author_ids] ||= []\n @description = Description.find(params[:id])\n @authors = AuthenticatedSystem::Person.order('fullname')\n respond_to do |format|\n if @description.update_attributes(params[:description])\n flash[:notice] = 'Description was successfully updated.'\n format.html do\n\t if @category != @main_category # if request.xhr?\n\t redirect_to category_child_url(@main_category, @category)\n\t else\n\t redirect_to(@category)\n\t end\n\t end\n\t format.js { render 'categories/show' }\n\t format.xml { head :ok }\n else\n @languages = ComplexScripts::Language.order('title')\n @authors = AuthenticatedSystem::Person.order('fullname')\n format.html { render 'edit' }\n format.js { render 'edit' } #.js.erb\n format.xml { render :xml => @description.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit_description\n end",
"def set_description\n @description = Description.find_by(uuid: params[:id])\n end",
"def description\n\t\t# has this merchant uploaded an epub file yet?\n\t\tif is_ebook_options_selected?(description_params[:products_type_id]) && !temporary_epub_session_active?\n \t@epub_not_uploaded = true\n\n \t# respond to js and html\n\t respond_to do|format|\n\t format.js\n\t format.html\n\t end\n\t return\n\t\tend\n \n # Process form data\n check_member_details = TemporaryProductsDescription.find_by(merchant_id: session[:merchant_id])\n @temporary_products = if check_member_details != nil then check_member_details else TemporaryProductsDescription.new(description_params) end\n\n if check_member_details.nil?\n # save book description details temporarily\n @temporary_products.add_merchant_id = session[:merchant_id]\n if @temporary_products.save\n \tactivate_temporary_book_desc_session @temporary_products.id\n else\n @error = true\n end\n else\n \t # update previous record to save space\n \t if @temporary_products.update(description_params)\n \t \tactivate_temporary_book_desc_session @temporary_products.id\n \t else\n \t \t@error = true\n \t end\n end\n\n # respond to js and html\n respond_to do|format|\n format.js\n format.html\n end\n\tend",
"def update_description\n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.description = params[:description]\n @photo.save()\n render :json => @photo\n end",
"def fleximage_editor\n \n ar_object = Kernel::const_get(params[:ar_object_class]).find(params[:ar_object_id])\n display_editor = (params[:display_editor] == \"false\")\n display_thumbnail = (params[:display_thumbnail] == \"true\")\n \n render :update do |page| \n page.replace(MainController.fleximage_domid(ar_object),\n render(:partial => \"/main/media_edit\", \n :locals => {:ar_object => ar_object, \n :timestamp => nil,\n :display_thumbnail => display_thumbnail, \n :display_editor => display_editor})\n )\n\t\tend\n end",
"def set_description\n @description = Description.find(params[:id])\n end",
"def set_description\n @description = Description.find(params[:id])\n end",
"def set_title_and_description\n \t\tresp = get_resp(self.url)\n \t\tself.title = resp.match(/<title>(.+)<\\/title>/)[1]\n \t\tself.description = resp.match(/<meta name=\"description\" content=\"([^\\\"]*)/)[1]\n \t\tself.save!\n \tend",
"def update_html_for_abstract\n return unless details\n self.details_filtered = textile_to_html( details )\n end",
"def edit\n @object = referenced_object\n @attribute = params[:attribute]\n @form_element = params[:form_element]\n @sub_id = params[:sub_id]\n @update_span = params[:update]\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { }\n end\n end",
"def list_media_details(gallery_name = \"test\", _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Listing Media properties and ids to edit it (for Gallery: #{gallery_name.inspect})\")\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_media) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n edit_media_ids = Hash.new\n i = 1\n wait.until { _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-')]\") }\n med_ct = Integer(_browser.find_elements(:xpath => \"//div[contains(@id, 'media-edit-')]\").size)\n Log.logger.info(\"Found editable images: #{med_ct}\")\n while i < med_ct+1\n media_url = _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-#{i}')]//img[contains(@class, '')]\").attribute(\"src\")\n Log.logger.info(\"Working on image number #{i}: #{media_url.inspect}\")\n if (i == 1)\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value']\"\n media_tag = \"//input[@id = 'edit-field-tags-und']\"\n else\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und--#{i}']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und--#{i}']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value--#{i}']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value--#{i}']\"\n media_tag = \"//input[@id = 'edit-field-tags-und--#{i}']\"\n end\n\n Log.logger.info(\"image number #{i} media-type: #{media_type.inspect}\")\n Log.logger.info(\"image number #{i} media-title: #{media_title.inspect}\")\n edit_media_ids[media_url] = Hash.new() unless (edit_media_ids[media_url])\n edit_media_ids[media_url][:license] = media_license_setting\n edit_media_ids[media_url][:tag] = media_tag\n edit_media_ids[media_url][:desc] = media_description\n edit_media_ids[media_url][:title] = media_title\n edit_media_ids[media_url][:type] = media_type\n i += 1\n end\n return edit_media_ids\n end",
"def set_description\n @company = Company.find(params[:company_id])\n @description = @company.description\n end",
"def description\n element = Element.find(params[:element_id])\n \n respond_with(element.description.to_json)\n end",
"def set_admin_additional_description\n @admin_additional_description = AdditionalDescription.find(params[:id])\n end",
"def update\n json_response(@description.update!(description_params))\n end",
"def set_time_entry_description\n data=params\n @time_entry = TneInvoiceTimeEntry.find(data[:id])\n @time_entry.update_attribute(:description,data[:value])\n render :text => @time_entry.description\n end",
"def set_expense_entry_description\n data=params\n @tne_invoice_expense_entry = TneInvoiceExpenseEntry.find(data[:id])\n @tne_invoice_expense_entry.update_attribute(:description,data[:value])\n render :text => @tne_invoice_expense_entry.description\n end",
"def update\n @medium = Medium.find(params[:id])\n params_medium = params.require(:medium).permit(:recording_note, :resource_type_id, :photographer_id, :taken_on, :partial_taken_on, :capture_device_model_id,\n :quality_type_id, :private_note, :rotation, web_address_attributes: [:parent_resource_id, :url])\n respond_to do |format|\n params_web_address = params_medium.delete(:web_address_attributes)\n @medium.attributes = params_medium\n @medium.web_address.attributes = params_web_address if !params_web_address.nil?\n @medium.ingest_taken_on(params_medium)\n is_picture = @medium.instance_of? Picture\n redo_thumbs = @medium.rotation_changed? if is_picture\n if @medium.save # @medium.update_attributes(params[:medium])\n @medium.update_thumbnails if is_picture && redo_thumbs\n flash[:notice] = ts('edit.successful', :what => Medium.model_name.human.capitalize)\n format.html { redirect_to medium_url(@medium) }\n format.xml { head :ok }\n else\n format.html do\n @capture_device_models = CaptureDeviceMaker.all.order('title').collect{|maker| maker.capture_device_models}.flatten\n @media_publisher = MediaPublisher.all\n @photographers = AuthenticatedSystem::Person.all.order('fullname')\n @quality_types = QualityType.all.order('id')\n @recording_orientations = RecordingOrientation.all.order('title')\n @resource_types = Topic.find(2636).children\n @root_topics = Topic.roots \n render :action => 'edit'\n end\n format.xml { render :xml => @medium.errors.to_xml }\n end\n end\n end",
"def update\n\n generated_thumbnail = author_widget_params[:thumbnail].match(/^\\/assets/)\n\n params[:author_widget].delete(:thumbnail) if generated_thumbnail\n params[:author_widget][:widget_category_id] = @category.id\n\n respond_to do |format|\n\n if @author_widget.update(author_widget_params)\n if request.xhr?\n widget = WidgetLib::Generate.new\n widget.init_params(@author_widget.resource)\n widget.generate_css(@author_widget.thumbnail) unless generated_thumbnail\n on_success_xhr(format, @author_widget)\n else\n on_success(format, @author_widget, t('widget_update_success'))\n end\n else\n format.html {render :edit}\n format.json {render json: @author_widget.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update_description\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = \"Course updated Successfully\"\n else\n flash[:error] = \"An error occured!\"\n end\n format.html\n format.js\n end\n end",
"def set_admin_description\n @admin_description = Admin::Description.find(params[:id])\n end",
"def description\n if element.blank?\n log_warning \"Content with id #{self.id} is missing its Element.\"\n return {}\n end\n desc = self.element.content_description_for(self.name)\n if desc.blank?\n self.element.available_content_description_for(self.name)\n end\n desc || {}\n end",
"def update\n respond_to do |format|\n if @video.update(video_params)\n @publication = Publication.find_by_published_id_and_published_type(@video.id, 'Video')\n @publication.update(:content => @video.content + @video.name + @video.description + @video.tag_list.join(' '))\n format.html { redirect_to videos_path, notice: 'El video fue actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: 'list' }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @object = referenced_object\n @attribute = params[:attribute]\n @form_element = params[:form_element]\n @sub_id = params[:sub_id]\n @update_span = params[:update]\n send(\"#{@form_element.to_s}_update\", @object, @attribute)\n @object.save\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { }\n end\n end",
"def set_elements\n super\n element(:message) {b.li(:class => 'uif-infoMessageItem')}\n element(:messages) {b.lis(:class => 'uif-infoMessageItem')}\n element(:message_header) {b.h3(:class => 'uif-pageValidationHeader')}\n element(:submit_button) {b.button(:id => \"submitEditor\")}\n element(:cancel_button) {b.button(:id => \"cancelEditor\")}\n element(:close_button) {b.button(:id => \"closeEditor\")}\n element(:return_to_search_button) {b.button(:id => \"returnToSearch_button\")}\n # Navigation Area Elements\n element(:delete_bib_button) {b.button(:title => 'Delete Bib')}\n element(:add_instance_button) {b.button(:title => 'Add Instance')}\n element(:add_einstance_button) {b.button(:title => 'Add EInstance')}\n # @note Vakata Context Menu items are only present on the screen after the containing menu header has been right-clicked.\n element(:delete_instance_button) {b.div(:id => 'vakata-contextmenu').ul.li(:index => 0).a(:rel => \"Delete\")}\n element(:add_item_button) {b.button(:title => 'Add Item')}\n element(:delete_item_button) {b.div(:id => 'vakata-contextmenu').ul.li(:index => 0).a(:rel => 'Delete')}\n end",
"def update_flickr_description\n if caption_changed? && flickr_image\n description = caption.to_s unless user.flickr_title\n description += \"\\n\\nTwitter: #{tweet_url}\" if tweet_url\n flickr_image.set_meta(:description => description)\n flickr_image.add_tags(tags.join(',')) unless tags.empty?\n end\n end",
"def set_internal\n @description = Description.find(params[:id])\n @internal = @description.internal\n end",
"def set_internal\n @description = Description.find(params[:id])\n @internal = @description.internal\n end",
"def set_internal\n @description = Description.find(params[:id])\n @internal = @description.internal\n end",
"def create\n if @category.descriptions.empty?\n params[:description][:is_main] = \"true\"\n end\n @description = Description.new(params[:description])\n @description.creator = current_user\n respond_to do |format|\n if @description.save\n authors = @description.authors\n session[:default_author_id] = authors.first.id if authors.size==1\n session[:default_language_id] = @description.language.id\n format.html do\n flash[:notice] = 'Description was successfully created.'\n\t\t if @category != @main_category\n\t\t redirect_to category_child_url(@main_category, @category)\n\t\t else\n\t\t redirect_to(@category)\n\t\t end\n end\n format.js { render 'categories/show' }\n format.xml { render :xml => @description, :status => :created, :location => @description }\n else\n @languages = ComplexScripts::Language.order('title')\n @authors = AuthenticatedSystem::Person.order('fullname')\n format.html {render 'new'}\n format.js {render 'new'}\n format.xml { render :xml => @description.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_additional_description.update(admin_additional_description_params)\n format.html { redirect_to admin_products_path, notice: 'Additional description was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_additional_description }\n else\n format.html { render :edit }\n format.json { render json: @admin_additional_description.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_gallery_title_desc(gallery_name = \"test\", gallery_title = \"samplegallery\", gallery_desc = \"Its a sample gallery\",_browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Editing '#{gallery_name}' Gallery properties (Title + Desc).\")\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n temp = wait.until { _browser.find_element(:xpath => @galmgr.gallery_title) }\n temp.clear\n temp.send_keys(gallery_title)\n wait.until { _browser.find_element(:xpath => @galmgr.gallery_desc) }\n self.type_text_in_wysiwyg_editor(gallery_desc)\n ## we need to be on the overlay at this point of execution\n wait.until { _browser.find_element(:xpath => @galmgr.save_gallery_btn) }.click\n _browser.switch_to.default_content\n end",
"def modifier_lien\n if params[:lien] != \"\" \n @lien = Lien.find(params[:id])\n @donnee_url = OpenGraph.fetch(params[:lien])\n \n @url_lien = params[:lien]\n element = @url_lien.split(\".\")\n tab = @url_lien.split(\"//\")\n if tab[0] == \"http:\"\n @url = @url_lien\n else\n @url = \"http://\"+@url_lien\n end\n name = \"/images_liens/thumb#{Time.now.to_i}.jpg\"\n if @donnee_url\n\t titre = @donnee_url.title\n\t desc = @donnee_url.description\n\t image = @donnee_url.image\n image_or = Magick::Image.read(image)[0]\n image = image_or.crop_resized!(297, 195, Magick::NorthGravity)\n image.write(\"#{RAILS_ROOT}/public\"+name) do self.quality = 100 end\n else\n\t begin\n uri =URI(@url)\n #htmlcontent = #Net::HTTP.get(uri)\n #soup = BeautifulSoup.new(htmlcontent)\n hdrs = {\"User-Agent\"=>\"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\", \"Accept-Charset\"=>\"utf-8\", \"Accept\"=>\"text/html\"}\n my_html = \"\"\n \n open(@url, hdrs).each{|s| my_html << s}\n doc = Hpricot(my_html)\n desc = HTMLEntities.new.decode(doc.search(\"meta[@name*=description]\").map {|e| e.get_attribute(\"content\") }.to_s)#soup.find('meta', {'name' => 'description'})['content']\n titre = HTMLEntities.new.decode(doc.at(\"html/head/title\").inner_html)#soup.html.head.title.string\n\t rescue\n titre = \"\"\n flash[:error] = \"Ce lien est certainement plein de joie mais malheureusement, le format n'est pas conforme à la Boite à Joie, peut être existe t-il un autre lien qui vous rende joyeux ?\"\n redirect_to (:controller => 'liens', :action => \"new\", :p => \"home\")\n return 0\n end\n \n #desc = \"\"\n\t name = \"http://api.url2png.com/v3/P4F280C28BB8E7/#{Digest::MD5.hexdigest('S94BC47B3A5190+'+@url)}/297x195/#{@url}\"#\"https://www.apercite.fr/api/apercite/800x600/oui/oui/#{@url}\"\n end\n \n \n respond_to do |format|\n if Lien.update(params[:id], :titre_lien =>titre, :description_lien => desc, :url_lien => params[:lien], :image_lien => name)\n format.html { redirect_to(:controller => 'auteurs', :action => 'new', :id => params[:idauteur], :p => \"user\", :idlien => params[:id], :auteur => params[:auteur][:pseudo_auteur]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"new\", :p => \"home\" }\n format.xml { render :xml => @lien.errors, :status => :unprocessable_entity }\n end\n end\n else\n flash[:notice] = \"Désolé monsieur ou madame !!\"\n redirect_to :back\n end\n end",
"def edit_metadata_fields\n end",
"def update\n @article = Article.find(params[:id])\n content = @article.contents[0]\n# @article.contents.create(:title => @article.title, :body => params[:body]) unless content\n# content.update_attributes(:title => @article.title, :body => params[:body]) if content\n Content.create(:title => @article.title, :body => params[:body], :article_id => @article.id) unless content\n content.update_attributes(:title => @article.title, :body => params[:body]) if content\n \n respond_to do |format|\n @article = Article.find(params[:id])\n if @article.update_attributes(params[:article])\n flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to \"/admin/articles?standalone=true\" }\n format.xml { head :ok }\n format.js { \n @channel, @articles = find_articles(params[:article][:channel_id])\n render(:update) { |page| page.replace_html 'channel-form', :partial => 'list' } \n }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @article.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def media_url_upload\n ar_object = Kernel.const_get(params[:ar_object_class]).find(params[:ar_object_id])\n ar_object.media_url = params[:media_url]\n if ar_object.save\n @messages = 'media updated'\n else\n @messages = 'Oups updating fleximage'\n ar_object.errors.each { |field, msg| puts \"********* field:#{field} --> #{msg}\" }\n end\n render :update do |page| \n page.replace(MainController.media_domid(ar_object),\n render(:partial => \"/main/media_editor\", :locals => {:title => params[:title], :ar_object => ar_object }))\n\t\tend\n end",
"def description=(description)\n end",
"def set_description(page)\n if !page.data['description']\n page.data['description'] = \"Check end-of-life, release policy and support schedule for #{page.data['title']}.\"\n end\n end",
"def update_introduction\n @cookbook = current_cookbook\n\n # Process Paperclip attachments\n @cookbook.process_attachments(params)\n\n if params[:cookbook]\n @cookbook.intro_type = params[:cookbook][:intro_type] if params[:cookbook][:intro_type]\n @cookbook.center_introduction = params[:cookbook][:center_introduction] if params[:cookbook][:center_introduction]\n @cookbook.intro_text = params[:cookbook][:intro_text] if params[:cookbook][:intro_text]\n @cookbook.intro_image_grayscale = params[:cookbook][:intro_image_grayscale] if params[:cookbook][:intro_image_grayscale]\n @cookbook.intro_image = params[:cookbook][:intro_image] if !params[:cookbook][:intro_image].nil?\n\n # If the user has checked the \"Do not include this page\" checkbox, set the intro_type do '2'\n @cookbook.intro_type = 2 if params[:do_not_include]\n @cookbook.intro_type = 0 if !params[:do_not_include] && @cookbook.intro_type == 2\n end\n\n if @cookbook.save\n flash[:notice] = 'The introduction of your cookbook was saved.'\n end\n respond_to do |format|\n format.js { render :update_introduction, content_type: \"text/plain\" }\n end\n end",
"def ajax_detail\n @eob = Eob.find(params[:id])\n @eob_details = []\n if params[:eob]\n @attributes = params[:eob][:eob_details_attributes]\n @attributes.each do |key, value|\n @eob_details.push @eob.eob_details.build(value)\n end\n end\n @count = @eob.eob_details.count\n @eob_details.push @eob.eob_details.build()\n\n respond_to do |format|\n format.js {render :layout => false }\n end\n end",
"def edit_all_galleries(new_title = \"Galleries\", desc_format = \"Plain text\", new_desc = \"\",\n new_url = \"galleries\", new_cols = 4, new_rows = 3, new_display = \"Show title on hover\", _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 10)\n Log.logger.info(\"Editing All Galleries\")\n Log.logger.info(\"Waiting for gallery overlay frame\")\n frame = wait.until { _browser.find_element(:xpath => @galmgr.eag_overlay_frame) }\n _browser.switch_to.frame(frame)\n Log.logger.info(\"Waiting for the 'Gallery settings' title. (to make really sure we're on the right iframe)\")\n #<h1 id=\"overlay-title\">Gallery settings</h1>\n wait.until { _browser.find_element(:xpath => \"//h1[@id='overlay-title' and text()='Gallery settings']\") }\n Log.logger.info(\"Waiting for eag_title\")\n already_retried = false\n temp = wait.until { _browser.find_element(:xpath => @galmgr.eag_title) }\n temp.clear\n temp.send_keys(new_title)\n JQuery.wait_for_events_to_finish(_browser)\n Log.logger.info(\"Selecting eac_desc_format (#{desc_format.inspect} in text-format list.\")\n elm = wait.until { _browser.find_element(:xpath => \"#{@galmgr.eag_desc_format}/option[text()='#{desc_format}']\") }\n wait.until { elm.displayed? }\n elm.click\n if desc_format == \"Plain text\"\n Log.logger.info(\"Waiting for text 'Allowed tags: None' to show up (Because 'Plain text' option was selected)\")\n wait.until { _browser.find_element(:xpath => \"//div[@class='wysiwyg-none-header']//span[contains(text(), 'None')]\") }\n else\n JQuery.wait_for_events_to_finish(_browser)\n end\n=begin\n begin\n _browser.find_element(:xpath => @galmgr.eag_url_path).send_keys(new_url)\n##### THIS HAS CHANGED DUE TO THE NEW SEO SHIT\n rescue\n Log.logger.info(\"TF!!\")\n gets\n end\n=end\n Log.logger.info(\"Setting columns to: #{new_cols}\")\n wait.until { _browser.find_element(:xpath => \"#{@galmgr.edit_gallery_cols}/option[text()='#{new_cols}']\") }.click\n Log.logger.info(\"Setting row to: #{new_rows}\")\n r_ows = _browser.find_element(:xpath => @galmgr.edit_gallery_rows)\n r_ows.clear\n r_ows.send_keys(new_rows)\n wait.until { _browser.find_element(:xpath => \"#{@galmgr.edit_gallery_media_display}/option[text()='#{new_display}']\") }.click\n if (desc_format == \"Plain text\")\n Log.logger.info(\"Typing in new description \")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.eag_desc) }\n temp.clear\n temp.send_keys(new_desc)\n else\n _browser.switch_to.default_content\n Log.logger.info(\"Selecting ckeditor frame\")\n frame = wait.until { _browser.find_element(:xpath => @galmgr.ckeditor_frame) }\n _browser.switch_to.frame(frame)\n Log.logger.info(\"Waiting for ckeditor body\")\n wait.until { _browser.find_element(:xpath => @galmgr.ckeditor_body) }\n Log.logger.info(\"Typing in new description\")\n\n type_text_in_wysiwyg_editor(new_desc)\n\n _browser.switch_to.default_content\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n end\n Log.logger.info(\"Clicking on save gallery button\")\n wait.until { _browser.find_element(:xpath => @galmgr.save_gallery_btn) }.click\n Log.logger.info(\"Waiting for confirmation message\")\n confirmation_msg = wait.until { _browser.find_element(:xpath => @galmgr.confirmation_message) }.text\n Log.logger.info(\"Got confirmation message: #{confirmation_msg.inspect}\")\n frame = wait.until { _browser.find_element(:xpath => @galmgr.close_overlay) }\n Log.logger.info(\"Clicking on close overlay link\")\n begin\n alert = _browser.switch_to.alert\n Log.logger.info(\"Encountered an alert while closing overlay...perhaps I shouldn't be using the overlay!!!!\")\n alert.accept\n rescue\n Log.logger.info(\"No alert present...continuing\")\n end\n wait.until { _browser.find_element(:xpath => @galmgr.close_overlay) }.click\n _browser.switch_to.default_content\n return confirmation_msg\n end",
"def init_description\n if notification_type_id\n begin\n type = NotificationType.find(notification_type_id)\n @description = type.description\n rescue Exception => e \n @description = ''\n end\n end\n end",
"def update\n @web_profile = WebProfile.find(params[:id])\n\n respond_to do |format|\n format.js do\n if @web_profile.update_attributes(params[:web_profile])\n replace_content(dom_id(@web_profile), :partial => @web_profile)\n else\n show_error_messages(@web_profile)\n end\n end\n end\n end",
"def show_update_attachment_form\n show_params(params)\n get_frbr_object_from_id\n logger.debug \"+++++ UPDATE ATTACHMENT +++++\"\n @media_item = MediaItem.find(params[:media_item_id])\n get_attachment_types(@frbr_object)\n @mode = params[:mode]\n #we need the attachment type\n \n attachment_klass = (@frbr_object.class.to_s+\"Attachment\").constantize\n frbr_class_id = \"#{@frbr_object.class.to_s.tableize.singularize}_id\"\n attachments = attachment_klass.find(:all, \n :conditions => [\"media_item_id=? and #{frbr_class_id} = ?\", \n @media_item.media_item_id, \n @frbr_object.send(frbr_class_id)]\n )\n \n #There should be one\n @attachment_type = attachments[0].attachment_type\n \n logger.debug \"ATTACHMENTS ARE:#{attachments} of len #{attachments.length}\"\n logger.debug \"ATT TYPE:#{@attachment_type.attachment_type_desc}\"\n \n \n \n render :partial => 'shared/attachments/attachment_form',\n :locals => {:object => @frbr_object, :submission => :update, :media_item => @media_item, :mode => @mode}\n end",
"def setDescription(description)\r\n\t\t\t\t\t@description = description\r\n\t\t\t\tend",
"def setDescription(description)\r\n\t\t\t\t\t@description = description\r\n\t\t\t\tend",
"def update\n respond_to do |format|\n if @admin_description.update(admin_description_params)\n format.html { redirect_to @admin_description, notice: 'Description was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_description }\n else\n format.html { render :edit }\n format.json { render json: @admin_description.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_title_and_description\n website = Nokogiri::HTML(open(self.url))\n self.title = website.css('title').text\n self.description = website.at(\"meta[name='description']\")['content'] unless website.at(\"meta[name='description']\").nil?\n end",
"def extra_description\n attributes_description + content_description + count_description\n end",
"def show_seo\n @robots=\"noindex,nofollow\"\n @gallery = Roxiware::Gallery.where(:seo_index=>params[:gallery_seo_index]).first\n @title = @title + \" : Gallery : \" + @gallery.name\n @meta_description = @meta_description +\" : Gallery : \" + @gallery.name\n\n raise ActiveRecord::RecordNotFound if @gallery.nil?\n authorize! :read, @gallery\n \n if can? :create, Roxiware::GalleryItem\n logger.debug(\"adding new gallery item\");\n @gallery.gallery_items.build({:name=>\"Upload New Picture\", :person_id=>current_user.id}, :as=>@role) \n end \n logger.debug(\"items\" + @gallery.gallery_items.to_json);\n respond_to do |format|\n format.html { render :show }\n format.json { render :json => @gallery.ajax_attrs(@role) }\n end\n end",
"def set_redescription\n @recompany = Recompany.find(params[:recompany_id])\n @redescription = @recompany.redescription\n end",
"def update\n if description_params[:mode]\n @description.create_activity key: 'Updated Description', owner: @folder\n end\n respond_to do |format|\n if @description.update(description_params)\n format.html { redirect_to trip_folder_descriptions_path(:trip_id => @trip.name,:folder_id => @folder.name ), notice: 'Description was successfully updated.' }\n format.json { render :show, status: :ok, location: @description }\n else\n format.html { render :edit }\n format.json { render json: @description.errors, status: :unprocessable_entity }\n end\n end\n end",
"def updateProgramme()\n @media_operation = :update\n end",
"def edit\n @l1_bu = @workflow.l1_bu\n @l1_component = @workflow.l1_component\n @bu_options = @workflow.bu_options.where(recording_level: 'L1')\n @action = 'UPDATE'\n @btn_action = 'UPDATE'\n @status_list = @workflow.statuses.where(recording_level: 'L1')\n @attr_list = @workflow.label_attributes.where(recording_level: 'L1', is_visible: true).order(:sequence)\n @attr_values = @l1.attribute_values\n respond_to do |format|\n format.html\n format.js\n end\n\n\n end",
"def update_old_data(id1,id2,data)\n render :update do |page|\n page << \"jQuery('##{id1}').hide();jQuery('##{id2}').show();jQuery('##{id1} span input[name]').val('#{data}');\"\n page << \"jQuery('#name').html('<strong>#{data}</strong>')\" if params[:field] == 'name'\n page << \"jQuery('#comment_description').html('<h>#{data}</h>')\" if params[:field] == 'comment'\n page.call \"flash_writter\", \"Blank submission is not possible\" if !params[:name].present?\n end\nend",
"def show\n @invitation_message = InvitationMessage.find(params[:id])\n @owner = User.find(@invitation_message.owner_id)\n \n \n if @invitation_message.video\n @video_html = opentok_video_html(@invitation_message.video)\n else\n @video_html = \"\"\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @invitation_message }\n end\n end",
"def update!(**args)\n @full_description = args[:full_description] unless args[:full_description].nil?\n @language = args[:language] unless args[:language].nil?\n @short_description = args[:short_description] unless args[:short_description].nil?\n @title = args[:title] unless args[:title].nil?\n @video = args[:video] unless args[:video].nil?\n end",
"def update\n if request.xhr?\n @product = Product.find(params[:product][:id])\n\n @product.photos.each do |photo|\n photo.update_attribute(:main, false)\n end\n\n if params[:photo][:id].empty?\n return\n else\n @photo = Photo.find(params[:photo][:id])\n end\n\n else\n @photo = Photo.find(params[:id])\n end\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n flash[:notice] = 'Plik został zapisany poprawnie.' unless request.xhr?\n format.html { redirect_to([:admin, @photo]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def orchard_id_changed\n orchard_id = get_selected_combo_value(params)\n session[:delivery_form][:orchard_id_combo_selection] = orchard_id\n @orchard_description = \"\"\n\n orchard = Orchard.find(orchard_id)\n if (orchard != nil)\n orchard_description = orchard.orchard_description\n @orchard_description = orchard_description\n session[:delivery_form][:orchard_description] = orchard_description\n else\n @orchard_description = \"\"\n end\n\n @rmt_product_codes = [\"select a value from rmt_product_type_code above\"]\n\n render :inline => %{\n <%= @orchard_description_content = @orchard_description %>\n <%= @rmt_product_codes_content = select('delivery','rmt_product_id',@rmt_product_codes,{:sorted=>true})%>\n <script>\n <%= update_element_function(\"orchard_description_cell\", :action => :update,:content => @orchard_description_content) %>\n <%= update_element_function(\"advised_rmt_product_code_cell\", :action => :update,:content => @rmt_product_codes_content) %>\n </script>\n }\n\n end",
"def load_edit_product_page\n @product = Product.find(params[:product_id])\n\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n\n @product_components = @product.components\n @product_valuefields = @product.valuefields\n @product_properties = @product.properties\n @product_images = @product.images\n @product_datafiles = @product.data_files\n @product_categories = @product.categories\n\n respond_to do |format|\n format.js\n end\n end",
"def set_description(text)\n @description_label.set_text(text)\n if text\n @description_label.set_hidden(false)\n else\n @description_label.set_hidden(true)\n end\n end",
"def update_form_title_and_description\n form_params = params.require(:form).permit(:id, :title, :description)\n\n render json: Form.update_form_title_and_description(current_user[\"id\"], form_params)\n end",
"def set_meta_description\n html = html_overview || html_content || ''\n\n self.meta_description =\n html.\n gsub(/<\\/?[^>]*>/, ' '). # replace HTML tags with spaces\n gsub(/&\\w{1,9};|\"/, ''). # remove HTML special chars and double quotes\n gsub(/\\n+/, \" \"). # remove new lines\n gsub(/\\s+/, ' '). # remove duplicated spaces\n strip[0..200] # strip spaces and get first 200 chars\n end",
"def show\n @object = referenced_object\n @attribute = params[:attribute]\n @form_element = params[:form_element]\n close = params[:close] || false\n if @form_element == \"associated\"\n @sub_id = params[:sub_id]\n if @sub_id.to_i > 0\n @associated_record_id = @object.send(@attribute.to_s.singularize + \"_ids\").index(@sub_id.to_i)\n @associated_record = @object.send(@attribute)[@associated_record_id]\n end\n end\n if @form_element == \"has_one\"\n @associated_record = @object.send(@attribute)\n @associated_record_id = @associated_record.id\n end\n @update_span = params[:update]\n if @attribute.nil?\n respond_to do |format|\n @attributes = @object.inline_forms_attribute_list\n if close\n format.js { render :close }\n else\n format.js { }\n end\n end\n else\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { render :show_element }\n end\n end\n end",
"def edit_tags\n self.div(:id=>\"contentmetadata_tags_container\").fire_event \"onclick\"\n end",
"def edit\n @persona = Persona.find(:first, :conditions => { :screen_name => params[:persona_id] })\n @mediaset = Mediaset.find(params[:id])\n\n @mediaset_photos = Array.new\n if !@mediaset.photos.empty? then\n @mediaset.mediaset_photos.order(:order).pluck(:photo_id).each do |photo_id|\n @mediaset_photos.push Photo.find(photo_id)\n end\n end\n\n #@photos = Photo.find(:all, :order => 'id desc', :conditions => {\n # :persona_id => Persona.find(:first, :conditions => {:screen_name => params[:persona_id]} )\n #})\n\n @upload_date_list = Photo.where(:persona_id => @persona.id).pluck(:created_at).map{|s| s.to_date }.uniq.reverse\n\n\t\tjs :form, :params => { :photo_last_id => Photo.last.id , :persona_screen_name => @persona.screen_name, :exclude_mediaset => @mediaset.id } \n end",
"def update_attributes(attributes)\n if attributes[\"tracking_elements\"]\n attributes[\"tracking_elements\"].each do |key,value|\n @element=TrackingElement.find(key)\n @element.visibility=\"hide\"\n @element.update_attributes(value)\n end\n end\n attributes.delete(\"tracking_elements\")\n if attributes[\"generic_report_elements\"]\n attributes[\"generic_report_elements\"].each do |key,value|\n @element=GenericReportElement.find(key)\n @element.update_attributes(value)\n end\n end\n if attributes[\"interim_report_elements\"]\n attributes[\"interim_report_elements\"].each do |key,value|\n @element=InterimReportElement.find(key)\n @element.update_attributes(value)\n end\n end\n attributes.delete(\"generic_report_elements\")\n attributes.delete(\"interim_report_elements\")\n attributes.delete(\"tracking_elements\")\n super(attributes)\n self.reload\n end",
"def forFriendfunctions\n @status = false\n self.hide\n showElements\n end",
"def touch_media\n lecture.media_with_inheritance.update_all(updated_at: Time.now)\n end",
"def description\n\t\tif params[:preview]\n session[:preview] = true\n end\n \n @object = find_product_or_service(params[:slug])\n \n if @object.nil?\n redirect_to bazar_path\n else \n @description = @object.description\n @supplier = @object.supplier_account.supplier\n \t\t@schedule = @object.schedule if @object.is_a? Service\n @title_content = @supplier.supplier_account.fantasy_name+': '+@object.name+' | Descripción'\n \t@meta_description_content = @supplier.supplier_account.fantasy_name+' | '+@object.name+': '+@object.description\n products_and_services_breadcrumbds(@object)\n end\n if numeric? params[:slug]\n redirect_to products_and_services_catalog_description_path(:slug => @object.slug)\n end\n end",
"def description; attributes[:description] || attributes[:desc] end",
"def load_edit_component_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n @component = Component.find(params[:component_id])\n\n @component_components = @component.components\n @component_valuefields = @component.valuefields\n @component_properties = @component.properties\n @component_images = @component.images\n @component_datafiles = @component.data_files\n @component_products = @component.products\n @component_group = @component.group\n respond_to do |format|\n format.js\n end\n end",
"def description= new_description\n @gapi.update! description: new_description\n end",
"def update\n respond_to do |format|\n if @description.update(description_params)\n format.html { redirect_to @description, notice: 'Description was successfully updated.' }\n format.json { render :show, status: :ok, location: @description }\n else\n format.html { render :edit }\n format.json { render json: @description.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @description.update(description_params)\n format.html { redirect_to @description, notice: 'Description was successfully updated.' }\n format.json { render :show, status: :ok, location: @description }\n else\n format.html { render :edit }\n format.json { render json: @description.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bio = Bio.find(params[:id])\n\n respond_to do |format|\n if @bio.update_attributes(params[:bio])\n flash[:notice] = 'Bio was successfully updated.'\n format.html { redirect_to(@bio) }\n format.js do\n @bios = Bio.find(:all, :order => :position)\n responds_to_parent do\n render :js => \"$('#page_sections_container').html('\" + @template.escape_javascript(render_to_string( :partial => \"bio\" )) + \"');\n $('#sidebar').html('\" + @template.escape_javascript(render_to_string( :partial => \"menu\" )) + \"');\n $('#modal-content').html(\"\");\n $('#modal').jqmHide();\"\n end\n end\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js do\n responds_to_parent do \n render :js => \"$('#modal-content').html('\" + @template.escape_javascript(render_to_string(:action => \"edit\", :layout => false)) + \"')\"\n end\n end\n format.xml { render :xml => @bio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @video.update_attributes(params[:text]) && @resource.update_attributes(params[:resource])\n format.js\n end\n end\n end",
"def show\n find_description(params)\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @description.to_xml(:include => { :edition => {:include => {:book => {:include => [:keywords, :sb_keywords, :signum]}}}, :user => { :except => [:email, :password_hash], :include => :library } }) }\n end\n end",
"def update\n @medium = Medium.find(params[:id])\n @medium.update_attributes(params[:medium])\n @parent = @medium.multimedia\n respond_to do |format|\n format.html { render edit_medium(@medium) }\n format.json { head :no_content }\n end\n end",
"def publish_description # :norobots:\n pass_query_params\n if draft = find_description(params[:id].to_s)\n parent = draft.parent\n old = parent.description\n type = parent.type_tag\n old_partial = old.unique_partial_format_name if old\n draft_partial = draft.unique_partial_format_name\n\n # Must be admin on the draft in order for this to work. (Must be able\n # to delete the draft after publishing it.)\n if !draft.is_admin?(@user)\n flash_error(:runtime_edit_description_denied.t)\n redirect_to(:action => parent.show_action, :id => parent.id,\n :params => query_params)\n\n # Can't merge it into itself!\n elsif old == draft\n flash_error(:runtime_description_already_default.t)\n redirect_to(:action => draft.show_action, :id => draft.id,\n :params => query_params)\n\n # I've temporarily decided to always just turn it into a public desc.\n # User can then merge by hand if public desc already exists.\n else\n draft.source_type = :public\n draft.source_name = ''\n draft.project = nil\n draft.admin_groups.clear\n draft.admin_groups << UserGroup.reviewers\n draft.writer_groups.clear\n draft.writer_groups << UserGroup.all_users\n draft.reader_groups.clear\n draft.reader_groups << UserGroup.all_users\n draft.save\n parent.log(:log_published_description, :user => @user.login,\n :name => draft.unique_partial_format_name, :touch => true)\n parent.description = draft\n parent.save\n Transaction.send(\"put_#{type}_description\",\n :id => draft,\n :set_source_type => draft.source_type,\n :set_source_name => draft.source_name,\n :set_project => draft.project,\n :set_admins => draft.admin_groups,\n :set_writers => draft.writer_groups,\n :set_readers => draft.reader_groups\n )\n redirect_to(:action => parent.show_action, :id => parent.id,\n :params => query_params)\n end\n end\n end",
"def admin_edit_prep\n\n @artist = Artist.find_by_url_slug(params[:url_slug])\n authorize! :admin, @artist\n\n @artist_test=\"blah\"\n\n image_upload_prep(@artist)\n\n @form = render_to_string('artists/_form',:layout => false)\n\n #varable to remove defualt artist loading. Loads the edit layout insted\n @edit = \"true\" #see new\n\n layout(params[:layout])\n\n\n\n end",
"def change_caption\n @picture.update_attribute(:caption, params[:value])\n \n respond_to do |format|\n format.js { render :action => 'update' }\n end\n end",
"def load_edit_vf_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n\n @valuefield = Valuefield.find(params[:valuefield_id])\n if(!@valuefield.property_id.nil?)\n @property = Property.find(@valuefield.property_id)\n end\n\n\n respond_to do |format|\n format.js\n end\n end",
"def show\n @comment = Comment.new\n @comments = @event.comments.paginate(:page => params[:page], :per_page => 4)\n @event_attachments = @event.event_attachments.all\n @providers = @event.providers.all\n\n\nif @event.event_attachments.present?\nprepare_meta_tags(title: @event.nombre,\n description: @event.categoria, \n keywords: @event.tags\n)\nend\n\n end",
"def public_load\n @note = Note.find_by_user_id(current_user.id)\n respond_to do |format|\n if @note\n format.js\n else\n @note = Note.new\n @note.user_id = current_user.id\n @note.public = \"Click the edit link above to add your thought to share...\"\n @note.save\n format.js\n end\n end \n end",
"def field_update\n\n @artist = Artist.find_by_url_slug(params[:url_slug])\n\n authorize! :admin, @artist\n\n\n @artist.update_attribute('quick_start_popup_toggle',params[:field][:value])\n\n\n respond_to do |format|\n\n\n format.json {\n render :json => {\n :success => true}\n }\n\n end\n end",
"def set_default_description_if_public\n return unless !@name.description && @description.fully_public?\n\n @name.description = @description\n end",
"def show\n @robots=\"noindex,nofollow\"\n @title = @title + \" : Gallery : \" + @gallery.name\n @meta_description = @meta_description +\" : Gallery : \" + @gallery.name\n\n if can? :create, Roxiware::GalleryItem\n @gallery.gallery_items.create({:name=>\"Upload New Picture\", :person_id=>current_user.id}, :as=>@role) \n end \n respond_to do |format|\n format.html { render }\n format.json { render :json => @gallery.ajax_attrs(@role) }\n end\n end",
"def update\n @story = Story.find(params[:id])\n @application = find_application\n if(@story.brighttext==false)\n params[:story][:description] = \"\"\n end\n \n @story_author = StoryAuthor.where(:user_id=>session[:user_id], :story_id=>@story.id).first\n if(@story_author.nil?)\n @story.story_authors.build().user_id = session[:user_id] \n end\n respond_to do |format|\n if @story.update_attributes(params[:story])\n format.html { redirect_to @story, notice: 'Story was successfully created.' }\n format.xml { render :xml => @story, :status => :updated, :location => @story }\n format.json { render json: @story, status: :updated, location: @story }\n format.js\n else\n logger.debug \"#{@story}\" \n format.html { render :action => \"edit\" }\n format.xml { render :xml => @story.errors, :status => :unprocessable_entity }\n format.json{ render :json=> {:success => \"false\"} }\n format.js\n end\n end\n end",
"def set_elements\n super\n # Circulation desk elements\n element(:circulation_desk_selector) {b.select_list(:id => 'LoanCirculationDesk_control')}\n element(:circulation_desk_yes) {b.button(:id => 'ChangeCirculationLocationBtn')}\n element(:circulation_desk_no) {b.button(:id => 'CirculationLocationCloseBtn')}\n # Loan Elements\n element(:patron_field) {b.text_field(:id => 'Patron-barcode_control')}\n element(:patron_search_button) {b.fieldset(:id => 'Patron-barcode_fieldset').input(:title => \"Search Field\")}\n element(:item_field) {b.text_field(:id => 'Patron-item_control')}\n element(:item_search_button) {b.fieldset(:id => 'Patron-item_fieldset').input(:title => \"Search Field\")}\n element(:fast_add_button) {b.button(:id => 'FastAddItemSectionLink')}\n element(:loan_popup_box) {b.div(:id => \"MessagePopupSection\")}\n element(:due_date_field) {b.text_field(:id => 'popUpDate_control')}\n element(:due_time_field) {b.text_field(:id => 'popUpTime_control')}\n element(:loan_button) {b.button(:id => 'loanBtn')}\n element(:do_not_loan_button) {b.button(:id => 'noLoanBtn')}\n # Current Item Elements\n element(:current_items_toggle) {b.a(:id => 'Patron-LoanItemListSection-HorizontalBoxSection_toggle').span}\n element(:checked_out_items_toggle) {b.a(:id => 'Patron-ExistingLoanItemListSection-HorizontalBoxSection_toggle').span}\n # General\n element(:loan_messages) {b.div(:id => 'LoanMessageFieldSection').spans(:class => 'uif-message')}\n element(:return_button) {b.button(:id => 'ReturnLinkView-buttons')}\n element(:header_close_button) {b.button(:id => 'headerDoneButton')}\n element(:header_clear_patron_button) {b.button(:id => 'headerClearPatronButton')}\n element(:header_alter_due_date_button) {b.button(:id => 'headerEditDueDateButton')}\n element(:header_claims_return_button) {b.button(:id => 'headerClaimsButton')}\n element(:header_renew_button) {b.button(:id => 'headerRenewalButton')}\n element(:clear_patron_button) {b.button(:id => 'clearPatronButton')}\n element(:close_button) {b.button(:id => 'doneButton')}\n element(:alter_due_date_button) {b.button(:id => 'editDueDateButton')}\n element(:claims_return_button) {b.button(:id => 'claimsButton')}\n element(:renew_button) {b.button(:id => 'renewalButton')}\n # Patron Details Area\n element(:patron_details_toggle) {b.a(:id => 'PatronDetailList-HorizontalBoxSection_toggle').span(:class => \"uif-headerText-span\")}\n element(:patron_name) {b.div(:id => 'patronName').a}\n element(:patron_type) {b.span(:id => 'patronType_control')}\n element(:patron_preferred_address) {b.span(:id => 'patronPreferredAddress_control')}\n element(:patron_phone_number) {b.span(:id => 'patronPhone_control')}\n element(:patron_email) {b.span(:id => 'patronEmail_control')}\n # Special\n element(:renewal_box) {b.div(:id => 'RenewalDueDateSection-HorizontalBoxSection')}\n end",
"def set_information_content\n @information_content = InformationContent.find(params[:id])\n end",
"def set_main\n @picture.become_main_picture\n \n respond_to do |format|\n format.js\n end\n end",
"def description_params\n params.require(:description).permit(:content)\n end",
"def edit_info(info)\n puts Paint[\"Editing the info about: #{publisher.namespace}\", :blue]\n\n listing = Google::Apis::AndroidpublisherV2::Listing.new\n listing.full_description = info['full_description']\n listing.short_description = info['short_description']\n listing.title = info['title']\n listing.language = info['language']\n\n publisher.edit_info(listing)\n\n puts Paint['Alterações realizadas :)', :green]\n end",
"def description=(value)\n @description = value\n end",
"def description=(value)\n @description = value\n end",
"def description=(value)\n @description = value\n end",
"def description=(value)\n @description = value\n end"
] | [
"0.5705707",
"0.5652698",
"0.5647921",
"0.5594134",
"0.55600524",
"0.5498407",
"0.54231143",
"0.53772646",
"0.53547984",
"0.5341152",
"0.53327996",
"0.5322458",
"0.5298105",
"0.5264204",
"0.5262664",
"0.5225102",
"0.5189534",
"0.5179718",
"0.51662725",
"0.51457626",
"0.51078725",
"0.50974554",
"0.5079378",
"0.5055707",
"0.50372154",
"0.5016488",
"0.5016094",
"0.50080824",
"0.50052214",
"0.50052214",
"0.50052214",
"0.49981982",
"0.49941823",
"0.49897695",
"0.49864054",
"0.49854708",
"0.49838847",
"0.49705717",
"0.49655136",
"0.49636394",
"0.49517956",
"0.49431944",
"0.4936628",
"0.49329096",
"0.4930646",
"0.4928719",
"0.49258962",
"0.49258962",
"0.4919924",
"0.49171406",
"0.4914819",
"0.49134013",
"0.49127832",
"0.4912452",
"0.49036112",
"0.48958883",
"0.48749337",
"0.4872206",
"0.48688918",
"0.48685548",
"0.4868226",
"0.48634878",
"0.48587814",
"0.48581833",
"0.48454744",
"0.48452604",
"0.4839826",
"0.48314753",
"0.48252526",
"0.48232487",
"0.4822459",
"0.48204118",
"0.48197833",
"0.48160332",
"0.48053744",
"0.48039025",
"0.48039025",
"0.480116",
"0.47970775",
"0.47951636",
"0.47934353",
"0.4792099",
"0.4777593",
"0.47768256",
"0.47740388",
"0.47720417",
"0.47710887",
"0.4768203",
"0.4767701",
"0.47666365",
"0.4764955",
"0.4759998",
"0.47551",
"0.47530183",
"0.47529268",
"0.47524843",
"0.4751596",
"0.4751596",
"0.4751596",
"0.4751596"
] | 0.6263109 | 0 |
Description Loads the preview of the element (to be shown inside a special popup) Mode Ajax | def load_preview
@media_element_id = correct_integer?(params[:media_element_id]) ? params[:media_element_id].to_i : 0
@media_element = MediaElement.find_by_id @media_element_id
if !@media_element.nil? && (@media_element.is_public || @media_element.user_id == current_user.id) && @media_element.converted
@ok = true
@media_element.set_status current_user.id
else
@ok = false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @text = params[:deliverable][:description]\n render :partial => 'common/preview'\n end",
"def content_preview\n self.description.present? ? self.description : self.main_content\n end",
"def preview\n end",
"def preview\n end",
"def preview() @page.find(input_elements[:preview]) end",
"def content_preview\n self.send(content_preview_method)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n PreviewAnnouncements.new(@browser)\n end",
"def feedback_popup\n @page.find(:div_id => \"layer_main_content\")\n end",
"def edit_description\n self.div(:id=>\"contentmetadata_description_container\").fire_event \"onmouseover\"\n self.div(:id=>\"contentmetadata_description_container\").fire_event \"onclick\"\n end",
"def preview_text\n return @preview_text\n end",
"def preview\r\n\t\t\trender(\"option_#{self.id}_preview\")\r\n\t\tend",
"def render\n content_tag(:section, class: \"umm-preview #{form_id}\") do\n render_preview_accordion\n end\n end",
"def preview_text\n return @preview_text\n end",
"def preview_text(maxlength = 30)\n return \"\" if description.blank?\n my_contents = description[\"contents\"]\n return \"\" if my_contents.blank?\n content_flagged_as_preview = my_contents.select { |a| a[\"take_me_for_preview\"] }.first\n if content_flagged_as_preview.blank?\n content_to_take_as_preview = my_contents.first\n else\n content_to_take_as_preview = content_flagged_as_preview\n end\n preview_content = self.contents.select { |content| content.name == content_to_take_as_preview[\"name\"] }.first\n return \"\" if preview_content.blank? || preview_content.essence.blank?\n text = preview_content.essence.preview_text(maxlength)\n text.size > maxlength ? \"#{text[0..maxlength]}...\" : text\n end",
"def show\n @digital_edition = DigitalEdition.find(params[:id])\n @desc_snippet = @digital_edition.digital_edition_description\n if @desc_snippet.length > 50\n @desc_snippet = @desc_snippet[0..49] + \"...\"\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @digital_edition }\n end\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def show\n render :update do |page|\n page.replace_html :good_details, :partial=>\"details\"\n end\n end",
"def show\n json_response(@description)\n end",
"def review_popup\n respond_to do |format|\n format.js # review_popup.html.erb\n end\n end",
"def show\n @card = Card.find(params[:id])\n respond_to do |format|\n format.html do\n if request.xhr?\n render :update do |page|\n page.replace_html 'see_answer_div', ''\n page.replace_html 'answer_div', :partial => 'show'\n page['answer_div'].visual_effect :appear, :duration => 1\n end\n end\n end # show.html.erb\n format.xml { render :xml => @card }\n end\n end",
"def data_popup\n respond_to do |format|\n @identifier = Identifier.find(params[:id])\n @internal_datum = if params[:internal_datum_id]\n InternalDatum.find(params[:internal_datum_id])\n else\n InternalDatum.new(identifier_id: @identifier.id)\n end\n setup_internal_data_list\n format.js\n end\n end",
"def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end",
"def preview\n @text = params[:faq][:answer]\n render :partial => 'common/preview'\n end",
"def preview\n \n # @lg = PageTag::PageGenerator.previewer( @menu, @theme, {:resource=>(@resource.nil? ? nil:@resource),:controller=>self})\n # html = @lg.generate\n # css,js = @lg.generate_assets \n #insert css to html\n # style = %Q!<style type=\"text/css\">#{css}</style>!\n #editor_panel require @theme, @editors, @editor ...\n # html.insert(html.index(\"</head>\"),style)\n # html.insert(html.index(\"</body>\"),@editor_panel)\n # respond_to do |format|\n # format.html {render :text => html}\n # end\n \n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def show_preview(model_class, options = {}, &block)\n return unless params[:preview_id]\n previewed = model_class.find(params[:preview_id], options)\n return unless previewed\n locals = {:body=>capture(previewed, &block)}\n concat(render(:partial => \"shared/ubiquo/preview_box\", :locals => locals))\n end",
"def show\n @web_profile = WebProfile.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.js do\n replace_content(dom_id(@web_profile), :partial => 'web_profile')\n end\n end\n end",
"def preview\n return @preview\n end",
"def lightbox_obs_caption(html, obs_data, identify)\n if identify ||\n (obs_data[:obs].vote_cache.present? && obs_data[:obs].vote_cache <= 0)\n html << propose_naming_link(obs_data[:id], context: \"lightbox\")\n html << content_tag(:span, \" \".html_safe, class: \"mx-2\")\n html << mark_as_reviewed_toggle(obs_data[:id])\n end\n html << caption_obs_title(obs_data)\n html << render(partial: \"observations/show/observation_details\",\n locals: { obs: obs_data[:obs], caption: true })\n end",
"def note_popup\n respond_to do |format|\n resource = Resource.includes(:identifier, :curation_activities).find(params[:id])\n @curation_activity = CurationActivity.new(\n resource_id: resource.id,\n status: resource.current_curation_activity.status\n )\n format.js\n end\n end",
"def description\n\t\tif params[:preview]\n session[:preview] = true\n end\n \n @object = find_product_or_service(params[:slug])\n \n if @object.nil?\n redirect_to bazar_path\n else \n @description = @object.description\n @supplier = @object.supplier_account.supplier\n \t\t@schedule = @object.schedule if @object.is_a? Service\n @title_content = @supplier.supplier_account.fantasy_name+': '+@object.name+' | Descripción'\n \t@meta_description_content = @supplier.supplier_account.fantasy_name+' | '+@object.name+': '+@object.description\n products_and_services_breadcrumbds(@object)\n end\n if numeric? params[:slug]\n redirect_to products_and_services_catalog_description_path(:slug => @object.slug)\n end\n end",
"def popup_attrs(feature)\n {\n :class=>'thickbox',\n :title=>link_to('Link to this Feature', feature_path(feature.fid))\n }\n end",
"def show\n @medium = Medium.find(params[:id]) \n @tab_options ||= {}\n @tab_options[:entity] = @medium\n respond_to do |format|\n format.html do # show.rhtml\n @pictures = Picture.all.order('RAND()').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n @videos = Video.all.order('RAND()').limit(1)\n @documents = Document.all.order('RAND()').limit(1)\n @titles = { :picture => ts(:daily, :what => Picture.model_name.human(:count => :many).titleize), :video => ts(:daily, :what => Video.model_name.human(:count => :many).titleize), :document => ts(:daily, :what => Document.model_name.human(:count => :many).titleize) }\n @more = { :type => '' }\n end\n format.js\n format.xml #{ render :xml => @medium.to_xml }\n format.json { render :json => Hash.from_xml(render_to_string(:action => 'show.xml.builder')) }\n end\n end",
"def show\n debugger\n @trigger = @operation.trigger\n @show_modal = 'show'\n respond_to do |format|\n format.js\n format.html\n end \n end",
"def show_preview path\n @windows.load_preview path\n end",
"def show\n @product = Product.find(params[:id])\n if Rails.env.development?\n @domain = \"http://localhost:3000\"\n else\n @domain = \"https://hawkeye360.herokuapp.com\"\n end\n @iframe = '<iframe src=\"%s/products/%s/preview\" width=\"%s\" height=\"%s\"></iframe>' % [@domain, @product.id, @product.display_width, @product.display_height]\n gon.image_path = \"https://s3-us-west-2.amazonaws.com/#{ENV['S3_BUCKET']}/uploads/product/images/#{@product.id}/\"\n gon.total_frames = @product.total_frames\n gon.file_extension = @product.file_extension\n gon.display_width = @product.display_width\n gon.display_height = @product.display_height\n end",
"def list_items_preview\n end",
"def preview\n @article = article\n @article.title = params[:title] if params[:title]\n @article.markdown = params[:markdown] if params[:markdown]\n @article.html = rendered_content if params[:markdown]\n\n render partial: 'articles/article_content'\n end",
"def popup\n respond_to do |format|\n format.js\n end\n end",
"def edit_description\n end",
"def preview_text(maxlength = 60)\n preview_text_from_preview_ingredient(maxlength) ||\n preview_text_from_nested_elements(maxlength)\n end",
"def content\n \"#{title} #{description_text}\"\n end",
"def preview(*)\n nil\n end",
"def preview(*)\n nil\n end",
"def show \r\n end",
"def title\n preview_json['title']\n end",
"def show\n @board = Board.find_by_permalink(params[:id])\n @topics = @board.topics\n\n respond_to do |format|\n format.html # show.html.erb\n format.js {\n render :update do |page|\n page[@board].replace_html :partial => \"board_info\", :object => @board\n end \n }\n format.xml { render :xml => @board }\n end\n end",
"def note_popup\n respond_to do |format|\n @identifier = Identifier.find(params[:id])\n format.js\n end\n end",
"def edit_gallery_title_desc(gallery_name = \"test\", gallery_title = \"samplegallery\", gallery_desc = \"Its a sample gallery\",_browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Editing '#{gallery_name}' Gallery properties (Title + Desc).\")\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_gallery) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n temp = wait.until { _browser.find_element(:xpath => @galmgr.gallery_title) }\n temp.clear\n temp.send_keys(gallery_title)\n wait.until { _browser.find_element(:xpath => @galmgr.gallery_desc) }\n self.type_text_in_wysiwyg_editor(gallery_desc)\n ## we need to be on the overlay at this point of execution\n wait.until { _browser.find_element(:xpath => @galmgr.save_gallery_btn) }.click\n _browser.switch_to.default_content\n end",
"def show\n @aliment = Aliment.find(params[:id], :include => [:effects, :organs, :comments, :aliment_photo])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @aliment }\n format.js {render :partial => 'preview'}#show.js.rjs\n end\n end",
"def show\n @resp = Response.find(params[:id])\n\n respond_to do |format|\n format.html\n format.js do\n content = render_to_string(:layout => false)\n render :update do |page|\n page.replace_html 'responsebody', content\n page.replace_html 'responsetitle', @resp.title\n page.call 'showResponseViewer', @resp.id\n page << \"$$('#responsebody > form input[type=submit]').each(function(elt) { elt.hide(); });\"\n end\n end\n end\n end",
"def show\n @preview = Preview.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @preview }\n end\n end",
"def show \n catch :flash_now do find_detail end\n div_id = params[:div_id]\n render :update do |page|\n page[div_id].replace_html :partial => \"detail\"\n end\n end",
"def data_popup\n authorize %i[stash_engine admin_datasets]\n respond_to do |format|\n @identifier = Identifier.find(params[:id])\n @internal_datum = if params[:internal_datum_id]\n InternalDatum.find(params[:internal_datum_id])\n else\n InternalDatum.new(identifier_id: @identifier.id)\n end\n setup_internal_data_list\n format.js\n end\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def description\n page.render_part('description') rescue ''\n end",
"def preview\n #for debug\n params[:d] = 'www.rubyecommerce.com'\n editor = params[:editor]\n website=menu=layout=theme = resource = nil\n website = Website.find_by_url(params[:d])\n if params[:c]\n menu = Menu.find_by_id(params[:c])\n if params[:r]\n resource = BlogPost.find_by_id(params[:r])\n end \n else\n menu = Menu.find_by_id(website.index_page) \n end\n theme = TemplateTheme.find(menu.find_theme_id(is_preview=true))\n html,css = do_preview(theme, menu, {:blog_post_id=>(resource.nil? ? nil:resource.id),:editor=>editor})\n #insert css to html\n style = %Q!<style type=\"text/css\">#{css}</style>!\n \n #editor_panel require @theme, @editors, @editor ...\n prepare_params_for_editors(theme)\n editor_panel = render_to_string :partial=>'layout_editor_panel'\n html.insert(html.index(\"</head>\"),style)\n html.insert(html.index(\"</body>\"),editor_panel)\n render :text => html\n end",
"def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end",
"def preview=(value)\n @preview = value\n end",
"def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end",
"def get_galleries_desc(_browser = @browser)\n JQuery.wait_for_events_to_finish(_browser)\n desc_present = _browser.find_elements(:xpath => @galmgr.galleries_desc).size > 0\n if(desc_present)\n actual_desc = _browser.find_element(:xpath => @galmgr.galleries_desc).text\n return actual_desc\n else\n return nil\n end\n end",
"def update_html_for_abstract\n return unless details\n self.details_filtered = textile_to_html( details )\n end",
"def preview\n redirect_to preview_url\n end",
"def callback_description(results)\n\t\t\n\t\t# Remove blank descriptions and select first\n\t\t@content = results.map { |description| (description.blank? ? nil : description) }.compact.first\n\t\t\n\tend",
"def show() end",
"def show() end",
"def show() end",
"def pic_preview_widget templateer, options={}\n page_url = templateer.url rescue nil\n img_url_display = templateer.picdata_with_fallback\n img_url_value = templateer.picurl\n entity_id = templateer.id\n input_id = pic_preview_input_id(templateer, :picurl) # \"recipe_picurl\"\n input_name = templateer.field_name(:picurl) # \"recipe[picurl]\"\n img_id = pic_preview_img_id(templateer)\n link_id = \"golink#{entity_id}\"\n pic_picker_link = pic_preview_golink page_url, img_url_value, link_id, img_id, input_id\n pic_preview =\n %Q{<img alt=\"Image Link is Broken\"\n id=\"#{img_id}\"\n src=\"#{img_url_display}\"\n style=\"width:100%; height: auto\">\n <input type=\"hidden\"\n id=\"#{input_id}\"\n name=\"#{input_name}\"\n rel=\"jpg,png,gif\"\n type=\"text\"\n value=\"#{img_url_value}\">\n }.html_safe\n content_tag( :div, pic_preview, :class => :pic_preview)+\n content_tag( :div, pic_picker_link, :class => :pic_picker_link)\n end",
"def description\n\t\t# has this merchant uploaded an epub file yet?\n\t\tif is_ebook_options_selected?(description_params[:products_type_id]) && !temporary_epub_session_active?\n \t@epub_not_uploaded = true\n\n \t# respond to js and html\n\t respond_to do|format|\n\t format.js\n\t format.html\n\t end\n\t return\n\t\tend\n \n # Process form data\n check_member_details = TemporaryProductsDescription.find_by(merchant_id: session[:merchant_id])\n @temporary_products = if check_member_details != nil then check_member_details else TemporaryProductsDescription.new(description_params) end\n\n if check_member_details.nil?\n # save book description details temporarily\n @temporary_products.add_merchant_id = session[:merchant_id]\n if @temporary_products.save\n \tactivate_temporary_book_desc_session @temporary_products.id\n else\n @error = true\n end\n else\n \t # update previous record to save space\n \t if @temporary_products.update(description_params)\n \t \tactivate_temporary_book_desc_session @temporary_products.id\n \t else\n \t \t@error = true\n \t end\n end\n\n # respond to js and html\n respond_to do|format|\n format.js\n format.html\n end\n\tend",
"def job_preview(job)\n content_tag :dl do\n # Descripcion de distancia de tiempo en palabras\n content_tag(:span, \"Hace #{distance_of_time_in_words(Time.now, job.created_at)}\", :class => 'pull-right') +\n content_tag(:dt, (link_to job.job_title, job) + \" - #{job.company_name}\") + \n content_tag(:dd, content_tag(:em, job.location)) +\n # Truncar descripcion de trabajo, quitar tags HTML\n content_tag(:dd, content_tag(:span, truncate(strip_tags(job.job_description), :length => 130), :class => 'muted')) +\n content_tag(:dd, job.job_types.to_sentence) + \n content_tag(:dd, \n raw(\n job.technologies.collect do |skill|\n content_tag(:span, \"#{skill.name}\", :class => 'label label-info') + ' '\n end.join\n )\n ) +\n content_tag(:hr)\n end\n end",
"def show\n #Hicbir sey yazmasa da olur!!!\n setComment\n end",
"def description; @text; end",
"def show\n respond_to do |format|\n format.js { render :show, locals: { :'@resume' => @resume_recomendation.resume } }\n end\n end",
"def live_preview_block(**options)\n unless options[:url]\n raise \"A URL is required for `live_preview_block`\"\n end\n block_component('live-preview-block', options)\n end",
"def detail_for record, &block\n concat(render_default_css, block.binding) unless @_showhide_css_done\n div_for(record, 'detail_for', :style => 'display: none;', :class => 'detail', &block)\n @_showhide_css_done = true # prevents to print the CSS multiple times\n nil\n end",
"def preview\n content[0..19]\n end",
"def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end",
"def model_dialog(dialog_title, dialog_content)\n @dialog_title = dialog_title\n @content_string = render_to_string :partial => dialog_content\n respond_to do |format|\n format.js{ render \"base/model_dialog\"}\n end\n end",
"def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end",
"def preview\n # generate html according to wiki notation type\n result = ContentFormatter.to_html(params[:content], params[:notation_type])\n respond_to do |format|\n format.html {\n # return html text\n render text: result\n }\n end\n end",
"def on_display\n update!\n end",
"def boxview_data\n desc = self.description.nil? ? \"\" : \"#{self.description.slice(0, 80)}..\"\n { :controller => 'boxview/capolettera',\n :title => \"Capolettera: #{self.anastatica.page_position}\", \n :description => desc,\n :res_id => \"pi_letter_illustration_#{self.id}\", \n :box_type => 'image',\n :thumb => nil\n }\n end",
"def show\n @preview_page_1=@member.preview_page_1\n @preview_page_2=@member.preview_page_2\n end",
"def preview\n self.content.split(' ')[0...5].join(' ') + '...'\n end",
"def markup_editor_area(name, method, options ={}, html_options ={})\n id = options[:id]\n pl_caption = options.delete(:caption)\n pl_caption ||= \"Preview #{method}\"\n\n preview_dom_id = method_to_preview_dom(name, method, id)\n preview_target = \"#{preview_dom_id}_target\"\n\n editor_opts = {:class => 'markup-editor'}.merge(html_options)\n #links\n markup_link = link_to('Textile Markup reference', \"#{ActionController::Base.asset_host}/textile_reference.html\",\n :popup => ['Textile markup reference',\n 'height=400,width=520,location=0,status=0,menubar=0,resizable=1,scrollbars=1'])\n preview_link = link_to pl_caption,\n {:controller => '/markup', :action => \"preview_content\", :object => name, :control => method}, {:id => \"#{preview_dom_id}_link\", :style => \"display: none;\"}\n\n links = content_tag('div', markup_link + ' | ' + preview_link, {:class => 'markup-area-link'})\n #preview container\n preview_target = content_tag('div', ' ', :id => preview_target, :class => 'markup-preview')\n preview_close_link = content_tag(:div, link_to('Close preview', '#', {:id => \"#{preview_dom_id}_close\", :style => \"display: none;\"}), {:class => 'markup-area-link'})\n preview = content_tag('div', preview_target << preview_close_link, :id => \"#{preview_dom_id}\", :style => 'display: none;')\n #render all\n content_tag('div', text_area(name, method, editor_opts) << links << preview , :id => \"#{name}_#{method}_editor\")\n end",
"def show_html\n\t\t# things to be done\n\t\tif @mode == 'saveconf' then\n\t\t\tcase @current_mode\n\t\t\twhen Options\n\t\t\t\tupdate_options\n\t\t\twhen RefList\n\t\t\t\tupdate_tables\n\t\t\tend\n\t\tend\n\n\t\t# update cache\n\t\tif not @setup.secure then\n\t\t\tif not @setup['no_cache'] then\n\t\t\t\tunless @cache then\n\t\t\t\t\t@need_cache_update = true\n\t\t\t\t\t@cache = DispRef2Cache.new( @setup )\n\t\t\t\tend\n\t\t\t\tif not 'never' == @cgi.params['dr2.cache.update'][0] and ('force' == @cgi.params['dr2.cache.update'][0] or @need_cache_update) then\n\t\t\t\t\t@updated_url = @cache.update\n\t\t\t\telsif 'scan' == @cgi.params['dr2.cache.update'][0] then\n\t\t\t\t\t@scanned_url = @cache.scan\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif @setup['no_cache'] then\n\t\t\t\t\t@cache = nil\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# result\n\t\tr = show_description\n\t\tcase @current_mode\n\t\twhen Options\n\t\t\tr << show_options\n\t\twhen RefList\n\t\t\tr << show_unknown_list\n\t\tend\n\t\tr\n\tend",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def _display(replace)\n\t\treturn @contents._display(replace)\n\tend",
"def show\n @section_preview = SectionPreview.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @section_preview.to_xml }\n end\n end",
"def show\n ### Retrieved by Callback function\n end",
"def show\n ### Retrieved by Callback function\n end",
"def preview\n #for debug\n params[:d] = 'www.rubyecommerce.com'\n \n the_website=the_menu=the_layout=the_theme = nil\n the_website = Website.find_by_url(params[:d])\n if params[:c]\n the_menu = Menu.find_by_id(params[:c])\n else\n the_menu = Menu.find_by_id(the_website.index_page) \n end\n the_theme = TemplateTheme.find(the_menu.find_theme_id(is_preview=true))\n do_preview(the_theme.id, the_theme.layout_id, the_menu.id)\n render :text => File.read(\"#{Rails.public_path}/shops/#{the_theme.file_name('html')}\")\n end",
"def show\n if params['tooltip'].nil?\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @team }\n end\n else # show ajax tooltip\n render :partial => 'shared/tooltip', :locals => {\n :image => @team.team_logo.url(:thumb),\n :simple_data => { 'Team name' => @team.name, 'Score' => @team.score },\n :collection => { 'Members' => @team.players.collect { |player| player.full_name } }\n }\n end\n end",
"def description\n\t\t\t@data[\"description\"]\n\t\tend",
"def display_snippet(content)\n content = display_full(content)\n\n # If our entire post fits in the snippet, just parse the HTML and return it.\n return content if content.length <= MINIMUM_CHARS_FOR_PREVIEW\n \n\n first_part = content[0...MINIMUM_CHARS_FOR_PREVIEW]\n remainder = content[MINIMUM_CHARS_FOR_PREVIEW..-1]\n (first_part + remainder.split(\"</p>\").first + \"</p>\")\n\n end",
"def location_detail_popup\n respond_to :js\n end",
"def ajax_detail\n @eob = Eob.find(params[:id])\n @eob_details = []\n if params[:eob]\n @attributes = params[:eob][:eob_details_attributes]\n @attributes.each do |key, value|\n @eob_details.push @eob.eob_details.build(value)\n end\n end\n @count = @eob.eob_details.count\n @eob_details.push @eob.eob_details.build()\n\n respond_to do |format|\n format.js {render :layout => false }\n end\n end",
"def preview\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: @article }\n end\n end"
] | [
"0.677189",
"0.651203",
"0.6223139",
"0.6223139",
"0.61364055",
"0.6119763",
"0.6056621",
"0.60314924",
"0.6027012",
"0.6024347",
"0.6022112",
"0.5994158",
"0.5931087",
"0.59216595",
"0.57912004",
"0.5769556",
"0.5758151",
"0.5754315",
"0.5750362",
"0.574581",
"0.57400817",
"0.57380176",
"0.57370406",
"0.57113004",
"0.56938505",
"0.5679065",
"0.5679065",
"0.56770915",
"0.56562626",
"0.5655468",
"0.5652112",
"0.56458294",
"0.56277317",
"0.56159717",
"0.5613192",
"0.55990887",
"0.5579243",
"0.55664647",
"0.55524087",
"0.554858",
"0.55349606",
"0.5528249",
"0.5519053",
"0.5513935",
"0.5501647",
"0.5501647",
"0.5494514",
"0.54860485",
"0.54750204",
"0.5472002",
"0.54614663",
"0.54481155",
"0.54415774",
"0.54383296",
"0.5433013",
"0.54187167",
"0.54186165",
"0.54186165",
"0.5417",
"0.5414409",
"0.541029",
"0.53973657",
"0.5386936",
"0.53831065",
"0.53739893",
"0.5367326",
"0.5365554",
"0.5365554",
"0.5365554",
"0.53623873",
"0.5360987",
"0.5358498",
"0.5347958",
"0.5346061",
"0.5345564",
"0.5343746",
"0.53411824",
"0.5337401",
"0.53372234",
"0.5333929",
"0.53316706",
"0.5331395",
"0.5315227",
"0.53118795",
"0.531036",
"0.530387",
"0.53032345",
"0.5302227",
"0.52994907",
"0.52994907",
"0.5298664",
"0.5298051",
"0.52914655",
"0.52914655",
"0.52906793",
"0.5286106",
"0.5285956",
"0.52857286",
"0.5281246",
"0.527403",
"0.52725804"
] | 0.0 | -1 |
Description Reloads the element if it's in conversion Mode Ajax | def check_conversion
@mes = []
params.keys.each do |key|
if key[0, 2] == 'me'
id = key[2, key.length - 2]
media_element_id = correct_integer?(id) ? id.to_i : 0
media_element = MediaElement.find_by_id media_element_id
ok = (media_element && current_user.id == media_element.user_id && !media_element.is_public)
media_element.set_status current_user.id if ok
@mes << {
:ok => ok,
:media_element_id => media_element_id,
:media_element => media_element
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_part\n\n if params[:restream].nil?\n @msg = current_user.check_message\n render layout: false\n else\n @msg = current_user.check_message\n\n respond_to do |format|\n format.js\n end\n end\n\n end",
"def toggle_feedback\n product_idurl params[:product_idurl]\n next_feedback_code = Integer(params[:next_feedback_code])\n dom_id = \"feedback_#{product_idurl}\"\n render :update do |page|\n page.replace_html(dom_id, :partial => \"/quizzes/feedback\",\n :locals => {:product_idurl => product_idurl, :feedback_code => next_feedback_code})\n end\n end",
"def orchard_id_changed\n orchard_id = get_selected_combo_value(params)\n session[:delivery_form][:orchard_id_combo_selection] = orchard_id\n @orchard_description = \"\"\n\n orchard = Orchard.find(orchard_id)\n if (orchard != nil)\n orchard_description = orchard.orchard_description\n @orchard_description = orchard_description\n session[:delivery_form][:orchard_description] = orchard_description\n else\n @orchard_description = \"\"\n end\n\n @rmt_product_codes = [\"select a value from rmt_product_type_code above\"]\n\n render :inline => %{\n <%= @orchard_description_content = @orchard_description %>\n <%= @rmt_product_codes_content = select('delivery','rmt_product_id',@rmt_product_codes,{:sorted=>true})%>\n <script>\n <%= update_element_function(\"orchard_description_cell\", :action => :update,:content => @orchard_description_content) %>\n <%= update_element_function(\"advised_rmt_product_code_cell\", :action => :update,:content => @rmt_product_codes_content) %>\n </script>\n }\n\n end",
"def show_ajax\n @element = Element.find_by(tag: params[:tag])\n @previous_color = @element.previous_color || \"\" if @element\n respond_to do |format|\n format.js\n end\n end",
"def ajaxify_extra_content\n ''\n end",
"def getProductType\n @product_type_description=ProductType.where(id: params[:id]).first.description\n @product_type={description: @product_type_description}\n respond_to do |format|\n format.html #need for ajax with html datatype \n format.json { render json: @product_type }#need for ajax with json datatyp \n end\n end",
"def change_language\n self.language_button\n wait_for_ajax\n self.class.class_eval { include AccountPreferencesPopUp }\n end",
"def new\n @question = Question.new\n if request.xhr?\n \n @subcat = Subcategory.find(:all,:conditions=>['category_id=?',params[:id]])\n render :update do |page|\n page.replace_html :test, :partial => 'test'\n end\n else\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question }\n end\n end\n end",
"def render_rb_ajax\n render_code(@rb, :ajax)\n end",
"def downtime_sub_type_downtime_category_code_changed\n\tdowntime_category_code = get_selected_combo_value(params)\n\tsession[:downtime_sub_type_form][:downtime_category_code_combo_selection] = downtime_category_code\n\t@downtime_division_codes = DowntimeSubType.downtime_division_codes_for_downtime_category_code(downtime_category_code)\n#\trender (inline) the html to replace the contents of the td that contains the dropdown \n\trender :inline => %{\n\t\t<%= select('downtime_sub_type','downtime_division_code',@downtime_division_codes)%>\n\t\t<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_downtime_sub_type_downtime_division_code'/>\n\t\t<%= observe_field('downtime_sub_type_downtime_division_code',:update => 'downtime_type_code_cell',:url => {:action => session[:downtime_sub_type_form][:downtime_division_code_observer][:remote_method]},:loading => \"show_element('img_downtime_sub_type_downtime_division_code');\",:complete => session[:downtime_sub_type_form][:downtime_division_code_observer][:on_completed_js])%>\n\t\t}\n\nend",
"def load_preview\n @media_element_id = correct_integer?(params[:media_element_id]) ? params[:media_element_id].to_i : 0\n @media_element = MediaElement.find_by_id @media_element_id\n if !@media_element.nil? && (@media_element.is_public || @media_element.user_id == current_user.id) && @media_element.converted\n @ok = true\n @media_element.set_status current_user.id\n else\n @ok = false\n end\n end",
"def reload_case_detail_page(uuid)\n visit \"/queue/appeals/#{uuid}\"\n page.find(\"a\", text: \"refresh the page\").click if page.has_text?(COPY::CASE_DETAILS_LOADING_FAILURE_TITLE)\n end",
"def content_type_switch\n\t\t@old_content_type = params[:old_content_type]\n\t\t@content_type = params[:content_type];\n\t\tif @old_content_type != @content_type\n\t\t\t@content = render_to_string :partial=>'convert_content',\n\t\t\t\t:locals=>{:content=>params[:content],\n\t\t\t\t\t:from_type=>@old_content_type,\n\t\t\t\t\t:to_type=>@content_type}\n\t\telse\n\t\t\t@content = params[:content]\n\t\tend\n\t\t@page = Page.new(:content=>@content, :content_type=>@content_type)\n\t\t#render :layout=>false\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.js { render :layout=>false }\n\t\t\tformat.xml { render :xml=>@page.to_xml }\n\t\tend\n\tend",
"def update_feature\n if request.xhr?\n existed_feature = Feature.find_by_id(params[\"hidden_feature_id\"])\n return render :json =>{\"success\" =>false} if existed_feature.blank?\n updated = existed_feature.update_attributes(:description => params[\"description\"], :status =>params[\"status\"])\n return render :js =>\"success_update(true)\" if updated ==true\n return render :js =>\"success_update(false)\"\n else\n return render :js =>\"success_update(false)\"\n end\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 show\n if params[:mode] == 'force_reload'\n @news_feed.force_reload\n end\n\n respond_to do |format|\n format.html # show.html.erb\n end\n end",
"def update_old_data(id1,id2,data)\n render :update do |page|\n page << \"jQuery('##{id1}').hide();jQuery('##{id2}').show();jQuery('##{id1} span input[name]').val('#{data}');\"\n page << \"jQuery('#name').html('<strong>#{data}</strong>')\" if params[:field] == 'name'\n page << \"jQuery('#comment_description').html('<h>#{data}</h>')\" if params[:field] == 'comment'\n page.call \"flash_writter\", \"Blank submission is not possible\" if !params[:name].present?\n end\nend",
"def display_inline_scrap_topic\n respond_to do |format|\n format.html { redirect_to scrap_topic_path(@scrap.scrap_topic.slug) and return }\n format.js { @scraps = @scrap_topic.scraps if @scraps.nil?; render :partial => \"scrap\", :layout => false and return }\n format.xml { return }\n end\n end",
"def toggle_type\n @document = Document.toggle_type(params[:document_id])\n if @document.content_type == 1\n @document.content = markdown_to_html(@document.content)\n @document.save\n else\n @document.content = html_to_markdown(@document.content)\n @document.save\n end\n @task = Task.find(@document.task_id)\n respond_to do |format|\n format.html {render :new }\n end\n end",
"def ajax_container_save\n @current_object = params[:container].classify.constantize.find(params[:id])\n \tif @current_object.update_attribute(\"body\", params[:content])\n \t message = \"Saved\"\n \telse\n \t message = \"Unable to Save\"\n \tend\n\n \trender :text => '<script type=\"text/javascript\">$(\\'#notice\\').showMessage(\"#{message}\", 1500);</script>', :layout => false\n end",
"def comment\n comment_button\n wait_for_ajax(2)\n end",
"def update_html_for_abstract\n return unless details\n self.details_filtered = textile_to_html( details )\n end",
"def edit\n @object = referenced_object\n @attribute = params[:attribute]\n @form_element = params[:form_element]\n @sub_id = params[:sub_id]\n @update_span = params[:update]\n respond_to do |format|\n format.html { } unless @Klass.not_accessible_through_html?\n format.js { }\n end\n end",
"def edit_comment\n self.button(:text=>\"Edit comment\").click\n wait_for_ajax(2) #wait_until { self.textarea(:title=>\"Edit your comment\").present? == false }\n end",
"def refresh\n self.text = @text_string if @image\n end",
"def update_description\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update_attributes(params[:course])\n flash[:notice] = \"Course updated Successfully\"\n else\n flash[:error] = \"An error occured!\"\n end\n format.html\n format.js\n end\n end",
"def show\n @card = Card.find(params[:id])\n respond_to do |format|\n format.html do\n if request.xhr?\n render :update do |page|\n page.replace_html 'see_answer_div', ''\n page.replace_html 'answer_div', :partial => 'show'\n page['answer_div'].visual_effect :appear, :duration => 1\n end\n end\n end # show.html.erb\n format.xml { render :xml => @card }\n end\n end",
"def edit\n respond_to do |format|\n format.html { render :action => \"edit\" and return }\n format.js { render :partial => \"scrap_form\", :layout => false and return }\n format.xml { return }\n end\n end",
"def update_content\n @note = Note.find(params[:id], :select => \"article_id\")\n\n respond_to do |format|\n if @note.article.update_attribute(:content, params[:newContent])\n # Technically html :)\n format.text { render :text => RedCloth.new(white_list(@note.article.content),[:filter_styles]).to_html(:textile, :youtube, :note) }\n else\n format.text { render :text => \"<p>Content update error.</p>\" }\n end\n end\n end",
"def ajax_refresh\n\t\trender(file: 'sales/ajax_reload.js.erb')\n\tend",
"def xhr?; end",
"def show\n @resp = Response.find(params[:id])\n\n respond_to do |format|\n format.html\n format.js do\n content = render_to_string(:layout => false)\n render :update do |page|\n page.replace_html 'responsebody', content\n page.replace_html 'responsetitle', @resp.title\n page.call 'showResponseViewer', @resp.id\n page << \"$$('#responsebody > form input[type=submit]').each(function(elt) { elt.hide(); });\"\n end\n end\n end\n end",
"def reloads\n load_page\n end",
"def add_change_ajax\r\n @plan = Plan.find(params[\"plan_id\"])\r\n\r\n #MES- Create the comment item, using a helper in the plan object\r\n change_type = PlanChange::CHANGE_TYPE_COMMENT\r\n change_type = params[:change_type].to_i if params[:change_type]\r\n @plan.add_comment(current_user, params[\"change_tb\"], change_type)\r\n\r\n @comment_access = @plan.comment_access_level(current_user)\r\n #MES- Since they're adding a comment, there will be comments, right?\r\n # We don't have to handle the \"no comments\" case\r\n render(:partial => 'changes', :object => @plan.plan_changes.sort)\r\n end",
"def edit_scrap_topic\n if can_modify_scrap_topic?\n respond_to do |format|\n format.html { return }\n format.js { render :action => 'edit_scrap_topic', :layout => false and return }\n format.xml { return }\n end\n else\n render_401 and return\n end\n end",
"def get_detail_if_not_yet(entity, detail_div_id, options = {})\n controller = entity.controller_name\n options.merge! :url => \"\\/#{controller}\\/show\\/#{entity.to_param}\"\n options[:params] ||= {}\n options[:params].merge! :div_id => detail_div_id\n options[:success] = \"$('#{detail_div_id}').className = #{Loaded_Class_Name}; \"\n \"if ($('#{detail_div_id}').className != #{Loaded_Class_Name}) { #{remote_function_with_params(options)};}; \" +\n \"if ($('#{detail_div_id}').className == #{Loaded_Class_Name}) Element.toggle('#{detail_div_id}') ;\" \n end",
"def ajax?\n return @ajax\n end",
"def button\n @edit = session[:edit] # Restore @edit for adv search box\n @refresh_div = \"main_div\" # Default div for button.rjs to refresh\n\n unless @refresh_partial # if no button handler ran, show not implemented msg\n add_flash(_(\"Button not yet implemented\"), :error)\n @refresh_partial = \"layouts/flash_msg\"\n @refresh_div = \"flash_msg_div\"\n end\n end",
"def auto_complete_for_questionbank_topic\n if params[:questionbank][:topic] and request.xhr?\n auto_complete_responder_for_questionbanks params[:questionbank][:topic]\n end\n end",
"def select_payment_mode\n @payment_mode = params[:payment_mode]\n if @payment_mode == \"Others\" or @payment_mode == \"Cheque\"\n render :update do |page|\n page.replace_html \"payment_mode_details\", :partial => \"finance/fees_payment/select_payment_mode\"\n end\n else\n render :update do |page|\n page.replace_html \"payment_mode_details\", :text => \"\"\n end\n end\n end",
"def ajax_item_save\n #TODO translate & DOC\n @current_object = params[:item_type].classify.constantize.find(params[:id])\n\t\tif @current_object.update_attribute(\"body\", params[:content])\n\t\t message = \"Saved\"\n\t\telse\n\t\t message = \"Unable to Save\"\n\t\tend\n\t\t\n\t\trender :text => message, :layout => false\n end",
"def update_for_analysis_type\n \t@selected_analysis = params[:selected_analysis]\n \t\n \trespond_to do |format|\n format.js { \n \trender :update do |page|\n \t\tpartial_used = case @selected_analysis\n \t\t\t\twhen \"Log Rank\" then \"log_rank\"\n \t\t\t\twhen \"t-Test, 1-sided\" then \"choice_of_grouping\"\n \t\t\t\twhen \"t-Test, 2-sided\" then \"two_sided_t\"\n \t\t\t\telse \"default\"\n \t\t\tend\n \t page.replace_html \"comparison_level1\", :partial=>\"outcome_analyses/partials/analyses/\"+partial_used.to_s\n \tend\n }\n end\n end",
"def reload_data\n if(@all_stories.nil?)\n build_story_list\n end\n\n return unless @all_stories\n\n @premium_collection_view.reloadData\n @basic_view.reload_data(@basic_stories)\n\n if(@all_stories.length < 1)\n @info_label.text = 'Bitte warten, unser Shop wird gerade geladen...'\n @info_label.hidden = false\n else\n if(@premium_stories == [] && @basic_stories == [])\n @info_label.text = 'Keine weiteren Inhalte verfügbar, mehr ist auf dem Weg!'\n @info_label.hidden = false\n else\n @info_label.hidden = true\n end\n end\n\n @premium_collection_view.hidden = !@info_label.hidden?\n end",
"def acknowledgements\n self.acknowledgements_link\n sleep 1\n wait_for_ajax\n Acknowledgements.new @browser\n end",
"def html?; end",
"def html?; end",
"def html?; end",
"def item_pack_product_commodity_group_code_changed\n \n\tcommodity_group_code = get_selected_combo_value(params)\n\tsession[:item_pack_product_form][:commodity_group_code_combo_selection] = commodity_group_code\n\t@commodity_codes = ItemPackProduct.commodity_codes_for_commodity_group_code(commodity_group_code)\n#\trender (inline) the html to replace the contents of the td that contains the dropdown \n\trender :inline => %{\n\t\t<%= select('item_pack_product','commodity_code',@commodity_codes)%>\n\t\t<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_item_pack_product_commodity_code'/>\n\t\t<%= observe_field('item_pack_product_commodity_code',:update => 'basic_pack_code_cell',:url => {:action => 'item_pack_product_commodity_code_changed'},:loading => \"show_element('img_item_pack_product_commodity_code');\",:complete => session[:item_pack_product_form][:commodity_code_observer][:on_completed_js])%>\n\t\t}\n\nend",
"def update_title\n return if params[:design_id].nil?\n\n @design = Design.find(params[:design_id])\n @design.title = params[:design_title]\n\n respond_to do |format|\n if @design.save\n format.html { redirect_to :back }\n format.js { render template: 'singles/update_title.js.erb' }\n else\n format.html { redirect_to root_path, notice: 'Erro ao atualizar o titulo do design.' }\n end\n end\n end",
"def load_edit_datafile_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n @data_file = DataFile.find(params[:datafile_id])\n\n respond_to do |format|\n format.js\n end\n end",
"def new_title\n @title = Title.find(params[:title_id])\n \n respond_to do |format|\n format.js\n end\n end",
"def show\n @message.read! unless request.xhr?\n end",
"def model_dialog(dialog_title, dialog_content)\n @dialog_title = dialog_title\n @content_string = render_to_string :partial => dialog_content\n respond_to do |format|\n format.js{ render \"base/model_dialog\"}\n end\n end",
"def component_update_expense_manager\r\n @show_wrapper = false # don't show the outer wrapper elements if we are just updating an existing scaffold \r\n if request.xhr?\r\n # If this is an AJAX request then we just want to delegate to the component to rerender itself\r\n component_expense_manager\r\n else\r\n # If this is from a client without javascript we want to update the session parameters and then delegate\r\n # back to whatever page is displaying the scaffold, which will then rerender all scaffolds with these update parameters\r\n redirect_to(:action => :list_expense_manager) \r\n end\r\n end",
"def update_subtitle\n return if params[:design_id].nil?\n\n @design = Design.find(params[:design_id])\n @design.subtitle = params[:design_subtitle]\n\n respond_to do |format|\n if @design.save\n format.html { redirect_to :back }\n format.js { render template: 'singles/update_subtitle.js.erb' }\n else\n format.html { redirect_to root_path, notice: 'Erro ao atualizar o subtítulo do design' }\n end\n end\n end",
"def change_form_content \n\tend",
"def update\n #formats as js since it's getting parsed on the front end\n respond_to do |format|\n format.js\n end\n end",
"def toggle_completion\n return unless request.post?\n completion = @semester.completions.find(params[:id])\n if completion.visible?\n completion.visible = false\n else\n completion.visible = true\n end\n if(completion.save)\n render :update do |page|\n page.replace \"completion-#{params[:id]}\", :partial => 'completion', :locals => {:completion => completion}\n page.visual_effect :highlight, \"completion-#{params[:id]}\"\n end\n else\n render :update do |page|\n page.visual_effect :shake, 'head'\n end\n end\n end",
"def votecannotbecast\t\t\n\t\trespond_to do |format|\n\t\t\tformat.js {}\n\t\tend\n\tend",
"def edit\n @l1_bu = @workflow.l1_bu\n @l1_component = @workflow.l1_component\n @bu_options = @workflow.bu_options.where(recording_level: 'L1')\n @action = 'UPDATE'\n @btn_action = 'UPDATE'\n @status_list = @workflow.statuses.where(recording_level: 'L1')\n @attr_list = @workflow.label_attributes.where(recording_level: 'L1', is_visible: true).order(:sequence)\n @attr_values = @l1.attribute_values\n respond_to do |format|\n format.html\n format.js\n end\n\n\n end",
"def refresh_selected_data\n entry = extract_entry_by_entry_id(params[:entry_id])\n\n parameter = \"\"\n if entry[:parameter] # Parameter erwähnt (erwartet als Array)\n entry[:parameter].each do |p|\n parameter << \"<div title='#{my_html_escape(p[:title])}'>#{my_html_escape(p[:name])} <input name='#{p[:name]}' size='#{p[:size]}' value='#{p[:default]}' type='text'></div><br/>\"\n end\n end\n respond_to do |format|\n format.js {render :js => \"$('#show_selection_header_area').html('<b>#{j my_html_escape(entry[:name]) }</b>');\n $('#show_selection_hint_area').html('#{j my_html_escape(entry[:desc]) }');\n $('#show_selection_param_area').html('#{j parameter }');\n $('#dragnet_show_selection_do_selection').prop('disabled', #{entry[:sql] ? 'false' : 'true'});\n $('#dragnet_show_selection_show_sql').prop('disabled', #{entry[:sql] ? 'false' : 'true'});\n $('#dragnet_drop_personal_selection_button').#{entry[:personal] ? 'show' : 'hide'}();\n $('#dragnet_hidden_entry_id').val('#{params[:entry_id]}');\n \"\n }\n end\n end",
"def load_edit_vf_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n\n @valuefield = Valuefield.find(params[:valuefield_id])\n if(!@valuefield.property_id.nil?)\n @property = Property.find(@valuefield.property_id)\n end\n\n\n respond_to do |format|\n format.js\n end\n end",
"def load_edit_component_page\n @all_groups = Group.all\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n @component = Component.find(params[:component_id])\n\n @component_components = @component.components\n @component_valuefields = @component.valuefields\n @component_properties = @component.properties\n @component_images = @component.images\n @component_datafiles = @component.data_files\n @component_products = @component.products\n @component_group = @component.group\n respond_to do |format|\n format.js\n end\n end",
"def scaffold_habtm_with_ajax\n @scaffold_habtm_with_ajax ||= scaffold_habtm_with_ajax_default\n end",
"def convert_status\n @message=params[:message]\n render('convert_status', :handlers => [:erb], :formats => [:js])\n end",
"def submit_in_loading_page!\n @submit_in_loading_page = true\n end",
"def update\n @team_consultation = TeamConsultation.find(params[:id])\n params[:team_consultation][:draft] = false if params[:commit] == \"Save\" #the js in the view does not work in ff\n\n respond_to do |format|\n if @team_consultation.update_attributes(params[:team_consultation])\n if @team_consultation.draft?\n msg=\"<p>The concern note has been sent to #{@team_consultation.school_team}.</p> <p>A discussion about this student will occur at an upcoming team meeting.</p>\"\n else\n msg = 'TeamConsultation was successfully updated.'\n end\n format.html { redirect_to(@team_consultation.student) }\n format.js { flash.now[:notice] = msg; responds_to_parent{render :action => 'create'} }\n else\n format.html { render :action => \"new\" }\n format.js { responds_to_parent{render :action => 'new'} }\n end\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.xml { render :xml => @mode.to_xml }\n\t\t\tformat.js { render :text => @mode.to_json }\n end\n end",
"def notify_modification\n if @ok\n msg = params[:details_placeholder].blank? ? '' : params[:details]\n @lesson.notify_changes msg\n end\n end",
"def save_charttext\n @charttext = Charttext.find(params[:charttext_id])\n assignment = Assignment.find(@task.assignment_id)\n respond_to do |format|\n if assignment.editable?(current_user)\n if @charttext.update_attributes(params[:charttext])\n @autopreview = @charttext\n unless params[:autopreview]\n format.js { render \"shared/save_success\" }\n else\n format.js { render \"shared/autopreview\" }\n end\n else\n format.js {render \"shared/save_failed\"}\n end\n else\n format.js {render \"shared/pastdue\"}\n end\n end\n end",
"def load_component_tab\n @item_id = params[:item]\n respond_to do |format|\n format.html\n format.js\n end\n end",
"def bins_tipped_production_schedule_name_search_combo_changed\n production_schedule_name = get_selected_combo_value(params)\n session[:bins_tipped_search_form][:production_schedule_name_combo_selection] = production_schedule_name\n @production_run_codes = BinsTipped.find_by_sql(\"select distinct production_run_code from production_runs where production_schedule_name = '#{production_schedule_name}'\").map { |p| [p.production_run_code] }\n @production_run_codes.unshift(\"<empty>\")\n query = \"SELECT track_indicator_code FROM public.production_schedules, public.rmt_setups\n WHERE rmt_setups.production_schedule_id = production_schedules.id AND public.production_schedules.production_schedule_name = '#{production_schedule_name}'\"\n @track_indicator_code = Carton.connection.select_one(query)['track_indicator_code']\n puts \"HELLO KK\"\n\n render :inline => %{\n <%= select('bin_tipped','production_run_code',@production_run_codes)%>\n <img src = '/images/spinner.gif' style = 'display:none;' id = 'img_bin_tipped_production_run_code'/>\n\t\t <%= observe_field('bin_tipped_production_run_code',:update => 'line_code_cell',:url => {:action => session[:bins_tipped_search_form][:production_run_code_observer][:remote_method]},:loading => \"show_element('img_bin_tipped_production_run_code');\",:complete => session[:bins_tipped_search_form][:production_run_code_observer][:on_completed_js])%>\n\n <script>\n <%=\n update_element_function(\"track_indicator_code_cell\",\n :action=>:update,\n :content=> @track_indicator_code)\n %>\n </script>\n }\n\n end",
"def load_form\n @symbole = Symbole.new if @symbole.nil?\n if params[:form_name].present?\n respond_to do |format|\n format.js { render \"ajax_form_\"+params[:form_name] }\n end\n end\n end",
"def save_and_close\n save_and_close_button\n wait_for_ajax\n end",
"def update_load_voyage\n begin\n\n\t id = params[:load_voyage][:id]\n\t if id && @load_voyage = LoadVoyage.find(id)\n\t\t if @load_voyage.update_attributes(params[:load_voyage])\n\t\t\tflash[:notice] = 'record saved'\n render :inline => %{\n <script>\n window.opener.frames[1].frames[1].location.reload(true);\n alert('load voyage edited');\n window.close();\n </script>\n }\n\n\t else\n\t render_edit_load_voyage\n\n\tend\n end\nrescue\n\t handle_error('record could not be saved')\nend\n end",
"def show\n render :update do |page|\n page.replace_html :good_details, :partial=>\"details\"\n end\n end",
"def refresh!\n load if changed?\n end",
"def edit\n @page_title = \"Edit Comment\"\n @comment = current_recipe.comments.find(params[:id])\n @btnText = \"Update Comment\"\n @obj = @comment\n respond_to do |f|\n f.html {render 'shared/form'}\n f.js\n end\n end",
"def page_revisions\n self.back_to_top\n page_revisions_button\n wait_for_ajax\n \n end",
"def toggle_content_type\n @blog = Blog.find(params[:blog_id])\n @blog.change_content_type\n respond_to do |format|\n format.html {render :edit}\n end\n end",
"def save\n save_button\n sleep 1\n wait_for_ajax\n end",
"def topic \n respond_to do |format|\n format.js \n end \n end",
"def add_content_with_webform(content_type, title, comp_names)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n case content_type\n when 'forum'\n self.add_content(content_type, title, comp_names)\n Log.logger.info(\"Selecting the proper forum type from the dropdown ('This is a forum')\")\n flag = false\n wait.until { @browser.find_element(:xpath => @webformmgr.forum_type) }.find_elements(:xpath => \"//option\").each {|e|\n next unless e.text.include?('This is a forum') ; flag = true; e.click ; break ;\n }\n Log.logger.info(\"Didn't add content!!!\") unless flag\n message = self.save_webform\n when 'poll'\n self.add_content(content_type, title, comp_names)\n temp = wait.until { @browser.find_element(:xpath => @webformmgr.poll_choice_one) }\n temp.clear\n temp.send_keys(\"Yes\")\n temp = wait.until { @browser.find_element(:xpath => @webformmgr.poll_choice_two) }\n temp.clear\n temp.send_keys(\"No\")\n message = self.save_webform\n else\n self.add_content(content_type, title, comp_names)\n message = self.save_webform\n end\n return message\n end",
"def dont_notify_modification\n if @ok\n @lesson.dont_notify_changes\n render :nothing => true\n end\n end",
"def processed_content\n self.read_attribute(:processed_content).html_safe\n end",
"def force_content(newcont)\n @ios = [{:str => newcont, :done => true}]\n end",
"def edit_page\n self.back_to_top\n edit_page_button\n wait_for_ajax\n self.class.class_eval { include DocumentWidget }\n end",
"def set_expense_entry_description\n data=params\n @tne_invoice_expense_entry = TneInvoiceExpenseEntry.find(data[:id])\n @tne_invoice_expense_entry.update_attribute(:description,data[:value])\n render :text => @tne_invoice_expense_entry.description\n end",
"def forecasts_track_slms_indicator_commodity_code_search_combo_changed\n commodity_code = get_selected_combo_value(params)\n session[:forecasts_track_slms_indicator_search_form][:commodity_code_combo_selection] = commodity_code\n @variety_codes = TrackSlmsIndicator.find_by_sql(\"Select distinct variety_code from track_slms_indicators where commodity_code = '#{commodity_code}' and variety_type = 'rmt_variety'\").map { |g| [g.variety_code] }\n @variety_codes.unshift(\"<empty>\")\n\n#\trender (inline) the html to replace the contents of the td that contains the dropdown\n render :inline => %{\n\t\t<%= select('forecasts_track_slms_indicator','variety_code',@variety_codes)%>\n\t\t<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_forecasts_track_slms_indicator_variety_code'/>\n\t\t<%= observe_field('forecasts_track_slms_indicator_variety_code',:update => 'track_slms_indicator_code_cell',:url => {:action => session[:forecasts_track_slms_indicator_search_form][:variety_code_observer][:remote_method]},:loading => \"show_element('img_forecasts_track_slms_indicator_variety_code');\",:complete => session[:forecasts_track_slms_indicator_search_form][:variety_code_observer][:on_completed_js])%>\n\t\t}\n\n end",
"def _child_updated\n render :js => update_recordset_js(false)\n end",
"def nodatamaster\n \n render :update do |page|\n #page.replace_html 'aux_div', '<font size=4 color=#08176C>No Data for Selected Values</font>'\n page.redirect_to url_for(:action=>'master')\n \n end \nend",
"def downtime_sub_type_downtime_category_code_search_combo_changed\n\tdowntime_category_code = get_selected_combo_value(params)\n\tsession[:downtime_sub_type_search_form][:downtime_category_code_combo_selection] = downtime_category_code\n\t@downtime_division_codes = DowntimeSubType.find_by_sql(\"Select distinct downtime_division_code from downtime_sub_types where downtime_category_code = '#{downtime_category_code}'\").map{|g|[g.downtime_division_code]}\n\t@downtime_division_codes.unshift(\"<empty>\")\n\n#\trender (inline) the html to replace the contents of the td that contains the dropdown \n\trender :inline => %{\n\t\t<%= select('downtime_sub_type','downtime_division_code',@downtime_division_codes)%>\n\t\t<img src = '/images/spinner.gif' style = 'display:none;' id = 'img_downtime_sub_type_downtime_division_code'/>\n\t\t<%= observe_field('downtime_sub_type_downtime_division_code',:update => 'downtime_type_code_cell',:url => {:action => session[:downtime_sub_type_search_form][:downtime_division_code_observer][:remote_method]},:loading => \"show_element('img_downtime_sub_type_downtime_division_code');\",:complete => session[:downtime_sub_type_search_form][:downtime_division_code_observer][:on_completed_js])%>\n\t\t}\n\nend",
"def submit_comment\n self.button(:text=>\"Submit comment\").click\n wait_for_ajax(2) #wait_until { self.text.include? \"about 0 seconds ago\" }\n end",
"def load_edit_product_page\n @product = Product.find(params[:product_id])\n\n @all_properties = Property.all\n @all_categories = Category.all\n @all_components = Component.all\n @all_products = Product.all\n @all_images = Image.all\n @all_datafiles = DataFile.all\n\n @product_components = @product.components\n @product_valuefields = @product.valuefields\n @product_properties = @product.properties\n @product_images = @product.images\n @product_datafiles = @product.data_files\n @product_categories = @product.categories\n\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 get_content\n respond_to do |format|\n format.js\n end\n end",
"def show \n catch :flash_now do find_detail end\n div_id = params[:div_id]\n render :update do |page|\n page[div_id].replace_html :partial => \"detail\"\n end\n end",
"def update\n respond_to do |format|\n if @lombard_tab.update(lombard_tab_params)\n format.html { redirect_to lombard_tabs_url, notice: 'Таб в ломбарде обновлен.'}\n format.json { render :show, status: :ok, location: @lombard_tab }\n else\n format.html { render :edit }\n format.json { render json: @lombard_tab.errors, status: :unprocessable_entity }\n end\n end\n end",
"def redraw(option, value, url = nil)\n remote_function(\n :url => url || send(\"redraw_#{controller.controller_name}_path\"),\n :with => \"{ #{option}: '#{value}' }\",\n :condition => \"$('#{option}').innerHTML != '#{value}'\",\n :loading => \"$('#{option}').update('#{value}'); $('loading').show()\",\n :complete => \"$('loading').hide()\"\n )\n end",
"def variety_commodity_group_code_changed\n\tcommodity_group_code = get_selected_combo_value(params)\n\tsession[:variety_form][:commodity_group_code_combo_selection] = commodity_group_code\n\t@commodity_codes = Variety.commodity_codes_for_commodity_group_code(commodity_group_code)\n#\trender (inline) the html to replace the contents of the td that contains the dropdown \n\trender :inline => %{\n\t\t<%= select('variety','commodity_code',@commodity_codes)%>\n <img src = '/images/spinner.gif' style = 'display:none;' id = 'img_variety_commodity_code'/>\n\t\t<%= observe_field('variety_commodity_code',:update => 'ajax_distributor_cell',:url => {:action => session[:variety_form][:commodity_code_observer][:remote_method]},:loading => \"show_element('img_variety_commodity_code');\",:complete => session[:variety_form][:commodity_code_observer][:on_completed_js])%>\n\t\t}\n\nend",
"def adding_answer_responder\n article = find_entity # article with questionnaire\n @thread = article.a_thread\n @question_entities = article.questionnaires\n base_div_id = params[:base_div_id] # id of div to add\n @answer_responder = article.answer_responder(@thread)\n @def_answer_responder_form_items = Def_Answering_Form_Items\n @answer_responder_form_items = Answering_Form_Items\n render :update do |page| \n page.replace_html base_div_id, \n :partial => \"article_threads/answer_responder\", \n :object => @answer_responder\n end\n end"
] | [
"0.5470013",
"0.54249144",
"0.5354219",
"0.5319931",
"0.52720785",
"0.5226924",
"0.5206482",
"0.51908624",
"0.5145297",
"0.5110697",
"0.51084536",
"0.5069864",
"0.5069537",
"0.5060468",
"0.505131",
"0.5040813",
"0.50330114",
"0.49955735",
"0.499359",
"0.4976219",
"0.49706966",
"0.4954893",
"0.49521542",
"0.49472022",
"0.4930176",
"0.49300578",
"0.49276403",
"0.49178782",
"0.49088755",
"0.48997882",
"0.48897848",
"0.48887828",
"0.48806983",
"0.48791113",
"0.4874134",
"0.48709726",
"0.48571095",
"0.4854434",
"0.48413885",
"0.48368096",
"0.48073378",
"0.48067817",
"0.4799159",
"0.47910038",
"0.47893065",
"0.47893065",
"0.47893065",
"0.47812402",
"0.4780962",
"0.4769458",
"0.47684738",
"0.4767171",
"0.47631654",
"0.47574273",
"0.47568324",
"0.47560236",
"0.4754078",
"0.47527027",
"0.47497883",
"0.47484905",
"0.47464913",
"0.47420228",
"0.47408786",
"0.47403353",
"0.47347996",
"0.4733033",
"0.4731073",
"0.47303316",
"0.47253773",
"0.4724529",
"0.47222474",
"0.47213382",
"0.47203943",
"0.4717943",
"0.47139615",
"0.47121838",
"0.4700507",
"0.46880585",
"0.4687615",
"0.4686784",
"0.46846136",
"0.4680878",
"0.46793643",
"0.4673578",
"0.46709546",
"0.46671653",
"0.466311",
"0.46629497",
"0.46620446",
"0.46614423",
"0.46523908",
"0.46501112",
"0.46496013",
"0.46490803",
"0.46484944",
"0.46484944",
"0.4645518",
"0.46389616",
"0.46380115",
"0.463661",
"0.46337324"
] | 0.0 | -1 |
Description Deletes an element which has not been correctly converted Mode Json Specific filters ApplicationControllerinitialize_media_element_destination | def destroy_fake
render :json => {:ok => true, :msg => nil}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n if @ok\n if !@media_element.check_and_destroy\n @ok = false\n @error = @media_element.get_base_error\n end\n else\n @error = I18n.t('activerecord.errors.models.media_element.problem_destroying')\n end\n render :json => {:ok => @ok, :msg => @error}\n end",
"def remove\n @ok_msg = t('other_popup_messages.correct.remove.media_element')\n if @ok\n bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).first\n if bookmark.nil?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')\n else\n bookmark.destroy\n if Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'MediaElement', :bookmarkable_id => @media_element_id).any?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')\n end\n end\n else\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_media_element')\n end\n if @destination == ButtonDestinations::FOUND_MEDIA_ELEMENT\n prepare_media_element_for_js\n render 'media_elements/reload.js'\n else\n render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}\n end\n end",
"def destroy\n authorize Element\n @element.is_valid=false;\n respond_to do |format|\n if @element.save\n format.html { redirect_to elements_url, notice: 'Element je bil označen kot neveljaven.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n puts \"------------------------\"\n document_item = ActiveStorage::Attachment.find(@document.doc.id)\n p document_item.purge\n puts \"------------------------\"\n\n @document.destroy\n respond_to do |format|\n\n\n\n\n format.html { redirect_to property_property_unit_documents_path(@property, @property_unit), notice: 'Dokumentet ble slettet.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_additional_description.destroy\n respond_to do |format|\n format.html { redirect_to admin_products_path, notice: 'Additional description was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @custom_media_entry.destroy\n respond_to do |format|\n format.html { redirect_to custom_media_entries_url, notice: 'Custom media entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_converter = MediaConverter.find(params[:id])\n @media_converter.destroy\n\n respond_to do |format|\n format.html { redirect_to media_converters_url, notice: 'メディコンマスターの削除が完了しました.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config_element.destroy\n respond_to do |format|\n format.html { redirect_to config_elements_url, notice: 'Config element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_attribute = MediaAttribute.find(params[:id])\n @media_attribute.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_attributes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @structure_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end",
"def remove_video\n\t\torder=Order.find(params[:id])\n\t\tx=order.custom_video.last\n\t\tif x.remove_path!\n\t\t\torder.clip_status=false\n\t\t\torder.save\n\t\t\ta=order.performer\n\t\t\tif a.white_label.id==1\n\t\t\t\ta.payment_to_be_done=a.payment_to_be_done-order.perf_cut.to_f\n\t\t\t\ta.save\n\t\t\telse\n\t\t\t\tb=a.white_label\n\t\t\t\tb.payment_to_be_done=b.payment_to_be_done-order.perf_cut.to_f\n\t\t\t\tb.save\n\t\t\tend\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to orders_path, notice: 'Video was successfully deleted' }\n\t\t\t\tformat.mobile { redirect_to orders_path, notice: 'Video was successfully deleted' }\n\t\t\tend\n\t\tend\n\tend",
"def destroy\n @element.destroy\n respond_with :elements\n end",
"def destroy\n @inform = @slide.inform\n if @slide.slide_tag[-1] != \"*\"\n\n @blocks = @inform.blocks.where(slide_tag: @slide.slide_tag) #Saco una coleccion de blocks asociadas al slide que voy a borrar\n\n @block = @blocks.first #Es para pasarla al render en JS\n\n @samples = @inform.samples.where(slide_tag: @slide.slide_tag, name: \"Extendido\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @sample = @samples.first #Es para pasarla al render en JS\n # @recipient = Recipient.where(inform_id: @sample.inform_id, tag: @sample.recipient_tag).first #Es para pasarla al render en JS\n @recipient = nil\n\n \n\n \n @samples.each do |sample|\n sample.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n @blocks.each do |block|\n block.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n end\n @samplesc = @inform.samples.where(name: \"Cassette\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @blocks = @inform.blocks #Recargo todos los block para renderizado\n @slide.destroy\n end",
"def destroy\n @media_type = MediaType.find(params[:id])\n @media_type.destroy\n\n respond_to do |format|\n format.html { redirect_to media_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = @media_file.resource\n\n @media_file.destroy\n respond_to do |format|\n format.html { redirect_to edit_resource_path(@resource), notice: 'Media was removed.' }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @admin_media_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_media_types_url, notice: 'Media type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataelement = Dataelement.find(params[:id])\n @dataelement.destroy\n\n respond_to do |format|\n format.html { redirect_to dataelements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @videoconferencium.destroy\n respond_to do |format|\n format.html { redirect_to videoconferencia_url, notice: 'Videoconferencium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_item.destroy\n respond_to do |format|\n format.html { redirect_to media_items_url, notice: t('media_items.was_deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_interest.destroy\n\n respond_to do |format|\n format.html { redirect_to media_interests_url }\n format.json { head :no_content }\n end\n end",
"def delete_element(element); end",
"def destroy\n @demo_song.destroy\n respond_to do |format|\n format.html { redirect_to(admin_product_attachment_url(@demo_song.product_attachment)) }\n format.xml { head :ok }\n format.js \n end\n website.add_log(user: current_user, action: \"Deleted a demo song\")\n end",
"def destroy\n @sample_photo.destroy\n render json: {message: 'Foto Excluida'} , status: :ok\n end",
"def destroy\n\n #論理削除\n @video.is_show = false\n @video.save\n respond_to do |format|\n format.html { redirect_to videos_url, notice: '動画情報を削除しました' }\n format.json { head :no_content }\n end\n end",
"def documentremove\n if self.documents.attached?\n document_urls = self.documents.map do |adoc| \n Rails.application.routes.url_helpers.delete_document_attachment_tbl_quality_issue_url(adoc, only_path: true)\n end \n else\n nil\n end \n end",
"def destroy\n @custom_medium.destroy\n respond_to do |format|\n format.html { redirect_to custom_media_url, notice: 'Custom medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_path = MediaPath.find(params[:id])\n @media_path.destroy\n\n respond_to do |format|\n format.html { redirect_to({:controller=>:rmedial_settings, :action=>:index}) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @campaign_medium.destroy\n respond_to do |format|\n format.html { redirect_to campaign_media_url, notice: 'Campaign medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mediation.destroy\n respond_to do |format|\n format.html { redirect_to mediations_url, notice: 'Mediation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n img_choices = @entry.optional_images\n @entry.destroy\n @json_response = {\"response\" => \"success\", \"img_choices\" => img_choices}\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { render json: @json_response }\n #format.js\n end\n end",
"def destroy\n @element = @account.elements.find(params[:id])\n @element.destroy\n respond_to do |format|\n format.html { redirect_to(elements_url, :notice => 'Element was sucessfully destroyed.') }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @documentary.remove_thumbnail = true\n @documentary.save!\n head :no_content\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to elements_url }\n format.json { head :ok }\n end\n end",
"def delete(element); end",
"def destroy\n @product_attachment.destroy\n @primary_photo = false\n if @product_attachment.primary_photo \n product = @product_attachment.product\n @primary_photo = product.photo\n end\n respond_to do |format|\n format.html { redirect_to(admin_product_attachments_url) }\n format.xml { head :ok }\n format.js\n end\n website.add_log(user: current_user, action: \"Deleted a product attachment from #{@product_attachment.product.name}\")\n end",
"def destroy_question_media\n\t\tif @question_media.destroy\n\t\t# response to the JSON\n\t\trender json: { success: true,message: \"Image deleted successfully\" },:status=>200\n\t\telse\n\t\trender :json=> { success: false, message: @question_media.errors },:status=> 203\n\t\tend\n\tend",
"def destroy\n @elemento.destroy\n respond_to do |format|\n format.html { redirect_to elementos_url, notice: 'Elemento fue eliminado con exito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_element.destroy\n respond_to do |format|\n format.html { redirect_to event_elements_url, notice: 'Event element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_element.destroy\n respond_to do |format|\n format.html { redirect_to list_elements_url, notice: 'List element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scraping_html_element.destroy\n respond_to do |format|\n format.html { redirect_to scraping_html_elements_url, notice: 'Scraping html element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_media_by_id id\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/media/{id}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"id\" => id,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"APIMATIC 2.0\",\r\n \"accept\" => \"application/json\",\r\n \"Content-Type\" => Configuration.content_type\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params headers\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.delete query_url, headers:headers\r\n\r\n #Error handling using HTTP status codes\r\n if !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n else \r\n puts \"Media ID Deleted\"\r\n end\r\n\r\n response.body\r\n end",
"def destroy\n @media_plan.destroy\n respond_to do |format|\n format.html { redirect_to media_plans_url, notice: 'Media plan was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @multimedia = find_media\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to @multimedia }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: 'Medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: 'Medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: 'Medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium.destroy\n respond_to do |format|\n format.html { redirect_to media_url, notice: \"Medium was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n run_callbacks :destroy do\n connection.delete(element_path, encode, self.class.headers)\n end\n end",
"def destroy\n @isncription = Isncription.find(params[:id])\n @isncription.destroy\n\n respond_to do |format|\n format.html { redirect_to isncriptions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_metadata_item = MediaMetadataItems.find(params[:id])\n @media_metadata_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_metadata_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @extracurricular.destroy\n respond_to do |format|\n format.html { redirect_to extracurriculars_url, notice: 'Extracurricular was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_item = MediaItem.find(params[:id])\n @media_item.destroy\n\n respond_to do |format|\n format.html { redirect_to media_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @element = @page.all_elements.find(params[:id])\n # Start by removing the element from the page\n page_element = Fe::PageElement.where(:element_id => @element.id, :page_id => @page.id).first\n page_element.destroy if page_element\n\n # If this element is not on any other pages, is not a question or has no answers, Destroy it\n if @element.reuseable? && (Fe::PageElement.where(:element_id => params[:id]).present? || @element.has_response?)\n @element.update_attributes(:question_grid_id => nil, :conditional_id => nil)\n else\n @element.destroy\n end\n\n respond_to do |format|\n format.js\n end\n end",
"def destroy\n @doc_type_am_configuration = DocTypeAmConfiguration.find(params[:id])\n @doc_type_am_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to doc_type_am_configurations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n \n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end",
"def remove plataform\n end",
"def destroy\n @embedded_attachment.destroy\n respond_to do |format|\n format.html { redirect_to embedded_attachments_url, notice: 'Video was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @creative_configuration.destroy\n respond_to do |format|\n format.html { redirect_to creative_configurations_url, notice: 'Creative configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove(params)\n params[:real_at] ||= AtStructure.new(params[:at])\n\n # Le text-item de référence\n unless params.key?(:titem_ref)\n params.merge!(titem_ref: params[:real_at].first_titem)\n end\n\n # Pour connaitre l'opération, pour faire la distinction, plus tard, entre\n # une pure suppression et un remplacement. Elle permet aussi d'enregistrer\n # l'opération dans l'historique operations.txt\n unless params.key?(:operation)\n params.merge!(operation: 'remove')\n end\n\n # Un débug (régler les valeurs en haut de ce module)\n if debug_replace? || debug_remove?\n log(\"-> remove(params=#{params.inspect})\")\n end\n\n if params[:operation] == 'remove'\n msg = \"Suppression de “#{params[:real_at].first_titem.content}” (index absolu #{params[:real_at].abs(:at)}, index relatif #{params[:real_at].at}).\"\n log(msg, true)\n end\n\n\n # Si c'est une vraie suppression (i.e. pas un remplacement), il faut\n # supprimer aussi l'espace après. S'il n'y a pas d'espace après, il faut\n # supprimer l'espace avant s'il existe.\n # La formule est différente en fonction du fait qu'on ait un rang ou\n # un index seul et une liste discontinue d'index.\n # ATTENTION AUSSI : l'espace supplémentaire à supprimer est peut-être\n # dans la liste des index à supprimer et dans ce cas il faut étudier\n # le mot suivant et le text-item non-mot suivant.\n #\n # Le but de cette partie est donc de produire la liste exacte des text-items\n # qui doivent être finalement supprimé.\n # Elle n'est valable que pour une suppression pure car pour un replacement,\n # il faut garder tous les éléments autour du mot ou des mots remplacés.\n at = params[:real_at]\n if params[:operation] == 'remove'\n if at.list?\n # Pour une liste, on doit faire un traitement particulier : il faut\n # vérifier les text-item après chaque \"trou\"\n liste_finale = at.list.dup\n at.titems.each_with_index do |titem, idx_in_list|\n # Les non-mots doivent être passés\n next if titem.non_mot?\n # On passe ce mot si le mot suivant appartient aussi à la liste\n next if at.list[idx_in_list + 1] == idx + 1\n # On passe ce mot si le mot précédent appartient aussi à la liste\n next if at.list[idx_in_list - 1] == idx - 1\n # On doit tester ce mot qui est \"seul\" dans la liste, c'est-à-dire\n # que la liste ne contient ni son mot juste après ni son mot\n # juste avant.\n next_index = idx + 1\n next_titem = extrait_titems[next_index]\n prev_index = idx - 1\n prev_index = nil if prev_index < 0\n prev_titem = prev_index.nil? ? nil : extrait_titems[prev_index]\n if next_titem && next_titem.space?\n # On l'ajoute à la liste des items à supprimer\n liste_finale.insert(idx_in_list + 1, next_index)\n elsif prev_titem && prev_titem.space?\n liste_finale.insert(idx_in_list, prev_index)\n end\n end #/ boucle sur la liste\n\n # Si la liste finale a changé, il faut corrigé le at\n if liste_finale != at.list\n params[:real_at] = at = AtStructure.new(liste_finale.join(VG))\n end\n\n else\n # Pour un rang et un index seul, le traitement est plus simple, il\n # suffit de voir l'index après le dernier.\n # Noter qu'on ne supprime pas les espaces ici, on modifie le rang\n # ou on transforme l'index en range, ceci afin de ne pas provoquer\n # de doubles suppressions\n next_index = at.last + 1\n prev_index = at.first - 1\n prev_index = nil if prev_index < 0\n if extrait_titems[next_index].space?\n params[:real_at] = at = AtStructure.new(\"#{at.first}-#{next_index}\")\n elsif prev_index && extrait_titems[prev_index].space?\n params[:real_at] = at = AtStructure.new(\"#{prev_index}-#{at.last}\")\n end\n end\n end\n\n # On mémorise l'opération pour pouvoir l'annuler\n if params.key?(:cancellor) # pas quand c'est une annulation\n at.titems.each do |titem|\n params[:cancellor] << {operation: :insert, index: titem.index, content: params[:content]}\n end\n end\n\n # SUPPRESSION\n # ------------\n # On procède vraiment à la suppression des mots dans le texte\n # lui-même, ainsi que dans la base de données avec une formule différente en\n # fonction du fait que c'est un rang ou une liste (note : un index unique\n # a été mis dans une liste pour simplifier les opérations)\n if at.range?\n extrait_titems.slice!(at.from, at.nombre)\n itexte.db.delete_text_items(from:at.abs(:from), for:at.nombre)\n else\n at.list.each { |idx| extrait_titems.slice!(idx) }\n itexte.db.delete_text_items(at.abs(:list))\n end\n\n # Si c'est vraiment une opération de destruction, on l'enregistre\n # en tant qu'opération et on actualise l'affichage en indiquant que\n # l'extrait a changé\n if params[:operation] == 'remove'\n itexte.operator.add_text_operation(params)\n update\n end\n\nend",
"def destroy\n @article.images.purge if @article.images.attached?\n @article.destroy\n respond_to do |format|\n format.html { redirect_to articles_url, notice: '記事を削除しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@document = current_user.documents.find(params[:document_id])\n @document_photo = @document.document_photos.find(params[:id])\n if @document_photo\n \n @document_photo.destroy\n\n respond_to do |format|\n format.html { redirect_to document_itemimages_url(@document) }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @redescription.destroy\n respond_to do |format|\n format.html { redirect_to redescriptions_url, notice: 'Redescription was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condominium.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @description = Description.find(params[:id])\n @description.destroy\n \n respond_to do |format|\n format.html { redirect_to(descriptions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @feed_element = FeedElement.find(params[:id])\n @feed_element.destroy\n\n respond_to do |format|\n format.html { redirect_to feed_elements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @device_sub_content.destroy\n respond_to do |format|\n format.html { redirect_to device_sub_contents_url, notice: 'Device sub content was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @observation_home_element = ObservationHomeElement.find(params[:id])\n @observation_home_element.destroy\n\n respond_to do |format|\n format.html { redirect_to observation_home_elements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def destroy\n @other_medium.destroy\n respond_to do |format|\n format.html { redirect_to other_media_url, notice: 'Other medium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium = Medium.find_by_local_key(params[:local_key])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { render json: @medium.item }\n end\n end",
"def destroy\n @prospecto_meta_mediano_plazo.destroy\n respond_to do |format|\n format.html { redirect_to prospecto_meta_mediano_plazos_url, notice: 'Prospecto meta mediano plazo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @design_image_attachment.destroy\n respond_to do |format|\n format.html { redirect_to design_image_attachments_url, notice: 'Design image attachment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @file_description.destroy\n respond_to do |format|\n format.html { redirect_to file_descriptions_url, notice: 'File description was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def log_removal_of_element(kd_el, xml_node)\n xml_node.children.each do |child|\n case child.name\n when 'Properties', 'HyperlinkTextDestination'\n @validation_logger.log_debug_info(\n [\n @validation_file_descriptor,\n sprintf(\"story %5s\", story_name_for_xml_node(xml_node)),\n sprintf(\"line %5s\", xml_node.line)\n ],\n ['Discarding Element', child.name]\n )\n end\n end\n end",
"def tradeoff_product_remove\n choice = Choice.find(params[:id]) \n choice.tips.clear\n render :update do |page|\n page.replace_html(\"dropzone_choice_#{choice.id}\", \"\")\n end\n end",
"def destroy\n @resource_breakdown_structure.destroy\n respond_to do |format|\n format.html { redirect_to resource_breakdown_structures_url, notice: 'Resource Breakdown Structure wurde erfolgreich gelöscht' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quality_document = QualityDocument.find(params[:id])\n @quality_document.destroy\n\n respond_to do |format|\n format.html { redirect_to quality_documents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @security_case_medium = SecurityCaseMedium.find(params[:id])\n @security_case_medium.destroy\n\n respond_to do |format|\n format.html { redirect_to(security_case_media_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mapping_data_tindakan_medi = MappingDataTindakanMedi.find(params[:id])\n #@mapping_data_tindakan_medi.destroy\n\n @id = params[:id]\n\n respond_to do |format|\n if request.xhr?\n format.js do\n render :update do |page|\n page[\"list#{params[:id]}\"].fade()\n end\n end\n else\n if @mapping_data_tindakan_medi.destroy\n format.html { redirect_to(mapping_data_tindakan_medis_url) }\n else\n format.html { redirect_to(:action => \"edit\", :id => @id, :error => DELETE_CASCADE_ERROR_MSG) }\n end\n\n #format.xml { head :ok }\n end\n end\n end",
"def destroy\n @content_group_element = ContentGroupElement.find(params[:id])\n @content_group_element.destroy\n\n respond_to do |format|\n format.html { redirect_to content_group_elements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @description_item.destroy\n respond_to do |format|\n format.html { redirect_to description_items_url, notice: 'Description item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adaptive_thought.destroy\n respond_to do |format|\n format.html { redirect_to adaptive_thoughts_url, notice: 'Adaptive thought was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @creative.destroy\n respond_to do |format|\n format.html { redirect_to campaign_creatives_url(@campaign), notice: 'Вид рекламы удален.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @media_item = MediaItem.find(params[:id])\n @media_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(media_items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @element = Element.find(params[:id])\n @element.destroy\n\n respond_to do |format|\n format.html { redirect_to(elements_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @military_document_type = MilitaryDocumentType.find(params[:id])\n @military_document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to military_document_types_url, :notice => 'Tipo de Documento Militar excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_description.destroy\n respond_to do |format|\n format.html { redirect_to admin_descriptions_url, notice: 'Description was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @registro_videoconferencium.destroy\n respond_to do |format|\n format.html { redirect_to registro_videoconferencia_url, notice: 'Registro videoconferencium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @criterion_detail.destroy\n respond_to do |format|\n format.html { redirect_to criterion_criterion_details_path, notice: 'تم حذف المقياس بنجاح' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @microfilm_reel = MicrofilmReel.find(params[:id])\n @microfilm_reel.destroy\n\n respond_to do |format|\n format.html { redirect_to microfilm_reels_url }\n format.json { head :no_content }\n end\n end",
"def remove_elem\n elem =eval(params[:type]).find(params[:elem])\n elem.position= 0\n case params[:type]\n when \"Activity\"\n elem.model_id = -1\n when \"Action\"\n elem.activity_id = -1\n when 'PfTask'\n elem.action_id = -1\n end\n elem.update_attributes(elem.attributes)\n redirect_to :action => 'show_subs', :parent_id =>params[:parent_id], :parent_type =>eval(params[:type]).get_parent_name\n end",
"def destroy\n respond_to do |format|\n if @article.input\n format.html { redirect_to articles_url, notice: 'No es posible eliminar un Artículo que ya ha sido vendido, o alquilado.' }\n format.json { render json: @article.errors, status: :unprocessable_entity }\n else\n @article.destroy\n format.html { redirect_to articles_url }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n respond_to do |format|\n if @order_custom_item.update_attributes({accept: false, accept_time: Time.now})\n CustomItem.decline(@order_custom_item.id, params[:lang]).deliver\n format.html {redirect_to action: :index}\n else\n format.html {render json: @order_custom_item.errors}\n end\n end\n end",
"def delete_media_action(_browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n item = wait.until { _browser.find_element(:xpath => @galmgr.action) }\n if not item.displayed?\n Log.logger.info(\"Select bar is not visible...you haven't checked any content to delete!\")\n return\n end\n wait.until { _browser.find_element(:xpath => \"#{@galmgr.action}/option[contains(@value,'delete')]\") }.click\n JQuery.wait_for_events_to_finish(@browser)\n Log.logger.info(\"Clicking delete button.\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.confirm_delete) }\n wait.until { temp.displayed? }\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n next_body_text = wait.until { _browser.find_element(:xpath => \"//body\") }.text\n if next_body_text.include?(\"Error 503 Service Unavailable\")\n raise \"Got an error while trying to delete media items.\"\n end\n\n #are you sure?\n Log.logger.info(\"Waiting for and consuming confirmation.\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.confirm_delete) }\n wait.until { temp.displayed? }\n temp.click\n JQuery.wait_for_events_to_finish(@browser)\n end",
"def delete_elem\n elem = eval(params[:type]).find(params[:elem])\n eval(params[:type]).delete(params[:elem])\n elems = nil\n case params[:type]\n when \"ProcessModel\"\n elems = elem.activities\n for e in elems\n e.model_id =-1\n e.update_attributes(e.attributes)\n end\n when \"Activity\"\n elems = elem.actions\n for e in elems\n e.activity_id =-1\n e.update_attributes(e.attributes)\n end\n when \"Action\"\n elems = elem.pf_tasks\n for e in elems\n e.action_id =-1\n e.update_attributes(e.attributes)\n end\n end\n redirect_to :action => 'index', :tab =>params[:type]\n rescue\n flash[:error] = l(:error_can_not_delete_custom_field)\n redirect_to :action => 'index',:tab =>params[:type]\n end",
"def destroy\n @demanda_videomonitoramento.destroy\n respond_to do |format|\n format.html { redirect_to demanda_videomonitoramentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medium = Medium.find(params[:id])\n @medium.destroy\n\n respond_to do |format|\n format.html { redirect_to media_url }\n format.xml { head :ok }\n end\n end",
"def watermark_attachment_delete\n @attributes[:watermark_attachment_delete]\n end"
] | [
"0.6416994",
"0.6255369",
"0.58502597",
"0.5704979",
"0.56556714",
"0.56113976",
"0.5580223",
"0.5564969",
"0.5553642",
"0.5538928",
"0.54998577",
"0.54893374",
"0.5467149",
"0.5460922",
"0.54432493",
"0.54323936",
"0.54239345",
"0.54103184",
"0.5403993",
"0.54009694",
"0.53718835",
"0.53669167",
"0.5345952",
"0.5345486",
"0.534305",
"0.5335185",
"0.53329766",
"0.5310606",
"0.53069466",
"0.52939975",
"0.5293223",
"0.52845997",
"0.5284544",
"0.5278401",
"0.5276152",
"0.52692777",
"0.52564114",
"0.5247553",
"0.5240096",
"0.5239238",
"0.52383465",
"0.5233798",
"0.5233663",
"0.52331245",
"0.52302176",
"0.52302176",
"0.52302176",
"0.5229014",
"0.5228369",
"0.5228263",
"0.5223792",
"0.5205652",
"0.52053374",
"0.51994926",
"0.51974183",
"0.5196325",
"0.5194109",
"0.5189961",
"0.51885164",
"0.5186594",
"0.5183528",
"0.5182003",
"0.51753914",
"0.5172323",
"0.5169326",
"0.5165816",
"0.5160425",
"0.51578724",
"0.515782",
"0.5157148",
"0.5156985",
"0.5155928",
"0.51505023",
"0.51436144",
"0.51413727",
"0.51399714",
"0.5138511",
"0.51380914",
"0.51355207",
"0.51336735",
"0.51303977",
"0.5128205",
"0.51184464",
"0.51173955",
"0.51168984",
"0.5115668",
"0.5115668",
"0.51127857",
"0.5110451",
"0.5106553",
"0.5105089",
"0.5101218",
"0.5101161",
"0.5096312",
"0.5091916",
"0.5090607",
"0.5090059",
"0.50880116",
"0.50857663",
"0.5084619",
"0.50750786"
] | 0.0 | -1 |
Gets media elements using Userown_media_elements | def get_own_media_elements
current_user_own_media_elements = current_user.own_media_elements(@page, @for_page, @filter)
@media_elements = current_user_own_media_elements[:records]
@pages_amount = current_user_own_media_elements[:pages_amount]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_media_elements(page)\n MediaElement.joins(:taggings).where(:taggings => {:tag_id => self.id}).order('media_elements.updated_at DESC').page(page)\n end",
"def media_elements_at\n case self.kind\n when AUDIO, VIDEO1, VIDEO2\n resp = self.media_elements_slides.first\n resp.nil? ? nil : resp.media_element\n when COVER, IMAGE1, IMAGE3\n self.media_elements_slides.first\n when IMAGE2\n resp = [nil, nil]\n mes = self.media_elements_slides\n resp[mes[0].position - 1] = mes[0] if !mes[0].nil?\n resp[mes[1].position - 1] = mes[1] if !mes[1].nil?\n resp\n when IMAGE4\n resp = [nil, nil, nil, nil]\n mes = self.media_elements_slides\n resp[mes[0].position - 1] = mes[0] if !mes[0].nil?\n resp[mes[1].position - 1] = mes[1] if !mes[1].nil?\n resp[mes[2].position - 1] = mes[2] if !mes[2].nil?\n resp[mes[3].position - 1] = mes[3] if !mes[3].nil?\n resp\n else\n nil\n end\n end",
"def get_medias(data)\n result = @client.api_request(\n :method => \"usermedia.get\",\n :params => {\n :userids => data[:userid],\n :output => \"extend\"\n }\n )\n result ? result : nil\n end",
"def mediafiles\n source_node.xpath('.//MediaFile').to_a.collect do |node|\n Mediafile.new(node)\n end\n end",
"def media\n parse(delete('media'))\n end",
"def get_user_recent_media\n response = @client.get(\"#{@base_url}/v1/users/self/media/recent\", access_token: get_user_access_token)\n medias = JSON.parse(response.body) \n if(medias[\"meta\"][\"code\"] == 200)\n media_url = []\n medias[\"data\"].each do |media|\n url = media[\"images\"][\"standard_resolution\"][\"url\"]\n media_url.push(url)\n end\n media_url \n end\n end",
"def find_media(media_u_id)\n\t\t\tif !@media.nil? \n\t\t\t\treturn @media.find { |m| m.u_id == media_u_id }\n\t\t\tend\n\t\t\treturn nil\n\t\tend",
"def media\n return @media\n end",
"def media\n self\n end",
"def items\n media.map(&:proper_items_by_time).flatten\n end",
"def retrieve_media_url(tweet)\n retrieve_media_element(tweet, 'media_url')\n end",
"def media_list\n DATABASE.execute(\"SELECT media.cover_name FROM media_members JOIN media ON media_members.media_id = media.id WHERE media_members.member_id = #{id};\")\n end",
"def index\n @custom_media = ((GeneralMedium.joins(:personal_media_parameters).where('personal_media_parameters.users_id =?', current_user.id)).joins(:custom_medium))\n end",
"def get_media_per_user_single\n playlist_array = []\n current_user.workout_sets.find(params[:id]).media.each do |v|\n sources_array = []\n videos_hash = {}\n sources_array << {\n src: rails_blob_path(v.video),\n type: 'video/mp4'\n }\n videos_hash[:name] = v.title\n videos_hash[:sources] = sources_array\n playlist_array << videos_hash\n end\n gon.mediaSets = playlist_array\n end",
"def find_media_by_id(message_id)\n UploadedMedium.find(message_id)\n end",
"def visible_media_for_user(user)\n media.select { |m| m.visible_for_user?(user) }\n end",
"def case_media_list\n\t\t@case_media_attachments = @surgery_case.case_media.case_media_attachments\n\tend",
"def media_list\n @redis.hkeys(\"contact_media:#{self.id}\") - ['pagerduty']\n end",
"def medium_names\n primary_media | secondary_media | component_media\n end",
"def selfMedia\n myMedia = Medium.all.filter{|media| media.user_id == decoded_token}\n # ItinActiv = Activity.all.filter{ |activity| activity.itinerary_id == myItin.id }\n render json: myMedia\n end",
"def get_mediaitem_fields()\n @restv9.get_mediaItems_fields()\n end",
"def search_media\n session.delete(:media)\n if !params[:q].blank? && !advanced_search?\n session[:media] = simple_search_api.map { |m| m.id }.compact\n elsif advanced_search?\n session[:media] = advanced_search_api.map { |m| m.id }.compact\n else\n session[:media] = Medium.all.first(500).map { |m| m.id }\n end\n end",
"def get_media_per_user\n playlist_array = []\n current_user.workout_sets.each do |set|\n set.media.each do |v|\n sources_array = []\n videos_hash = {}\n sources_array << {\n src: rails_blob_path(v.video),\n type: 'video/mp4'\n }\n videos_hash[:name] = v.title\n videos_hash[:sources] = sources_array\n playlist_array << videos_hash\n end\n end\n gon.mediaSets = playlist_array\n end",
"def get_all_media_from_all_messages\n begin\n media_sql = \"SELECT * FROM mediacontent WHERE mediacontentid IN\";\n media_sql += \" (SELECT messagemediacontent.mediaid FROM messagemediacontent)\";\n media_sql += \" AND (HighQFilePath IS NOT NULL AND HighQFilePath != '' ) \";\n message_media_data = Immutable.dbh.execute(media_sql);\n return message_media_data;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n end\n end",
"def index\n @custom_media_entries = CustomMediaEntry.all\n end",
"def get_all_media_items_for_model_type(model_name)\n attachments_table_name = model_name.tableize.singularize+\"_attachments\"\n query_main = \"DISTINCT(media_item_id), media_item_desc, filename, updated_at \"\n query_join = \" inner join #{attachments_table_name} using (media_item_id)\"\n @images = MediaItem.find(:all, :select => query_main, \n :joins => query_join,\n :order => 'updated_at desc')\n @images\n \n end",
"def index\n @other_media = OtherMedium.all\n end",
"def get_medias(page=1, page_size=10, sort_by=\"created_time\", order=\"desc\")\n from = (page.to_i-1)*page_size.to_i\n opt = {}\n opt[:order] = order\n opt[:by] = \"media:*:score\"\n #opt[:by] = \"media:*:#{sort_by}\"\n opt[:limit] = [from, page_size]\n\n # key for caching search result \n store_key = \"user#{id}_page#{page}_by_#{sort_by}_#{order}\"\n opt[:store] = store_key\n\n medias.sort(opt)\n # cache result for 5 minutes\n self.redis.expire(store_key, 300)\n stored_result = self.redis.lrange(store_key, 0, -1)\n # return media instances\n p stored_result\n stored_result.map do |media_id|\n Media.find(media_id)\n end\n end",
"def index\n @media = case params[\"mode\"]\n when \"all\" then Medium.fetch_ordered\n when \"paginated\" then Medium.fetch_ordered_by_page(params[\"page\"])\n else Medium.fetch_ordered_by_page(params[\"page\"])\n end\n end",
"def media(source)\n if source.media? && source.media.count == 1\n source.media[0].media_url.to_s\n else\n nil\n end\n end",
"def media_types\n return @media_types\n end",
"def index\n @media = Medium.all\n end",
"def index\n @media = Medium.all\n end",
"def index\n @media = Medium.all\n end",
"def extract(media_element_id, an_user_id, my_sti_type)\n media_element = find_by_id media_element_id\n return nil if media_element.nil? || media_element.sti_type != my_sti_type\n media_element.set_status(an_user_id)\n return nil if media_element.status.nil?\n media_element\n end",
"def all\n xml_doc.xpath('/MediaContainer/User').map {|n| [n['email'],n['username']] }\n end",
"def load_mediasets\n []\n end",
"def media_sizes\n return @media_sizes\n end",
"def popular_media\n get '/media/popular', auth_params\n end",
"def each\n medias.each{ |media| yield media }\n end",
"def media_list\n source_media.sort{|x,y| x.medium <=> y.medium }.map{ |x| x.medium }.join(', ')\n end",
"def get_media_element_from_hash(hash, key, user_id, my_sti_type)\n hash[key].kind_of?(Integer) ? MediaElement.extract(hash[key], user_id, my_sti_type) : nil\n end",
"def tags\n if properties.key?(:media_content) and\n properties[:media_content][:url].present? and\n properties.key?(:media_thumbnail) and\n properties[:media_thumbnail][:url].present?\n %w[image]\n else\n []\n end\n end",
"def scoped_medium_types\n [primary_media.prepend('primary'), secondary_media.prepend('secondary'), component_media.prepend('component')]\n end",
"def index\n @campaign_media = CampaignMedium.all\n end",
"def elements\n find_by_tag('*')\n end",
"def media_search\n\t\tcase_media = media_list(params[:searchterm])\n\t\t# check condition for case media is present or not.\n\t\tif case_media.present?\n\t\t# response to the JSON\n\t render json: { success: true, response: case_media.map(&:attachment).as_json }\n\t else\n\t render :json=> { success: false, message: \"Media are not present\" },:status=> 203\n\t end \n\tend",
"def media_search(options={})\n get '/media/search', auth_params.merge(options)\n end",
"def sprint_process_media(doc)\n srcs = Array.new\n # collect all the images in the document, even though\n # they are <img> tag some might actually refer to video.\n # To know the link refers to vide one must look at the \n # content type on the http GET response.\n imgs = doc.search(\"/html/body//img\")\n imgs.each do |i|\n src = i.attributes['src']\n # we don't want to double fetch content and we only\n # want to fetch media from the content server, you get\n # a clue about that as there is a RECIPIENT in the URI path\n # of real content\n next unless /mmps\\/RECIPIENT\\//.match(src)\n next if srcs.detect{|s| s.eql?(src)}\n srcs << src\n end\n\n #we've got the payload now, go fetch them\n cnt = 0\n srcs.each do |src|\n begin\n \n url = URI.parse(CGI.unescapeHTML(src))\n unless @is_video\n query={}\n url.query.split('&').each{|a| p=a.split('='); query[p[0]] = p[1]}\n query.delete_if{|k, v| k == 'limitsize' or k == 'squareoutput' }\n url.query = query.map{|k,v| \"#{k}=#{v}\"}.join(\"&\")\n end\n # sprint is a ghetto, they expect to see & for video request\n url.query = url.query.gsub(/&/, \"&\") if @is_video\n\n res = Net::HTTP.get_response(url)\n rescue StandardError => err\n log(\"#{self.class} processing error, #{$!}\", :error)\n next\n end\n\n # if the Sprint content server uses response code 500 when the content is purged\n # the content type will text/html and the body will be the message\n if res.content_type == 'text/html' && res.code == \"500\"\n log(\"Sprint content server returned response code 500\", :error)\n next\n end\n\n # setup the file path and file\n base = /\\/RECIPIENT\\/([^\\/]+)\\//.match(src)[1]\n type = res.content_type\n file_name = \"#{base}-#{cnt}.#{self.class.default_ext(type)}\"\n file = File.join(msg_tmp_dir(),File.basename(file_name))\n\n # write it and add it to the media hash\n type, file = sprint_write_file(type, res.body, file)\n add_file(type, file) unless type.nil? || file.nil?\n cnt = cnt + 1\n end\n\n end",
"def media\n super\n end",
"def list(filter=KalturaNotImplemented, pager=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\t# Media entry filter\n\t\t\tclient.add_param(kparams, 'filter', filter);\n\t\t\t# Pager\n\t\t\tclient.add_param(kparams, 'pager', pager);\n\t\t\tclient.queue_service_action_call('media', 'list', 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 collect_media(prefix=\"\")\n media = {}\n\n s3_media = list_objects(prefix)\n puts \"Found #{s3_media.count} objects\"\n s3_media.each do |object|\n path = object[:key].slice(6, object[:key].length)\n media[path] ||= {}\n media[path][:s3] = object\n end\n\n local_media = list_files(prefix)\n puts \"Found #{local_media.count} files\"\n local_media.each do |file|\n path = file[:path].slice(6, file[:path].length)\n media[path] ||= {}\n media[path][:local] = file\n end\n\n media\nend",
"def index\n @media_objects = MediaObject.all\n end",
"def media(url, **keyword_args)\n append(Media.new(url, **keyword_args))\n end",
"def item_only_attachments\n @relevant_object = convert_id_to_model(params[:id])\n @images = @relevant_object.media_items\n end",
"def list_html(medias)\n list = \"\"\n log \"list_html: #{medias.size}\"\n medias.each do |media|\n log \"media: #{media.title}\"\n list << \"<li><img src='\" << media.url << \"'><br>\" << media.title << \"</li>\"\n end\n \"<ul class='gallery_detail'>#{list}</ul>\"\n end",
"def type\n Medium.find(self.source.medium_id).media\n end",
"def media(url)\n append(Media.new(url))\n end",
"def media() @media = Media.new end",
"def get_liked_media\n case likeable_type\n when 'Post'\n return Post.find(likeable_id)\n when 'Comment'\n return Comment.find(likeable_id)\n end\n end",
"def get_media_content_for_message(message_id)\n begin\n message_sql = \"SELECT * FROM mediacontent WHERE mediacontentid IN\";\n message_sql += \" (SELECT messagemediacontent.mediaid FROM messagemediacontent WHERE messageid = #{message_id})\";\n message_sql += \" AND (( iPodVideo IS NOT NULL AND iPodVideo != '') OR (HighQFilePath IS NOT NULL AND HighQFilePath != '' ))\";\n message_media_content_data = Immutable.dbh.execute(message_sql);\n\n return message_media_content_data;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n abort('An error occurred while getting message media content data from DB, Check migration log for more details');\n end\n end",
"def entity_objects\n ProjectMedia.where(id: self.entities).to_a\n end",
"def load_mediaset\n nil\n end",
"def show\n medium_id = params[:medium_id]\n @medium = nil\n if !medium_id.blank?\n begin\n @medium = Medium.find(medium_id)\n rescue ActiveRecord::RecordNotFound\n @medium = nil\n end\n end\n @place = Place.find(params[:id]) \n @pictures = @place.media(:type => 'Picture').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n @videos = @place.media(:type => 'Video').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n @documents = @place.media(:type => 'Document').limit(Medium::COLS * Medium::PREVIEW_ROWS)\n render_media\n end",
"def index\n get_own_media_elements\n if @page > @pages_amount && @pages_amount != 0\n @page = @pages_amount\n get_own_media_elements\n end\n render_js_or_html_index\n end",
"def download_media post\n files = []\n post.media_attachments.each_with_index do |img, i|\n extension = File.extname(img.url).split('?').first\n if ValidMediaTypes.include? extension\n files << \"#{i}#{extension}\"\n File.write(files[i], Net::HTTP.get(URI.parse(img.url)))\n end\n end\n files\n end",
"def list_media_details(gallery_name = \"test\", _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Listing Media properties and ids to edit it (for Gallery: #{gallery_name.inspect})\")\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_media) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n edit_media_ids = Hash.new\n i = 1\n wait.until { _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-')]\") }\n med_ct = Integer(_browser.find_elements(:xpath => \"//div[contains(@id, 'media-edit-')]\").size)\n Log.logger.info(\"Found editable images: #{med_ct}\")\n while i < med_ct+1\n media_url = _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-#{i}')]//img[contains(@class, '')]\").attribute(\"src\")\n Log.logger.info(\"Working on image number #{i}: #{media_url.inspect}\")\n if (i == 1)\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value']\"\n media_tag = \"//input[@id = 'edit-field-tags-und']\"\n else\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und--#{i}']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und--#{i}']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value--#{i}']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value--#{i}']\"\n media_tag = \"//input[@id = 'edit-field-tags-und--#{i}']\"\n end\n\n Log.logger.info(\"image number #{i} media-type: #{media_type.inspect}\")\n Log.logger.info(\"image number #{i} media-title: #{media_title.inspect}\")\n edit_media_ids[media_url] = Hash.new() unless (edit_media_ids[media_url])\n edit_media_ids[media_url][:license] = media_license_setting\n edit_media_ids[media_url][:tag] = media_tag\n edit_media_ids[media_url][:desc] = media_description\n edit_media_ids[media_url][:title] = media_title\n edit_media_ids[media_url][:type] = media_type\n i += 1\n end\n return edit_media_ids\n end",
"def medias_for(type)\n found = {}\n type.media_type_representations.each do |key|\n found[key] = media_types[key]\n end\n found.values\n end",
"def media=(value)\n @media = value\n end",
"def index\n @media_files = MediaFile.all\n end",
"def find_image_items\n manifest_items.select { |item| item['media_type'] =~ /^image\\// }\n end",
"def all_group_attachments\n @relevant_object = convert_id_to_model(params[:id])\n @images = get_all_media_items_for_model_type(@relevant_object.class.to_s.tableize)\n end",
"def to_s\n '#<Twilio.Intelligence.V2.MediaList>'\n end",
"def attached_files\n array = []\n frm.ul(:class=>/attachList/).lis.each { |li| array << li.link.text }\n array\n end",
"def index\n @space = Space.find(params[:space_id])\n @media = @space.media\n end",
"def media_element\n if correct_integer?(params[:media_element_id])\n @media_element_id = params[:media_element_id].to_i\n @resp = current_user.report_media_element(@media_element_id, params[:content])\n @error = current_user.get_base_error\n else\n @media_element_id = nil\n @resp = false\n @error = I18n.t('activerecord.errors.models.user.problem_reporting')\n end\n end",
"def active_media\n super\n end",
"def media_text\n if @media_text.nil?\n @media_text = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"media:text/text()\"\n ], :select_result_value => true),\n FeedTools::XmlHelper.try_xpaths(self.root_node, [\n \"media:text/text()\"\n ], :select_result_value => true)\n ])\n unless @media_text.blank?\n @media_text = FeedTools::HtmlHelper.unescape_entities(@media_text)\n @media_text = FeedTools::HtmlHelper.sanitize_html(@media_text)\n @media_text.strip!\n else\n @media_text = nil\n end\n end\n return @media_text\n end",
"def find_medium(id)\n self.class.get(\"/media/#{id}.json?apikey=#{apikey}\")\n end",
"def find_case_media\n\t\t@case_medium = CaseMedium.find(params[:id])\n\tend",
"def og_media(key)\n {\n url: og(\"#{key}:secure_url\") || og(\"#{key}:url\") || og(key),\n width: og(\"#{key}:width\"),\n height: og(\"#{key}:height\"),\n type: og(\"#{key}:type\")\n }.compact\n end",
"def media(options = {})\n @fotolia.search(options.merge({:representative_category => self}))\n end",
"def getUserBy_social_media( name, id)\n params = Hash.new\n params['name'] = name\n params['id'] = id\n return doCurl(\"get\",\"/user/by_social_media\",params)\n end",
"def media_for_collection(medias)\n result = ''\n medias.each do |media|\n result << render_background_thumbnail(media) do\n link_to(image_tag('view.png'), media_view_path(media),\n :title => media.title, :class => 'photo_link collection_view') <<\n check_box_tag(\"out_#{media.id}\", \"1\", false, :name => \"media[#{media.id}]\", :class => 'out_collection')\n end\n end\n result\n end",
"def embeddables\n self.page_items.collect{|qi| qi.embeddable}\n end",
"def initialize(media_elem)\n super()\n\n @id = nil\n @media_url = nil # メディアの URL\n @media_url_https = nil # メディアの SSL URL\n @url = nil # メディア URL(展開)\n @display_url = nil\n @expanded_url = nil\n @type = MEDIA_TYPE_PHOTO # only \"photo\" for now\n @sizes = nil\n @indices = nil\n end",
"def index\n @artist_mediums = ArtistMedia.all\n end",
"def get_media(cloud_file)\n uri = {file_path: cloud_file.path} if cloud_file.path\n\n media = format_response(Dropbox.successful_request?(:media, access_token, uri))\n media[:url]\n end",
"def elements\n model = self.model.constantize\n model.respond_to?(:generic_listing_elements) ? model.generic_listing_elements : model.all\n end",
"def media\n MediaInfoTracksDecorator.new(media_info_tracks)\n end",
"def index\n @relevant_object = get_object(params[:id], params[:source_object_id])\n @images = @relevant_object.media_items\n \n #Note the name of the table has been checked for validity in get_object method\n #An argument exception is thrown\n attachments_table_name = params[:id].singularize+\"_attachments\"\n query_main = \"DISTINCT(media_item_id), media_item_desc, filename, updated_at \"\n query_join = \" inner join #{attachments_table_name} using (media_item_id)\"\n @images = MediaItem.find(:all, :select => query_main, \n :joins => query_join,\n :order => 'updated_at desc')\n \n respond_to do |format|\n format.html # index.rhtml\n format.xml { render :xml => @mailout_images.to_xml }\n format.js\n end\n end",
"def get_thumbs\n self.xpath(\"//url[@type='\" + Settings.thumbnail_size + \"']\").collect { |node| node.text }\n end",
"def member_list\n DATABASE.execute(\"SELECT members.name FROM media_members JOIN members ON media_members.member_id = members.id WHERE media_members.media_id = #{id};\")\n end",
"def count_media\n general_data['nb_media']\n end",
"def get_media_content_by_media_content_id(id)\n begin\n content_sql = \"SELECT mediacontent.* FROM channelmedia\";\n content_sql += \" JOIN mediacontent ON mediacontent.mediaContentId = channelmedia.mediaId\";\n content_sql += \" WHERE postId = #{id}\";\n media_content = Immutable.dbh.execute(content_sql);\n return media_content;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n abort('An error occurred while getting media content from DB, Check migration log for more details');\n end\n end",
"def image_elements #:nodoc:\n @image_elements[0...number_elements]\n end",
"def get_characters\n Role.all.select {|role| role.media == self}\n end",
"def get_media\n raise Errors::BadRequestError, \"Bad course site ID #{canvas_course_id}\" if canvas_course_id.blank?\n authorize Canvas::Course.new(canvas_course_id: canvas_course_id), :can_view_course?\n render :json => Canvas::CanvasMediacasts.new(user_id: session[:user_id], course_id: canvas_course_id).get_feed\n end",
"def media_quality_list\n return @media_quality_list\n end",
"def mediaSubescapular\n\t\tmedia = 0.0\n\t\t@subescapular.length.times do |i|\n\t\t media += @subescapular[i]\n\t\tend\n\t\tmedia /= @subescapular.length.to_f\n\t\tmedia.round(2)\n\tend"
] | [
"0.71667904",
"0.69947106",
"0.6593392",
"0.65456766",
"0.6522452",
"0.6473865",
"0.646598",
"0.64359754",
"0.63486004",
"0.61855525",
"0.61852956",
"0.61313766",
"0.6085632",
"0.6076357",
"0.6076312",
"0.60489213",
"0.6029287",
"0.60000145",
"0.5949952",
"0.5942411",
"0.5934963",
"0.5918686",
"0.58894545",
"0.5879462",
"0.5844019",
"0.57971215",
"0.57623154",
"0.57587713",
"0.57333535",
"0.5722212",
"0.5695658",
"0.56795096",
"0.56795096",
"0.56795096",
"0.5646623",
"0.56399375",
"0.56379694",
"0.56305254",
"0.5627198",
"0.5610625",
"0.5577076",
"0.55601215",
"0.55569345",
"0.5551113",
"0.5544666",
"0.55389243",
"0.5522416",
"0.5508906",
"0.54985934",
"0.5486016",
"0.5482881",
"0.54810166",
"0.54656273",
"0.54370487",
"0.5426805",
"0.5415662",
"0.54006106",
"0.5396853",
"0.5372548",
"0.5372123",
"0.5356774",
"0.535516",
"0.5351083",
"0.5350401",
"0.5338753",
"0.5336084",
"0.5329048",
"0.53260046",
"0.5317031",
"0.5287071",
"0.5281013",
"0.5267243",
"0.52518326",
"0.52476394",
"0.52343607",
"0.523022",
"0.5211454",
"0.5208091",
"0.5200168",
"0.51990706",
"0.5193256",
"0.5186788",
"0.5182004",
"0.5173379",
"0.5169098",
"0.5167343",
"0.5149489",
"0.5146078",
"0.5141259",
"0.5131712",
"0.51144165",
"0.50941175",
"0.5093645",
"0.50745624",
"0.50722927",
"0.50684416",
"0.5063839",
"0.50584537",
"0.505293",
"0.50524217"
] | 0.79123586 | 0 |
Initializes pagination parameters and filters | def initialize_paginator
@page = correct_integer?(params[:page]) ? params[:page].to_i : 1
@display = [MediaElement::DISPLAY_MODES[:compact], MediaElement::DISPLAY_MODES[:expanded]].include?(params[:display]) ? params[:display] : MediaElement::DISPLAY_MODES[:expanded]
if @display == MediaElement::DISPLAY_MODES[:expanded]
@for_row = correct_integer?(params[:for_row]) ? params[:for_row].to_i : 1
@for_row = 1 if @for_row > 50
@for_page = @for_row * 2
else
@for_page = FOR_PAGE
end
@filter = params[:filter]
@filter = Filters::ALL_MEDIA_ELEMENTS if !Filters::MEDIA_ELEMENTS_SET.include?(@filter)
@just_resizing = params[:resizing].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_paginator\n @page = correct_integer?(params[:page]) ? params[:page].to_i : 1\n @for_page = FOR_PAGE\n @filter = params[:filter]\n @filter = Filters::ALL_LESSONS if !Filters::LESSONS_SET.include?(@filter)\n end",
"def initialize_paginator\n @page = correct_integer?(params[:page]) ? params[:page].to_i : 1\n @for_page = FOR_PAGE\n @order = SearchOrders::DOCUMENTS_SET.include?(params[:order]) ? params[:order] : SearchOrders::CREATED_AT\n @word = params[:word].blank? ? nil : params[:word]\n end",
"def do_pagination\n @page_number = 1\n if params[:page] && params[:page].to_i > 0\n @page_number = params[:page].to_i\n end\n @pagination = true\n @pagination_options = { :limit => items_per_page, :offset => (@page_number - 1) * items_per_page }\n @pagination_options = {} if params[:all]\n end",
"def set_page_vars\n @page = params[:page] ? params[:page].to_i : START_PAGE\n @per_page = PER_PAGE\n end",
"def set_params\n params[:page] ||= 1\n params[:per_page] ||= 15\n params[:order_by] ||= \"id\"\n params[:order_direction] ||= \"ASC\"\n end",
"def set_params_page\n params[:page] = params.fetch(\"page\"){1}.to_i\n params[:per_page] = params.fetch(\"per_page\"){20}.to_i\n end",
"def set_params_page\n params[:page] = params.fetch(\"page\"){1}.to_i\n params[:per_page] = params.fetch(\"per_page\"){20}.to_i\n end",
"def prepare_attributes\n @current_page = params[:page] ? params[:page].to_i : 1\n @rows_per_page = params[:rows] ? params[:rows].to_i : 10\n end",
"def initialize(pagination_data={})\n @page = pagination_data.fetch(:page, 1)\n @per_page = pagination_data.fetch(:per_page, 1000)\n @total_pages = pagination_data.fetch(:total_pages, 1)\n @total_records = pagination_data.fetch(:total_records, -1)\n @page_first_index = pagination_data.fetch(:page_first_index, -1)\n @page_last_index = pagination_data.fetch(:page_last_index, -1)\n end",
"def _pagination\n return @_pagination if @_pagination\n\n pagination = {}\n attrs = request.action&.params&.type&.attributes\n pagination[:paginator] = request.params.pagination if attrs&.key? :pagination\n pagination[:order] = request.params.order if attrs&.key? :order\n\n @_pagination = PaginationStruct.new(pagination[:paginator], pagination[:order])\n end",
"def pagination!\n parameter :page, :integer, :required => false, :default => 1, :paramType => \"query\"\n parameter :per_page, :integer, :required => false, :default => 30, :paramType => \"query\", \n :allowed => 1..1000\n end",
"def pagination_params\n page = params[:page].to_i\n page = 1 unless page > 0\n per = params[:per].to_i\n per = 25 unless per > 0\n {page: page, per: per}\n end",
"def pagination_options\n { :offset => offset, :limit => per_page } if paginated?\n end",
"def page_params \n params.has_key?(:pagination) ? get_page_params( params.require(:pagination) ) : {}\n end",
"def set_pagination\n set_params_page\n @updates = @updates.paginate(:page => params[:page], :per_page => params[:per_page], :order => :created_at.desc)\n set_pagination_buttons(@updates)\n end",
"def set_paging\n if extjs_paging?\n offset = params[:start].to_i\n @page_limit = params[:limit].to_i\n @current_page = (offset / @page_limit) + 1 # start at page 1\n else\n @page_limit = 20 # sync with ExtJS PagingToolbar configuration in view!\n @current_page = 1\n end\n end",
"def pagination_setup(paginator: SearchPaginator, **opt)\n # noinspection RubyMismatchedReturnType\n super\n end",
"def populate_pagination_attributes_from_options(options={})\n self.page = options[:page] || page || 1\n self.per_page = options[:per_page] || per_page || 50\n end",
"def defaults\n { :per_page => 50, :max_per_page => 100 }\n end",
"def pagination_setup(paginator: User::Paginator, **opt)\n # noinspection RubyMismatchedReturnType\n super\n end",
"def with_pagination(pagination_params)\n scoped(:offset => pagination_params.start_index - 1, :limit => pagination_params.items_per_page)\n end",
"def initialize_filters(params)\n # integer arrays\n [\n :location_ids,\n :model_ids,\n :scenario_ids,\n :indicator_ids,\n :sector_ids,\n :category_ids\n ].map do |param_name|\n if params[param_name].present? && params[param_name].is_a?(Array)\n value = params[param_name].map(&:to_i)\n end\n instance_variable_set(:\"@#{param_name}\", value)\n end\n @start_year = params[:start_year]&.to_i\n unless @start_year.present? && @start_year > MINIMUM_YEAR_FROM\n @start_year = MINIMUM_YEAR_FROM\n end\n @end_year = params[:end_year]&.to_i\n end",
"def init_parameters\n @filters = []\n @sorts = {}\n @columns = {}\n @extra_fields = []\n @exporting = {}\n @operations = []\n @macro = Macro.new\n end",
"def initialize(*args)\n super\n\n raise ArgumentError, 'No items given' unless options[:items]\n\n paginate\n end",
"def paginate\n @people = Person.paginate(page: page, per_page: 10) if scope_params.blank?\n end",
"def pagination_setup(paginator: ManifestItem::Paginator, **opt)\n # noinspection RubyMismatchedReturnType\n super\n end",
"def pagination\n Pagination.new( total_items, search_args)\n end",
"def add_pagination(params, scope = self.all)\n if params[:page] || params[:per_page]\n scope = scope.paginate(\n page: params[:page] || 1,\n per_page: params[:per_page] || 20\n )\n end\n return scope\n end",
"def initialize(current_page, total_pages, per_page, base_url, params = {})\n @current_page = current_page\n @total_pages = total_pages\n @per_page = per_page\n @base_url = base_url\n @params = params\n end",
"def initialize_available_filters\n @@available_filters ||= {}\n end",
"def initialize(objects, **options)\n super(nil, options)\n remove_instance_variable(:@object)\n @paginator = options[:paginator]\n @filter = options[:filter]\n @objects = initalize_objects(objects)\n end",
"def paginate(extra_parameters = {})\n klass.paginate(params(extra_parameters))\n end",
"def pagination_params(opts = {})\n { :page => params[:page] || 1, :per_page => params[:per_page] || 10 }.merge(opts)\n end",
"def initialize(options = {})\n @paged_objects = {0 => options[:seed_page]}\n @total = options[:total].to_i\n @per_page = options[:per_page].to_i\n @pages = @per_page > 0 ? (@total.to_f / @per_page.to_f).ceil : 0\n @load_more_call = options[:load_more_call]\n @no_threads = options[:no_threads] || DEFAULT_NO_THREADS\n end",
"def crear_paginacion\n @page = params[:page].nil? ? 1 : params[:page].to_i\n @per_page = 3\n end",
"def prepare(params)\n @query = params[:keywords]\n @taxons = params[:taxon]\n if params[:search]\n # price\n @price_min = params[:search][:price][:min].to_f\n @price_max = params[:search][:price][:max].to_f\n # properties\n @properties = params[:search][:properties]\n end\n\n @per_page = (params[:per_page].to_i <= 0) ? Spree::Config[:products_per_page] : params[:per_page].to_i\n @page = (params[:page].to_i <= 0) ? 1 : params[:page].to_i\n end",
"def configure_sorting_and_filtering_and_facet_counts\n set_view_as_options\n @view_as = params[:view_as].blank? ? @collection.view_style_or_default : ViewStyle.find(params[:view_as])\n set_sort_options\n @sort_by = params[:sort_by].blank? ? @collection.sort_style_or_default : SortStyle.find(params[:sort_by])\n @filter = params[:filter]\n @page = params[:page]\n @selected_collection_items = params[:collection_items] || []\n\n # NOTE - you still need these counts on the Update page:\n @facet_counts = EOL::Solr::CollectionItems.get_facet_counts(@collection.id)\n end",
"def pagination_params()\n normalize_param_value(:_pg).permit(:_s, :_p, :_c)\n end",
"def initialize pager, page; @pager, @page = pager, page; end",
"def page_params\n []\n end",
"def paginate_opts\n ({}).tap do |ret|\n ret[:per_page] = Spree::Config[:products_per_page]\n ret[:page] = params[:page]\n end\n end",
"def jsonapi_pagination_params\n pagination = params[:page].try(:slice, :number, :size) || {}\n per_page = jsonapi_page_size(pagination)\n num = [1, pagination[:number].to_f.to_i].max\n\n [(num - 1) * per_page, per_page, num]\n end",
"def initialize(page: nil, per_page: nil, max_per_page: nil)\n # initialize to the default value on nil or \"\"\n page = 1 if page.blank?\n\n # initialize to the default value on nil or \"\"\n per_page = Westfield::Paginator.config.default_per_page if per_page.blank?\n\n # initialize to the default value on nil or \"\"\n max_per_page = Westfield::Paginator.config.max_per_page if max_per_page.blank?\n\n @per_page = [per_page.to_i, max_per_page].min\n @page = page\n end",
"def opts_for_paginate\n paginate_opts = combined_options.reject { |k,v| !OPTIONS_FOR_PAGINATE.include?(k) }\n paginate_opts[:finder] = :find_all_by_id unless paginate_opts.include?(:finder)\n paginate_opts[:per_page] = klass.per_page if klass && !paginate_opts.include?(:per_page)\n paginate_opts\n end",
"def initialize(parameters, query, model, filter_settings)\n # might need this at some point: Rack::Utils.parse_nested_query\n @key_prefix = 'filter_'\n key_partial_match = :filter_partial_match\n\n @default_page = 1\n @default_items = 25\n @max_items = 500\n @table = relation_table(model)\n\n # `.all' adds 'id' to the select!!\n @initial_query = !query.nil? && query.is_a?(ActiveRecord::Relation) ? query : relation_all(model)\n # the check for an active record relation above can lead to some subtle\n # bugs when you pass some non-nil query like thing.\n # temporarily throwing here to see what breaks. All tests pass so\n # we'll make the check below a validation that always runs\n unless query.is_a?(ActiveRecord::Relation)\n raise ArgumentError, \"query was not an ActiveRecord::Relation. Query: #{query}\"\n end\n\n validate_filter_settings(filter_settings)\n @valid_fields = filter_settings[:valid_fields].map(&:to_sym)\n @text_fields = filter_settings.include?(:text_fields) ? filter_settings[:text_fields].map(&:to_sym) : []\n @render_fields = filter_settings[:render_fields].map(&:to_sym)\n @filter_settings = filter_settings\n @default_sort_order = filter_settings[:defaults][:order_by]\n @default_sort_direction = filter_settings[:defaults][:direction]\n @custom_fields2 = filter_settings[:custom_fields2] || {}\n @capabilities = filter_settings[:capabilities] || {}\n\n @build = Build.new(@table, filter_settings)\n\n @parameters = CleanParams.perform(parameters)\n validate_hash(@parameters)\n\n @parameters = decode_payload(@parameters)\n\n @filter = @parameters.include?(:filter) && !@parameters[:filter].blank? ? @parameters[:filter] : {}\n @projection = parse_projection(@parameters)\n\n # remove key_partial_match key from parameters hash\n parameters_for_generic = @parameters.dup\n parameters_for_generic.delete(key_partial_match) if parameters_for_generic.include?(key_partial_match)\n\n # merge filters from qsp partial text match into POST body filter\n partial_match_filters = parse_qsp_partial_match_text(@parameters, key_partial_match, @text_fields)\n @filter = add_qsp_to_filter(@filter, partial_match_filters, :or)\n\n # merge filters from qsp generic equality match into POST body filter\n qsp_generic_filters = parse_qsp(nil, parameters_for_generic, key_prefix)\n @filter = add_qsp_to_filter(@filter, qsp_generic_filters, :and)\n\n # populate properties with qsp filter spec\n @qsp_text_filter = @parameters[key_partial_match]\n @qsp_generic_filters = {}\n qsp_generic_filters.each do |key, value|\n @qsp_generic_filters[key] = value[:eq]\n end\n\n @paging = parse_paging(@parameters, @default_page, @default_items, @max_items)\n @sorting = parse_sorting(@parameters, @default_sort_order, @default_sort_direction)\n end",
"def prepare(params)\n @query = params[:keywords]\n @sorting = params[:sorting]\n @taxons = params[:taxon] unless params[:taxon].nil?\n @browse_mode = params[:browse_mode] unless params[:browse_mode].nil?\n if params[:search] && params[:search][:price]\n # price\n @price_min = params[:search][:price][:min].to_f\n @price_max = params[:search][:price][:max].to_f\n # properties\n @properties = params[:search][:properties]\n end\n\n @per_page = (params[:per_page].to_i <= 0) ? Spree::Config[:products_per_page] : params[:per_page].to_i\n @page = (params[:page].to_i <= 0) ? 1 : params[:page].to_i\n end",
"def initialize(products, paginator, sortable, filterable)\n @products_list = products\n @paginator = paginator\n @sortable = sortable\n @filterable = filterable\n end",
"def make_pagination_params(options)\n params = {}\n params['Marker'] = options[:marker] if options[:marker]\n params['MaxItems'] = options[:max_items] if options[:max_items]\n params\n end",
"def initialize(params)\n form_params = params.fetch(:search, {})\n\n @q = form_params.fetch(:q, \"\").strip\n @status = form_params.fetch(:status, STATUS_ALL)\n @page = params.fetch(:page, 1)\n @per_page = params.fetch(:per_page, 20)\n end",
"def initialize(attributes={})\n self.filters ||= {}\n super\n end",
"def set_filter_options\n @sort_modes = Organization.sort_modes\n @view_modes = Organization.view_modes\n\n @current_sort_mode = if @sort_modes.keys.include?(params[:sort_by])\n params[:sort_by]\n else\n @sort_modes.keys.first\n end\n\n @current_view_mode = if @view_modes.keys.include?(params[:view])\n params[:view]\n else\n @view_modes.keys.first\n end\n\n @query = params[:query]\n end",
"def paginator=(_arg0); end",
"def paginate_by_filter(opts={})\n paginate(filter_and_sort_options(opts))\n end",
"def pagination_params(page)\n # TODO: include sort params\n {\n :page => page,\n :per_page => per_page\n }.tap do |params|\n params.delete(:per_page) if per_page == default_per_page\n end\n end",
"def resource_filter_permitted_params\n %i[page per_page]\n end",
"def initialize(parameters={})\n @publisher = parameters[:publisher]\n @categories = load_categories_by_name_or_id(@publisher, parameters[:categories])\n @location = lookup_location(parameters[:location])\n @distance = parameters[:distance]\n @distance_unit = parameters[:distance_unit]\n \n @sort_by = parameters[:sort_by]\n @sort_direction = parameters[:sort_direction]\n \n @page = (parameters[:page] || 1).to_i\n @page_size = (parameters[:page_size] || 20).to_i\n end",
"def paginate!(*args) # @private :nodoc:\n options = args.extract_options!\n self.items_per_page = options[:per_page] || 50\n self.current_page = args.first || 1\n self.limit_value = items_per_page\n self.offset_value = items_per_page * (current_page - 1)\n end",
"def set_pagination_info(page_no, page_size, record_count)\n @current_page = page_no\n @page_size = page_size\n @pagination_record_count = record_count\n @page_count = (record_count / page_size.to_f).ceil\n end",
"def initialize(attributes)\n self.filters ||= {}\n super\n end",
"def initialize(attributes)\n self.filters ||= {}\n super\n end",
"def initialize(attributes)\n self.filters ||= {}\n super\n end",
"def initialize(attributes)\n self.filters ||= {}\n super\n end",
"def initialize(attributes)\n self.filters ||= {}\n super\n end",
"def apply_pagination(data)\n data = data.paginate(page: params[:page], per_page: params[:limit])\n end",
"def paginator\n @paginator ||= paginator_klass.new(page_params)\n end",
"def paginate opts = {}\n @paginator = true\n page = (opts[:page] || 1).to_i\n per_page = (opts[:per_page] || 20).to_i\n page = 1 if page < 1\n limit( per_page, ( page - 1 ) * per_page )\n end",
"def initialize\n @all_filters = []\n @errors = []\n @conditions = nil\n filters\n reset\n end",
"def adjust_for_parameters(params)\n params = params[\"filter\"] if params[\"filter\"]\n \n #self.paginate = false\n if params && params[\"paginate\"]\n self.paginate = true\n self.paginate = false if params[\"do_viewall\"]\n elsif params && params[\"viewall\"]\n self.paginate = false\n self.paginate = true if params[\"do_paginate\"]\n end\n \n #--- set up perpage\n if params && params[\"perpage\"]\n self.set_items_per_page(params[:perpage])\n end\n\n params[\"dropdowns\"].each_pair do |name,value|\n dropdowns[name][\"value\"] = value if dropdowns[name]\n end if params && params[\"dropdowns\"] # do params\n \n params[\"custom_fields\"].each_pair do |name,value|\n custom_fields[name][\"value\"] = CUSTOM_DEFAULT_VALUE \n custom_fields[name][\"value\"] = value if custom_fields[name] && value!=CUSTOM_VALUE_FOR_ALL \n end if params && params[\"custom_fields\"] # do params\n \n params[\"boolean_fields\"].each_pair do |name,value|\n boolean_fields[name][\"value\"] = BOOLEAN_VALUE_FOR_ALL \n boolean_fields[name][\"value\"] = value if boolean_fields[name] && value!=BOOLEAN_VALUE_FOR_ALL \n end if params && params[\"boolean_fields\"] # do params\n \n if params[:sort_by] #&& params[:old_sort_by] && params[:old_sort_by_order]\n \n self.sort_by = params[:sort_by]\n self.sort_by_order = params[:old_sort_by_order] == 'ASC' ? 'ASC' : 'DESC'\n if params[:old_sort_by] == params[:sort_by] && params[:sort_by_order_flip] == 'yes'\n self.sort_by_order = params[:old_sort_by_order] == 'DESC' ? 'ASC' : 'DESC' \n end\n \n self.sql_sortorder = \"#{self.sort_by} #{self.sort_by_order}\"\n self.sql_sortorder += \", #{self.secondary_sort}\" unless self.secondary_sort.blank?\n \n end # if sort_order \n \n params[\"dates\"].each_pair do |name,value|\n if dates[name]\n dates[name][\"value\"] = Date.new(\n value[\"date(1i)\"].to_i,\n value[\"date(2i)\"].to_i,\n value[\"date(3i)\"].to_i\n )\n end\n end if params && params[\"dates\"] # do params\n \n self.search_string = RFilter.sanitize_sql(params[\"search_for\"]) if params && params[\"search_for\"]\n\n generate_sql_conditions\n end",
"def set_filters\n filter_param_keys = [\n 'brand', 'color',\n 'size', 'department', 'keywords'\n ]\n @filters = []\n filter_param_keys.each do |key|\n if !params[key].blank?\n params[key].split(',').each do |val|\n @filters << {:key => key, :val => val}\n end\n end\n end\n \n \n if params[:price]\n params[:price].split(',').each_slice(2).to_a.each do |range|\n @filters << {:key => 'price', :val => range.join(',')}\n end\n end\n\n if @products\n @brands = @products.facet('brand_facet').rows.sort_by{ |brand| brand.value.capitalize}\n @departments = @products.facet('department_facet').rows\n end\n \n @colors = ['green', 'blue', 'purple', 'red', 'pink', 'beige', 'brown', 'yellow', 'orange', 'black', 'white', 'gray', 'teal', 'glowing', 'gold', 'silver']\n \n if !@taxon.nil? && @taxon.has_size?\n sizes = (Spree::Product.sizes.sort_by{|size| size.position}.map(&:presentation) & @products.facet(\"size_facet\").rows.map(&:value))\n end\n end",
"def page_params\n end",
"def params\n @pagination.request.query_parameters\n end",
"def new_page_params\n return {} if params[:filter].blank?\n\n params[:filter].permit(:page_num, :length)\n end",
"def paginator; end",
"def index\n if params.count <= 3 && cookies['st_admin_setup']\n CGI.parse(cookies['st_admin_setup']).each{|x|\n name = x[0]\n value = x[1][0]\n params[name] = value\n }\n end\n # Update number of items to show on page (if supplied)\n Page.per_page = params[:per_page].to_i if params[:per_page]\n Page.per_page = 10 if Page.per_page <= 0\n\n @authors = Page.select('DISTINCT(author_id)')\n\n @pages = Page.get_my_pages :user => current_user,\n :page_no => params[:page] || 1,\n :locale => I18n.locale,\n :sort => (\"#{sort_column} #{sort_direction}\"),\n :search => params[:search],\n :flocale => params[:flocale],\n :filter => {:status => params[:status], :page_type => params[:page_type], :author => params[:author]}\n end",
"def set_page_size\n unless params[:per_page].blank?\n cookies[:per_page] = params[:per_page]\n @per_page = params[:per_page]\n else\n @per_page = cookies[:per_page] || 20\n end\n end",
"def initialize()\n @filters ||= []\n end",
"def build_scroll_params(response = nil)\n @page += 1 if response\n @opts[:query_params][:filter] = { skip: @page * @limit, limit: @limit }\n @opts\n end",
"def setup_pager!\n page\n end",
"def initialize(collection, options = {})\n @page = Integer(options[:page] || 1)\n @per_page = Integer(options[:per_page] || Pagination.per_page)\n end",
"def set_pagination_buttons(data, options = {})\n return if data.nil? || data.empty?\n\n if data.next_page\n params = {\n :page => data.next_page,\n :per_page => data.per_page\n }.merge(options)\n\n @next_page = \"?#{Rack::Utils.build_query params}\"\n end\n\n if data.previous_page\n params = {\n :page => data.previous_page,\n :per_page => data.per_page\n }.merge(options)\n\n @prev_page = \"?#{Rack::Utils.build_query params}\"\n end\n end",
"def set_pagination_buttons(data, options = {})\n return if data.nil? || data.empty?\n\n if data.next_page\n params = {\n :page => data.next_page,\n :per_page => data.per_page\n }.merge(options)\n\n @next_page = \"?#{Rack::Utils.build_query params}\"\n end\n\n if data.previous_page\n params = {\n :page => data.previous_page,\n :per_page => data.per_page\n }.merge(options)\n\n @prev_page = \"?#{Rack::Utils.build_query params}\"\n end\n end",
"def pagination=(count)\n settings.pagination = count\n end",
"def paginate!\n paginated?? nil : page!(1)\n end",
"def paginate; false; end",
"def initialize *args\n super *args\n self.page = (page.to_i < 1 ? 1 : page.to_i)\n end",
"def merge_params(number)\n @params.merge(page: { number: number, limit: @per_page })\n end",
"def paginate(options={})\n populate_pagination_attributes_from_options(options)\n limit(per_page)\n offset((page - 1) * per_page)\n self\n end",
"def apply_filter\n offset = (params[:page].to_i - 1) * params[:perpage].to_i\n limit = params[:perpage]\n\n results = get_results(offset, limit)\n result_list = get_fields_to_show(results['elements'])\n \n data = Hash.new\n data['total'] = results['total']\n data['result'] = result_list\n respond_to do |format|\n format.json { render :json => data.to_json }\n end\n end",
"def initialize\n @filters = []\n end",
"def load_records\n get_paging_parameters\n @filter, @subfilter, find_include, find_conditions, @total_records = filter_prepare\n find_order = @sortable_columns.has_key?(@sidx) ? (@sortable_columns[@sidx] + ' ' + ((@sord == 'desc') ? 'DESC' : 'ASC')) :\n (@default_sidx ? @sortable_columns[@default_sidx] + ' ASC' : nil)\n # find_order = @sortable_columns.include?(@sidx) ? (@sidx + ' ' + ((@sord == 'desc') ? 'DESC' : 'ASC')) :\n # (@default_sidx ? @default_sidx + ' ASC' : nil)\n rows_per_page = @rows_per_page\n if rows_per_page > 0\n @total_pages = (@total_records > 0 && rows_per_page > 0) ? 1 + (@total_records/rows_per_page).ceil : 0\n @page = @total_pages if @page > @total_pages\n @page = 1 if @page < 1\n @start_offset = rows_per_page*@page - rows_per_page\n else\n @total_pages = 1\n rows_per_page = @total_records\n @start_offset = 0\n end\n if @start_offset < 0\n puts \"??Why is start_offset negative?\"\n @start_offset = 0\n end\n if @livesearch && @livesearch.size > 0\n livesearch_fields = @livesearch_fields[@livesearch_field] rescue []\n if livesearch_fields.size > 0\n fields_conditions = []\n @livesearch.split(' ').each do |substring|\n live_conditions = [] \n livesearch_fields.each do |f|\n find_conditions << \"%#{substring}%\"\n live_conditions << \"#{f} LIKE ?\" \n end\n fields_conditions << '(' + live_conditions.join(' or ') + ')'\n end\n find_conditions[0] += ' and (' + fields_conditions.join(' and ') + ')'\n end\n end\n puts \"Rows per page #{@rows_per_page}, offset #{@start_offset}, find_order #{find_order}, find_conditions #{find_conditions}, find_include #{find_include}.\"\n scoped_model.find(:all, :include => find_include, :conditions => find_conditions,\n :limit => rows_per_page, :offset => @start_offset, :order => find_order)\n end",
"def page_params\n params.permit(:page, :per_page)\n end",
"def initialize\n @collection = {}\n @filters = []\n end",
"def init_page(request, params)\r\n init_request\r\n end",
"def paginate(options = {})\n raise ArgumentError, \"parameter hash expected (got #{options.inspect})\" unless Hash === options\n\n page = (options[:page] || 1).to_i\n per_page = (options[:per_page] || 30).to_i\n\n @total_entries = count\n @total_pages = (@total_entries / per_page.to_f).ceil\n @current_page = page\n\n query.update(offset: (page - 1) * per_page, limit: per_page)\n\n self\n end",
"def set_activities_for_pagination\n \n end",
"def pagination_range\n case JSONAPI.configuration.default_paginator\n when :paged\n number = page_params['number'].to_i.nonzero? || 1\n size = page_params['size'].to_i.nonzero? || JSONAPI.configuration.default_page_size\n (number - 1) * size..number * size - 1\n when :offset\n offset = page_params['offset'].to_i.nonzero? || 0\n limit = page_params['limit'].to_i.nonzero? || JSONAPI.configuration.default_page_size\n offset..offset + limit - 1\n else\n paginator.pagination_range(page_params)\n end\n end",
"def paginate(current_page, request = nil)\n changed\n @page_criteria = dbi.paginate(current_page,@per_page,:request => request, :pagination_method => @pagination_method)\n notify_observers(:paginate,self,request)\n @page_criteria\n end",
"def prepare_show\n @page = params[:page] || 1\n types = CollectionItem.types\n @collection_item_scopes = [[I18n.t(:selected_items), :selected_items], [I18n.t(:all_items), :all_items]]\n @collection_item_scopes << [I18n.t(\"all_#{types[@filter.to_sym][:i18n_key]}\"), @filter] if @filter\n @recently_visited_collections = Collection.find_all_by_id(recently_visited_collections(@collection.id)) if @collection\n end",
"def load_data(params = {})\n paging_info = parse_paging_options(params)\n # Paginate with Will_paginate.\n self.paginate(:page => paging_info.page_id,\n :per_page => paging_info.page_size,\n :order => paging_info.sort_string)\n end",
"def pagination(items_count, default_per_page: 20,\n maxium_per_page: 100,\n set_header: true)\n items_count = items_count.count if items_count.respond_to? :count\n\n @pagination_per_page = (params[:per_page] || default_per_page).to_i\n @pagination_per_page = maxium_per_page if @pagination_per_page > maxium_per_page\n @pagination_per_page = 1 if @pagination_per_page < 1\n\n items_count = 0 if items_count < 0\n pages_count = (items_count.to_f / @pagination_per_page).ceil\n pages_count = 1 if pages_count < 1\n\n @pagination_items_count = items_count\n @pagination_pages_count = pages_count\n\n @pagination_page = (params[:page] || 1).to_i\n @pagination_page = pages_count if @pagination_page > pages_count\n @pagination_page = 1 if @pagination_page < 1\n\n if current_page > 1\n @pagination_first_page_url = add_or_replace_uri_param(request.url, :page, 1)\n @pagination_prev_page_url = add_or_replace_uri_param(request.url, :page, (current_page > pages_count ? pages_count : current_page - 1))\n end\n\n if current_page < pages_count\n @pagination_next_page_url = add_or_replace_uri_param(request.url, :page, current_page + 1)\n @pagination_last_page_url = add_or_replace_uri_param(request.url, :page, pages_count)\n end\n\n if set_header\n link_headers ||= []\n\n if current_page > 1\n link_headers << \"<#{@pagination_first_page_url}>; rel=\\\"first\\\"\" if @pagination_first_page_url\n link_headers << \"<#{@pagination_prev_page_url}>; rel=\\\"prev\\\"\" if @pagination_prev_page_url\n end\n\n if current_page < pages_count\n link_headers << \"<#{@pagination_next_page_url}>; rel=\\\"next\\\"\" if @pagination_next_page_url\n link_headers << \"<#{@pagination_last_page_url}>; rel=\\\"last\\\"\" if @pagination_last_page_url\n end\n\n link_header = link_headers.join(', ')\n\n if self.respond_to?(:header)\n self.header('Link', link_header)\n self.header('X-Items-Count', items_count.to_s)\n self.header('X-Pages-Count', pages_count.to_s)\n end\n\n if defined?(response) && response.respond_to?(:headers)\n response.headers['Link'] = link_header\n response.headers['X-Items-Count'] = items_count.to_s\n response.headers['X-Pages-Count'] = pages_count.to_s\n end\n end\n end"
] | [
"0.81804955",
"0.7580574",
"0.75481284",
"0.73435843",
"0.7307405",
"0.72276783",
"0.70673984",
"0.70617324",
"0.6955872",
"0.6863854",
"0.68290067",
"0.6822881",
"0.6807381",
"0.6766881",
"0.67356074",
"0.6732658",
"0.67267615",
"0.6671169",
"0.6663352",
"0.6656369",
"0.66431725",
"0.6641953",
"0.6640096",
"0.66269976",
"0.6608517",
"0.6597066",
"0.65827113",
"0.6565114",
"0.65648514",
"0.6547748",
"0.649861",
"0.649067",
"0.6476599",
"0.64628506",
"0.6462844",
"0.64402306",
"0.643069",
"0.6428687",
"0.6423769",
"0.64100665",
"0.6398656",
"0.63969976",
"0.6383834",
"0.6365475",
"0.63531893",
"0.6351579",
"0.633743",
"0.6330642",
"0.6324942",
"0.6321308",
"0.63106877",
"0.6306961",
"0.6304225",
"0.63017815",
"0.62976146",
"0.6294844",
"0.6290646",
"0.6284228",
"0.62818295",
"0.62818295",
"0.62818295",
"0.62818295",
"0.62818295",
"0.6272613",
"0.6268249",
"0.62633896",
"0.6259071",
"0.62555766",
"0.62547433",
"0.62456745",
"0.6235439",
"0.6233499",
"0.62066555",
"0.6201137",
"0.6200034",
"0.6198791",
"0.61944264",
"0.6192029",
"0.61916703",
"0.61912555",
"0.61859214",
"0.61763704",
"0.6170381",
"0.616989",
"0.6158115",
"0.6149069",
"0.612555",
"0.6119172",
"0.6112533",
"0.6103962",
"0.6099561",
"0.60978323",
"0.6082438",
"0.60605365",
"0.6055525",
"0.6044699",
"0.60420305",
"0.6027765",
"0.60272706",
"0.60244286"
] | 0.74732095 | 3 |
Convert the google cloud sql instance representation to "our" representation | def convert_instance(acct, i)
route = ApiResources::Instances.actions[:show].named_routes[:instance_href]
i['href'] = make_href(acct, i['instance'])
i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_instance(instance)\n state = @@INSTANCE_STATE_MAP[instance[\"status\"]]\n Instance.new(\n :id => instance[\"id\"],\n :owner_id => instance[\"owner\"],\n :image_id => instance[\"imageId\"],\n :name => instance[\"name\"],\n :realm_id => instance[\"location\"],\n :state => state,\n :actions => instance_actions_for(state),\n :public_addresses => [ InstanceAddress.new(instance[\"primaryIP\"][\"ip\"]) ],\n :private_addresses => [],\n :instance_profile => InstanceProfile.new(instance[\"instanceType\"].gsub('/', '-')),\n :launch_time => instance[\"launchTime\"],\n :keyname => instance[\"keyName\"]\n )\n end",
"def to_s\n \"RDS DBInstance: #{@dbi_name}\"\n end",
"def to_s\n \"RDS DBInstance: #{@dbi_name}\"\n end",
"def to_s\n \"<Edurange::Instance name:#{@name} ami_id: #{@ami_id} ip: #{@ip_address} key: #{@key_pair} running: #{@running} instance_id: #{@instance_id}>\"\n end",
"def to_s\n \"#{name}\\t#{dns_name}\\t#{instance_id}\"\n end",
"def to_s()\n @sql ||= print_to(Printer.new()).to_s()\n end",
"def convert(value) \n return value.to_formatted_s(:db) if value.respond_to?(:to_formatted_s)\n value.to_s\n end",
"def to_s\n regex = REPLACEMENT\n\n if Gitlab::Database.mysql?\n regex = Regexp.union(regex, MYSQL_REPLACEMENTS)\n end\n\n sql = @sql.gsub(regex, '?').gsub(CONSECUTIVE) do |match|\n \"#{match.count(',') + 1} values\"\n end\n\n # InfluxDB escapes double quotes upon output, so lets get rid of them\n # whenever we can.\n if Gitlab::Database.postgresql?\n sql = sql.delete('\"')\n end\n\n sql.tr(\"\\n\", ' ')\n end",
"def to_bson\n to_h.to_bson\n end",
"def db_instance_class\n data.db_instance_class\n end",
"def to_sql_hash\n { \n 'iso_time' => iso_time,\n 'date' => date,\n 'hostname' => hostname,\n 'process' => process,\n 'pid' => pid,\n 'raw_message' => raw_message\n }\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def db_instance_class\n data[:db_instance_class]\n end",
"def to_db_hash\n db_hsh = {}\n to_hash.each{|k,v| db_hsh[k.to_s] = v.to_s unless v.nil? }\n db_hsh\n end",
"def to_s\n \"<Twilio.Api.V2010.RecordInstance>\"\n end",
"def to_s\n out = ''\n database.each_value do |v|\n out+= \"#{v}\"\n end\n\n out\n end",
"def canonical_instance(opennebula_instance)\n fail 'Instance object not provided!' unless opennebula_instance\n {\n id: opennebula_instance['ID'].to_i,\n name: opennebula_instance['NAME'],\n group: opennebula_instance['GNAME'],\n owner: user_by_id(opennebula_instance['UID']),\n appliance: image_by_id(opennebula_instance['TEMPLATE/DISK[1]/IMAGE_ID']),\n ips: canonical_instance_ips(opennebula_instance),\n identifiers: canonical_instance_identifiers(opennebula_instance),\n host: canonical_instance_host(opennebula_instance),\n state: \"#{opennebula_instance.state_str} - #{opennebula_instance.lcm_state_str}\",\n }\n end",
"def instance_to_json\n\t\t# byebug\n\t\t{\n\t\tid: self.id,\n\t\tname: self.name,\n\t\theight: self.height,\n\t\tlast_watered: self.last_watered,\n\t\tlast_watered_amount: self.last_watered_amount,\n\t\tgrow_zone: self.grow_zone,\n\t\tnotes: self.notes,\n\t\tplanted_date: self.planted_date,\n\t\tfarm: self.farm,\t\n\t\tsensor: self.sensor\n\t\t# farm: { \n\t\t# \tfarm: self.farm.name,\n\t\t# \tfarm: self.farm.id,\n\t\t# },\n\t\t}\n\tend",
"def to_sql\n self.to_datetime.to_sql\n \tend",
"def to_database\n {\n type: self.class.name,\n params: params,\n # account: Current.account,\n }\n\n end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_sequel_blob\n self\n end",
"def to_sequel_blob\n SQL::Blob.new(self)\n end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s\n \"<Twilio.Voice.V1.BulkCountryUpdateInstance>\"\n end",
"def to_s\n return @to_s if @to_s\n parsed = parse_operation\n if parsed\n @to_s = \"#{model}/#{parsed}\"\n else\n @to_s = regex_name(sql)\n end\n end",
"def create_instance_for_env(instance)\n whitelist = [:instance_id, :instance_index, :name, :uris, :users, :version, :start, :runtime, :state_timestamp, :port]\n env_hash = {}\n whitelist.each {|k| env_hash[k] = instance[k] if instance[k]}\n env_hash[:limits] = {\n :fds => instance[:fds_quota],\n :mem => instance[:mem_quota],\n :disk => instance[:disk_quota],\n }\n env_hash[:host] = @local_ip\n env_hash.to_json\n end",
"def to_s\n PgQuery::Deparse.from ast\n end",
"def type_cast_for_schema(value)\n cast(value).value.inspect\n end",
"def to_s\n Psych.dump to_hash\n end",
"def to_h()\n #This is a stub, used for indexing\n end",
"def to_v\n @qry.to_v\n end",
"def to_data\n to_s\n end",
"def db_instance_arn\n data[:db_instance_arn]\n end",
"def from_database_type(obj)\n case obj\n when String, Float, Integer, NilClass, TrueClass, FalseClass\n obj\n when java.sql.Date, java.sql.Time, java.sql.Timestamp\n Time.at(obj.time/1000)\n when java.sql.Blob\n String.from_java_bytes(obj.get_bytes(1,obj.length))\n when java.sql.Clob\n obj.get_sub_string(1, obj.length)\n when java.math.BigDecimal\n BigDecimal.new(obj.to_s)\n else\n raise \"Can't find correct type to convert #{obj.inspect} into\"\n end\n end",
"def instance_class\n @dbi.db_instance_class\n end",
"def instance_class\n @dbi.db_instance_class\n end",
"def db_cluster_instance_class\n data[:db_cluster_instance_class]\n end",
"def to_raw; end",
"def to_ruby\n [key,fields]\n end",
"def to_h\r\n {\r\n \"name\": @name,\r\n \"id\": @id,\r\n \"rev\": @rev,\r\n \"isSmart\": @isSmart,\r\n \"numberOfShards\": @numberOfShards,\r\n \"replicationFactor\": @replicationFactor,\r\n \"smartGraphAttribute\": @smartGraphAttribute,\r\n \"edgeDefinitions\": edgeDefinitionsRaw,\r\n \"orphanCollections\": orphanCollectionsRaw,\r\n \"cache_name\": @cache_name,\r\n \"database\": @database.name\r\n }.delete_if{|k,v| v.nil?}\r\n end",
"def to_mongo_value\n h = {}\n self.class.column_names.each {|iv|\n val = read_attribute(iv)\n h[iv] = val == nil ? nil : val.to_mongo_value\n }\n h\n end",
"def to_sql\n \"timestamp '#{to_s}'\"\n end",
"def to_s\n values = @params.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Api.V2010.DomainInstance #{values}>\"\n end",
"def to_s\n \"From #{@description} [#{@database}]:\\n\\n\" +\n \"#{@definition.inject(''){ |s, l| s << ' ' << l }}\\n\\n\"\n end",
"def type_cast_for_schema(value) # :nodoc:\n value.inspect\n end",
"def type_cast_for_schema(value) # :nodoc:\n value.inspect\n end",
"def result_to_s\n self.class.construct_value @result\n end",
"def instance\n node = 'AWS_EC2_INSTANCE'\n q = []\n\n # instance node\n q.push(_upsert({ node: node, id: @name }))\n\n # vpc node and relationship\n if @data.vpc_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_VPC',\n child_name: @data.vpc_id,\n relationship: 'MEMBER_OF_VPC'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # network_interfaces and relationship\n @data.network_interfaces.each do |ni|\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_NETWORK_INTERFACE',\n child_name: ni.network_interface_id,\n relationship: 'ATTACHED_TO_INSTANCE'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # security_groups and relationship\n @data.security_groups.each do |sg|\n opts = {\n child_node: 'AWS_SECURITY_GROUP',\n child_name: sg.group_id,\n parent_node: node,\n parent_name: @name,\n relationship: 'IN_SECURITY_GROUP'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # subnet and relationship\n if @data.subnet_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_SUBNET',\n # child_name: \"arn:aws:ec2:#{@region}:#{@account}:subnet/#{@data.subnet_id}\",\n child_name: @data.subnet_id,\n relationship: 'IN_SUBNET'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n if @data.iam_instance_profile\n opts = {\n node: 'AWS_EC2_IAM_PROFILE',\n id: @data.iam_instance_profile.arn\n }\n\n q.push(_merge(opts))\n\n opts = {\n from_node: node,\n from_name: @name,\n to_node: 'AWS_EC2_IAM_PROFILE',\n to_name: @data.iam_instance_profile.arn,\n relationship: 'HAS_IAM_PROFILE'\n }\n\n q.push(_link(opts))\n end\n\n if @data.metadata_options\n metadata_options = \"#{@name}-metadata-options\"\n\n opts = {\n node: 'AWS_EC2_INSTANCE_METADATA_OPTIONS',\n id: metadata_options\n }\n\n q.push(_merge(opts))\n\n opts = {\n from_node: node,\n from_name: @name,\n to_node: 'AWS_EC2_INSTANCE_METADATA_OPTIONS',\n to_name: metadata_options,\n relationship: 'HAS_METADATA_OPTIONS',\n relationship_attributes: @data.metadata_options.to_h\n }\n\n q.push(_link(opts))\n end\n\n q\n end",
"def to_s(ds)\n ds.subscript_sql(self)\n end",
"def queryAndConvert() \n\t\tres = self.query()\n\t\treturn res.convert()\n end",
"def instance_data\n @instance_data ||= JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def strclass() @records.get_data(GRT_STRCLASS); end",
"def type_to_sql(*args); connection.type_to_sql(*args); end",
"def to_s\n \"<Twilio.Supersim.V1.SimIpAddressInstance>\"\n end",
"def serialize(row)\n row\n .map { |c| db_format(c) }\n .join(\",\")\nend",
"def to_s\n self.query.to_s\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end"
] | [
"0.6233626",
"0.62113255",
"0.62113255",
"0.60122085",
"0.5929376",
"0.54381394",
"0.5413843",
"0.53734714",
"0.5343331",
"0.53222305",
"0.5285177",
"0.52780044",
"0.52780044",
"0.52780044",
"0.52718884",
"0.5271502",
"0.5270497",
"0.5235592",
"0.5227139",
"0.5199248",
"0.5184022",
"0.5172743",
"0.5161448",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5119791",
"0.5104514",
"0.5099324",
"0.5095533",
"0.5095533",
"0.5095533",
"0.5051588",
"0.5050686",
"0.50377285",
"0.5029809",
"0.50228155",
"0.5021154",
"0.5012688",
"0.49990717",
"0.49959356",
"0.49945015",
"0.4976315",
"0.49718326",
"0.49718326",
"0.49707186",
"0.49702495",
"0.49621415",
"0.49616146",
"0.49609515",
"0.4958882",
"0.4956488",
"0.49541587",
"0.49532944",
"0.4953233",
"0.4941854",
"0.49418464",
"0.49280834",
"0.4924469",
"0.49203888",
"0.49152285",
"0.49119854",
"0.49117854",
"0.48998004",
"0.48961034",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815",
"0.48948815"
] | 0.0 | -1 |
and returns the average of all numbers in the array. The array will never be empty and the numbers will always be positive integers. in: array of ints out: average of ints assume: array will not be empty, ints always pos logic: create sum variable and divide by length of array | def average(ary)
ary.sum / ary.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average(array)\n sum = 0\n array.each do |int|\n sum += int\n end\n sum / array.length\nend",
"def average(integer_array)\n sum = integer_array.sum\n average = sum / integer_array.size\nend",
"def average(array)\n i = 0\n sum = 0\n while i < array.length\n sum += array[i].to_int\n i += 1\n end\n return (sum.to_f / array.length.to_f)\nend",
"def average(array)\n return 0 if array.empty?\n array.sum / array.size\nend",
"def average(array)\n sum = 0\n\n if array.empty? || array.index {|x| x > 0} == 1\n puts \"Your array may be empty or contain negative intergers\"\n else\n array.each do |int|\n sum +=int\n end\n sum /= array.size\n end\nend",
"def average\n @array.inject(0.0) {|total, n| total + n} / @array.size\n end",
"def average(array)\n if array.size <= 0\n return 0.0\n end\n return sum(array) / array.size\nend",
"def average_array(array)\n array.each do |ele|\n raise \"All member must be numbers\" if !(ele.instance_of?(Integer))\n end\n\n array.sum / array.length.to_f\nend",
"def find_average \n result = array.sum(0.0)/array.size\n return result\n end",
"def average(num_array)\n sum = 0\n num_array.each { |num| sum += num }\n sum / num_array.length\nend",
"def array_average arr\n arr_sum = 0.0\n\n arr.each do |num|\n arr_sum += num\n end\n\n arr_avg = arr_sum / arr.size\nend",
"def average (array)\n if array.empty? then\n 0\n else\n (sum(array)/array.size)\n end\nend",
"def average(array)\n sum = 0\n array.each { |value| sum += value }\n sum / array.length\nend",
"def average(array)\n total = 0\n array.each do |num|\n total += num\n end\n total.to_f / array.size\nend",
"def average(array)\n total = 0\n array.each do |number|\n total = total + number\n end\n total / array.size\nend",
"def average_of_array(array)\n\tn = [10, 15, 25]\n\taverage = n.inject(0.0) { | total, num | total + num } / n.count\n\taverage.round\nend",
"def average(array)\n total = 0\n array.each { |num| total += num }\n total / array.length\nend",
"def average_of_array(array)\n sum = 0\n array.each {|x|\n sum += x\n }\n (sum.round(2) / array.size).round\nend",
"def average(array)\n sum = 0\n array.each { |n| sum += n }\n average = sum / array.count\nend",
"def average(input_array)\n sum = 0\n \n input_array.each {|num| sum += num}\n \n average = sum.to_f/input_array.length\nend",
"def calc_mean(ary)\n if !ary.is_a?(Array)\n 0\n elsif ary.empty?\n 0\n else\n # Your code goes here \n\n #add the numbers \n #divide by the amount of numbers in array\n temp = 0\n ary.each do |index|\n temp = temp + index\n\n end\n\n mean = temp / ary.size\n\n return mean\n end\nend",
"def average_of_array(array)\n (array.sum).to_f / (array.length)\nend",
"def average(array)\n total = 0\n array.each do |number|\n total += number\n end\n total / array.length\nend",
"def average(arr)\n int = 0\n arr.each { |num| int += num }\n int / arr.length.to_f\nend",
"def average(array)\n result = array.inject { |sum, n| sum + n }\n result / array.size\nend",
"def average(input_array)\n n = input_array.length\n sum = 0 \n\n input_array.each do |num|\n sum = sum + num\n end\n average_of_array = sum.to_f / n\nend",
"def average(array)\n array.inject(&:+) / array.length\n end",
"def mean(arr)\n return 0 if arr.empty?\n sum = 0\n\n arr.each do |num|\n sum = sum + num\n end\n \n sum / arr.count\nend",
"def average_of_array(array)\n (array.inject(:+) / array.size.to_f).round\nend",
"def average(array)\n sum = 0\n array.each { |x| sum += x }\n (sum / array.count).to_f\nend",
"def average_of_array(array)\n (1.0*array.inject{|sum, ele| sum + ele}/array.length).round(0)\nend",
"def average(array)\n array.inject(:+).to_f / array.size\nend",
"def mean array\n length = array.length\n sum = 0 \n array.each do |x|\n sum += x\n end\n sum / length\nend",
"def average(array)\n if !array.is_a?(Array)\n return nil\n else \n sum = 0\n array.each do |i|\n sum += i\n end\n return sum / (array.length * 1.0)\n end\nend",
"def average(anArray)\n avg = 0\n sum = sum(anArray)\n if (anArray.length > 0) then\n avg = sum / anArray.length\n else\n return 0\n end\nend",
"def average arr\n sum = 0\n arr.each {|i| sum += i}\n average = sum/(arr.size) \nend",
"def avg(input_array)\n n = input_array.size \n sum = 0 \n n.times{|x|\n sum = sum + input_array[x]\n }\n return ((sum/n).to_f)\n end",
"def average (anArray)\n if (anArray.length <= 0)\n return 0.0;\n else\n return sum(anArray) / anArray.length;\n end\nend",
"def average(arr)\n output = 0\n i = 0\n while i < arr.length\n output += arr[i].to_i\n i += 1\n end\n output = output/arr.length\n return output.to_f\nend",
"def average(input_array)\n i = 0\n sum = 0\n while i < input_array.length\n sum += input_array[i]\n i += 1\n end\n\n average = sum.to_f/input_array.length\nend",
"def average(array)\n sum = array.reduce(:+)\n sum.to_f / array.size.to_f\nend",
"def average(array)\n result = array.inject(:+)\n result / array.count\nend",
"def average_array(arr)\n\n i = 0\n sum = 0\n avg = 0.0\n\n while i < arr.length\n\n old = arr[i]\n\n sum += old \n\n i += 1\n end\n\n avg = sum / arr.length.to_f\n\n return avg\nend",
"def average(arr)\n sum = arr.reduce(:+)\n sum / arr.size\nend",
"def average_of_array(array)\n sum_of_array = array.inject{ |x, y| x + y }.to_f\n (sum_of_array.to_f/array.length).round\nend",
"def average(array)\n index = 0\n sum = 0\n while index < array.length\n sum += array[index]\n index += 1 \n end\n sum = sum / array.length.to_f\nend",
"def mean(array)\n total = array.inject(0) {|sum, x| sum += x}\n # use to_f to avoid get integer result\n return total.to_f / array.length\nend",
"def non_zero_array_average(arr)\n debug_puts \"average of the entire array = #{arr.inject{ |sum, el| sum + el }.to_f / arr.size}\"\n arr.delete(0)\n debug_puts \"average of the non-zero numbers in the array = #{arr.inject{ |sum, el| sum + el }.to_f / arr.size}\"\n return arr.inject{ |sum, el| sum + el }.to_f / arr.size\n end",
"def average(array)\n return sum(array)/array.length \nend",
"def average(array)\n array.sum / array.size.to_f\nend",
"def average\n check_numeric_array!\n a = numerify\n a.sum / length.to_f\n end",
"def average(arr)\n arr.reduce(:+).to_f / arr.size\nend",
"def average(arr)\n output = 0\n i = 0\n while i < arr.length\n output += arr[i]\n i += 1\n end\n output = output.to_f/arr.length\n return output\nend",
"def average(anArray)\n if anArray.empty? then\n return 0.0\n else\n return sum(anArray) / anArray.size\n end \nend",
"def averages(array)\n return [] if !array.is_a? Array\n averages_array = []\n array.each_index do |index|\n unless array[index + 1].nil?\n sum = (array[index] + array[index + 1])\n sum % 2 == 0 ? averages_array << sum / 2 : averages_array << sum / 2.0\n end\n end\n averages_array\nend",
"def find_average(array)\n array.sum / array.size.to_f\nend",
"def average(array)\n array.reduce(:+) / array.size\nend",
"def average(array)\n array.reduce(:+) / array.size\nend",
"def average(array)\n average = array.sum / array.count\nend",
"def mean array\n array.inject(:+).to_f / array.length.to_f\n end",
"def average(arr)\n sum = arr.reduce(:+).to_f \n sum / arr.size\nend",
"def average(integer_array)\n sum = 0\n integer_array.each do |number|\n sum << sum += number\n end\n sum\nend",
"def average(array)\n array.sum / array.length\nend",
"def average(array)\n (array.reduce(&:+) / array.length.to_f).round(2)\nend",
"def mean(array)\n total = 0.0\n array.each do |value|\n total += value\n end\n total / array.size\nend",
"def average(arr)\n (arr.sum.to_f / arr.size).round(2)\nend",
"def average(arr)\n arr.sum / arr.size\nend",
"def average(num_arr)\n (num_arr.sum/num_arr.length).to_f\nend",
"def average(array)\n array.reduce(:+) / array.length\nend",
"def average (anArray)\n\n\t#if the array is empty...\n\tif anArray.empty?\n\t\treturn 0.0\n\n\t# otherwise, return the sum divided by the number of values\n\telse\n\t\treturn sum(anArray) / anArray.size\n\tend\nend",
"def average(arr)\n (arr.sum / arr.length.to_f).round(2)\nend",
"def average(arr)\n arr.inject(:+) / arr.length\nend",
"def average(arr)\n arr.sum / arr.length\nend",
"def average(arr)\n arr.sum / arr.length\nend",
"def average(arr)\n arr.sum / arr.length\nend",
"def mean(array)\n array.sum(0.0) / array.size\nend",
"def average(array)\n puts array.sum.to_f / array.length\nend",
"def calcAvg(numArray)\n\tresult = 0;\n\t\n\t# Check to see if our array is empty\n\tif (numArray.length() > 0)\n\t\tresult = calcTotal(numArray) / numArray.length().to_f();\n\tend\n\t\n\treturn result;\nend",
"def average (array_of_integers)\n\n # Establish default return value\n average_value = 0.0\n\n # If 2 or fewer elements, just return default value\n if array_of_integers.size > 2\n\n # Delete minimum\n array_of_integers.delete_at(array_of_integers.index(array_of_integers.min))\n\n # Delete maximum\n array_of_integers.delete_at(array_of_integers.index(array_of_integers.max))\n\n # Compute average of remaining elements\n sum_of_values = array_of_integers.inject(&:+)\n average_value = sum_of_values.to_f / array_of_integers.size\n\n end\n\n # Return\n return average_value\n\nend",
"def mean(array)\n array.inject(:+).to_f / array.size\nend",
"def average(array)\n \n sum = 0\n array.each do |element|\n sum = sum + element\n end\n puts \"The sum is #{sum}\"\n puts \"The array size is #{array.size}\"\n puts \"The average is #{(sum / array.size)}\"\n return (sum / array.size)\nend",
"def findAverage arr\n sum = 0\n for ocenka in arr do\n sum = sum + ocenka \n \n end\n average = sum / arr.length\n return average\nend",
"def mean(array)\n total = 0\n array.each { |i| total+= i.to_f }\n total / array.count\n puts total\nend",
"def mean( array )\n sum( array ) / array.size\nend",
"def averagefloat(array)\n totalval = 0\n array.each { |x| totalval += x }\n totalval / array.length.to_f\nend",
"def average(anArray)\n\tif anArray.size > 0 then\n\t\treturn sum(anArray) / anArray.size\n\telse\n\t\treturn 0.0\n\tend\nend",
"def mean(array)\n\ttotal = 0\n\tarray.each do |x|\n\t\ttotal = total + x\n\tend\n\tmean = total.to_f / array.count\n\tputs mean\nend",
"def average(arry)\n sum = 0\n size = arry.size\n \n for num in arry \n sum += num\n end\n \n sum / size\nend",
"def average numbers\n ave = numbers.reduce 0 do |total, number|\n sum = (total + number)\n end\n ave / numbers.length.to_f\nend",
"def mean(arr)\n arr.reduce(:+) / arr.size\nend",
"def mean(ary)\n # your implementation here\n avg = ary.reduce(0) {|item,acc| acc + item} / ary.length\n avg\nend",
"def average(arr)\ncounting_variable = 0\narr.each {|element| counting_variable += element }\ncounting_variable / arr.length\nend",
"def average numbers\n avg = numbers.reduce 0 do |total, num|\n total + num\n end\n return avg / numbers.length.to_f\nend",
"def average(arr)\n total = 0\n arr.select do |num|\n total += num\n end\n average = total / arr.length\nend",
"def mean(ary)\n ary.inject(0) { |sum, i| sum += i }/ary.length.to_f \nend",
"def average(integers)\n sum = integers.reduce(:+)\n sum / integers.size\nend",
"def average numbers\n average = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n average.inject{ |sum, el| sum + el }.to_f / average.size\nend",
"def average numbers\n sum = numbers.reduce 0.0 do |total, number| #im using 0.0 to go directly into floats\n total + number\n end\n sum / numbers.length\nend",
"def average(ary)\n ary.inject(&:+) / ary.size\nend",
"def get_average(arr)\n\tputs arr.reduce(:+)/arr.length\nend"
] | [
"0.8394138",
"0.83514893",
"0.8273032",
"0.82706636",
"0.82688683",
"0.8222824",
"0.8210271",
"0.81731826",
"0.81629723",
"0.81601846",
"0.81511325",
"0.81434655",
"0.8141863",
"0.8136513",
"0.8120261",
"0.8109243",
"0.8104943",
"0.81039983",
"0.8096044",
"0.809392",
"0.80931425",
"0.8085667",
"0.80844945",
"0.8059816",
"0.80523336",
"0.8048838",
"0.8044598",
"0.80424786",
"0.8034456",
"0.80163175",
"0.8009091",
"0.79954445",
"0.7983351",
"0.79832697",
"0.7983063",
"0.79822826",
"0.798187",
"0.79558015",
"0.7944087",
"0.79419655",
"0.79378337",
"0.79207975",
"0.79190904",
"0.79023165",
"0.7897607",
"0.78939295",
"0.7891454",
"0.7878988",
"0.7870495",
"0.78662914",
"0.7863354",
"0.7857498",
"0.7857484",
"0.7851159",
"0.7846916",
"0.78436357",
"0.7834188",
"0.7834188",
"0.7823846",
"0.7821777",
"0.78214246",
"0.7800617",
"0.77938837",
"0.7791094",
"0.77910864",
"0.77824396",
"0.776862",
"0.7757342",
"0.7753361",
"0.77474004",
"0.7731591",
"0.7726966",
"0.77178746",
"0.77178746",
"0.77178746",
"0.7714199",
"0.7711489",
"0.7705768",
"0.7702439",
"0.7700719",
"0.76940376",
"0.7691981",
"0.7690664",
"0.7665676",
"0.7660093",
"0.7650368",
"0.7642197",
"0.76220936",
"0.76173794",
"0.7616347",
"0.76099485",
"0.7599508",
"0.75604725",
"0.7541027",
"0.7527821",
"0.7516924",
"0.7516328",
"0.7499752",
"0.7468214",
"0.7460558"
] | 0.75944585 | 92 |
GET /action_states GET /action_states.json | def index
@action_states = ActionState.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def index\n @api_states = Api::State.all\n end",
"def index\n @states = State.all\n \n render json: @states\n end",
"def index\n @states = State.all\n respond_with(@states)\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @event_states = EventState.all\n end",
"def index\n @page_title = 'States'\n @states = State.all\n end",
"def index\n @states = State.order(\"name\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @states }\n end\n end",
"def index\n @project_states = ProjectState.all\n json_response(@project_states)\n end",
"def _region_states(region_id)\n get('region/states', region_id)\n end",
"def states\n (['show'] + actions).uniq\n end",
"def show\n render json: @state\n end",
"def device_states_list\n get \"deviceStates\"\n end",
"def index\n @user_states = UserState.all\n end",
"def index\n @user_states = UserState.all\n end",
"def states\n @attributes[\"data\"][\"states\"]\n end",
"def states\r\n @states.collect {|id| $data_states[id] }\r\n end",
"def index\n @asset_states = AssetState.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asset_states }\n end\n end",
"def index\n @states = @country.states.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @states }\n end\n end",
"def states\n []\n end",
"def states\n []\n end",
"def index\n @sprint_states = SprintState.all\n end",
"def states\n @states ||= {}\n end",
"def show\n @state = State.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @state }\n end\n end",
"def show\n @state = State.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @state }\n end\n end",
"def search\n @states = State::ALL_STATES\n end",
"def states\n @finity.states.map { |name, _| name }\n end",
"def index\n @task_states = TaskState.all\n end",
"def show\n \n @states = State.find(:all)\n @state = State.find(params[:id], :include => [ { :offices => :office_type }, {:offices => :incumbents }])\n @us_senator_offices = []\n @us_rep_offices = []\n @state_senator_offices = []\n @state_rep_offices = []\n @state.offices.each do |o|\n case o.office_type.ukey\n when 'US_SENATOR'\n @us_senator_offices.push(o)\n when 'US_REP'\n @us_rep_offices.push(o)\n when 'HOUSE_DELEGATE'\n @us_rep_offices.push(o)\n when 'STATE_SENATOR'\n @state_senator_offices.push(o)\n when 'STATE_REP'\n @state_rep_offices.push(o)\n end\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @state }\n end\n end",
"def show\n @map_state = MapState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @map_state }\n end\n end",
"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 index\n @state_types = StateType.all\n end",
"def get_state\n \"Treasury state: #{@resources}\"\n end",
"def index\n @modelstates = Modelstate.all\n end",
"def states\n [\n ['0', 'TEST_ACTION_LOADED', 'Test state been loaded into DB']\n ]\n end",
"def actions\n return @actions if @actions\n @actions = Client.get(\"/organizations/#{id}/actions\").json_into(Action)\n end",
"def us_states\n response = get('AllUSStates')\n StoreStatesSerializer.new([]).from_xml(response) #.map(&:state)\n end",
"def get_actions_for_state(a_state)\r\n \tactions_list=Array.new\t\r\n \tself.adjacency_matrix[a_state].each do |a_transition|\r\n \t\tactions_list.push a_transition.action\t\r\n \tend # end each\r\n \t\r\n \treturn actions_list\t\r\n end",
"def index\n @locations = Location.find(:all, :order => 'state, name ASC')\n @states = []\n @locations.each do |loc|\n @states << loc.state unless loc.state.nil?\n end\n @states.uniq!\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end",
"def index\n @states_assigns = StatesAssign.all\n end",
"def states\n render :partial => 'state_option', :collection => State.all\n end",
"def show\n @state = State.find(params[:id])\n end",
"def index\n @program_states = ProgramState.all\n end",
"def index\n @receipt_states = ReceiptState.all\n end",
"def state\n params['state']\n end",
"def states; end",
"def get_state\n send_request(FUNCTION_GET_STATE, [], '', 2, '? ?')\n end",
"def states; @_hegemon_states.keys; end",
"def display_all_waiaria_states\n # Interface method\n end",
"def set_action_state\n @action_state = ActionState.find(params[:id])\n end",
"def query_contact_states(options = nil)\n require_relative 'contactservicestate'\n @api.cursor(ContactServiceState, get_base_api_path() + \"/states\", options)\n end",
"def index\n @surgery_states = SurgeryState.all\n end",
"def update\n respond_to do |format|\n if @action_state.update(action_state_params)\n format.html { redirect_to [project, @action_state], notice: 'Action state was successfully updated.' }\n format.json { render :show, status: :ok, location: @action_state }\n end\n end\n end",
"def index\n @action_names = ActionName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @action_names }\n end\n end",
"def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end",
"def all_state(id)\n $app_sessions[id][:state]\nend",
"def action_state=(value)\n @action_state = value\n end",
"def create\n @action_state = ActionState.new(action_state_params)\n\n respond_to do |format|\n if @action_state.save\n format.html { redirect_to [project, @action_state], notice: 'Action state was successfully created.' }\n format.json { render :show, status: :created, location: @action_state }\n end\n end\n end",
"def index\n @tutorial_states = Tutorial::State.all\n\n respond_to do |format|\n format.html do\n @tutorial_states = Tutorial::State.paginate(:page => params[:page], :per_page => 50) \n @paginate = true \n end\n format.json { render json: @tutorial_states }\n end\n end",
"def states\n\t[:shelf,:in_use,:borrowed,:misplaced,:lost]\nend",
"def index\n @host_states = HostState.all\n end",
"def show\n @goal_state = GoalState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal_state }\n end\n end",
"def index\n @states = State.sorted # sorted defined in model, creating instance variable @states\n end",
"def states(refresh=false)\n @states ||= []\n assert_states if refresh\n @states\n end",
"def show\n init_au_states(:all);\n respond_to do |format| \n respond_do(format, @collection)\n end \n end",
"def pull_states\n render template: 'responses/pull_states.xml.builder', layout: false\n end",
"def show\n @state = @country.states.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @state }\n end\n end",
"def show\n json_response(@project_state)\n end",
"def available_transitions_from(state)\n find_all_transitions(:from_state => state)\n end",
"def action_state\n return @action_state\n end",
"def list\n List.from_response client.get(\"/actions/#{action_id}/list\")\n end",
"def state\r\n\t\t\t`#{BITS::BITSADMIN} /getstate {#{@id}}`\r\n\t\tend",
"def index\n @federal_states = FederalState.all\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_state\n@state.keys\nend",
"def index\n# @states = State.all\n#pagination:\n\t@states = State.all.paginate :per_page => 5, :page => params[:page]\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @states }\n end\n end",
"def list_alert_state(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/alerts_state'\n\t\targs[:query]['Action'] = 'ListAlertState'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :alert_name\n\t\t\targs[:query]['AlertName'] = optional[:alert_name]\n\t\tend\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :start_time\n\t\t\targs[:query]['StartTime'] = optional[:start_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def state_list(states)\n ul(states.map { |s| state_short s })\n end",
"def index\n @state = State.find(params[:state_id])\n @cities = City.where(:state_id => params[:state_id]).paginate(:page => params[:page], :per_page => 10, :order => 'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cities }\n end\n end",
"def _lex_to_state_actions; end",
"def _lex_to_state_actions; end",
"def _lex_to_state_actions; end",
"def _lex_to_state_actions; end",
"def state_list\n @state_list=State.find_all_by_country_id(params[:city][:value])\n end",
"def known_states; end",
"def known_states; end",
"def known_states; end",
"def get_states(user, ids)\n _coordinator.get_states(user, ids)\n end",
"def edit\n @event = Event.find(params[:id])\n @states = ['AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN',\n 'IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV',\n 'NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN',\n 'TX','UT','VT','VA','WA','WV','WI','WY']\n end",
"def index\n @state = params[:state]\n if params[:state]\n @elections = Election.where(state: params[:state])\n else\n @elections = Election.all\n end\n end",
"def index\n @ticketstates = Ticketstate.all\n end",
"def to_states; end",
"def to_states; end",
"def states *args, &block\n valid_unless_nested()\n each_state_or_event 'state', *args, &block\n end",
"def orderStates\n @states = Hash.new\n @states[0] = \"Processing\"\n @states[1] = \"Shipped\"\n @states[2] = \"Delivered\"\n @states[3] = \"Cancelled\"\n end"
] | [
"0.7573909",
"0.7290489",
"0.7100373",
"0.6914498",
"0.68387026",
"0.68236977",
"0.68236977",
"0.68236977",
"0.68236977",
"0.68236977",
"0.6608056",
"0.6543935",
"0.65251696",
"0.6519283",
"0.64381415",
"0.6428163",
"0.6417171",
"0.6399927",
"0.63791746",
"0.63791746",
"0.63665384",
"0.63656485",
"0.6361189",
"0.6343378",
"0.62408763",
"0.62408763",
"0.62313724",
"0.61758506",
"0.6174284",
"0.6174284",
"0.6171993",
"0.6141437",
"0.6111778",
"0.61112416",
"0.60289025",
"0.6009456",
"0.60083765",
"0.5966394",
"0.59508675",
"0.59325874",
"0.5929195",
"0.5926918",
"0.5914758",
"0.5910335",
"0.58991015",
"0.58939356",
"0.5881007",
"0.58769727",
"0.58697194",
"0.58670425",
"0.5860428",
"0.5835198",
"0.58349174",
"0.5830653",
"0.58164674",
"0.5800465",
"0.57986975",
"0.5796949",
"0.5791376",
"0.5790343",
"0.57798207",
"0.5775613",
"0.5762481",
"0.576205",
"0.5757671",
"0.57483983",
"0.57375014",
"0.5733179",
"0.5732479",
"0.5728173",
"0.5727002",
"0.5721698",
"0.57189035",
"0.57175785",
"0.57137245",
"0.5710983",
"0.57032305",
"0.5702423",
"0.56983525",
"0.5690934",
"0.5688804",
"0.568879",
"0.5687315",
"0.5675318",
"0.5673915",
"0.5673915",
"0.5673915",
"0.5673915",
"0.5669144",
"0.56588006",
"0.56588006",
"0.56588006",
"0.56503725",
"0.56445515",
"0.5640161",
"0.5630457",
"0.56271505",
"0.56271505",
"0.56251264",
"0.560398"
] | 0.7819178 | 0 |
GET /action_states/1 GET /action_states/1.json | def show
respond_to do |format|
format.html { render :show }
format.text do
data = LuaScript::Dumper.dump_with_func('actionstate', @action_state.for_lua).encode('Shift_JIS')
name = @action_state.chara + '.lua'
send_data(data, filename: name)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def index\n @action_states = ActionState.all\n end",
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def index\n @states = State.all\n \n render json: @states\n end",
"def index\n @api_states = Api::State.all\n end",
"def show\n @state = State.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @state }\n end\n end",
"def show\n @state = State.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @state }\n end\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def show\n render json: @state\n end",
"def index\n @states = State.all\n respond_with(@states)\n end",
"def index\n @states = State.order(\"name\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @states }\n end\n end",
"def show\n @map_state = MapState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @map_state }\n end\n end",
"def index\n @page_title = 'States'\n @states = State.all\n end",
"def index\n @project_states = ProjectState.all\n json_response(@project_states)\n end",
"def show\n @state = State.find(params[:id])\n end",
"def index\n @asset_states = AssetState.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @asset_states }\n end\n end",
"def index\n @event_states = EventState.all\n end",
"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 index\n @states = @country.states.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @states }\n end\n end",
"def show\n @goal_state = GoalState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal_state }\n end\n end",
"def show\n @state = @country.states.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @state }\n end\n end",
"def index\n @user_states = UserState.all\n end",
"def index\n @user_states = UserState.all\n end",
"def show\n \n @states = State.find(:all)\n @state = State.find(params[:id], :include => [ { :offices => :office_type }, {:offices => :incumbents }])\n @us_senator_offices = []\n @us_rep_offices = []\n @state_senator_offices = []\n @state_rep_offices = []\n @state.offices.each do |o|\n case o.office_type.ukey\n when 'US_SENATOR'\n @us_senator_offices.push(o)\n when 'US_REP'\n @us_rep_offices.push(o)\n when 'HOUSE_DELEGATE'\n @us_rep_offices.push(o)\n when 'STATE_SENATOR'\n @state_senator_offices.push(o)\n when 'STATE_REP'\n @state_rep_offices.push(o)\n end\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @state }\n end\n end",
"def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end",
"def show\n @expense_state = ExpenseState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @expense_state }\n end\n end",
"def create\n @action_state = ActionState.new(action_state_params)\n\n respond_to do |format|\n if @action_state.save\n format.html { redirect_to [project, @action_state], notice: 'Action state was successfully created.' }\n format.json { render :show, status: :created, location: @action_state }\n end\n end\n end",
"def index\n @sprint_states = SprintState.all\n end",
"def index\n @state_types = StateType.all\n end",
"def _region_states(region_id)\n get('region/states', region_id)\n end",
"def show\n json_response(@project_state)\n end",
"def set_action_state\n @action_state = ActionState.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @action_state.update(action_state_params)\n format.html { redirect_to [project, @action_state], notice: 'Action state was successfully updated.' }\n format.json { render :show, status: :ok, location: @action_state }\n end\n end\n end",
"def show\n #@leader = Leader.find_by_slug(params[:id])\n #@state = State.find_by_slug(params[:id])\n #debugger\n render json: @state\n #render json: @state\n #debugger\n #raise @state.inspect\n #@state = @leader.state\n end",
"def state\n params['state']\n end",
"def state\r\n\t\t\t`#{BITS::BITSADMIN} /getstate {#{@id}}`\r\n\t\tend",
"def get_state\n \"Treasury state: #{@resources}\"\n end",
"def states\n (['show'] + actions).uniq\n end",
"def byState\n @companies = Company.where(\"state_id = ?\", company_params[:state_id])\n\n render json: @companies\n end",
"def search\n @states = State::ALL_STATES\n end",
"def show\n @state = State.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @state }\n end\n end",
"def get_state\n send_request(FUNCTION_GET_STATE, [], '', 2, '? ?')\n end",
"def index\n @task_states = TaskState.all\n end",
"def show\n @tender_state = TenderState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tender_state }\n end\n end",
"def index\n @modelstates = Modelstate.all\n end",
"def index\n @locations = Location.find(:all, :order => 'state, name ASC')\n @states = []\n @locations.each do |loc|\n @states << loc.state unless loc.state.nil?\n end\n @states.uniq!\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end",
"def show\n @asset_state = AssetState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset_state }\n end\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 specific\n @state = State.find(params[:id])\n @loans = @state.loans.where(:purpose_id == params[:purpose_id])\n render json: { state: @state, loans: @loans }\n end",
"def show\n init_au_states(:all);\n respond_to do |format| \n respond_do(format, @collection)\n end \n end",
"def index\n @state = State.find(params[:state_id])\n @cities = City.where(:state_id => params[:state_id]).paginate(:page => params[:page], :per_page => 10, :order => 'name')\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cities }\n end\n end",
"def byState\n @company_types = CompanyType.where(\"state_id = ?\", company_type_params[:state_id])\n\n render json: @company_types\n end",
"def index\n @program_states = ProgramState.all\n end",
"def states\n []\n end",
"def states\n []\n end",
"def index\n @states_assigns = StatesAssign.all\n end",
"def device_states_list\n get \"deviceStates\"\n end",
"def states\r\n @states.collect {|id| $data_states[id] }\r\n end",
"def index\n @receipt_states = ReceiptState.all\n end",
"def index\n @action_names = ActionName.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @action_names }\n end\n end",
"def show\n @psa_state = PsaState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @psa_state }\n end\n end",
"def index\n @tutorial_states = Tutorial::State.all\n\n respond_to do |format|\n format.html do\n @tutorial_states = Tutorial::State.paginate(:page => params[:page], :per_page => 50) \n @paginate = true \n end\n format.json { render json: @tutorial_states }\n end\n end",
"def states\n render :partial => 'state_option', :collection => State.all\n end",
"def states\n @states ||= {}\n end",
"def all_state(id)\n $app_sessions[id][:state]\nend",
"def states\n @attributes[\"data\"][\"states\"]\n end",
"def view\n\t@country = Country.all\n @state = State.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @state }\n end\n end",
"def show\n @unemployment_form = UnemploymentForm.find(params[:id])\n @states = State.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unemployment_form }\n end\n end",
"def find_kanban_state_id\n issues_status_id = params[:issue_status_id]\n issue_states = IssueStatusKanbanState.where(:issue_status_id=>issues_status_id)\n if issue_states.present?\n kanban_state_id = issue_states.map(&:kanban_state_id).first\n end\n\n if request.xhr?\n render :json => {\n :kanban_state_id=> kanban_state_id\n }\n end\n\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 show\n @sectioneight_form = SectioneightForm.find(params[:id])\n @states = State.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sectioneight_form }\n end\n end",
"def new\n @state = State.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @state }\n end\n end",
"def new\n @state = State.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @state }\n end\n end",
"def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to(states_path, :notice => 'State was Created Successfully.') }\n format.xml { render :xml => @state, :status => :created, :location => @state }\n else\n\t@country = Country.all\n format.html { render :action => \"new\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def current_statuses_three\n @current_statuses = CurrentStatus.where(status:true, id: [1,2,3]).order('name ASC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @current_statuses}\n end\n end",
"def show\n @hand_state = HandState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hand_state }\n end\n end",
"def state\n status[\"state\"]\n end",
"def situations_arrivals_countries_three\n @situations_arrivals_countries = SituationsArrivalsCountry.where(status:true, id: [1,2,3]).order('name ASC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @situations_arrivals_countries}\n end\n end",
"def state\n states.first\n end",
"def tourney_state(id)\n tournament = JSON.parse(`curl -s --user #{CHALLONGE_USER}:#{CHALLONGE_TOKEN} -X GET #{api_url(id)}.json`)\n return tournament['tournament']['state']\nend",
"def state_list\n @state_list=State.find_all_by_country_id(params[:city][:value])\n end",
"def index\n @state = params[:state]\n if params[:state]\n @elections = Election.where(state: params[:state])\n else\n @elections = Election.all\n end\n end",
"def index\n @surgery_states = SurgeryState.all\n end",
"def edit\n\t\t@state = State.find(params[:id])\n\tend",
"def edit\n @event = Event.find(params[:id])\n @states = ['AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN',\n 'IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV',\n 'NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN',\n 'TX','UT','VT','VA','WA','WV','WI','WY']\n end",
"def index\n# @states = State.all\n#pagination:\n\t@states = State.all.paginate :per_page => 5, :page => params[:page]\n\t\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @states }\n end\n end",
"def create\n @api_state = Api::State.new(api_state_params)\n\n if @api_state.save\n render json: @api_state, status: :created, location: @api_state\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end",
"def action_state=(value)\n @action_state = value\n end",
"def show\n @action_name = ActionName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @action_name }\n end\n end",
"def state_beers\n render json: BreweryDb::ShowBeers.new('state', params[:state]).results\n end",
"def index\n [] << @state.id << @state.state.id \n end",
"def state_events(state)\n api_return = RestClient.get('https://app.ticketmaster.com/discovery/v2/events.json?stateCode=' + state + '&apikey=' + $ticket_master_api_key)\n JSON.parse(api_return)\nend",
"def index\n @federal_states = FederalState.all\n end",
"def pull_states\n render template: 'responses/pull_states.xml.builder', layout: false\n end",
"def show\n @state = State.find_by_slug(params[:state_slug])\n end",
"def states; end"
] | [
"0.76807547",
"0.74640995",
"0.7050605",
"0.70203876",
"0.70077246",
"0.676901",
"0.676901",
"0.6731739",
"0.6731739",
"0.6731739",
"0.6731739",
"0.6731739",
"0.66922796",
"0.66896033",
"0.658945",
"0.64759487",
"0.6475215",
"0.6441073",
"0.6432022",
"0.632255",
"0.63185734",
"0.63065875",
"0.63065463",
"0.6291097",
"0.6161852",
"0.6159184",
"0.6159184",
"0.61536115",
"0.6138377",
"0.61094433",
"0.60936683",
"0.6073873",
"0.6047078",
"0.60180646",
"0.6015426",
"0.60149425",
"0.5994759",
"0.5983907",
"0.59610754",
"0.59603447",
"0.5956284",
"0.5949211",
"0.5947794",
"0.59380984",
"0.5931294",
"0.5916746",
"0.59028053",
"0.5902404",
"0.5897288",
"0.58804184",
"0.58697474",
"0.58679986",
"0.58679986",
"0.58627456",
"0.58442676",
"0.5844259",
"0.58399415",
"0.5822756",
"0.5821474",
"0.5821474",
"0.5819338",
"0.5802734",
"0.5801329",
"0.5795937",
"0.57897836",
"0.5782833",
"0.5770372",
"0.5770315",
"0.5753229",
"0.57516694",
"0.5742938",
"0.5731216",
"0.5730461",
"0.5730375",
"0.5718193",
"0.5680649",
"0.5679775",
"0.5679775",
"0.565985",
"0.56552464",
"0.5636878",
"0.5619973",
"0.56189454",
"0.5614201",
"0.5610545",
"0.56096125",
"0.56043184",
"0.56043124",
"0.5601625",
"0.55954987",
"0.5590146",
"0.55852026",
"0.5584606",
"0.5583167",
"0.5581097",
"0.55800873",
"0.5579156",
"0.5576997",
"0.5573459",
"0.55689836",
"0.55665946"
] | 0.0 | -1 |
POST /action_states POST /action_states.json | def create
@action_state = ActionState.new(action_state_params)
respond_to do |format|
if @action_state.save
format.html { redirect_to [project, @action_state], notice: 'Action state was successfully created.' }
format.json { render :show, status: :created, location: @action_state }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @action_states = ActionState.all\n end",
"def create\n @state = State.new(state_params)\n\n if @state.save\n render json: @state, status: :created, location: @state\n # 'state was successfully created.'\n else\n render json: @state.errors, status: :unprocessable_entity\n end\n end",
"def states_params\n\t \t params.require(:state).permit(:country_id, :name, :status)\n\t end",
"def create\n @project_states = ProjectState.create!(project_state_params)\n json_response(@project_states, :created)\n end",
"def create\n @map_state = MapState.new(params[:map_state])\n\n respond_to do |format|\n if @map_state.save\n format.html { redirect_to @map_state, :notice => 'Map state was successfully created.' }\n format.json { render :json => @map_state, :status => :created, :location => @map_state }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @map_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json: @state, status: :created, location: @state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json: @state, status: :created, location: @state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(state_params)\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @state }\n else\n format.html { render :new }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_state = Api::State.new(api_state_params)\n\n if @api_state.save\n render json: @api_state, status: :created, location: @api_state\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end",
"def create\n @state = State.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render action: 'show', status: :created, location: @state }\n else\n format.html { render action: 'new' }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @state }\n else\n format.html { render :new }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @states_assign = StatesAssign.new(states_assign_params)\n\n respond_to do |format|\n if @states_assign.save\n format.html { redirect_to @states_assign, notice: 'State was successfully created.' }\n format.json { render :show, status: :created, location: @states_assign }\n \"#{@states_assign.assigned_to}StateMachine\".constantize.state @states_assign.state.name.to_sym\n\n puts '##############################'\n puts LeadStateMachine.states\n puts '##############################'\n\n else\n format.html { render :new }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to(states_path, :notice => 'State was Created Successfully.') }\n format.xml { render :xml => @state, :status => :created, :location => @state }\n else\n\t@country = Country.all\n format.html { render :action => \"new\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(state_params)\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to @state, notice: 'State was successfully created.' }\n format.json { render json:{message:'State was successfully created.'}, status: :created, location: @state }\n else\n format.html { render action: 'new' }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = @country.states.build(params[:state])\n\n respond_to do |format|\n if @state.save\n format.html { redirect_to([@country, @state], :notice => 'State was successfully created.') }\n format.xml { render :xml => @state, :status => :created, :location => [@country, @state] }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @event_state = EventState.new(event_state_params)\n\n respond_to do |format|\n if @event_state.save\n format.html { redirect_to @event_state, notice: 'Event state was successfully created.' }\n format.json { render :show, status: :created, location: @event_state }\n else\n format.html { render :new }\n format.json { render json: @event_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@state = State.create(states_params)\n\t\tif @state.save\n\t\t\tflash[:success] = \"Record updated successfully\"\n\t\t\tredirect_to states_path\n\t\t else\n\t\t \tflash[:error] = \"Record not updated\"\n\t\t redirect_to states_path\n\t\tend\n\tend",
"def add_states(new_states); end",
"def index\n @states = State.all\n \n render json: @states\n end",
"def state_params\n params.require(:state).permit(:name, :abbreviation)\n end",
"def create\n @user_state = UserState.new(user_state_params)\n\n respond_to do |format|\n if @user_state.save\n format.html { redirect_to @user_state, notice: 'User state was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_state }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.new(recipe_params)\n @states = State.all\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_state = UserState.new(user_state_params)\n\n respond_to do |format|\n if @user_state.save\n format.html { redirect_to @user_state, notice: 'User state was successfully created.' }\n format.json { render :show, status: :created, location: @user_state }\n else\n format.html { render :new }\n format.json { render json: @user_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def action_state=(value)\n @action_state = value\n end",
"def state_params\n params.require(:state).permit(:name, :code, :description, :country_id, :active)\n end",
"def create\n #we're going to be tailoring a message in the case of a wrong or duplicate answer:\n\n@message = \"\"\n\n \n\n#your standard new instance of the Resource line:\n\n@state = State.new(state_params)\n\n \n\n#we'll need this to check if the answer is a duplicate:\n\n@states = State.all\n\n \n\n#let's make sure the answer is correct, and that it's not a duplicate.\n\n#see the Application Helper for these methods:\n\ncorrect = check_answer_state(@state.name)\n\nis_dup = check_for_dup_state(@state.name,@states)\n\n \n\n#we're going to have a couple messages for when the user enters something that is not a city, or is a duplicate answer\n\nif correct == false\n\n@message = \"That is not a state TTS is in.\"\n\nelsif is_dup == true\n\n@message = \"You already guessed that one!\"\n\nend\n\n \n\nrespond_to do |format|\n\n#if we have > 1 city left to name, and the user's answer is true and not a duplicate answer, we'll save it in the database and redirect back to the same page\n\nif @states.count <= 48 && correct == true && is_dup == false && @state.save\n\nformat.html { redirect_to new_state_path, notice: 'State was successfully created.' }\n\nformat.json { render action: 'show', status: :created, location: @state }\n\n#if this is our last city to name, and the user's answer is true and not a duplicate answer, we'll save it in the database and redirect to the 'you won!' page\n\nelsif @states.count == 49 && correct == true && is_dup == false && @state.save\n\nformat.html { redirect_to youwonstate_path, notice: 'State was successfully created.' }\n\nformat.json { render action: 'show', status: :created, location: @state }\n\nelse\n\nformat.html { render action: 'new' }\n\nformat.json { render json: @state.errors, status: :unprocessable_entity }\n\nend\n\nend\n\nend",
"def state_params\n params.require(:state).permit(:name, :abbrev, :favorite, :favorites )\n end",
"def action_state_params\n params.require(:action_state).permit(:project_id, :chara, :field, :freq, :precis)\n end",
"def create\n @expense_state = ExpenseState.new(params[:expense_state])\n\n respond_to do |format|\n if @expense_state.save\n format.html { redirect_to @expense_state, notice: 'Expense state was successfully created.' }\n format.json { render json: @expense_state, status: :created, location: @expense_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @expense_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @action_state.update(action_state_params)\n format.html { redirect_to [project, @action_state], notice: 'Action state was successfully updated.' }\n format.json { render :show, status: :ok, location: @action_state }\n end\n end\n end",
"def create\n @modelstate = Modelstate.new(modelstate_params)\n\n respond_to do |format|\n if @modelstate.save\n format.html { redirect_to @modelstate, notice: 'Modelstate was successfully created.' }\n format.json { render :show, status: :created, location: @modelstate }\n else\n format.html { render :new }\n format.json { render json: @modelstate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sprint_state = SprintState.new(sprint_state_params)\n\n respond_to do |format|\n if @sprint_state.save\n format.html { redirect_to @sprint_state, notice: 'Sprint state was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sprint_state }\n else\n format.html { render action: 'new' }\n format.json { render json: @sprint_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tender_state = TenderState.new(params[:tender_state])\n\n respond_to do |format|\n if @tender_state.save\n format.html { redirect_to @tender_state, notice: 'Tender state was successfully created.' }\n format.json { render json: @tender_state, status: :created, location: @tender_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tender_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @united_state = UnitedState.new(united_state_params)\n\n respond_to do |format|\n if @united_state.save\n format.html { redirect_to @united_state, notice: 'United state was successfully created.' }\n format.json { render :show, status: :created, location: @united_state }\n else\n format.html { render :new }\n format.json { render json: @united_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def state_params\n params.require(:state).permit(:name)\n end",
"def state_params\n params.require(:state).permit(:name)\n end",
"def create\n @surgery_state = SurgeryState.new(surgery_state_params)\n\n respond_to do |format|\n if @surgery_state.save\n format.html { redirect_to @surgery_state, notice: 'Surgery state was successfully created.' }\n format.json { render :show, status: :created, location: @surgery_state }\n else\n format.html { render :new }\n format.json { render json: @surgery_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(state_params)\n\n end",
"def create\n @task_state = TaskState.new(task_state_params)\n\n respond_to do |format|\n if @task_state.save\n format.html { redirect_to @task_state, success: 'Task state was successfully created.' }\n format.json { render :show, status: :created, location: @task_state }\n else\n format.html { render :new }\n format.json { render json: @task_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @goal_state = GoalState.new(params[:goal_state])\n\n respond_to do |format|\n if @goal_state.save\n format.html { redirect_to @goal_state, notice: 'Goal state was successfully created.' }\n format.json { render json: @goal_state, status: :created, location: @goal_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @goal_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_action_state\n @action_state = ActionState.find(params[:id])\n end",
"def index\n @api_states = Api::State.all\n end",
"def get_state\n @states = State.find_state(params[:id])\n respond_to do |format|\n format.json { render :json => @states }\n end\n end",
"def create\n @state_type = StateType.new(state_type_params)\n\n respond_to do |format|\n if @state_type.save\n format.html { redirect_to @state_type, notice: 'State type was successfully created.' }\n format.json { render :show, status: :created, location: @state_type }\n else\n format.html { render :new }\n format.json { render json: @state_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @state = State.new(params[:state])\n @state.created_by = @created_by\n respond_to do |format|\n if @state.save\n format.html { redirect_to([:admin,@state], :notice => 'State was successfully created.') }\n format.xml { render :xml => @admin_state, :status => :created, :location => @state }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def state_params\n params.require(:state).permit(:title, :country_id)\n end",
"def create\n @datum = Datum.new(params[:datum])\n @datum.action_list = ActionList.new(:name => \"Empty\")\n @datum.action_list.datum = @datum\n @datum.user = current_user\n @user_state = current_user.user_state\n respond_to do |format|\n if not @datum.action_list.save\n format.html { render action: \"new\" }\n format.json { render json: @datum.action_list.errors, status: :unprocessable_entity }\n elsif not @datum.save\n format.html { render action: \"new\" }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n else\n @user_state.reset(@datum.action_list.id)\n\n if not @user_state.save\n format.html { render action: \"new\" }\n format.json { render json: @user_state.errors, status: :unprocessable_entity }\n\n else\n format.html { redirect_to @datum, notice: 'Datum was successfully created.' }\n format.json { render json: @datum, status: :created, location: @datum }\n end\n end\n end\n end",
"def update_episode_states(episode)\n episode.states = control_points_to_states(objectify_json(episode.control_points), episode.timestep).to_json\n episode.save\n end",
"def orderStates\n @states = Hash.new\n @states[0] = \"Processing\"\n @states[1] = \"Shipped\"\n @states[2] = \"Delivered\"\n @states[3] = \"Cancelled\"\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @states = State.all\n end",
"def index\n @event_states = EventState.all\n end",
"def create\n @federal_state = FederalState.new(federal_state_params)\n\n respond_to do |format|\n if @federal_state.save\n format.html { redirect_to @federal_state, notice: 'Federal state was successfully created.' }\n format.json { render action: 'show', status: :created, location: @federal_state }\n else\n format.html { render action: 'new' }\n format.json { render json: @federal_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def state_params\n params.require(:state).permit(:name, :shortname, :code, :population)\n end",
"def state_params\n params.fetch(:state, {}).permit(:name, :code, :country_id)\n end",
"def create\n unless params[:country_id]\n @city = City.new(params[:city])\n @city.step=\"2\"\n state = State.find_by_id(params[:city][:state_id]) if params[:city][:state_id]\n @city.state = state\n if @city.save\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@city.errors)\n end\n end\n end",
"def index\n @states = State.all\n respond_with(@states)\n end",
"def update_states\n @episode = Episode.find(params[:id])\n update_episode_states(@episode)\n update_episode_diff_states(@episode)\n update_episode_commands(@episode)\n redirect_to(@episode)\n end",
"def state_params\n params.require(:state).permit(:country_id, :name, :short_name)\n end",
"def state\n @instance = Instance.find_by_instance_id(params[:id])\n @instance.state = params[:state] if params[:state]\n @instance.save\n \n \n respond_to do |format|\n format.html { redirect_to(instances_url) }\n format.xml { head :ok }\n end\n end",
"def set_active_all\n @states.set_active_all\n\n respond_to do |format|\n format.json {\n render json: {\n 'message': t('.success'),\n 'type': 'success'\n }\n }\n end\n end",
"def state_params\n params.fetch(:state, {}).permit(:name, :description)\n end",
"def create \n \n\tputs params[:country]\n\tcountry = Country.where(:code => params[:country]).first\n\t\n\tputs country\n\tcountryId = country.id\n \n\tputs countryId\n\t\n @state = State.new :code => params[:code], :name => params[:name], :country_id => countryId\n \n respond_to do |format|\n if @state.save\n format.html { redirect_to(:action => \"index\") }\n else\n format.html { render action: \"new\" } \n end\n end\n end",
"def state_params\n # extend with your own params\n accessible = %i[iso name country_id]\n params.require(:state).permit(accessible)\n end",
"def set_draft_all\n @states.set_draft_all\n\n respond_to do |format|\n format.json {\n render json: {\n 'message': t('.success'),\n 'type': 'success'\n }\n }\n end\n end",
"def update\n respond_to do |format|\n \"#{@states_assign.assigned_to}StateMachine\".constantize.states.delete(@states_assign.state.name)\n if @states_assign.update(states_assign_params)\n format.html { redirect_to @states_assign, notice: 'State was successfully updated.' }\n format.json { render :show, status: :ok, location: @states_assign }\n \"#{@states_assign.assigned_to}StateMachine\".constantize.state @states_assign.state.name.to_sym\n\n puts '##############################'\n puts LeadStateMachine.states\n puts '##############################'\n\n puts '##############################'\n puts PaymentStateMachine.states\n puts '##############################'\n\n\n else\n format.html { render :edit }\n format.json { render json: @states_assign.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @project_states = ProjectState.all\n json_response(@project_states)\n end",
"def create\n @host_state = HostState.new(host_state_params)\n\n respond_to do |format|\n if @host_state.save\n format.html { redirect_to @host_state, notice: 'Host state was successfully created.' }\n format.json { render :show, status: :created, location: @host_state }\n else\n format.html { render :new }\n format.json { render json: @host_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def states\n @states ||= {}\n end",
"def state_params\n params.require(:state).permit(:name, :abbreviation, :description, :longitude, :latitude, :hashtag, :zoom)\n end",
"def index\n @page_title = 'States'\n @states = State.all\n end",
"def to_states; end",
"def to_states; end",
"def states; end",
"def create\n @tutorial_state = Tutorial::State.new(params[:tutorial_state])\n\n respond_to do |format|\n if @tutorial_state.save\n format.html { redirect_to @tutorial_state, notice: 'State was successfully created.' }\n format.json { render json: @tutorial_state, status: :created, location: @tutorial_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tutorial_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @psa_state = PsaState.new(params[:psa_state])\n\n respond_to do |format|\n if @psa_state.save\n format.html { redirect_to @psa_state, notice: 'Psa state was successfully created.' }\n format.json { render json: @psa_state, status: :created, location: @psa_state }\n else\n format.html { render action: \"new\" }\n format.json { render json: @psa_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @counties = County.all\n\n @county = County.create(county_params)\n\n @states = State.all.order(:state_name)\n end",
"def update\n if @state.update(state_params)\n render json: @state\n # 'State was successfully updated.'\n else\n render json: @state.errors, status: :unprocessable_entity\n end\n end",
"def encode_state(action=nil)\n pieces = @state.url_encode(\"\", [])\n pieces.unshift(action) if action\n pieces.join(\"&\")\n end",
"def states\n []\n end",
"def states\n []\n end",
"def state_params\n params.require(:state).permit(:visited, :unvisited, :plan_to)\n end",
"def index\n @surgery_states = SurgeryState.all\n end",
"def _lex_to_state_actions; end",
"def _lex_to_state_actions; end",
"def _lex_to_state_actions; end",
"def _lex_to_state_actions; end",
"def states\n @attributes[\"data\"][\"states\"]\n end",
"def create\n @task_state = TaskState.new(params[:task_state])\n\n respond_to do |format|\n if @task_state.save\n format.html { redirect_to(@task_state, :notice => t(\"screens.notice.successfully_created\")) }\n format.xml { render :xml => @task_state, :status => :created, :location => @task_state }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n render json: @state\n end",
"def pull_states\n render template: 'responses/pull_states.xml.builder', layout: false\n end",
"def create\n @state_object = States.new\n @states = @state_object.abbreviations\n @restaurant = Restaurant.new(restaurant_params)\n\n if @restaurant.save\n redirect_to \"/restaurants/#{@restaurant.id}\"\n else\n flash[:notice] = \"Your restaurant couldn't be saved. Sorry!\"\n render :new\n end\n end",
"def state_check(states)\n failed = false\n states = [states] unless states.is_a?(Array)\n unless states.include?(@object.current_state)\n flash[:error] = '<h2>Invalid state for action.</h2>The requested action requires the <code>[' + states.collect { |state| state.to_s }.join(' || ') + ']</code> state.'\n redirect_to(users_path)\n end\n end",
"def index\n @states = State.order(\"name\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @states }\n end\n end",
"def create\n @state_statistic = StateStatistic.new(state_statistic_params)\n\n respond_to do |format|\n if @state_statistic.save\n format.html { redirect_to @state_statistic, notice: 'State statistic was successfully created.' }\n format.json { render :show, status: :created, location: @state_statistic }\n else\n format.html { render :new }\n format.json { render json: @state_statistic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def stateform_params\n params.require(:stateform).permit(:date, :tax, :time_type, :income,:status ,:state )\n end"
] | [
"0.6681765",
"0.6533226",
"0.6487266",
"0.64165443",
"0.64110124",
"0.63889223",
"0.63889223",
"0.6381537",
"0.63767755",
"0.6347029",
"0.6346201",
"0.6326781",
"0.6256764",
"0.6248286",
"0.6225454",
"0.62234485",
"0.62085706",
"0.6071389",
"0.60122657",
"0.60032153",
"0.60027814",
"0.5998451",
"0.59648556",
"0.5910847",
"0.59079546",
"0.5892906",
"0.5877481",
"0.5876509",
"0.58655274",
"0.58565265",
"0.5851667",
"0.58296263",
"0.582913",
"0.5815333",
"0.58121645",
"0.5811615",
"0.5811615",
"0.5809884",
"0.5794935",
"0.5785033",
"0.578046",
"0.57584846",
"0.5750999",
"0.57448274",
"0.57437813",
"0.573382",
"0.57321244",
"0.5719538",
"0.5719182",
"0.5709969",
"0.56809217",
"0.56809217",
"0.56809217",
"0.56809217",
"0.56809217",
"0.5676359",
"0.56722593",
"0.5671507",
"0.5653096",
"0.56529546",
"0.56528527",
"0.5650445",
"0.56412965",
"0.56310385",
"0.56274885",
"0.5603994",
"0.5584078",
"0.5565776",
"0.5554429",
"0.55519426",
"0.5549811",
"0.552846",
"0.55275726",
"0.5501416",
"0.5490132",
"0.54876506",
"0.54876506",
"0.54874754",
"0.5484591",
"0.5482137",
"0.54530036",
"0.5447414",
"0.54455173",
"0.5444347",
"0.5444347",
"0.5443496",
"0.5440979",
"0.5439426",
"0.5439426",
"0.5439426",
"0.5439426",
"0.5437522",
"0.5434213",
"0.5398513",
"0.53836787",
"0.53807044",
"0.53732127",
"0.53731656",
"0.5369023",
"0.53671503"
] | 0.68875045 | 0 |
PATCH/PUT /action_states/1 PATCH/PUT /action_states/1.json | def update
respond_to do |format|
if @action_state.update(action_state_params)
format.html { redirect_to [project, @action_state], notice: 'Action state was successfully updated.' }
format.json { render :show, status: :ok, location: @action_state }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @state.update(state_params)\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @state = State.find(params[:id])\n\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @state = State.find(params[:id])\n\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @state = State.find(params[:id])\n\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_state = Api::State.find(params[:id])\n\n if @api_state.update(api_state_params)\n head :no_content\n else\n render json: @api_state.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @state.update(state_params)\n render json: @state\n # 'State was successfully updated.'\n else\n render json: @state.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @state.update_attributes(state_params)\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { render json:{message:'State was successfully updated.'} }\n else\n format.html { render action: 'edit' }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @state.update(state_params)\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { render :show, status: :ok, location: @state }\n else\n format.html { render :edit }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @state.update(state_params)\n format.html { redirect_to @state, notice: 'State was successfully updated.' }\n format.json { render :show, status: :ok, location: @state }\n else\n format.html { render :edit }\n format.json { render json: @state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @state = State.find(params[:id])\n\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to(states_path, :notice => 'State was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @state = @country.states.find(params[:id])\n\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to([@country, @state], :notice => 'State was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @modelstate.update(params[:modelstates])\n format.html { redirect_to @modelstate, notice: 'Modelstate was successfully updated.' }\n format.json { render :show, status: :ok, location: @modelstate }\n else\n format.html { render :edit }\n format.json { render json: @modelstate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @map_state = MapState.find(params[:id])\n\n respond_to do |format|\n if @map_state.update_attributes(params[:map_state])\n format.html { redirect_to @map_state, :notice => 'Map state was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @map_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sprint_state.update(sprint_state_params)\n format.html { redirect_to @sprint_state, notice: 'Sprint state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sprint_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event_state.update(event_state_params)\n format.html { redirect_to @event_state, notice: 'Event state was successfully updated.' }\n format.json { render :show, status: :ok, location: @event_state }\n else\n format.html { render :edit }\n format.json { render json: @event_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @current_state.update(current_state_params)\n format.html { redirect_to \"/\", notice: 'CurrentState was successfully updated.' }\n format.json { render :root, status: :ok, location: @current_state }\n else\n format.html { render :edit }\n format.json { render json: @current_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @federal_state.update(federal_state_params)\n format.html { redirect_to @federal_state, notice: 'Federal state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @federal_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @expense_state = ExpenseState.find(params[:id])\n\n respond_to do |format|\n if @expense_state.update_attributes(params[:expense_state])\n format.html { redirect_to @expense_state, notice: 'Expense state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @state_type.update(state_type_params)\n format.html { redirect_to @state_type, notice: 'State type was successfully updated.' }\n format.json { render :show, status: :ok, location: @state_type }\n else\n format.html { render :edit }\n format.json { render json: @state_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n \"#{@states_assign.assigned_to}StateMachine\".constantize.states.delete(@states_assign.state.name)\n if @states_assign.update(states_assign_params)\n format.html { redirect_to @states_assign, notice: 'State was successfully updated.' }\n format.json { render :show, status: :ok, location: @states_assign }\n \"#{@states_assign.assigned_to}StateMachine\".constantize.state @states_assign.state.name.to_sym\n\n puts '##############################'\n puts LeadStateMachine.states\n puts '##############################'\n\n puts '##############################'\n puts PaymentStateMachine.states\n puts '##############################'\n\n\n else\n format.html { render :edit }\n format.json { render json: @states_assign.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @goal_state = GoalState.find(params[:id])\n\n respond_to do |format|\n if @goal_state.update_attributes(params[:goal_state])\n format.html { redirect_to @goal_state, notice: 'Goal state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @goal_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_state.update(user_state_params)\n format.html { redirect_to @user_state, notice: 'User state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @state = State.find(params[:id])\n @state.updated_by = @updated_by\n respond_to do |format|\n if @state.update_attributes(params[:state])\n format.html { redirect_to([:admin,@state], :notice => 'State was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @event = Event.find(params[:id])\n @states = ['AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN',\n 'IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV',\n 'NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN',\n 'TX','UT','VT','VA','WA','WV','WI','WY']\n end",
"def update\n @datum = Datum.find(params[:id])\n verify_user(@datum.user.id)\n\n action_list = @datum.action_list\n switch_action_list(action_list.id)\n\n respond_to do |format|\n if @datum.update_attributes(params[:datum])\n @datum.user.user_state.reset(action_list.id)\n if not @datum.user.user_state.save\n format.html { render action: \"edit\" }\n format.json { render json: @datum.user.user_state.errors, status: :unprocessable_entity }\n else \n format.html { redirect_to @datum, notice: 'Datum was successfully updated.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tender_state = TenderState.find(params[:id])\n\n respond_to do |format|\n if @tender_state.update_attributes(params[:tender_state])\n format.html { redirect_to @tender_state, notice: 'Tender state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tender_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @asset_state = AssetState.find(params[:id])\n respond_to do |format|\n if @asset_state.update_attributes(params[:asset_state])\n format.html { redirect_to system_asset_states_path, notice: 'Asset type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asset_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @task_state.update(task_state_params)\n format.html { redirect_to @task_state, success: 'Task state was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_state }\n else\n format.html { render :edit }\n format.json { render json: @task_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n puts params\n @state = State.find(params[:targetId])\n \n data = Hash.new\n #pagination - see doc\n data[\"code\"] = params[:code] \n data[\"name\"] = params[:name] \n data[\"countryId\"] = params[:countryId] \n\t\n respond_to do |format|\n if @state.update_attributes(data)\n format.html { redirect_to(:action => \"index\") }\n else \n\t puts @state.errors\n format.html { redirect_to(:action => \"edit\", :id => (params[:targetId])) }\n end\n end\n end",
"def update\n respond_to do |format|\n if @united_state.update(united_state_params)\n format.html { redirect_to @united_state, notice: 'United state was successfully updated.' }\n format.json { render :show, status: :ok, location: @united_state }\n else\n format.html { render :edit }\n format.json { render json: @united_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_action_state\n @action_state = ActionState.find(params[:id])\n end",
"def update\n respond_to do |format|\n # if food is passed, won't check it again.\n if @food.state == 1\n state = 1 \n else\n state = 0\n end\n\n if @food.update(food_params.merge state: state) # 1 means valid\n format.html { redirect_to @food, notice: 'Food was successfully updated.' }\n format.json { render :show, status: :ok, location: @food }\n else\n format.html { render :edit }\n format.json { render json: @food.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @project_state.update(project_state_params)\n head :no_content\n end",
"def update\n head :forbidden\n\n #@action = Action.find(params[:id])\n\n #if @action.update_attributes(params[:action])\n # head :no_content\n # else\n # render json: @action.errors, status: :unprocessable_entity\n # end\n end",
"def update\n @poll_workflow_state = PollWorkflowState.find(params[:id])\n\n respond_to do |format|\n if @poll_workflow_state.update_attributes(params[:poll_workflow_state])\n format.html { redirect_to @poll_workflow_state, notice: 'Poll workflow state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll_workflow_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@state = State.find(params[:id])\n\t\tif @state.update(states_params)\n\t\t\tflash[:success] = \"Record updated successfully\"\n\t\t redirect_to states_path\n\t\t else\n \tflash[:error] = \"Record not updated\"\n redirect_to states_path\n\t\tend\n\tend",
"def update\n @task_state = TaskState.find(params[:id])\n\n respond_to do |format|\n if @task_state.update_attributes(params[:task_state])\n format.html { redirect_to(@task_state, :notice => t(\"screens.notice.successfully_updated\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @task_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @state_statistic.update(state_statistic_params)\n format.html { redirect_to @state_statistic, notice: 'State statistic was successfully updated.' }\n format.json { render :show, status: :ok, location: @state_statistic }\n else\n format.html { render :edit }\n format.json { render json: @state_statistic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @psa_state = PsaState.find(params[:id])\n\n respond_to do |format|\n if @psa_state.update_attributes(params[:psa_state])\n format.html { redirect_to @psa_state, notice: 'Psa state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @psa_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @process_state.update(process_state_params)\n format.html { redirect_to @process_state, notice: 'Process state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @process_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_states\n @episode = Episode.find(params[:id])\n update_episode_states(@episode)\n update_episode_diff_states(@episode)\n update_episode_commands(@episode)\n redirect_to(@episode)\n end",
"def update\n @tutorial_state = Tutorial::State.find(params[:id])\n\n respond_to do |format|\n if @tutorial_state.update_attributes(params[:tutorial_state])\n format.html { redirect_to @tutorial_state, notice: 'State was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @tutorial_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @surgery_state.update(surgery_state_params)\n format.html { redirect_to @surgery_state, notice: 'Surgery state was successfully updated.' }\n format.json { render :show, status: :ok, location: @surgery_state }\n else\n format.html { render :edit }\n format.json { render json: @surgery_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def state\n @instance = Instance.find_by_instance_id(params[:id])\n @instance.state = params[:state] if params[:state]\n @instance.save\n \n \n respond_to do |format|\n format.html { redirect_to(instances_url) }\n format.xml { head :ok }\n end\n end",
"def update\n @estate = Estate.find(params[:id])\n\n respond_to do |format|\n if @estate.update_attributes(params[:estate])\n format.html { redirect_to @estate, notice: 'Estate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @user_state.update(user_state_params)\n format.html { redirect_to @user_state, notice: 'User state was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_state }\n else\n format.html { render :edit }\n format.json { render json: @user_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n\t\t@state = State.find(params[:id])\n\tend",
"def update\n authorize @kanban_state\n\n respond_to do |format|\n if @kanban_state.update(kanban_state_params)\n url = params[:url] || edit_admin_project_path(@kanban_state.project_id, anchor: \"kanban_states\")\n\n format.html { redirect_to url, notice: t('actions.updated_with_success')}\n format.json { render :edit, status: :ok, location: @kanban_state }\n else\n format.html { render :edit }\n format.json { render json: @kanban_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_draft_all\n @states.set_draft_all\n\n respond_to do |format|\n format.json {\n render json: {\n 'message': t('.success'),\n 'type': 'success'\n }\n }\n end\n end",
"def update\n respond_to do |format|\n if @property_state.update(property_state_params)\n format.html { redirect_to @property_state, notice: 'Property state was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_state }\n else\n format.html { render :edit }\n format.json { render json: @property_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @stateform.update(stateform_params)\n format.html { redirect_to @stateform, notice: 'stateform was successfully updated.' }\n format.json { render :show, status: :ok, location: @stateform }\n else\n format.html { render 'new' }\n format.json { render json: @stateform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @counties = County.all\n @county = County.find(params[:id])\n\n @county.update_attributes(county_params)\n\n @states = State.all.order(:state_name)\n end",
"def set_active_all\n @states.set_active_all\n\n respond_to do |format|\n format.json {\n render json: {\n 'message': t('.success'),\n 'type': 'success'\n }\n }\n end\n end",
"def update\n @request_status = RequestStatus.find(params[:id])\n\n respond_to do |format|\n if @request_status.update_attributes(params[:request_status])\n format.html { redirect_to @request_status, notice: 'Request status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n @status_events = args[:status_events] if args.key?(:status_events)\n end",
"def update\n respond_to do |format|\n if @event_action.update(event_action_params)\n format.html { redirect_to @event_action, notice: \"Event action was successfully updated.\" }\n format.json { render :show, status: :ok, location: @event_action }\n else\n format.html { render :edit }\n format.json { render json: @event_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:commit] == 'Accept'\n params[:scoot][:state] = 'accepted'\n else\n params[:scoot][:state] = 'rejected'\n end\n respond_to do |format|\n if @scoot.update(scoot_params)\n format.html { redirect_to root_url, notice: 'Scoot was successfully updated.' }\n format.json { render :show, status: :ok, location: @scoot }\n else\n format.html { render :edit }\n format.json { render json: @scoot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @v1_order = V1::Order.find(params[:id])\n\n case @v1_order.state\n when 0\n if @v1_order.update(v1_order_params)\n head :no_content\n else\n render json: @v1_order.errors, status: :unprocessable_entity\n end\n else\n render json: {message: 'Can be edited only when in draft(0) state'}, status: 400\n end\n \n end",
"def update\n @action_name = ActionName.find(params[:id])\n\n respond_to do |format|\n if @action_name.update_attributes(params[:action_name])\n format.html { redirect_to @action_name, notice: 'Action name was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @action_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @program_state.update(program_state_params)\n format.html { redirect_to @program_state, notice: 'Program state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @program_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n @event.update(status: \"Pending\")\n else\n @reopen = true\n format.json { render json: @event.errors, status: :unprocessable_entity }\n format.html { render :show }\n end\n end\n end",
"def update\n @civil_state = CivilState.find(params[:id])\n\n respond_to do |format|\n if @civil_state.update_attributes(params[:civil_state])\n flash[:notice] = 'CivilState was successfully updated.'\n format.html { redirect_to([:admin, @civil_state]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @civil_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @state_prov.update(state_prov_params)\n format.html { redirect_to @state_prov, notice: 'State prov was successfully updated.' }\n format.json { render :show, status: :ok, location: @state_prov }\n else\n format.html { render :edit }\n format.json { render json: @state_prov.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @flat_stage.update(flat_stage_params)\n format.html { redirect_to @flat_stage, notice: 'Stage was successfully updated.' }\n format.json { render :show, status: :ok, location: @flat_stage }\n else\n format.html { render :edit }\n format.json { render json: @flat_stage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @receipt_state.update(receipt_state_params)\n format.html { redirect_to @receipt_state, notice: 'Receipt state was successfully updated.' }\n format.json { render :show, status: :ok, location: @receipt_state }\n else\n format.html { render :edit }\n format.json { render json: @receipt_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def states_params\n\t \t params.require(:state).permit(:country_id, :name, :status)\n\t end",
"def update\n respond_to do |format|\n if @empire_rc_state.update(empire_rc_state_params)\n format.html { redirect_to @empire_rc_state, notice: 'Empire rc state was successfully updated.' }\n format.json { render :show, status: :ok, location: @empire_rc_state }\n else\n format.html { render :edit }\n format.json { render json: @empire_rc_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change\n task = Task.find(params[:id])\n task.completed = params[:state]\n task.save\n render :json => { status: 200 }\n end",
"def update\n respond_to do |format|\n if @sa_request_status.update(sa_request_status_params)\n format.html { redirect_to @sa_request_status, notice: 'Sa request status was successfully updated.' }\n format.json { render :show, status: :ok, location: @sa_request_status }\n else\n format.html { render :edit }\n format.json { render json: @sa_request_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render status: 501, json: { errors: ['Action not implemented yet!'] }\n end",
"def edit\n @countries = Countr.all\n @states = []\n @cities = []\n if params[:country].present? or params[:state].present?\n @states = Stat.where(:countr_id => params[:country] )\n @cities = City.where(:stat_id => params[:state] )\n end\n if request.xhr?\n respond_to do |format|\n format.json {\n render json: {states: @states} if params[:country].present?\n render json: {cities: @cities} if params[:state].present?\n }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticketstate.update(ticketstate_params)\n format.html { redirect_to @ticketstate, notice: '更新成功' }\n format.json { render :show, status: :ok, location: @ticketstate }\n else\n format.html { render :edit }\n format.json { render json: @ticketstate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @event = Event.using(:shard_one).find(params[:id])\n\n respond_to do |format|\n if @event.update_attributes(params[:event])\n format.html { redirect_to @event, :notice => 'Event was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @event.errors, :status => :unprocessable_entity }\n end\n end\n\n\n\n end",
"def update\n respond_to do |format|\n if @host_state.update(host_state_params)\n format.html { redirect_to @host_state, notice: 'Host state was successfully updated.' }\n format.json { render :show, status: :ok, location: @host_state }\n else\n format.html { render :edit }\n format.json { render json: @host_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client = Client.find(params[:id])\n @states = State.find(:all,:order=>\"short_name\")\n @genders = Gender.find(:all)\n @email_priorities = EmailPriority.find(:all)\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n @giftstate = Giftstate.find(params[:id])\n\n respond_to do |format|\n if @giftstate.update_attributes(params[:giftstate])\n flash[:notice] = 'Giftstate was successfully updated.'\n format.html { redirect_to(@giftstate) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @giftstate.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @state_cadre = StateCadre.find(params[:id])\n\n respond_to do |format|\n if @state_cadre.update_attributes(params[:state_cadre])\n format.html { redirect_to @state_cadre, notice: 'State cadre was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @state_cadre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @state_copd.update(state_copd_params)\n format.html { redirect_to @state_copd, notice: 'State copd was successfully updated.' }\n format.json { render :show, status: :ok, location: @state_copd }\n else\n format.html { render :edit }\n format.json { render json: @state_copd.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hand_state = HandState.find(params[:id])\n\n respond_to do |format|\n if @hand_state.update_attributes(params[:hand_state])\n format.html { redirect_to @hand_state, notice: 'Hand state was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hand_state.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cultural_heritage_collection_state = CulturalHeritage::CollectionState.find(params[:id])\n\n respond_to do |format|\n if @cultural_heritage_collection_state.update_attributes(params[:cultural_heritage_collection_state])\n format.html { redirect_to(@cultural_heritage_collection_state, :notice => 'Collection state was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cultural_heritage_collection_state.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @current_stage.update_attributes(params[:stage])\n format.html { redirect_to @current_stage, notice: 'Stage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @current_stage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @country = Country.find(params[:id])\n if @country.update_attributes(:name=>params[:body][:country])\n render :json=>{:response=>\"success\"}\n else\n render :json=>failure1(@country.errors)\n end\n end",
"def update\n respond_to do |format|\n if @status.update(status_params)\n format.html { redirect_to @status, notice: 'Status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sa_action_type.update(sa_action_type_params)\n format.html { redirect_to @sa_action_type, notice: 'Sa action type was successfully updated.' }\n format.json { render :show, status: :ok, location: @sa_action_type }\n else\n format.html { render :edit }\n format.json { render json: @sa_action_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @status = Status.find(params[:id])\n\n respond_to do |format|\n if @status.update_attributes(params[:status])\n format.html { redirect_to @status, notice: 'Status was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @status = Status.find(params[:id])\n\n respond_to do |format|\n if @status.update_attributes(params[:status])\n format.html { redirect_to @status, notice: 'Status was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end",
"def set_status\n\t @id=params[:id]\n\t @state = State.find(@id)\n\t @status = @state.status\n if @status == true\n @state.update_attributes(status: 'false')\n flash[:success] = \"Status upadated In-Active\"\n else\n @state.update_attributes(status: 'true')\n flash[:success] = \"Status updated Active\"\n end\n redirect_to states_path\n end",
"def update\n if @scenario.update(scenario_params)\n \trender json: @scenario\n else\n \trender json: {status: 'ERROR', data: @scenario.errors}\n end\n end",
"def update\r\n @stage = Stage.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @stage.update_attributes(params.required(:stage).permit!)\r\n format.html {redirect_to @stage, :notice => 'Stage was successfully updated.'}\r\n format.json {head :no_content}\r\n else\r\n format.html {render :action => \"edit\"}\r\n format.json {render :json => @stage.errors, :status => :unprocessable_entity}\r\n end\r\n end\r\n end",
"def update\n @story_status = StoryStatus.find(params[:id])\n\n respond_to do |format|\n if @story_status.update_attributes(params[:story_status])\n format.html { redirect_to @story_status, :notice => 'Story status was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @story_status.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if :opr == 'edit'\n update\n else\n @team = Team.find_by_id(params[:id])\n @team.update_attributes({:id => params[:id], :name => params[:name], :status => params[:status]})\n\n if request.xhr?\n render :json => @team\n end\n end\n end",
"def edit\n @user = User.find(params[:id])\n @states = ['AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN',\n 'IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV',\n 'NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN',\n 'TX','UT','VT','VA','WA','WV','WI','WY']\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end",
"def update!(**args)\n @state = args[:state] if args.key?(:state)\n end"
] | [
"0.68128395",
"0.67845887",
"0.67845887",
"0.67845887",
"0.67651767",
"0.67571896",
"0.67542475",
"0.66479415",
"0.66479415",
"0.6631263",
"0.6543808",
"0.6541712",
"0.64760345",
"0.63940316",
"0.6382878",
"0.6354047",
"0.62879497",
"0.62710017",
"0.6259483",
"0.62157136",
"0.61968744",
"0.6076953",
"0.6074817",
"0.6066577",
"0.6046632",
"0.60441303",
"0.6036468",
"0.60325843",
"0.60038066",
"0.6003071",
"0.5988555",
"0.59745246",
"0.59739107",
"0.5968458",
"0.5961055",
"0.5944909",
"0.59206784",
"0.59053594",
"0.5901633",
"0.58828026",
"0.5873397",
"0.586541",
"0.5849323",
"0.5839267",
"0.58101034",
"0.58031094",
"0.5795164",
"0.57872367",
"0.57682896",
"0.57611394",
"0.57517767",
"0.5725724",
"0.57221824",
"0.57201046",
"0.5714346",
"0.5712808",
"0.56933606",
"0.5691409",
"0.56896234",
"0.5679228",
"0.5670492",
"0.5662216",
"0.56304187",
"0.56283754",
"0.5626516",
"0.5625603",
"0.5610141",
"0.56015784",
"0.56009907",
"0.5588793",
"0.55816865",
"0.5565288",
"0.5560046",
"0.55577815",
"0.5557618",
"0.5553687",
"0.5552753",
"0.5552704",
"0.5544352",
"0.55423796",
"0.5527339",
"0.55244225",
"0.5511782",
"0.5511645",
"0.5510342",
"0.5510342",
"0.5507189",
"0.54952973",
"0.5492871",
"0.5480893",
"0.54753214",
"0.5472768",
"0.5471473",
"0.5467141",
"0.5467141",
"0.5467141",
"0.5467141",
"0.5467141",
"0.5467141",
"0.5467141"
] | 0.71217287 | 0 |
DELETE /action_states/1 DELETE /action_states/1.json | def destroy
@action_state.destroy
respond_to do |format|
format.html { redirect_to project, notice: 'Action state was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_states_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @state = State.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to(states_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url, notice: 'State was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url, notice: 'State was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @map_state = MapState.find(params[:id])\n @map_state.destroy\n\n respond_to do |format|\n format.html { redirect_to map_states_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @state = @country.states.find(params[:id])\n @state.destroy\n\n respond_to do |format|\n format.html { redirect_to(country_states_url(@country)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @expense_state = ExpenseState.find(params[:id])\n @expense_state.destroy\n\n respond_to do |format|\n format.html { redirect_to expense_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state.destroy\n respond_to do |format|\n format.html { redirect_to states_url }\n format.json { head :no_content }\n format.js { render json:{message:'State has been deleted.', status: :ok}}\n end\n end",
"def destroy\n @goal_state = GoalState.find(params[:id])\n @goal_state.destroy\n\n respond_to do |format|\n format.html { redirect_to goal_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @modelstate.destroy\n respond_to do |format|\n format.html { redirect_to modelstates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sprint_state.destroy\n respond_to do |format|\n format.html { redirect_to sprint_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asset_state = AssetState.find(params[:id])\n @asset_state.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_state.destroy\n respond_to do |format|\n format.html { redirect_to user_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @psa_state = PsaState.find(params[:id])\n @psa_state.destroy\n\n respond_to do |format|\n format.html { redirect_to psa_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tender_state = TenderState.find(params[:id])\n @tender_state.destroy\n\n respond_to do |format|\n format.html { redirect_to tender_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event_state.destroy\n respond_to do |format|\n format.html { redirect_to event_states_url, notice: 'Event state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @federal_state.destroy\n respond_to do |format|\n format.html { redirect_to federal_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \"#{@states_assign.assigned_to}StateMachine\".constantize.states.delete(@states_assign.state.name)\n @states_assign.destroy\n\n puts '##############################'\n puts LeadStateMachine.states\n puts '##############################'\n\n respond_to do |format|\n format.html { redirect_to states_assigns_url, notice: 'State was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\n\tputs params[:id]\n \n state = State.find(params[:id])\n\t\n\tputs state\n\t\n state.destroy \n\t\n redirect_to(:action => \"index\") \n end",
"def destroy\n @state_type.destroy\n respond_to do |format|\n format.html { redirect_to state_types_url, notice: 'State type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_state.destroy\n\n head :no_content\n end",
"def destroy\n @tutorial_state = Tutorial::State.find(params[:id])\n @tutorial_state.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_states_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @united_state.destroy\n respond_to do |format|\n format.html { redirect_to united_states_url, notice: 'United state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @civil_state = CivilState.find(params[:id])\n @civil_state.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_civil_states_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @process_state.destroy\n respond_to do |format|\n format.html { redirect_to process_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @task_state.destroy\n respond_to do |format|\n format.html { redirect_to task_states_url, success: 'Task state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_state.destroy\n respond_to do |format|\n format.html { redirect_to user_states_url, notice: 'User state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estate = Estate.find(params[:id])\n @estate.destroy\n\n respond_to do |format|\n format.html { redirect_to estates_url }\n format.json { head :no_content }\n end\n end",
"def delete\n ruta = \"/actions/#{action_id}\"\n client.delete(ruta)\n end",
"def destroy\n @program_state.destroy\n respond_to do |format|\n format.html { redirect_to program_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state_statistic.destroy\n respond_to do |format|\n format.html { redirect_to state_statistics_url, notice: 'State statistic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @host_state.destroy\n respond_to do |format|\n format.html { redirect_to host_states_url, notice: 'Host state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state.destroy\n end",
"def destroy\n @state.destroy\n end",
"def destroy\n @cultural_heritage_collection_state = CulturalHeritage::CollectionState.find(params[:id])\n @cultural_heritage_collection_state.deleted = 1\n @cultural_heritage_collection_state.save\n\n respond_to do |format|\n format.html { redirect_to(cultural_heritage_collection_states_url) }\n format.xml { head :ok }\n end\n end",
"def delete_state(state)\n states.remove(state)\n end",
"def destroy\n @stateform.destroy\n respond_to do |format|\n format.html { redirect_to stateforms_url, notice: 'stateform was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hand_state = HandState.find(params[:id])\n @hand_state.destroy\n\n respond_to do |format|\n format.html { redirect_to hand_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @receipt_state.destroy\n respond_to do |format|\n format.html { redirect_to receipt_states_url, notice: 'Receipt state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@state = State.find(params[:id])\n if @state.destroy\n \tflash[:success] = \"Record destroyed\"\n \tredirect_to states_path\n else\n \tflash[:error] = \"Record not destroyed\"\n end\n\tend",
"def destroy\n @property_state.destroy\n respond_to do |format|\n format.html { redirect_to property_states_url, notice: 'Property state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state_cadre = StateCadre.find(params[:id])\n @state_cadre.destroy\n\n respond_to do |format|\n format.html { redirect_to state_cadres_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @surgery_state.destroy\n respond_to do |format|\n format.html { redirect_to surgery_states_url, notice: 'Surgery state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @poll_workflow_state = PollWorkflowState.find(params[:id])\n @poll_workflow_state.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_workflow_states_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @empire_rc_state.destroy\n respond_to do |format|\n format.html { redirect_to empire_rc_states_url, notice: 'Empire rc state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @current_state.destroy\n respond_to do |format|\n format.html { redirect_to projects_url, notice: 'CurrentState was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @giftstate = Giftstate.find(params[:id])\n @giftstate.destroy\n\n respond_to do |format|\n format.html { redirect_to(giftstates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @ticketstate.destroy\n respond_to do |format|\n format.html { redirect_to ticketstates_url, notice: '删除成功' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @state_copd.destroy\n respond_to do |format|\n format.html { redirect_to state_copds_url, notice: 'State copd was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @action_name = ActionName.find(params[:id])\n @action_name.destroy\n\n respond_to do |format|\n format.html { redirect_to action_names_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estate.destroy\n respond_to do |format|\n format.html { redirect_to estates_url, notice: 'Usunięto' }\n format.json { head :no_content }\n end\n end",
"def delete_state(state)\n @states.reject! { |_,v| v == state }\n#$stderr.print \"States: #{@states.length} \"\n end",
"def destroy\n @project_state.destroy\n head :no_content\n end",
"def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def delete; update(:status => 'DELETED'); end",
"def destroy\n @state_prov.destroy\n respond_to do |format|\n format.html { redirect_to state_provs_url, notice: 'State prov was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @socket_state = SocketState.find(params[:id])\n @socket_state.destroy\n\n respond_to do |format|\n format.html { redirect_to(socket_states_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @story_status = StoryStatus.find(params[:id])\n @story_status.destroy\n\n respond_to do |format|\n format.html { redirect_to story_statuses_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @private_message_state.destroy\n respond_to do |format|\n format.html { redirect_to private_message_states_url, notice: 'Private message state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @status.destroy\n respond_to do |format|\n format.html { redirect_to statuses_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Location.delete(params[\"id\"])\n end",
"def destroy\n @estate = Estate.find(params[:id])\n @estate.destroy\n \n respond_to do |format|\n format.html { redirect_to(estates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @request_status = RequestStatus.find(params[:id])\n @request_status.destroy\n\n respond_to do |format|\n format.html { redirect_to request_statuses_url }\n format.json { head :no_content }\n end\n end",
"def delete(action, **args); end",
"def destroy\n @state_province = StateProvince.find(params[:id])\n @state_province.destroy\n\n respond_to do |format|\n format.html { redirect_to(state_provinces_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @position_state.destroy\n respond_to do |format|\n format.html { redirect_to position_states_url, notice: 'Position state was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @realestate.destroy\n respond_to do |format|\n format.html { redirect_to realestates_url, notice: 'Realestate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realestate.destroy\n respond_to do |format|\n format.html { redirect_to realestates_url, notice: \"Realestate was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @project = @kanban_state.project\n\n authorize @kanban_state\n\n @project.tasks.where(kanban_state_id: @kanban_state.id).each do |task|\n task.update_attributes(kanban_state_id: nil)\n end\n @kanban_state.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_admin_project_path(@kanban_state.project_id, anchor: \"kanban_states\"), notice: t('actions.destroyed_with_success')}\n format.json { head :no_content }\n end\n end",
"def destroy\n @zone_status = ZoneStatus.find(params[:id])\n @zone_status.destroy\n\n respond_to do |format|\n format.html { redirect_to zone_statuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estate.destroy\n respond_to do |format|\n format.html { redirect_to estates_url, notice: 'Propiedad eliminada exitosamente.' }\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 delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @status = Status.find(params[:id])\n @status.destroy\n\n redirect_to statuses_url\n end",
"def destroy\n @sa_request_status.destroy\n respond_to do |format|\n format.html { redirect_to sa_request_statuses_url, notice: 'Sa request status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to country_state_cities_url, :notice => t('controller_message.deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sa_action_type.destroy\n respond_to do |format|\n format.html { redirect_to sa_action_types_url, notice: 'Sa action type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @status_animal = StatusAnimal.find(params[:id])\n @status_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to status_animais_url }\n format.json { head :no_content }\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 @tracked_action = TrackedAction.find(params[:id])\n @tracked_action.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_tracked_actions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @actiontype.destroy\n respond_to do |format|\n format.html { redirect_to actiontypes_url, notice: 'Actiontype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transition.destroy\n respond_to do |format|\n format.html { redirect_to workflow_events_transitions_url, notice: 'Transition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @outcome_mapping = OutcomeMapping.find(params[:id])\n @outcome_mapping.destroy\n\n respond_to do |format|\n format.html { redirect_to outcome_mappings_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @wallet_action.destroy\n respond_to do |format|\n format.html { redirect_to wallet_actions_url, notice: 'Wallet action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent_status = AgentStatus.find(params[:id])\n @agent_status.destroy\n\n respond_to do |format|\n format.html { redirect_to agent_statuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @accessory_act = AccessoryAct.find(params[:id])\n @accessory_act.destroy\n\n respond_to do |format|\n format.html { redirect_to accessory_acts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @status_ativ = StatusAtiv.find(params[:id])\n @status_ativ.destroy\n\n respond_to do |format|\n format.html { redirect_to status_ativs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unit_action_type.destroy\n respond_to do |format|\n format.html { redirect_to unit_action_types_url, notice: 'Unit action type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def set_deleted_all\n @states.set_deleted_all\n\n respond_to do |format|\n format.json {\n render json: {\n 'message': t('.success'),\n 'type': 'success'\n }\n }\n end\n end",
"def destroy\n @scene_of_action.destroy\n redirect_to scene_of_actions_url\n end",
"def delete_status(id)\n delete(\"/statuses/#{id}\")\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def destroy\n @flat_stage.destroy\n respond_to do |format|\n format.html { redirect_to flat_stages_url, notice: 'Stage was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reqstatus.destroy\n respond_to do |format|\n format.html { redirect_to reqstatuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kf_status = Kf::Status.find(params[:id])\n @kf_status.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/kf/statuses?page=#{params[:page]}&relation_id=#{params[:relation_id]}&status_type=#{params[:status_type]}&count_type=#{params[:count_type]}\" }\n format.json { head :no_content }\n end\n end"
] | [
"0.75898534",
"0.75869477",
"0.75869477",
"0.742729",
"0.73140097",
"0.7312422",
"0.7312422",
"0.7297364",
"0.72574395",
"0.7200444",
"0.7171735",
"0.7147914",
"0.7121784",
"0.7097709",
"0.7046991",
"0.7040303",
"0.70086247",
"0.69935286",
"0.6973888",
"0.69417274",
"0.69334567",
"0.69177896",
"0.6892989",
"0.68380976",
"0.6780091",
"0.6760999",
"0.6754426",
"0.6721001",
"0.6712873",
"0.6710391",
"0.6646847",
"0.6626562",
"0.6621888",
"0.65866053",
"0.65853953",
"0.65372425",
"0.65372425",
"0.65358275",
"0.6517536",
"0.6504415",
"0.6494946",
"0.6442748",
"0.6432162",
"0.6410893",
"0.6410403",
"0.64075595",
"0.6392823",
"0.63917017",
"0.6379263",
"0.63765496",
"0.63394433",
"0.6311514",
"0.6275273",
"0.62726927",
"0.62621063",
"0.6256067",
"0.6219085",
"0.61873114",
"0.6158262",
"0.6146823",
"0.6143478",
"0.6111779",
"0.6110663",
"0.6103199",
"0.61003566",
"0.6091311",
"0.6089883",
"0.6087478",
"0.60860676",
"0.6072386",
"0.6067436",
"0.60525215",
"0.6049603",
"0.6036351",
"0.60203034",
"0.5997994",
"0.59963524",
"0.5991681",
"0.59889394",
"0.59803367",
"0.597606",
"0.5974567",
"0.59710574",
"0.5968144",
"0.5966884",
"0.59446096",
"0.593279",
"0.5932104",
"0.59303635",
"0.5925583",
"0.5923349",
"0.59220195",
"0.59207135",
"0.59199566",
"0.59162974",
"0.5909675",
"0.59092975",
"0.5908557",
"0.5907182",
"0.58900607"
] | 0.7370482 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_action_state
@action_state = ActionState.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.5332605",
"0.5312215",
"0.5296594",
"0.52965283",
"0.52957606",
"0.5259903",
"0.52443177",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.523896",
"0.52329034",
"0.52322394",
"0.5227445",
"0.5222394",
"0.5220348",
"0.5212759",
"0.5207747",
"0.5205933",
"0.5176468",
"0.5173833",
"0.5171983",
"0.51663405",
"0.5159596",
"0.5158247",
"0.51526845",
"0.5152398",
"0.5151361",
"0.5145775",
"0.5140135",
"0.51338995",
"0.51127726",
"0.5112607",
"0.5112607",
"0.5110613",
"0.51067513",
"0.5092337",
"0.508788",
"0.5081578",
"0.5080434",
"0.50679874",
"0.50567716",
"0.5051213",
"0.5048352",
"0.5048352",
"0.5035347",
"0.5026666",
"0.5023127",
"0.5016081",
"0.50129867",
"0.5000684",
"0.4999752",
"0.49979812",
"0.499026",
"0.499026",
"0.49866846",
"0.49800366",
"0.49795717",
"0.49771172",
"0.4968475",
"0.4965813",
"0.4958072",
"0.49561292",
"0.4954901",
"0.49536785",
"0.4953058",
"0.49468648",
"0.49424478",
"0.4932989",
"0.49291888",
"0.49273813",
"0.49271655",
"0.4925948",
"0.49236968",
"0.49203572",
"0.49181753",
"0.49173692",
"0.4916862",
"0.49161318",
"0.49155986"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def action_state_params
params.require(:action_state).permit(:project_id, :chara, :field, :freq, :precis)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
Input: name and group assignment for new group list Output: new list with name and group to which the stduetns belong, with request to update one group that has too many students. Code is very simple steps: create new hash with information ofs student names with group assigned reassign student to a different group list the has of students and group assignment make a change for assignment and update the list | def add(list, student,group)
list[student] = group
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_groups list #hash or array\n updated=false\n if list.is_a? Array\n list.each do |grp|\n next if check_group grp\n @@groups[grp]=grp.to_s\n updated=true\n end\n else\n list.each_pair do |grp,name|\n next if check_group grp\n @@groups[grp]=name\n updated=true\n end\n end\n save if updated\n end",
"def assign_group(group_size, students)\n\nend",
"def assign_to_groups(number_of_students)\n if not ((number_of_students % 5) == 1 || (number_of_students % 5) == 2)\n group_size = 5\n easy = true\n else\n group_size = 4\n stragglers = number_of_students % group_size\n if stragglers == (0||3)\n easy = true\n else\n easy = false\n end\n end\n my_student_array = (1..number_of_students).to_a.shuffle\n group_assignments = Hash.new\n if easy == true\n assign(my_student_array, 0, group_assignments)\n else #easy = false\n assign(my_student_array, stragglers, group_assignments)\n while my_student_array.length > 0\n group_number -=1\n x = my_student_array.shift\n group_assignments[x] = group_number\n end\n end\n return group_assignments\nend",
"def clone_groupings_from(assessment_id)\n warnings = []\n original_assignment = Assignment.find(assessment_id)\n self.transaction do\n self.group_min = original_assignment.group_min\n self.group_max = original_assignment.group_max\n self.student_form_groups = original_assignment.student_form_groups\n self.group_name_autogenerated = original_assignment.group_name_autogenerated\n self.group_name_displayed = original_assignment.group_name_displayed\n self.groupings.destroy_all\n self.assignment_properties.save\n self.save\n self.reload\n original_assignment.groupings.each do |g|\n active_student_memberships = g.accepted_student_memberships.select { |m| !m.user.hidden }\n if active_student_memberships.empty?\n warnings << I18n.t('groups.clone_warning.no_active_students', group: g.group.group_name)\n next\n end\n active_ta_memberships = g.ta_memberships.select { |m| !m.user.hidden }\n grouping = Grouping.new\n grouping.group_id = g.group_id\n grouping.assessment_id = self.id\n grouping.admin_approved = g.admin_approved\n unless grouping.save\n warnings << I18n.t('groups.clone_warning.other',\n group: g.group.group_name, error: grouping.errors.messages)\n next\n end\n all_memberships = active_student_memberships + active_ta_memberships\n Repository.get_class.update_permissions_after(only_on_request: true) do\n all_memberships.each do |m|\n membership = Membership.new\n membership.user_id = m.user_id\n membership.type = m.type\n membership.membership_status = m.membership_status\n unless grouping.memberships << membership # this saves the membership as a side effect, i.e. can return false\n grouping.memberships.delete(membership)\n warnings << I18n.t('groups.clone_warning.no_member',\n member: m.user.user_name, group: g.group.group_name, error: membership.errors.messages)\n end\n end\n end\n end\n end\n\n warnings\n end",
"def assign_songs_to_group(songs_list, group, energy_level)\n gsas = []\n songs_list.each do |song_hash|\n song = Song.where(:itunes_persistent_id => song_hash['Persistent ID']).first\n # Create song if it's not there\n if song.nil?\n song = create_song(song_hash)\n end\n\n gsas << GroupSongAssignment.new(:song_id => song.id, :group_id => group.id, :energy_level_id => energy_level.id)\n end\n\n # Delete old song assignment (only delete the one of the same energy level)\n group.group_song_assignments.where(:energy_level_id => energy_level.id).delete_all\n\n # Create group_song_assignments. This will also blow out the old assignments\n # TODO: figure out how to mass delete and mass insert to speed things up\n gsas.each do |gsa|\n group.group_song_assignments << gsa\n end\n end",
"def make_groups(all_students)\n\n #calculate how many groups of 5, with one group of leftovers\n num_full_groups = all_students.size / 5\n leftovers = all_students.size % 5\n group_avg = all_students.size.to_f / num_full_groups\n\n #each entry in group_sizes represents one group - put 5 in each full one\n group_sizes = Array.new\n for i in 0...num_full_groups\n group_sizes[i] = 5\n end\n\n #if there's a leftover group- while its size is (1 or more) students less than average, move students into it from other groups one by one\n if leftovers != 0\n i = 0\n while ((group_avg - leftovers) >= 1)\n group_sizes[i] -= 1\n leftovers += 1\n if i.next == num_full_groups\n i = 0\n else\n i = i.next\n end\n end\n group_sizes << leftovers #add leftovers group to group_sizes list\n end\n\n #now we have an array of group sizes, ex: [4,4,5,5,4]\n #populate new groups_names array with arrays of student names of those sizes\n\n groups_names = Array.new\n groupcount=0\n group_sizes.cycle(1) do |i|\n groups_names[groupcount] = Array.new\n for j in 0...i\n groups_names[groupcount][j] = all_students.shift\n end\n groupcount += 1\n end\n\n groups_names\n\nend",
"def modify_group\n group = Group.find_by_id params[:group_id]\n current_maillist = get_maillist_for_space(group.id)\n\n if params[:join_type]\n params[:join_level] = convert_join_type_to_join_level(params[:join_type])\n end\n\n if params[:leader_id] && params[:leader_id] != group.leader_id\n membership = group.group_memberships.where(user_id: params[:leader_id]).first\n return render :json => {}, :status => :bad_request unless membership\n params[:leader] = membership.user\n end\n\n if params[:maillist] != current_maillist\n render json: { valid_maillist: false }, status: :ok unless params[:maillist].empty? || maillist_is_valid?(params[:maillist])\n # params[:new_membership] = maillist_members(params[:maillist]).map { |member| Pseudonym.find_by_unique_id(member).user rescue nil}.compact\n params[:new_membership] = maillist_members(params[:maillist]).map do |member|\n pseudonym = Pseudonym.active.by_unique_id member\n pseudonym.first.user unless pseudonym.empty?\n end\n params[:new_membership].compact!\n params[:new_membership].uniq!\n end\n\n if authorized_action(group, @current_user, :update)\n respond_to do |format|\n group.transaction do\n group.update_attributes(params.permit(*SETTABLE_GROUP_ATTRIBUTES))\n if params.has_key?(:leader)\n group.leader = params[:leader]\n end\n if params.has_key?(:new_membership) && params[:new_membership].empty?\n group.group_memberships.where(\"user_id NOT IN (?)\", [group.leader]).destroy_all\n delete_maillist_for_space(group.id)\n end\n group.set_users(params[:new_membership]) if params.has_key?(:new_membership)\n set_maillist_for_space(group.id, params[:maillist]) unless params[:maillist].nil? || params[:maillist].empty?\n end\n\n if !group.errors.any?\n format.json { render :json => group_formatter(group, { include: ['users'] }), :status => :ok }\n else\n format.json { render :json => @group.errors, :status => :bad_request }\n end\n end\n end\n end",
"def update_group\n if @ok\n @mailing_list_group.name = params[:name]\n @ok = @mailing_list_group.save\n @mailing_list_group = MailingListGroup.find @mailing_list_group_id if !@ok\n end\n end",
"def update\n @student.groups = []\n if params[:student][:group_ids]\n params[:student][:group_ids].each { |group_id| \n @student.groups << Group.find(group_id)\n }\n end\n\n respond_to do |format|\n if @student.update(student_params)\n @students = Student.all\n format.html { render action: \"index\", notice: \"Student was successfully updated.\" }\n format.json { render action: \"index\", status: :ok }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n if @student.isAdmin\n @student.groups = []\n @student.save\n end\n end",
"def assigned_groups=(array_hash)\n # Find new groups (but no duplicates)\n self.added_groups = []\n array_hash.each do |h|\n unless groups.detect { |c| c.id.to_s == h[:id] } || self.added_groups.detect { |f| f.id.to_s == h[:id] }\n c = !h[:id].blank? ? Group.find(h[:id]) : Group.new({:page_object => self})\n c.attributes = h.reject { |k,v| k == :id } # input values, but don't try to overwrite the id\n self.added_groups << c unless c.nil?\n end\n end\n # Delete removed groups\n groups.each do |c|\n if h = array_hash.detect { |h| h[:id] == c.id.to_s }\n c.attributes = h.reject { |k,v| k == :id }\n else\n c.destroy_association = 1\n end\n end\n end",
"def accountability_groups(students)\nnum_of_groups = (1..15).to_a #turns number of groups needed into an array\n\nstudent_groups = Array.new #array of arrays of 4 or 5 students \nacct_groups = Hash.new #keys[num_of_groups], value(student_groups)\n\nstudents.each_slice(4) { |s| student_groups << s } #returns array of 14 groups of 4, 1 group of 1\n\nleftover = student_groups.pop #assigns variable name to the group of 1 student\n\nstudent_groups[-1].push leftover #pushes 1 leftover student into the 14th group \n\nnum_of_groups.each_with_index { |i, j| acct_groups[i]=student_groups[j] } #assigns number of groups needed (15 groups) as the hash keys and assigns each student group to a key's value.\n\np acct_groups\n\nend",
"def update\n @group = StudentGroup.find(params[:id])\n users= []\n respond_to do |format|\n if @group.update_attributes(params[:student_group])\n if params[\"users\"].present?\n users = users+params[\"users\"]\n end\n if params[\"students\"].present?\n users = users+params[\"students\"]\n end\n if params[\"teachers\"].present?\n users = users+params[\"teachers\"]\n end\n unless users.empty?\n UserGroup.where(:group_id=>@group.id).destroy_all\n users.uniq.each do |i|\n UserGroup.create(:group_id=>@group.id,:user_id=>i.to_i)\n end\n end\n # @group.profile.update_attributes(params[:user][:profile_attributes]) if params[:user][:profile_attributes]\n #@group.user_group.update_attributes(params[:user][:user_group_attributes]) if params[:user][:user_group_attributes]\n format.html { redirect_to group_path(@group), notice: 'Group was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_groups_subgroup(glisthash, lines, defaultkey, groupcol, subgroupcol, \n\t\thighlighted_group=\"\", snpTags=nil)\n # set up hash for holding columns for main group names\n subnames = Hash.new\n subgrouporder = Array.new\n groupnames = Hash.new\n groupnameorder = Array.new\n \n for i in (1..lines.length-1)\n data = strip_and_split(lines[i])\n if subgroupcol\n unless subnames.has_key?(data[subgroupcol])\n subnames[data[subgroupcol]]=1\n subgrouporder << data[subgroupcol]\n end\n end\n if groupcol\n unless groupnames.has_key?(data[groupcol])\n groupnames[data[groupcol]]=1\n groupnameorder << data[groupcol]\n end\n end\n end\n \n groups = Hash.new\n grouporder = Array.new\n groupkeys = Array.new \n\tgroupcolors = Hash.new \n \n # construct the groups\n groupnameorder.each do |gname|\n gname == highlighted_group ? highlighted = true : highlighted = false\n if subnames.empty?\n key = gname\n#\t\t\tsnpTags.tags.has_key?(key) ? colorstr = snpTags.tags[key] : colorstr = GroupList.get_next_color\n\t\t\tcolorstr = GroupList.get_next_color\n groups.store(key, Group.new(key, highlighted,colorstr))\n\t\t\tgroupcolors[key]=colorstr\n grouporder << key\n groupkeys << key\n else\n subnames.each_key do |sname| \n key = gname + ':' + sname\n groups.store(key, Group.new(key, highlighted))\n grouporder << key\n groupkeys << key\n end\n end\n end\n \n mafcoltitle = 'MAF'\n headers = strip_and_split(lines[0])\n\n # create the groups using the headers \n headers.each_with_index do |header, i|\n \n if header =~ /snp\\s*id/i || header=~ /snp_id/i || header =~ /^snp$/i\n @snpid = i\n elsif header =~ /snp\\s*name/i\n @snpname = i\n elsif header =~ /chromosome|CHR|^chrom$/i\n @chromnum = i\n elsif header =~ /location|^pos$|^bp$/i\n @location = i\n\t\telsif header =~ /^snpcolor|snp\\scolor/i\n\t\t\t@snpcolorcol = i\n\t\telsif header =~ /anc\\d/i\n\t\t\t# should be anc0, anc1, or anc2\n\t\t\tallelenum = /anc(\\d)/.match(header)[1]\n\t\t\t@anccol[allelenum.to_i] = i\n elsif header =~ /^subgroup$/i || header =~ /^group$/i # skip if no _ to mark name\n next\n else\n header.strip!\n column_type = header\n if column_type =~ /pval|p_value/i\n groupkeys.each {|key| groups[key].pcol = i}\n elsif column_type =~ /beta_uci|betauci/i\n groupkeys.each {|key| groups[key].betaucicol = i}\n elsif column_type =~ /beta_lci|betalci/i\n groupkeys.each {|key| groups[key].betalcicol = i}\n elsif column_type =~ /beta/i or column_type =~ /^es$/i\n groupkeys.each {|key| groups[key].betacol = i}\n elsif column_type =~ /^n$|^sample_size$/i\n groupkeys.each {|key| groups[key].Ncol = i}\n elsif column_type =~ /cafcases/i\n groupkeys.each {|key| groups[key].cafcasescol = i}\n elsif column_type =~ /cafcontrols/i\n groupkeys.each {|key| groups[key].cafcontrolscol = i}\n elsif column_type =~ /^maf|caf$/i\n if column_type =~ /caf/i\n mafcoltitle = 'CAF'\n end\n groupkeys.each {|key| groups[key].mafcafcol = i}\n elsif column_type =~ /^or$/i\n groupkeys.each {|key| groups[key].orcol = i}\n elsif column_type =~ /^rank$/i\n groupkeys.each {|key| groups[key].rankcol = i}\t\t\t\t\n elsif column_type =~ /^upper_ci|uci$/i\n groupkeys.each {|key| groups[key].ucicol = i}\n elsif column_type =~ /lower_ci|lci/i\n groupkeys.each {|key| groups[key].lcicol = i}\n elsif column_type =~ /cases/i\n groupkeys.each {|key| groups[key].casescol = i }\n elsif column_type =~ /controls/i\n groupkeys.each {|key| groups[key].controlscol = i}\n elsif column_type =~ /study/i\n groupkeys.each {|key| groups[key].studycol = i}\n elsif column_type =~ /^power$/i\n groupkeys.each {|key| groups[key].powercol = i}\n else\n groupkeys.each {|key| groups[key].additional_cols[column_type] = i} \n end\n end\n end\n\n unless @snpid and @location and @chromnum\n puts \"ERROR: Need SNP, CHR, and POS columns in input file\"\n exit\n end\n # add groups to the grouplist\n grouporder.each do |g|\n namepcs = g.split /:/\n\n # add to default grouplist\n if namepcs.length == 1\n if !glisthash.has_key?(defaultkey)\n glisthash[defaultkey] = GroupList.new\n glisthash[defaultkey].mafcoltitle = mafcoltitle\n end\n glisthash[defaultkey].add_group(groups[g])\n else\n if !glisthash.has_key?(namepcs[1])\n glisthash[namepcs[1]] = GroupList.new\n glisthash[namepcs[1]].mafcoltitle = mafcoltitle\n end\n glisthash[namepcs[1]].add_group(groups[g])\n end\n end\n\n # need to match all colors when multiple grouplists\n if glisthash.length > 1\n # determine number of unique groups\n unique_names = Hash.new\n glisthash.each_value do |glist|\n glist.grouphash.each_key do |name|\n namepcs = name.split /:/\n unique_names[namepcs[0]] = 1\n end\n end\n colorhash = Hash.new\n unique_names.each_key do |name|\n#\t\t\tsnpTags.tags.has_key?(name) ? colorstr = snpTags.tags[name] : colorstr = GroupList.get_next_color\n\t\t\tcolorstr = GroupList.get_next_color\n colorhash[name] = colorstr\n\t\t\tgroupcolors[name]=colorstr\n end\n\n glisthash.each_value do |glist|\n glist.grouphash.each do |name, group|\n namepcs = name.split /:/\n group.colorstr = colorhash[namepcs[0]]\n end\n end\n\n end\n\t\n\t# set group list colors for the tags (if any)\n\tif(snpTags)\n\t\tsnpTags.tags.each_key do |key|\n\t\t\tif(groupcolors.has_key?(key))\n\t\t\t\tsnpTags.tags[key]=groupcolors[key]\n\t\t\telse\n\t\t\t\tsnpTags.tags[key]=GroupList.get_next_color\n\t\t\tend\n\t\tend\n\tend\n \nend",
"def update\n counter = 0\n groupCounter = 1\n if !params[:group].nil?\n $inspectparams = params[:group]\n params[:group].each do |group|\n if groupCounter > $groupUpdateNumber || group[:id] == \"\"\n puts \"WORKKKK\"\n break if group[:group_name] == \"\" || group[:end_time] == \"\"\n @group = current_user.groups.build(group_name: group[:group_name].downcase, end_time: group[:end_time], group_day: group[:group_day], conversation_id: group[:conversation_id], time_zone: current_user.time_zone)\n @group.save\n end\n break if group[:group_name] == \"\" || group[:end_time] == \"\"\n @groupUpdate = Group.find_by(id: group[:id])\n @groupUpdate.update(group_name: group[:group_name].downcase, end_time: group[:end_time], time_zone: current_user.time_zone) if !@groupUpdate.nil?\n puts \"this is @group: \" + @group.inspect.to_s\n groupCounter += 1\n counter += 1\n end\n end\n redirect_to root_path, notice: \"successfully updated your classes\"\n end",
"def update\n\n respond_to do |format|\n if @tutor_group.update(tutor_group_params)\n if params[:students]\n params[:students].each do |stud|\n @student=Student.find_by(:id=>stud)\n @student.temp_tg_user_id=0\n @student.save\n end\n updated_students = params[:students]\n\n existing_students = @tutor_group.students.collect{|s| \"#{s.id}\"}\n\n\n new_students = updated_students - existing_students\n deleted_students = existing_students - updated_students\n\n\n new_students.each do |s|\n @students_tg = TutorGroupStudent.find_or_initialize_by(:academic_session_id=>session[:global_academic_session], student_id: s) \n @students_tg.tutor_group_id = @tutor_group.id\n @students_tg.save\n end\n\n deleted_students.collect { |id| TutorGroupStudent.where(tutor_group_id: @tutor_group.id, student_id: id).destroy_all}\n else\n TutorGroupStudent.where(tutor_group_id: @tutor_group.id).destroy_all\n end\n\n format.html { redirect_to tutor_groups_path, notice: @tutor_group.name + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @tutor_group }\n else\n format.html { render :edit }\n format.json { render json: @tutor_group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @group = Group.find(params[:id])\n\n if @group.owner != current_user\n respond_to do |format|\n format.html { redirect_to @group, notice: 'User not authorized.' }\n format.json { render json: @group, status: :not_authorized, location: group }\n end\n return\n end\n\n new_group_name = params[:group][:name]\n group_name_exists = false\n\n if new_group_name != @group.name\n current_user.owned_groups.each do |g|\n if g.name == new_group_name\n group_name_exists = true\n end\n end\n end\n \n respond_to do |format|\n if group_name_exists\n format.html { redirect_to @group, :alert => \"You already have a group by the name '#{new_group_name}'.\" }\n format.json { head :no_content }\n elsif new_group_name == @group.name\n format.html { redirect_to @group }\n format.json { head :no_content }\n elsif @group.update_attributes(params[:group])\n format.html { redirect_to @group, :notice => 'Group was successfully updated.' }\n format.json { head :no_content }\n else\n error_msg = 'Unexpected error while updating group.'\n if @group.errors.messages.count > 0\n error_msg = 'Following error(s) prevented the group from being saved: '\n multiple = false\n @group.errors.full_messages.each do |msg|\n if multiple\n error_msg += ', '\n end\n error_msg += msg\n multiple = true\n end\n end\n format.html { redirect_to @group, :alert => error_msg }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def make_groups(name_master_list, group_size, min_group_size, shuffle_first = false)\n\tgroups = {}\n\t# Set initial group number\n\tgroup_num = 1\n\tname_master_list.shuffle! if shuffle_first\n\t\n\tname_master_list.each_with_index do |name, index|\n\t\t# Set the value as an empty array if it doesn't already exist\n\t\tgroups[\"Group #{group_num}\"] ||= [] \n\t\tgroups[\"Group #{group_num}\"] << name\n\t\t# Test whether we have either reached the group size already\n\t\t# Or if we have reached the final name (The item at the next index is nil)\n\t\tif (index + 1) % group_size == 0 && name_master_list[index + 1] != nil\n\t\t\t# Time to make a new group with a new group number\n\t\t\tgroup_num += 1\n\t\tend\n\tend\n\n\t# The last group will be the one with the current group_num value\n\tlast_group = groups[\"Group #{group_num}\"]\n\t# Test if the last group is too small; if so, add its members to the other groups\n\tif last_group.length < min_group_size\n\t\t# Make the second-to-last group the new group for the first member\n\t\tnew_group_num = group_num - 1\n\t\tlast_group.each do |name|\n\t\t\t# Put the member into its new group\n\t\t\tgroups[\"Group #{new_group_num}\"] << name\n\t\t\t# Set a different new group for the next member\n\t\t\tnew_group_num -= 1\n\t\tend\n\t\t# Get rid of the group that was too small, now that its members have new groups\n\t\tgroups.delete(\"Group #{group_num}\")\n\tend\n\n\treturn groups\nend",
"def add_new_student_to_schools_student_array(new_student_name, new_student_grade, school)\n new_student = {name: new_student_name, grade: new_student_grade}\n #school[:students].push(new_student)\n school[:students][school[:students].size] = new_student\n school\nend",
"def student_edit_grp_name(course, group, new_name)\n student_visit_grp(course, group)\n logger.debug \"Changing group title to '#{group.title = new_name}'\"\n wait_for_update_and_click edit_group_link_element\n wait_for_element_and_type(edit_group_name_input_element, group.title)\n wait_for_update_and_click save_button_element\n wait_until(Utils.short_wait) { recent_activity_heading.include? group.title }\n end",
"def create\n @student = Student.new(student_params)\n @student.count = 0\n @student.password = \"default\"\n if params[:student][:group_ids] \n params[:student][:group_ids].each { |group_id| \n @student.groups << Group.find(group_id)\n }\n end\n\n respond_to do |format|\n if @student.save\n @students = Student.all\n format.html { render action: \"index\", notice: \"Student was successfully created.\" }\n format.json { render :index, status: :created}\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n if @student.isAdmin\n @student.groups = []\n end\n end",
"def batch_create_groups(batch)\n # Load existing students\n students_by_studentnumber = {} # 'studentnumber' => User\n students_by_lti_user_id = {}\n students_by_email = {} # 'email' => User\n self.students.each do |student|\n students_by_studentnumber[student.studentnumber] = student\n students_by_lti_user_id[student.lti_user_id] = student\n students_by_email[student.email] = student\n end\n \n # Load existing groups\n groups_by_student_id = {} # student_id => [array of groups where the student belongs]\n self.groups.includes(:users, :reviewers).each do |group|\n group.users.each do |student|\n groups_by_student_id[student.id] ||= []\n groups_by_student_id[student.id] << group\n end\n end\n \n # Load assistants\n reviewers = {} # key => User\n reviewers_ambiguous_keys = {}\n reviewer_keys = [:email, :studentnumber] # , :firstname, :lastname, :name\n (self.course.teachers + self.assistants + self.students).each do |user|\n reviewer_keys.each do |key|\n value = user.send(key)\n next unless value\n value = value.downcase.strip\n \n # Mark the key as ambiguous if it has been seen already\n reviewers_ambiguous_keys[value] = true if reviewers[value]\n \n reviewers[value] = user\n end\n end\n \n batch.lines.each do |line|\n parts = line.split(';')\n student_keys = parts[0].split(',')\n \n # Find or create students\n group_students = [] # Array of User objects that were loaded or created based on the input row\n group_student_ids = []\n current_groups = [] # Array of arrays of Groups, [[groups of first student], [groups of second student], ...]\n student_keys.each do |student_key|\n student_key.strip!\n next if student_key.empty?\n \n student = nil\n if student_key.include?('@')\n # Search by email\n search_key = student_key\n student = students_by_email[search_key] # Search from students in the course\n \n unless student\n student = User.where(:email => search_key).first # Search from database\n unless student # Create new user\n student = User.new(:email => search_key, :firstname => '', :lastname => '')\n student.organization_id = self.course.organization_id\n student.save(:validate => false)\n end\n self.students << student # Add student to course\n students_by_studentnumber[student.studentnumber] = student\n students_by_email[student.email] = student\n end\n \n else\n # Search by studentnumber\n search_key = student_key\n student = students_by_studentnumber[search_key] || students_by_lti_user_id[search_key] # Search from students in the course\n \n unless student\n relation = User.where(:studentnumber => search_key) # Search from database\n # relation = relation.where(:organization_id => self.course.organization_id) if self.course.organization_id\n student = relation.first\n \n # Create new user\n if !student && self.submission_policy != 'lti'\n student = User.new(:firstname => '', :lastname => '')\n student.studentnumber = search_key\n student.organization_id = self.course.organization_id\n student.save(:validate => false)\n end\n \n if student\n self.students << student # Add student to course\n students_by_studentnumber[student.studentnumber] = student\n students_by_email[student.email] = student\n end\n end\n end\n \n if student\n g = groups_by_student_id[student.id] || []\n current_groups << g\n group_students << student\n group_student_ids << student.id\n end\n end\n \n next if group_students.empty?\n \n # Calculate the intersection of students' current groups, ie. find the groups that contain all of the given students.\n groups = current_groups.inject(:&)\n \n # The list now contains the groups with the requested students but possibly extra students as well.\n # Find the group that contains the requested amount of students.\n group = nil\n groups.each do |g|\n if g.users.size == group_students.size\n group = g\n break\n end\n end\n \n # Create group if not found\n unless group\n group_name = (group_students.collect { |user| user.studentnumber }).join('_')\n group = Group.new(:name => group_name, :course_instance_id => self.id, :max_size => group_students.size)\n group.save(:validate => false)\n\n group_students.each do |student|\n member = GroupMember.new(:email => student.email, :studentnumber => student.studentnumber)\n member.group = group\n member.user = student\n member.save(:validate => false)\n group.group_members << member\n \n groups_by_student_id[student.id] ||= []\n groups_by_student_id[student.id] << group\n end\n end\n \n # Set reviewers\n if parts.size >= 2\n reviewer_keys = parts[1].split(',')\n \n reviewer_keys.each do |reviewer_key|\n reviewer_key = reviewer_key.strip.downcase\n next if reviewer_key.blank?\n \n # Detect ambiguous keys\n if reviewers_ambiguous_keys[reviewer_key]\n # TODO: warn about ambiguous key\n next\n end\n \n reviewer = reviewers[reviewer_key]\n unless reviewer\n # TODO: warn that reviewer was not found\n next\n end\n \n group.reviewers << reviewer unless group.reviewers.include? reviewer\n end\n end\n end\n end",
"def student_create_grp(course, group)\n load_course_grps course\n logger.info \"Student is creating a student group called '#{group.title}' with #{group.members.length} additional members\"\n wait_for_update_and_click button_element(class: 'add_group_link')\n wait_for_element_and_type(add_group_name_input_element, group.title)\n group.members.each do |member|\n scroll_to_bottom\n (checkbox = checkbox_element(xpath: \"//span[text()='#{member.full_name}']/preceding-sibling::input\")).when_present Utils.short_wait\n checkbox.check\n end\n wait_for_update_and_click submit_button_element\n (link = student_visit_grp_link(group)).when_present Utils.short_wait\n logger.info \"Group ID is '#{group.site_id = link.attribute('href').split('/').last}'\"\n end",
"def groups(array_of_names)\r\n\r\n\tnum_people = array_of_names.length \t\t#how many people do we have?\r\n\tgroups_5 = num_people % 4 \t#how many groups will have 5\r\n\tgroups_4 = (num_people - (groups_5 * 5)) / 4 # how many groups will have 4\r\n\ttotal_groups = groups_4 + groups_5 \t\t#how many total groups\r\n\r\n\tgroup_hash = Hash.new([])\t#new hash initialized to empty arrays\r\n\t\r\n\tnum_group = 0\r\n\tindex = 0\r\n\r\n\tgroups_5.times do\r\n\t\tpeople_in_group = []\r\n\t\t5.times do\r\n\t\t\tpeople_in_group << array_of_names[index]\r\n\t\t\tindex += 1\r\n\t\tend\r\n\t\tgroup_hash[\"Accountability Group #{num_group}\"] = people_in_group\r\n\t\tnum_group += 1\r\n\tend\r\n\r\n\tgroups_4.times do\r\n\t\tpeople_in_group = []\r\n\t\t4.times do\r\n\t\t\tpeople_in_group << array_of_names[index]\r\n\t\t\tindex += 1\r\n\t\tend\r\n\t\tgroup_hash[\"Accountability Group #{num_group}\"] = people_in_group\r\n\t\tnum_group += 1\r\n\tend\r\n\r\n\treturn group_hash\r\n\r\nend",
"def create_groups(list)\n list_copy = []\n list.each {|item| list_copy.push(item)}\n all_groups = []\n list_copy.shuffle!\n while list_copy.size >= 4\n group = list_copy.pop(4)\n all_groups << group\n end\n if list_copy.size > 0\n list_copy.each_with_index do |person, index|\n person = list_copy.pop\n all_groups[index].push(person)\n end\n end\n hash = {}\n all_groups.each_with_index do |group, index|\n hash[\"Accountability Group #{index}\"] = group\n end\n p hash\nend",
"def update_groups\n unless group_ids.nil?\n self.groups_members.each do |m|\n m.destroy unless group_ids.include?(m.group_id.to_s)\n group_ids.delete(m.group_id.to_s)\n end\n group_ids.each do |g|\n self.groups_members.create(:group_id => g) unless g.blank?\n end\n reload\n self.group_ids = nil\n end\n end",
"def reset_group_membership\n shell_out!(\"group\", \"mod\", \"-n\", \"#{new_resource.group_name}_bak\", new_resource.group_name)\n\n shell_out!(\"group\", \"add\", set_options(overwrite_gid: true))\n\n shell_out!(\"group\", \"del\", \"#{new_resource.group_name}_bak\")\n end",
"def fidder_crabs(names)\n\n # Create empty container for everyone in the group\n everybody = Hash.new\n # Create a counter for group number, defalt to 1\n counter = 1\n\n names.shuffle\n #Mix it up.!!!!!\n\n #while the list is longer than 8 people, put 5 each in a group.\n while names.length >= 8 do\n names_in_group = names[0..4]\n everybody[counter] = names_in_group\n counter +=1\n names = names.drop(5)\n end\n\n #if the remainder is 5, have the last group with 5 people\n if names.length == 5\n names_in_group = names[0..4]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(5)\n\n #if the remaiinder group is 7, then we need to split the group into 4 and 3\n elsif names.length == 7\n names_in_group = names[0..3]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(4)\n #creating the last group\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n\n #if the remainder is 6, we can have 2 groups of 3's\n elsif names.length == 6\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n #creating last group of 3\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n\n #if there is a remainder of 4 then create 1 group\n elsif names.length == 4\n names_in_group = names[0..3]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(4)\n\n #if the remainder is 3, then create the last group with 3\n elsif names.length == 3\n names_in_group = names[0..2]\n everybody[counter] = names_in_group\n counter += 1\n names = names.drop(3)\n else\n names.length < 3\n names_in_group = names[0..1]\n everybody[counter] = names_in_group\n names = names.drop(3)\n end\n\n # since we filter by 8, the highest remainder is 7 and the lowest is 3, only 7 and 6 need to be split into 2 groups, while 3 and 4 could be in 1 group by themselfs.\n everybody\n #Return the hash of everybody in their group number with their names.\nend",
"def update_subgroups(sg_names, sg_descriptions)\n # get those previously saved so that we know what was deleted\n previous = self.outcome_subgroups\n previous_ids = previous.collect{|x| x.id}\n\n # the keys in either the names or descriptions hold the object ID\n sg_names.keys.each do |key|\n # if the key is positive\n if key.to_i > 0\n # remove it from the previous array\n if previous_ids.include?(key.to_i)\n previous.delete_at(previous_ids.index(key.to_i))\n previous_ids.delete(key.to_i)\n end\n # update the name and description and save changes\n begin\n sg = OutcomeSubgroup.find(key.to_i)\n rescue\n puts \"\\n\\nERROR: could not find the outcome subgroup with id = #{key}\\n\\n\"\n sg = nil\n end\n unless sg.nil?\n sg.update_attributes(:title => sg_names[key], :description=>sg_descriptions[key]);\n else\n OutcomeSubgroup.create(:outcome_id=>self.id,:title=>sg_names[key],\n :description=>sg_descriptions[key])\n end\n # else if the key is negative\n else\n # create a new outcome subgroup using the name and description provided\n OutcomeSubgroup.create(:outcome_id=>self.id, :title=>sg_names[key], \n :description=>sg_descriptions[key])\n end\n end\n # remove those still left in the previous array\n previous.each do |p|\n p.destroy();\n end\n end",
"def add_student(school, new_student_name, new_student_grade, new_student_semester)\n school[:students].push(:name => new_student_name, \n :grade => new_student_grade, :semester => new_student_semester)\nend",
"def make_acct_groups\n\tputs \"Type in the number of students you have: \"\n\tnumber_students = gets.chomp.to_i\n\n\t# Construct the array with the numbers 1 ... number_stdnts\n\tstudent_id = Array.new(number_students) {|i| i+1 }\n\t#print student_id\n\n\tshuffle_id = student_id.shuffle.to_a\n\t#print shuffle_id\nmod4 = number_students % 4\n\n\tif (number_students == 6)\n\t\tnumber_groups = 2\n\telsif (mod4 ==3)\n\t\tnumber_groups = (number_students / 4) + 1\n\telse\n\t\tnumber_groups = (number_students / 4)\n\tend\n\n\tacct_groups = {} \t\n\tif (number_students == 6)\n\t\tfor i in 1..2\n\t\t\tif (i == 1)\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[0], shuffle_id[1], shuffle_id[2]]\n\t\t\telse\t\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[3], shuffle_id[4], shuffle_id[5]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 3)\n\t\tfor i in 1..number_groups\n\t\t\tif i <= number_groups -1\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\t\telse\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 2)\n\t\tfor i in 1..number_groups\n\t\t\tif i <= (number_groups-2)\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\t\telsif (i == (number_groups -1))\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1], shuffle_id[4*i]]\n\t\t\telse\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1], shuffle_id[4*i], shuffle_id[4*i+1]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 1)\n\t\tfor i in 1..number_groups\n\t\t\tif i <= (number_groups-1)\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\t\telse\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1], shuffle_id[4*i]]\n\t\t\tend\n\t\tend\n\telsif (mod4 == 0)\n\t\tfor i in 1..number_groups\n\t\t\t\tacct_groups[i.to_s] = [shuffle_id[4*i-4], shuffle_id[4*i-3], shuffle_id[4*i-2], shuffle_id[4*i-1]]\n\t\tend\n\tend\n\treturn acct_groups\nend",
"def update_student\n name = ask_for(\"name of the student you want to change\")\n selected_student = find_student(name)\n print_names(selected_student)\n confirmation = ask_for(\" Y/N to modify\")\n if confirmation.downcase == \"y\"\n selected_student.first[:name] = ask_for(\"New name\")\n selected_student.first[:cohort] = ask_for(\"New cohort\")\n selected_student.first[:hobbies] = ask_for(\"New hobbies\")\n @students.map! {|student| (student[:name] == selected_student.first[:name]) ? selected_student.first : student }\n end\nend",
"def update\n @user_group = UserGroup.find_by_id(params[:id])\n permission_ids = params[\"permissions\"] || []\n permission_ids.map! {|p| p.to_i}\n current_permission_ids = @user_group.permission_ids\n group_name = params[\"user_group\"][\"name\"]\n\n existed_group = UserGroup.where(:name =>group_name)\n if existed_group.empty? || existed_group.first.id == params[:id].to_i\n if @user_group.update_attributes(params[\"user_group\"])\n\n # The update action make log saved or not\n is_logged = !@user_group.previous_changes.blank?\n if current_permission_ids != permission_ids\n @user_group.permission_ids = permission_ids\n\n # Create log if not logged before\n @user_group.create_activity :update, owner: current_user, params: {:detail => I18n.t('logs.update_group', group_name: @user_group.name)} if !is_logged\n end\n redirect_to organization_user_groups_path(params[:organization_id])\n end\n else\n flash[:error] = t('user_group.exist')\n redirect_to edit_organization_user_group_path(params[:organization_id],@user_group)\n end\n end",
"def update_group_permissions \n if group_id.present?\n permissions = self.permissions\n # checking if user has permissions or not\n if permissions.present? && self.changed.include?('group_id')\n group_permissions = self.group.permissions\n if group_permissions.present? \n group_permissions.each do |p|\n if p.no_model_permission? \n permission = self.permissions.where(\"no_model_permission = ? AND subject_class = ? AND action = ?\",p.no_model_permission,p.subject_class,p.action).first_or_initialize \n else\n permission = self.permissions.where(\"no_model_permission = ? AND subject_class IS NULL AND action = ?\",p.no_model_permission,p.action).first_or_initialize \n end \n permission.actions_list = (permission.actions_list + p.actions_list).uniq \n permission.status = p.status\n permission.save\n end \n end\n else\n group_permissions = self.group.permissions\n if group_permissions.present?\n columns = (Permission.column_names) - [\"id\",\"resource_id\",\"resource_type\",'created_at','updated_at']\n # Creating all group permissions to user\n self.permissions.create( self.group.permissions.all(:select => columns.join(\",\") ).map(&:attributes) )\n end\n end\n end\n end",
"def new_student(list, name, grade, semester)\n\tlist.push( {:name => name, :grade => grade, :semester => semester} )\nend",
"def create_group_assignment_repo(selected_group: group, new_group_title: nil)\n result = invitation.redeem_for(\n current_user,\n selected_group,\n new_group_title\n )\n\n case result.status\n when :failed\n report_invitation_failure if invitation.enabled?\n flash[:error] = result.error\n redirect_to group_assignment_invitation_path\n when :success, :pending\n GitHubClassroom.statsd.increment(\"group_exercise_invitation.accept\")\n route_based_on_status\n end\n end",
"def update_IT_Admin(roles)\n roles.each do |group|\n if group[\"groupTitle\"] == \"IT Administrator\"\n rights = group[\"rights\"]\n rights.push(SECURITY_EVENT_RIGHT).uniq!\n end\n end\nend",
"def manage_groups\n \n if request.get?\n course_id = params[:id]\n @course = Course.find(course_id)\n \n group_1 = CourseGroup.find_all_by_course_id_and_group(course_id, 0).collect(&:user_id)\n group_2 = CourseGroup.find_all_by_course_id_and_group(course_id, 1).collect(&:user_id)\n\n course_students = StudentInCourse.find_all_by_course_id(course_id).collect(&:user_id)\n \n @ungrouped = User.find_all_by_id(course_students).reject{ |user| user.id.in? group_1 or user.id.in? group_2 }\n @group_1 = User.find_all_by_id(group_1)\n @group_2 = User.find_all_by_id(group_2)\n else #post request\n course_id = params[:id]\n group1 = params['group1']\n group2 = params['group2']\n ungrouped = params['ungrouped']\n \n \n \n CourseGroup.destroy_all(:course_id => course_id)\n group1.each do |user|\n CourseGroup.create(:course_id => course_id, :user_id => user, :group => 0)\n end\n group2.each do |user|\n CourseGroup.create(:course_id => course_id, :user_id => user, :group => 1)\n end\n \n render :nothing => true\n flash[:notice] = \"Groups updated!\"\n end\n end",
"def grade_users(arr_of_discussing_user_ids)\n list_assignments = HTTParty.get(\n \"#{$canvas_url}/api/v1/courses/#{$canvas_course_id}/assignments\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" }\n )\n\n assignments_data = list_assignments.parsed_response\n assignment_AL1_id = nil\n assignment_AL2_id = nil\n\n assignments_data.each do |assignments_info|\n if assignments_info[\"name\"] == \"AL1\"\n assignment_AL1_id = assignments_info[\"id\"]\n elsif assignments_info[\"name\"] == \"AL2\"\n assignment_AL2_id = assignments_info[\"id\"]\n end\n end\n\n arr_of_discussing_user_ids.each { |id|\n if $arr_of_user_ids_AL1.include?(id)\n grade_student = HTTParty.put(\n \"#{$canvas_url}/api/v1/courses/#{$canvas_course_id}/assignments/#{assignment_AL1_id}/submissions/#{id}\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" },\n body: {\n \"submission[posted_grade]\" => \"pass\"\n }\n )\n puts grade_student.parsed_response\n elsif $arr_of_user_ids_AL2.include?(id)\n grade_student = HTTParty.put(\n \"#{$canvas_url}/api/v1/courses/#{$canvas_course_id}/assignments/#{assignment_AL2_id}/submissions/#{id}\",\n headers: { \"authorization\" => \"Bearer #{$canvas_token}\" },\n body: {\n \"submission[posted_grade]\" => \"pass\"\n }\n )\n puts grade_student.parsed_response\n else\n puts \"Something went wrong\"\n end\n }\nend",
"def list_as_hash(group_names=[], &each_group)\n group_names = [group_names].flatten.compact\n glist = @@ec2.describe_security_groups(:group_name => group_names) || {}\n return unless glist['securityGroupInfo'].is_a?(Hash)\n groups = {}\n glist['securityGroupInfo']['item'].each do |oldg| \n g = Groups.from_hash(oldg)\n groups[g.name] = g\n end\n groups.each_value { |g| each_group.call(g) } if each_group\n groups = nil if groups.empty?\n groups\n end",
"def update\n# debug(params[:group][:right_ids] Pour faire un debuggage dans le controlleur\n @group = Group.find(params[:id])\n @group.rights.clear\n\n #Mise à jour de droits que possède un groupe\n params[:group][:right_ids] ||= []\n params[:group][:right_ids].each do |right|\n if !(right.blank?)\n @group.add_right(Right.find_by_id(right))\n end\n end\n\n respond_to do |format|\n if @group.update(group_params)\n\n format.html { redirect_to @group, notice: t('group.updated_msg') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def groups=(newgroups)\n groups_to_add = Set.new(newgroups).subtract(@property_hash[:groups]).to_a.map { |name| iam.groups[name] }\n groups_to_remove = Set.new(@property_hash[:groups]).subtract(newgroups).to_a.map { |name| iam.groups[name] }\n groups_to_add.each { |g| @property_hash[:aws_item].groups.add(g) }\n groups_to_remove.each { |g| @property_hash[:aws_item].groups.remove(g) }\n end",
"def set_group_belonging\n #group_number = self.id % 4\n #self.update_attributes(group: group_number)\n self.update_attributes(group: 1)\n end",
"def add_student(student_name, student_grade)\n# pp @roster\n \n if roster[student_grade]\n roster[student_grade] << student_name\n else\n roster[student_grade] = []\n roster[student_grade] << student_name\n end\n\n# roster[grade] name\n end",
"def create\n @group = StudentGroup.new(params[:student_group])\n users = []\n #@group.institution_id = current_user.institution.id if current_user.institution\n #@group.center_id = current_user.center.id if current_user.center\n #@group.role_id = 10 #short_role for SG group\n respond_to do |format|\n if @group.save\n if current_user.is?'ET' or current_user.is? 'EO'\n StudentGroupOwner.create(student_group_id: @group.id, user_id: current_user.id)\n end\n if params[\"users\"].present?\n users = users + params[\"users\"]\n end\n if params[\"teachers\"].present?\n users = users + params[\"teachers\"]\n end\n unless users.empty?\n users.each do |i|\n UserGroup.create(:group_id=>@group.id,:user_id=>i.to_i)\n end\n end\n format.html { redirect_to group_path(@group), notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @personal_group = current_user.personal_groups.find(params[:id])\n params[:personal_group][:student_ids] ||= []\n\n respond_to do |format|\n if @personal_group.update_attributes(params[:personal_group])\n flash[:notice] = \"The students in the #{@personal_group.name} group have been updated. If you've changed students and want to work with all students in this group you will need to go back to the student search screen and select the group and select the students on the next screen.\"\n format.html { redirect_to(personal_groups_url) }\n else\n @students = Student.find_all_by_id(selected_student_ids.collect(&:to_i) | @personal_group.student_ids)\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def update\n\t\tparams[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n\t\t#special method update_attribute only updates explicitly stated attribute\n\t\tif @group.update_attributes(params[:group])\n\t\t\tredirect_to @group\n\t\t\tflash[:success] = \"group updated\"\n\t\tend\n\tend",
"def create_groups(people)\n number_people = people.length\n if number_people < 3\n group_quantity = 1\n else\n group_quantity = number_people / 3\n end\n group_number = 1\n groups_names = Hash.new(\"\")\n people.each do |name|\n if group_number <= group_quantity\n groups_names[group_number] += (name + \", \")\n group_number += 1\n else\n groups_names[1] += (name + \", \")\n group_number = 2\n end\n end\n groups_names.each do |group, name|\n print \"\\n\", \"Group \", group, \"\\n\"\n print name, \"\\n\"\n end\nend",
"def create_full_group(creator_id, groupname, title = nil, description = nil)\n creator = User.new(creator_id, \"testuser\")\n @sling.switch_user(creator)\n #POST 1 - creating the manager sub-group\n create_pseudo_group(groupname + \"-manager\", groupname + \" Manager\", description)\n\n #POST 2 - creating the member sub-group\n create_pseudo_group(groupname + \"-member\", groupname + \" Member\", description)\n\n #POST 3 creating the main group\n group = create_target_group(groupname, title, description) #POST 3\n\n update_uri = \"/#{$USERMANAGER_URI}group/\"\n\n #POST 4 - updating the group managers\n batch_post = []\n batch_post[0] = {\"url\" => \"#{update_uri}#{groupname}-member.update.json\", \"method\" => \"POST\", \"parameters\" => {\":manager\" => \"#{groupname}-manager\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[1] = {\"url\" => \"#{update_uri}#{groupname}-manager.update.json\", \"method\" => \"POST\", \"parameters\" => {\":manager\" => \"#{groupname}-manager\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[2] = {\"url\" => \"#{update_uri}#{groupname}.update.json\", \"method\" => \"POST\", \"parameters\" => {\":manager\" => \"#{groupname}-manager\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 4 - updating the group managersbatch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 4 - updating the group managersbatch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 4 - updating the group managers response code is: #{response.code}\")\n @file_log.info(\"POST 4 - updating the group managers response code is: #{response.code}\") if (@file_log)\n\n #POST 5 - updating the group members\n batch_post = []\n batch_post[0] = {\"url\" => \"#{update_uri}#{groupname}-manager.update.json\", \"method\" => \"POST\", \"parameters\" => {\":member\" => \"#{creator_id}\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[1] = {\"url\" => \"#{update_uri}#{groupname}.update.json\", \"method\" => \"POST\", \"parameters\" => {\":member\" => \"#{groupname}-member\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[2] = {\"url\" => \"#{update_uri}#{groupname}.update.json\", \"method\" => \"POST\", \"parameters\" => {\":member\" => \"#{groupname}-manager\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 5 - updating the group members batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 5 - updating the group members batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 5 - updating the group members response code is: #{response.code}\")\n @file_log.info(\"POST 5 - updating the group members response code is: #{response.code}\") if (@file_log)\n\n #POST 6 - creating test tags\n batch_post = []\n batch_post[0] = {\"url\" => \"/tags/test-tag1\", \"method\" => \"POST\", \"parameters\" => {\"sakai:tag-name\" => \"test-tag1\", \"sling:resourceType\" => \"sakai/tag\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[1] = {\"url\" => \"/tags/test-tag2\", \"method\" => \"POST\", \"parameters\" => {\"sakai:tag-name\" => \"test-tag2\", \"sling:resourceType\" => \"sakai/tag\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 6 - creating test tags batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 6 - creating test tags batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 6 - creating test tags response code is: #{response.code}\")\n @file_log.info(\"POST 6 - creating test tags response code is: #{response.code}\") if (@file_log)\n\n #POST 7 - updating group visibility, joinability and permissions\n batch_post = []\n batch_post[0] = {\"url\" => \"#{update_uri}#{groupname}.update.html\", \"method\" => \"POST\", \"parameters\" => {\"rep:group-viewers@Delete\" => \"\", \"sakai:group-visible\" => \"public\", \"sakai:group-joinable\" => \"yes\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[1] = {\"url\" => \"/~#{groupname}.modifyAce.html\", \"method\" => \"POST\", \"parameters\" => {\"principalId\" => \"everyone\", \"privilege@jcr:read\" => \"granted\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[2] = {\"url\" => \"/~#{groupname}.modifyAce.html\", \"method\" => \"POST\", \"parameters\" => {\"principalId\" => \"anonymous\", \"privilege@jcr:read\" => \"granted\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 7 - updating group visibility, joinability and permissions batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 7 - updating group visibility, joinability and permissions batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 7 - updating group visibility, joinability and permissions response code is: #{response.code}\")\n @file_log.info(\"POST 7 - updating group visibility, joinability and permissions response code is: #{response.code}\") if (@file_log)\n\n #POST 8 - creating initial sakai docs\n batch_post = []\n batch_post[0] = {\"url\" => \"/system/pool/createfile\", \"method\" => \"POST\", \"parameters\" => {\"sakai:pooled-content-file-name\" => \"Library\", \"sakai:description\" => \"\", \"sakai:permissions\" => \"public\", \"sakai:copyright\" => \"creativecommons\", \\\n \"structure0\" => \"{\\\"library\\\":{\\\"_ref\\\":\\\"id9867543247\\\",\\\"_order\\\":0,\\\"_nonEditable\\\":true,\\\"_title\\\":\\\"Library\\\",\\\"main\\\":{\\\"_ref\\\":\\\"id9867543247\\\",\\\"_order\\\":0,\\\"_nonEditable\\\":true,\\\"_title\\\":\\\"Library\\\"}}}\", \\\n \"mimeType\" => \"x-sakai/document\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n\n batch_post[1] = {\"url\" => \"/system/pool/createfile\", \"method\" => \"POST\", \"parameters\" => {\"sakai:pooled-content-file-name\" => \"Participants\", \"sakai:description\" => \"\", \"sakai:permissions\" => \"public\", \"sakai:copyright\" => \"creativecommons\", \\\n \"structure0\" => \"{\\\"participants\\\":{\\\"_ref\\\":\\\"id6573920372\\\",\\\"_order\\\":0,\\\"_nonEditable\\\":true,\\\"_title\\\":\\\"Participants\\\",\\\"main\\\":{\\\"_ref\\\":\\\"id6573920372\\\",\\\"_order\\\":0,\\\"_nonEditable\\\":true,\\\"_title\\\":\\\"Participants\\\"}}}\", \\\n \"mimeType\" => \"x-sakai/document\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"#POST 8 - creating initial sakai docs batch post is: #{batch_post_json}\")\n @file_log.debug(\"#POST 8 - creating initial sakai docs batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 8 - creating initial sakai docs response code is: #{response.code}\")\n @file_log.info(\"POST 8 - creating initial sakai docs response code is: #{response.code}\") if (@file_log)\n ruby_body = JSON response.body\n results = ruby_body[\"results\"]\n @log.debug(\"POST 8 - creating initial sakai docs results: #{results}\")\n @file_log.debug(\"POST 8 - creating initial sakai docs results: #{results}\") if (@file_log)\n library_doc_hash, participants_doc_hash = nil, nil\n i = 0\n results.each do |result|\n result_body_json = JSON result[\"body\"]\n content_item = result_body_json[\"_contentItem\"]\n doc_hash = content_item[\"poolId\"]\n content_item_name = content_item[\"item\"][\"sakai:pooled-content-file-name\"]\n if (\"Library\".eql? content_item_name)\n library_doc_hash = doc_hash\n elsif (\"Participants\".eql? content_item_name)\n participants_doc_hash = doc_hash\n else\n @log.warn(\"could not find sakai doc name to confirm doc_hash\")\n end\n end\n @log.info(\"POST 8 - creating initial sakai docs Library sakai doc hash: #{library_doc_hash}, Participants sakai doc hash #{participants_doc_hash}\")\n @file_log.info(\"POST 8 - creating initial sakai docs Library sakai doc hash: #{library_doc_hash}, Participants sakai doc hash #{participants_doc_hash}\") if (@file_log)\n\n #POST 9 - importing sakai docs content \n batch_post = []\n batch_post[0] = {\"url\" => \"/p/#{library_doc_hash}.resource\", \"method\" => \"POST\", \"parameters\" => {\":operation\" => \"import\", \":contentType\" => \"json\", \":replace\" => \"true\", \":replaceProperties\" => \"true\", \\\n \":content\" => \"{\\\"id9867543247\\\":{\\\"page\\\":\\\"<img id='widget_mylibrary_id1367865652332' class='widget_inline' style='display: block; padding: 10px; margin: 4px;' \\\n src='/devwidgets/mylibrary/images/mylibrary.png' data-mce-src='/devwidgets/mylibrary/images/mylibrary.png' data-mce-style='display: block; padding: 10px; margin: 4px;' border='1'><br></p>\\\"},\\\n \\\"id1367865652332\\\":{\\\"mylibrary\\\":{\\\"groupid\\\":\\\"#{groupname}\\\"}}}\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n\n batch_post[1] = {\"url\" => \"/p/#{participants_doc_hash}.resource\", \"method\" => \"POST\", \"parameters\" => {\":operation\" => \"import\", \":contentType\" => \"json\", \":replace\" => \"true\", \":replaceProperties\" => \"true\", \\\n \":content\" => \"{\\\"id6573920372\\\":{\\\"page\\\":\\\"<img id='widget_participants_id439704665' class='widget_inline' style='display: block; padding: 10px; margin: 4px;' src='/devwidgets/participants/images/participants.png' \\\n data-mce-src='/devwidgets/participants/images/participants.png' data-mce-style='display: block; padding: 10px; margin: 4px;' border='1'><br></p>\\\"}, \\\n \\\"id439704665\\\":{\\\"participants\\\":{\\\"groupid\\\":\\\"#{groupname}\\\"}}}\",\"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 9 - importing sakai docs content batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 9 - importing sakai docs content batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 9 - importing sakai docs content response code is: #{response.code}\")\n @file_log.info(\"POST 9 - importing sakai docs content response code is: #{response.code}\") if (@file_log)\n ruby_body = JSON response.body\n results = ruby_body[\"results\"]\n @log.debug(\"POST 9 - importing sakai docs content results from importing sakai docs post: #{results}\")\n @file_log.debug(\"POST 9 - importing sakai docs content results from importing sakai docs post: #{results}\") if (@file_log)\n\n #POST 10 - applying the test tags\n batch_post = []\n batch_post[0] = {\"url\" => \"/~#{groupname}/public/authprofile\", \"method\" => \"POST\", \"parameters\" => {\"key\" => \"/tags/test-tag1\", \":operation\" => \"tag\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n batch_post[1] = {\"url\" => \"/~#{groupname}/public/authprofile\", \"method\" => \"POST\", \"parameters\" => {\"key\" => \"/tags/test-tag2\", \":operation\" => \"tag\", \"_charset_\" => \"utf-8\"}, \"_charset_\" => \"utf-8\"}\n @log.debug(\"resource batch post is: #{batch_post}\")\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 10 - applying the test tags batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 10 - applying the test tags batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 10 - applying the test tags response code is: #{response.code}\")\n @file_log.info(\"POST 10 - applying the test tags response code is: #{response.code}\") if (@file_log)\n ruby_body = JSON response.body\n results = ruby_body[\"results\"]\n @log.debug(\"POST 10 - applying the test tags results from :operation => tag post: #{results}\")\n @file_log.debug(\"POST 10 - applying the test tags results from :operation => tag post: #{results}\") if (@file_log)\n\n\n #POST 11 - setting the global viewers and permissions on the sakai docs\n batch_post = []\n batch_post[0] = {\"url\" => \"/p/#{library_doc_hash}.members.html\", \"method\" => \"POST\", \"parameters\" => {\":viewer\" => [\"everyone\", \"anonymous\"]}}\n batch_post[1] = {\"url\" => \"/p/#{library_doc_hash}.modifyAce.html\", \"method\" => \"POST\", \"parameters\" => {\"principalId\" => [\"everyone\", \"anonymous\"], \"privilege@jcr:read\" => \"granted\"}}\n batch_post[2] = {\"url\" => \"/p/#{participants_doc_hash}.members.html\", \"method\" => \"POST\", \"parameters\" => {\":viewer\" => [\"everyone\", \"anonymous\"]}}\n batch_post[3] = {\"url\" => \"/p/#{participants_doc_hash}.modifyAce.html\", \"method\" => \"POST\", \"parameters\" => {\"principalId\" => [\"everyone\", \"anonymous\"], \"privilege@jcr:read\" => \"granted\"}}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 11 - setting the global viewers and permissions on the sakai docs batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 11 - setting the global viewers and permissions on the sakai docs batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 11 - setting the global viewers and permissions on the sakai docs response code is: #{response.code}\")\n @file_log.info(\"POST 11 - setting the global viewers and permissions on the sakai docs response code is: #{response.code}\") if (@file_log)\n ruby_body = JSON response.body\n results = ruby_body[\"results\"]\n @log.debug(\"POST 11 - setting the global viewers and permissions on the sakai docs results from setting permissions on sakai docs #{results}\")\n @file_log.debug(\"POST 11 - setting the global viewers and permissions on the sakai docs results from setting permissions on sakai docs #{results}\") if (@file_log)\n\n #POST 12 - setting the member viewer and manager viewer for the sakai docs\n batch_post = []\n batch_post[0] = {\"url\" => \"/p/#{library_doc_hash}.members.html\", \"method\" => \"POST\", \"parameters\" => {\":viewer\" => \"#{groupname}-member\", \"_charset_\" =>\"utf-8\"},\"_charset_\" => \"utf-8\"}\n batch_post[1] = {\"url\" => \"/p/#{library_doc_hash}.members.html\", \"method\" => \"POST\", \"parameters\" => {\":manager\" => \"#{groupname}-manager\", \"_charset_\" =>\"utf-8\"},\"_charset_\" => \"utf-8\"}\n batch_post[2] = {\"url\" => \"/p/#{participants_doc_hash}.members.html\", \"method\" => \"POST\", \"parameters\" => {\":viewer\" => \"#{groupname}-member\", \"_charset_\" =>\"utf-8\"},\"_charset_\" => \"utf-8\"}\n batch_post[3] = {\"url\" => \"/p/#{participants_doc_hash}.members.html\", \"method\" => \"POST\", \"parameters\" => {\":manager\" => \"#{groupname}-manager\", \"_charset_\" =>\"utf-8\"},\"_charset_\" => \"utf-8\"}\n batch_post_json = JSON.generate batch_post\n @log.debug(\"POST 12 - setting the member viewer and manager viewer for the sakai docs batch post is: #{batch_post_json}\")\n @file_log.debug(\"POST 12 - setting the member viewer and manager viewer for the sakai docs batch post is: #{batch_post_json}\") if (@file_log)\n parameters = {\"requests\" => batch_post_json}\n response = @sling.execute_post(@sling.url_for(\"#{$BATCH_URI}\"), parameters)\n @log.info(\"POST 12 - setting the member viewer and manager viewer for the sakai docs response code is: #{response.code}\")\n @file_log.info(\"POST 12 - setting the member viewer and manager viewer for the sakai docs response code is: #{response.code}\") if (@file_log)\n ruby_body = JSON response.body\n results = response.body[\"results\"]\n @log.debug(\"POST 12 - setting the member viewer and manager viewer for the sakai docs results from setting viewer and manager on sakai docs #{results}\")\n @file_log.debug(\"POST 12 - setting the member viewer and manager viewer for the sakai docs results from setting viewer and manager on sakai docs #{results}\") if (@file_log)\n\n #POST 13 - setting the doc structure on the sakai docs\n struct0 = {}\n str = \"{\\\"library\\\":{\\\"_title\\\":\\\"Library\\\",\\\"_order\\\":0,\\\"_nonEditable\\\":true,\\\"_view\\\":\\\"[\\\\\\\"everyone\\\\\\\",\\\\\\\"anonymous\\\\\\\",\\\\\\\"-member\\\\\\\"]\\\",\\\"_edit\\\":\\\"[\\\\\\\"-manager\\\\\\\"]\\\",\\\"_pid\\\":\\\"#{library_doc_hash}\\\"},\\\"participants\\\":{\\\"_title\\\":\\\"Participants\\\",\\\"_order\\\":1,\\\"_nonEditable\\\":true,\\\"_view\\\":\\\"[\\\\\\\"everyone\\\\\\\",\\\\\\\"anonymous\\\\\\\",\\\\\\\"-member\\\\\\\"]\\\",\\\"_edit\\\":\\\"[\\\\\\\"-manager\\\\\\\"]\\\",\\\"_pid\\\":\\\"#{participants_doc_hash}\\\"}}\"\n struct0[\"structure0\"] = str\n params = {}\n params[\":content\"] = JSON.generate struct0\n params[\":contentType\"] = \"json\"\n params[\":operation\"] = \"import\"\n params[\":replace\"] = true\n params[\":replaceProperties\"] = true\n params[\"_charset_\"] = \"utf-8\"\n @log.debug(\"POST 13 - setting the doc structure on the sakai docs post params are: \" + params.inspect)\n @file_log.debug(\"POST 13 - setting the doc structure on the sakai docs post params are: \" + params.inspect) if (@file_log)\n uri = \"/~#{groupname}/docstructure\"\n response = @sling.execute_post(@sling.url_for(uri), params)\n #this is an html response\n @log.info(\"POST 13 - setting the doc structure on the sakai docs response code: #{response.code}\")\n @file_log.info(\"POST 13 - setting the doc structure on the sakai docs response code: #{response.code}\") if (@file_log)\n\n # return the group that was created in create_target_group\n return group\n end",
"def update\n @cohort = Cohort.find(params[:id])\n @new_cohort = @cohort.generate_many_groupings(4)\n #group shuffling method goes here not sure if this is correct syntax\n #also need to make sure that the route i have created in the edit_cohort_path is correct\n @cohort = @new_cohort.sorted_groups(params[:size])\n end",
"def add_student(school,new_student)\n new_student_hash = {}\n new_student_hash[:name] = new_student\n school[:students] << new_student_hash\nend",
"def create\n\t\tif CompetenceGroup.find_by_competence_id_and_alu_group_id(params[:competence_group][:competence_id],params[:competence_group][:alu_group_id])\n flash[:notice] = 'El grupo ya existe.'\n\t\t\t\tredirect_to :controller => 'competences' , :action => 'edit' , :id => params[:competence_group][:competence_id]\n\t\t\t\treturn\n\t\t\n\t\tend\n @competence_group = CompetenceGroup.new(cg_params)\n\n if @competence_group.save\n\t\t\t\t#assign works to all users of groups\t\t\n\t\t\t\t#TODO new method \t all students of group\n\t\tworktype = Work::TEST_TYPE\n\t\t@competence_group.competence.nodes.each do |n|\n\t\tnode_id = n.id\n\t\t@competence_group.alu_group.students.each do |s|\n\t\t\tif not Work.where(student_id: s.id, node_id: node_id)\n\t\t\t\tWork.new(:node_id => node_id , :initialpoints => params[:initialpoints], :student_id => s.id, :worktype => worktype).save\n\t\t\tend\n\t\t\t#successors\n\t\t\tnodes = Array.new\n\t\t\tgetNodesRecursive(Work::ASSIGNEDTOSTUDENT, s.id, node_id, nodes)\n\t\t\tnodes.each do |n|\n\t\t\t\tif not Work.where(student_id: s.id, node_id: n.id)\n\t\t\t\t\tWork.new(:node_id => n.id , :initialpoints => params[:initialpoints], :student_id => s.id, :worktype => worktype).save\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tend\n\t\n flash[:notice] = t('competencegroup_created_success') \n\t\t\t\tredirect_to :controller => 'competences' , :action => 'edit' , :id => @competence_group.competence_id\n else\n render :action => \"newAluGroup\" \n end\n end",
"def create\n begin\n if params[:group1][:GroupID]!=\"\"\n if params[:group1][:GroupID]=='KEY 1'\n params[:group][:GroupID]=params[:group1][:GroupID]\n @g=Group.find_first([\"GroupID='KEY 1' and ShopName=? and ClusterName=?\",params[:group][:ShopName],params[:group][:ClusterName]])\n if(@g==nil)\n @group1 = Group.new(params[:group])\n if(@group1.save)\n end\n else\n end\n end\n if params[:group2][:GroupID]=='KEY 2'\n \n params[:group][:GroupID]=params[:group2][:GroupID]\n @g=Group.find_first([\"GroupID='KEY 2' and ShopName=? and ClusterName=?\",params[:group][:ShopName],params[:group][:ClusterName]])\n if(@g==nil)\n @group2 = Group.new(params[:group])\n if(@group2.save)\n end\n end\n end\n \n if params[:group3][:GroupID]=='KEY 3' \n params[:group][:GroupID]=params[:group3][:GroupID]\n @g=Group.find_first([\"GroupID='KEY 3' and ShopName=? and ClusterName=?\",params[:group][:ShopName],params[:group][:ClusterName]])\n if(@g==nil)\n @group3 = Group.new(params[:group])\n if(@group3.save)\n end\n end\n end\n \n if params[:group4][:GroupID]=='KEY 4' \n params[:group][:GroupID]=params[:group4][:GroupID]\n @g=Group.find_first([\"GroupID='KEY 4' and ShopName=? and ClusterName=?\",params[:group][:ShopName],params[:group][:ClusterName]])\n if(@g==nil)\n @group4 = Group.new(params[:group])\n if(@group4.save)\n end\n end\n end\n end\n if params[:group1][:GroupID]=='0'\n @s=Group.find_first([\"ShopName=? and GroupID='KEY 1'\",params[:group][:ShopName]])\n if(@s!=nil)\n @s.destroy\n end\n end\n if params[:group2][:GroupID]=='0'\n @s=Group.find_first([\"ShopName=? and GroupID='KEY 2'\",params[:group][:ShopName]])\n if(@s!=nil)\n @s.destroy\n end\n end\n \n if params[:group3][:GroupID]=='0'\n @s=Group.find_first([\"ShopName=? and GroupID='KEY 3'\",params[:group][:ShopName]])\n if(@s!=nil)\n @s.destroy\n end\n end\n if params[:group4][:GroupID]=='0'\n @s=Group.find_first([\"ShopName=? and GroupID='KEY 4'\",params[:group][:ShopName]])\n if(@s!=nil)\n @s.destroy\n end\n end\n @session[:clustername1]=nil\n @session[:clustername]=nil\n @session[:shopname]=nil\n if params[:group][:ClusterName]!=\"\"\n flash[:confirm]=\"<font color=green size=3><b>KEY GENERATED SUCCESSFULLY</b></font> \"\n end\n render :action=>'new'\n rescue Exception=>ex\n puts ex.message\n end\n end",
"def manage_group\n if new_resource.append\n members_to_be_added = [ ]\n if new_resource.excluded_members && !new_resource.excluded_members.empty?\n # First find out if any member needs to be removed\n members_to_be_removed = [ ]\n new_resource.excluded_members.each do |member|\n members_to_be_removed << member if current_resource.members.include?(member)\n end\n\n unless members_to_be_removed.empty?\n # We are using a magic trick to remove the groups.\n reset_group_membership\n\n # Capture the members we need to add in\n # members_to_be_added to be added later on.\n current_resource.members.each do |member|\n members_to_be_added << member unless members_to_be_removed.include?(member)\n end\n end\n end\n\n if new_resource.members && !new_resource.members.empty?\n new_resource.members.each do |member|\n members_to_be_added << member unless current_resource.members.include?(member)\n end\n end\n\n logger.debug(\"#{new_resource} not changing group members, the group has no members to add\") if members_to_be_added.empty?\n\n add_group_members(members_to_be_added)\n else\n # We are resetting the members of a group so use the same trick\n reset_group_membership\n logger.debug(\"#{new_resource} setting group members to: none\") if new_resource.members.empty?\n add_group_members(new_resource.members)\n end\n end",
"def add_assignment(assignment_symbol, user)\n past_assignments = GroupLoanAssignment.find(:all, :conditions => {\n :group_loan_id => self.id,\n :assignment_type => GROUP_LOAN_ASSIGNMENT[assignment_symbol],\n :user_id => user.id \n })\n \n if past_assignments.count > 0 \n puts \"The past assignment value is #{past_assignments.count}\"\n puts \"The user email is :#{user.email} \"\n puts \"past_assignments.first.inspect: #{past_assignments.first.inspect}\"\n return nil\n else\n puts \"we are gonna create the new one\"\n return GroupLoanAssignment.create(\n :group_loan_id => self.id,\n :assignment_type => GROUP_LOAN_ASSIGNMENT[assignment_symbol],\n :user_id => user.id\n )\n end\n end",
"def add_student(student_name, grade)\n # roster[grade] = [] # ...first: create the new key and point it to an empty array\n roster[grade] ||= [] # add multiple students to a grade & add students to different grades using ||=\n roster[grade] << student_name # ...then: push the new value into that array\n end",
"def student_group_add(student_group_name)\n players = []\n if not student_group = self.scenario.user.student_groups.find_by_name(student_group_name)\n errors.add(:name, \"student group not found\")\n return\n end\n student_group.student_group_users.each do |student_group_user|\n if not self.players.where(\"user_id = #{student_group_user.user_id} AND student_group_id = #{student_group.id}\").first\n\n cnt = 1\n login = \"#{student_group_user.user.name.filename_safe}\"\n while self.players.find_by_login(login)\n cnt += 1\n login = login += cnt.to_s\n end\n\n player = self.players.new(\n login: login,\n password: Player.random_password,\n user_id: student_group_user.user.id,\n student_group_id: student_group_user.student_group.id\n )\n player.save\n players.push(player)\n end\n end\n players\n end",
"def create\n @group = Group.new(params[:group])\n @group.owner = current_user\n\n group_name_exists = false\n current_user.owned_groups.each do |g|\n if g.name == @group.name\n group_name_exists = true\n break\n end\n end\n \n respond_to do |format|\n if group_name_exists\n format.html { redirect_to groups_path, :alert => \"You already have a list by the name '#{@group.name}'.\" }\n format.json { render :json => @group, :status => :created, :location => @group }\n elsif @group.save\n format.html { redirect_to @group, :notice => 'Group was successfully created.' }\n format.json { render :json => @group, :status => :created, :location => @group }\n else\n error_msg = 'Unexpected error while creating group.'\n if @group.errors.messages.count > 0\n error_msg = 'Following error(s) prevented the group from being saved: '\n multiple = false\n @group.errors.full_messages.each do |msg|\n if multiple\n error_msg += ', '\n end\n error_msg += msg\n multiple = true\n end\n end\n format.html { redirect_to groups_path, :action => 'index', :alert => error_msg }\n format.json { render :json => @group.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def group_creator(name_list)\n\n\taccountability_groups = []\n\trandomized_names = name_list.shuffle #Used non-destructive shuffle so that I can call on list again for unit 2/3\n\n\twhile (randomized_names.length > 4)\n\t\taccountability_groups << randomized_names.pop(4)\t\n\tend\n\n\tcounter = 0\n\tuntil (randomized_names.length == 0)\n\t\taccountability_groups[counter] << randomized_names.pop\n\t\tcounter\t+= 1\n\tend\n\t\t\n\tcounter = 0\n\tuntil accountability_groups[counter] == nil\n\t\tputs \"Group \" + (counter + 1).to_s + \":\" ; puts accountability_groups[counter]\n\t\tputs\n\t\tcounter += 1 \n\tend\nend",
"def form_groups\n # allows for the user to sort randomly, by section, by major, by section major, and asks users for desired number of students per group\n puts \"Enter how you would like groups to sorted, then choose the number of students in each group\"\n puts \"1-sort groups randomly\"\n puts \"2-sort groups by section\"\n puts \"3-sort groups by major\"\n puts \"4-sort groups by section and major\"\n user_selection = gets.chomp\n case user_selection\n when \"1\"\n puts \"Groups will be formed randomly and the student list will be permanantly sorted.\"\n puts \"Enter the number of students per group: \"\n num_students = gets.chomp.to_i\n # uses ruby's .shuffle method to randomly place students in @student_array\n @student_array = @student_array.shuffle\n # the code below takes the num_students and splits the elements (students) in @student_array into @group_array with num_students each nested array (the groups)\n # essentially, @student_array is 'chunked' into smaller pieces which become @group_array\n @group_array = @student_array.each_slice(num_students).to_a\n puts \"There are #{@group_array.length} groups\"\n puts \"Press 'enter' to return to menu\"\n temp = gets.chomp\n user_menu\n when \"2\"\n puts \"Groups will be formed by section and the student list will be permanantly sorted.\"\n puts \"Enter the number of students per group: \"\n num_students = gets.chomp.to_i\n # calls the bubble_sort_section method on @student_array, and then splits it into properly sized groups\n @student_array = bubble_sort_section(@student_array)\n @group_array = @student_array.each_slice(num_students).to_a\n puts \"There are #{@group_array.length} groups\"\n puts \"Press 'enter' to return to menu\"\n temp = gets.chomp\n user_menu\n when \"3\"\n puts \"Groups will be formed by major and the student list will be permanantly sorted.\"\n puts \"Enter the number of students per group: \"\n num_students = gets.chomp.to_i\n # calls the bubble_sort_major method on @student_array, and then splits it into properly sized groups\n @student_array = bubble_sort_major(@student_array)\n @group_array = @student_array.each_slice(num_students).to_a\n puts \"There are #{@group_array.length} groups\"\n puts \"Press 'enter' to return to menu\"\n temp = gets.chomp\n user_menu\n when \"4\"\n puts \"Groups will be formed by major and the student list will be permanantly sorted.\"\n puts \"Enter the number of students per group: \"\n num_students = gets.chomp.to_i\n # calls the bubble_sort_section method on @student_array, then the bubble_sort_major method and then splits it into properly sized groups\n # this sorts the @student_array by section, then major, so when groups are made the groups are sorted by section and major\n @student_array = bubble_sort_section(@student_array)\n @student_array = bubble_sort_major(@student_array)\n @group_array = @student_array.each_slice(num_students).to_a\n puts \"There are #{@group_array.length} groups\"\n puts \"Press 'enter' to return to menu\"\n temp = gets.chomp\n user_menu\n else\n puts @dash+\"error-invalid-selection\"+@dash\n user_menu\n end\n end",
"def update!(**args)\n @new_group_details = args[:new_group_details] if args.key?(:new_group_details)\n @prev_group_details = args[:prev_group_details] if args.key?(:prev_group_details)\n end",
"def update\n if request.post?\n if @group.update_attributes(params[:group])\n redirect_to :action => 'list'\n else\n render :action => 'rename'\n end\n end\n end",
"def grant_role_assignments_to_group_members_if_needed\n return unless entity.type == 'Group'\n\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n entity.members.each do |m|\n logger.info \"Granting role (#{role.id}, #{role.token}, #{role.application.name}) just granted to group (#{entity.id}/#{entity.name}) to its member (#{m.id}/#{m.name})\"\n ra = RoleAssignment.new\n ra.role_id = role.id\n ra.entity_id = m.id\n ra.parent_id = id\n ra.save!\n end\n end\n end",
"def addStudent(stu_name, grd)\n file_name = \"DB/\" + @name + \".db\"\n to_edit = File.read(file_name)\n File.open(file_name, 'w+') do |file|\n school = JSON.parse(to_edit)\n #students = []\n # #students << stu_name\n # if school['structure'][grd] != nil #school['structure'][grd] || = []\n # school['structure'][grd] << stu_name\n # #puts \"??????\"\n # else\n # students = []\n # students << stu_name\n # school['structure'][grd] = students\n # end\n school['structure'][grd.to_s] ||= []\n school['structure'][grd.to_s] << stu_name\n\n file.write(school.to_json)\n end\n end",
"def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:group][:member_ids] = (params[:group][:member_ids] << @group.member_ids).flatten\n @group.school_id = @user.school_id\n respond_to do |format|\n if @group.save\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @detail = Detail.find(params[:id])\n @guests = Guest.all_by_name\n @groups = Group.all_by_name\n respond_to do |format|\n if @detail.update_attributes(params[:detail])\n @guests.each do |guest|\n if params.has_key?(:guest_assign) and params[:guest_assign][guest.id.to_s] == \"true\"\n @detail.guests << guest unless @detail.guests.include?(guest)\n else\n @detail.guests.delete (guest) if @detail.guests.include?(guest)\n end\n end\n @groups.each do |group|\n if params.has_key?(:group_assign) and params[:group_assign][group.id.to_s] == \"true\"\n @detail.groups << group unless @detail.groups.include?(group)\n else\n @detail.groups.delete (group) if @detail.groups.include?(group)\n end \n end \n format.html { redirect_to admin_details_path, notice: 'Detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addstudent(newname, schoolvar)\n\tschoolvar[:students]<<{:name=>newname}\nend",
"def list_group_params\n params.require(:list_group).permit(:student_id, :group_id)\n end",
"def generate_hash\n @groups.flatten.inject([]) {|hash, stone| hash << stone.to_s}.sort.hash\n end",
"def replace_old_with_new_in_groups\n old_user.groups.each do |group|\n # Add new user to group if needed\n if !group.member?(new_user) && !group.banned?(new_user)\n group.redis.multi do\n group.member_ids << new_user.id\n new_user.group_ids << group.id\n new_user.group_join_times[group.id] = Time.current.to_i\n end\n\n # Make new user an admin if needed\n group.admin_ids << new_user.id if group.admin?(old_user)\n end\n\n # Remove old user from group and admin if needed\n group.redis.multi do\n group.admin_ids.delete(old_user.id)\n group.member_ids.delete(old_user.id)\n old_user.group_ids.delete(group.id)\n end\n\n # Publish group once after all changes\n faye_publisher.publish_to_group(group, PublishGroupSerializer.new(group).as_json)\n\n group_data = GroupSerializer.new(group).as_json\n faye_publisher.publish_group_to_user(new_user, group_data)\n faye_publisher.publish_group_to_user(old_user, group_data)\n end\n end",
"def update\n @producer = Producer.find(params[:id])\n\n @groupings = Grouping.all\n grouping_ids = params[:grouping_ids] if params[:grouping_ids] \n grouping_ids ||= []\n @producer.grouping_ids = grouping_ids\n\n\n\n respond_to do |format|\n if @producer.update_attributes(params[:producer])\n grouping_ids.each do |id|\n grouping_code = params[:grouping_code]\n code = grouping_code['grouping_'+id]\n gc = GroupingsProducer.where(:grouping_id => id, :producer_id => @producer.id).first\n if gc.nil?\n GroupingsProducer.create(:grouping_id => id, :producer_id => @producer.id, :code => code) \n else\n gc.code = code\n gc.save\n end \n end\n format.html { redirect_to producers_path, notice: \"El productor #{@producer.name} fue editado exitosamente.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @producer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def populateGroup(group_id)\n database = SQLite3::Database.new( @database )\n group = $gm.get(\"/groups/#{group_id}\", @token)['response']\n\n if group['image_url'].nil?\n group['image_url'] = 'img/groupme.png'\n elsif group['image_url'].empty?\n group['image_url'] = 'img/groupme.png'\n else\n group['image_url'] = \"#{group['image_url']}.avatar\"\n end\n\n group_info = Hash.new\n user_info = Hash.new\n user_group_info = Hash.new\n \n #Adds new group if they don't exist, and updates the group if they do \n if database.execute( \"SELECT * FROM groups WHERE group_id='#{group['group_id']}'\").empty? \n group_info[group['group_id']] = [group['created_at'], group['name'], group['image_url'], group['creator_user_id'], false ]\n $logger.info \"Adding new group #{group['name']} to the database\"\n else\n group_info[group['group_id']] = [group['created_at'], group['name'], group['image_url'], group['creator_user_id'], true ]\n end\n \n #Adds any new members to the group, and updates any members who have made changes \n group['members'].each do | member |\n\n if member['image_url'].nil?\n member['image_url'] = 'img/groupme.png'\n elsif member['image_url'].empty?\n member['image_url'] = 'img/groupme.png'\n else\n member['image_url'] = \"#{member['image_url']}.avatar\"\n end\n\n if database.execute( \"SELECT * FROM users WHERE user_id='#{member['user_id']}'\").empty?\n user_info[member['user_id'] ] = [member['image_url'], false ]\n else\n user_info[member['user_id'] ] = [member['image_url'], true ]\n end\n if database.execute( \"SELECT * FROM user_groups WHERE user_id='#{member['user_id']}' AND group_id='#{group['group_id']}'\").empty?\n user_group_info[member['user_id']] = [group['group_id'], member['nickname'], false]\n else\n user_group_info[member['user_id']] = [group['group_id'], member['nickname'], true]\n end\n end\n\n database.transaction\n group_info.each do | key, value |\n if value[4]\n database.execute( \"UPDATE groups SET name=?, image=?, creator=?, created_at=datetime('#{value[0]}','unixepoch') WHERE group_id='#{key}'\",\n value[1],\n value[2],\n value[3] ) \n else \n database.execute( \"INSERT INTO groups(group_id, name, image, creator, created_at) VALUES (?, ?, ?, ?, datetime('#{value[0]}','unixepoch'))\",\n\t\t key,\n value[1],\n value[2],\n value[3] )\n end\n end\n \n user_info.each do | key, value |\n if value[1]\n database.execute( \"UPDATE users SET avatar_url=? WHERE user_id='#{key}'\",\n value[0] )\n else\n database.execute( \"INSERT INTO users(user_id, avatar_url) VALUES (?, ?)\",\n key,\n value[0] )\n end \n end\n\n user_group_info.each do | key, value |\n if value[2]\n database.execute( \"UPDATE user_groups SET name=? WHERE user_id='#{key}' AND group_id='#{value[0]}'\",\n value[1] )\n else\n database.execute( \"INSERT INTO user_groups(user_id, group_id, name) VALUES (?, ?, ?)\",\n key,\n value[0],\n value[1] )\n end\n end\n database.commit\n end",
"def add_student(name, grade)\r\n roster[grade] = [] unless roster[grade]\r\n roster[grade] << name\r\n end",
"def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end",
"def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end",
"def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end",
"def update!(**args)\n @group_name = args[:group_name] if args.key?(:group_name)\n end",
"def update_muscle_groups groups\n groups = {} unless groups.is_a?(Hash)\n groups.symbolize_keys\n self.muscle_groups = \"\"\n Activity::MUSCLE_GROUP_VALUES.each do |name|\n bit = groups[name] == \"1\" ? \"1\" : \"0\"\n self.muscle_groups = self.muscle_groups + bit\n end\n end",
"def update!(**args)\n @grouped_entry = args[:grouped_entry] if args.key?(:grouped_entry)\n end",
"def update!(**args)\n @grouped_entry = args[:grouped_entry] if args.key?(:grouped_entry)\n end",
"def add_member\n return unless (request.post? && params[:student_user_name])\n # add member to the group with status depending if group is empty or not\n grouping = Grouping.find(params[:grouping_id])\n @assignment = Assignment.find(params[:id], include: [{groupings: [{student_memberships: :user, ta_memberships: :user}, :group]}])\n student = Student.find_by_user_name(params[:student_user_name])\n if student.nil?\n @error = \"Could not find student with user name #{params[:student_user_name]}\"\n render :error_single\n return\n end\n set_membership_status = grouping.student_memberships.empty? ?\n StudentMembership::STATUSES[:inviter] :\n StudentMembership::STATUSES[:accepted]\n grouping.invite(params[:student_user_name], set_membership_status)\n grouping.reload\n @grouping = construct_table_row(grouping, @assignment)\n end",
"def new\n @assignments = Assignment.all\n @assignment = Assignment.new\n @assignment.build_submission_rule\n #@assignment.assignment_files.build\n unless request.post?\n render :new\n return\n end\n # Is the instructor forming groups?\n if params[:is_group_assignment] == 'true' && params[:assignment][:student_form_groups] == '0'\n params[:assignment][:invalid_override] = true\n else\n params[:assignment][:invalid_override] = false\n end\n\n @assignment = Assignment.new(params[:assignment])\n\n # A little hack to get around Rails' protection of the \"type\"\n # attribute\n @assignment.submission_rule.type = params[:assignment][:submission_rule_attributes][:type]\n\n\n @assignment.transaction do\n\n unless @assignment.save\n render :new\n return\n end\n if params[:assignment_files]\n params[:assignment_files].each do |assignment_file_name|\n unless assignment_file_name.empty?\n assignment_file = AssignmentFile.new(filename: assignment_file_name, assignment: @assignment)\n assignment_file.save\n end\n end\n end\n if params[:persist_groups_assignment]\n @assignment.clone_groupings_from(params[:persist_groups_assignment])\n end\n @assignment.save\n end\n redirect_to action: 'edit', id: @assignment.id\n end",
"def update_subject(school, instructor_name, new_subject)\n school[:instructors].collect do |instructor|\n if instructor[:name] == instructor_name\n instructor[:subject] = new_subject\n end\n end\nend",
"def add_student(name, grade)\n if roster.key?(grade) == false\n roster[grade] = [ ]\n roster[grade] << name \n else \n roster[grade] << name\n end \n end",
"def create_example_groups(groups_count = 100)\n # FIXME: What if Example organization is not found?\n organization = Organization.where(:name => 'Example').first\n \n # Get example students\n users = User.where(:firstname => 'Student', :organization_id => organization.id).all\n user_counter = 0\n \n # Create groups and submissions\n for i in (1..groups_count)\n # Create group\n group = Group.new(:course_instance_id => self.id, :name => \"Group #{i}\", :max_size => 3)\n group.save(:validate => false)\n\n # Add users to group\n students_count = rand(3) # self.groupsizemin + rand(self.groupsizemax - self.groupsizemin + 1)\n for j in (0..students_count)\n user = users[user_counter]\n group.add_member(user) if user\n user_counter += 1\n end\n\n break if user_counter >= users.size\n end\n end",
"def organizeDecResults( decResults, studentHashNames, sheet ) \n # Find values for name and results\n decName = decResults.pop\n name = sheet.translateName( decName )\n strResults = formatAnswersToSimple( sheet.translateAllAnswers(decResults) )\n strAmbig = sheet.translateAllAmbig( decResults )\n sheet.ambiguous_answers = strAmbig\n unless strAmbig == \"\" then\n course = Course.find(self.course_id)\n teacher = Teacher.find(course.teacher_id)\n ambigIssue = Issue.new( :code => 1, :resolved => false,\n :scansheet_id => sheet.id, :teacher_id => teacher.id, \n :name => \"Ambiguous Answers\" )\n ambigIssue.save\n end\n\n # Enter and save data for the sheet\n sheet.name = decName\n sheet.answers_string = decResults\n\n sheet.save\n # Find the student from the given students for a match\n theStudent = findStudentFromName( name, studentHashNames )\n grade = gradeStudent( strResults, self.answer_key ) \n # If found, then handle data from here.\n unless theStudent == nil then\n @newAssignmentStudent = AssignmentsStudents.new({ :assignment_id => self.id,\n :student_id => theStudent.id, :scansheet_id => sheet.id,\n :grade => grade,:results => strResults, :answer_key => self.answer_key })\n theStudent.grade = theStudent.compileGrade\n theStudent.save\n else \n course = Course.find(self.course_id)\n teacher = Teacher.find(course.teacher_id)\n nameIssue = Issue.new( :code => 2, :resolved => false,\n :scansheet_id => sheet.id, :teacher_id => teacher.id,\n :name => \"Name Not Found\" )\n nameIssue.save \n nameArr = name.split(\",\")\n @newStudent = Student.new( :first_name => (\"~\" + nameArr[0]),\n :middle_name => (\"~\" + nameArr[1]), :last_name => (\"~\" + nameArr[2]), :grade => grade,\n :course_id => self.course_id )\n @newStudent.save\n @newAssignmentStudent = AssignmentsStudents.new({ :assignment_id => self.id,\n :student_id => @newStudent.id, :scansheet_id => sheet.id, :grade => grade,\n :results => strResults, :answer_key => self.answer_key} )\n end\n @newAssignmentStudent.save\n end",
"def update\n @group = Group.find(params[:id])\n @group.name = params[:group][:name]\n @group.set_members(params[:member])\n\n if @group.save\n redirect_to root_path\n else\n render 'edit'\n end\n end",
"def update_group(increment)\n end",
"def create\n if(params[:group][:name].nil?) or (params[:group][:name] == \"\")\n flash[:notice] = \"Group must have a name and description\"\n redirect_to new_group_path\n else\n \n #create a new group\n @group = Group.new(group_params)\n user = User.find(session[:user_id]) \n respond_to do |format|\n if @group.save\n #generate a code for the group\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n new_code = (0...8).map { o[rand(o.length)] }.join\n @group.update(code: new_code)\n #after group is created add creator to group as leader\n Membership.create!(user_id: session[:user_id], group_id: @group.id, member_type: 'leader', username: user.username)\n format.html {redirect_to @group, notice: \"Group was successfully created.\"}\n format.json {render :show, status: :created, location: @group}\n else\n format.html {render :new, status: :unprocessable_entity}\n format.json {render json: @group.errors, status: :unprocessable_entity}\n end\n end\n end\n end",
"def student_leave_grp(course, group)\n load_course_grps course\n logger.info \"Leaving group '#{group.title}'\"\n wait_for_update_and_click link_element(xpath: \"//a[contains(@aria-label,'Leave group #{group.title}')]\")\n list_item_element(xpath: '//li[contains(.,\"Left Group\")]').when_present Utils.short_wait\n end",
"def set_groups(glisthash, line, defaultkey, highlighted_group=\"\", \n\t\tsnpTags=nil)\n \n unless line =~ /\\t/\n puts \"\\nERROR:\\tInput file must be tab-delimited\\n\"\n exit\n end\n \n data = strip_and_split(line)\n groups = Hash.new\n grouporder = Array.new\n\tgroupcolors = Hash.new\n\t\n mafcoltitle = 'MAF'\n data.each_with_index do |header, i|\n if header =~ /snp\\s*id/i || header =~ /snp_id/i || header =~ /^snp$/i\n @snpid = i\n\t\telsif header =~ /snp1/\n\t\t\t@snp1 = i\n\t\telsif header =~ /snp2/\n\t\t\t@snp2 = i\n elsif header =~ /snp\\s*name/i\n @snpname = i\n elsif header =~ /chromosome|CHR/i\n @chromnum = i\n elsif header =~ /location|^pos$|^bp$/i\n @location = i\n\t\telsif header =~ /^snpcolor|snp\\scolor/i\n\t\t\t@snpcolorcol = i\n\t\telsif header =~ /anc\\d/i\n\t\t\t# should be anc0, anc1, or anc2\n\t\t\tallelenum = /anc(\\d)/.match(header)[1]\n\t\t\t@anccol[allelenum.to_i] = i\n elsif header !~ /:/ # skip if no _ to mark name\n next\n else # information for a group\n # split name on ':'\n header.strip!\n pcs = header.split(/:/)\n pcs[0].upcase!\n column_type = pcs[1]\n # get or create this group\n if pcs.length == 2\n if !groups.has_key?(pcs[0])\n pcs[0] == highlighted_group ? highlighted = true : highlighted = false\n #groups.store(pcs[0], Group.new(pcs[0],-1,-1,-1, GroupList.get_next_color,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,highlighted))\n\t\t\t\t\tcolorstr = GroupList.get_next_color\n groups.store(pcs[0], Group.new(pcs[0], highlighted, colorstr))\n\t\t\t\t\tgroupcolors[pcs[0]]=colorstr\n grouporder << pcs[0]\n end\n currgroup = groups.fetch(pcs[0])\n column_type = pcs[1].strip\n else # create subgroup if necessary and set current group to be this subgroup\n pcs[1].upcase!\n key = pcs[0] + ':' + pcs[1]\n key == highlighted_group ? highlighted = true : highlighted = false\n if !groups.has_key?(key)\n #groups.store(key, Group.new(key, -1, -1,-1, nil, -1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,highlighted))\n groups.store(key, Group.new(key, highlighted))\n grouporder << key\n end\n currgroup = groups.fetch(key)\n column_type = pcs[2].strip\n end\n \n if column_type =~ /pval|p_value/i\n currgroup.pcol = i\n elsif column_type =~ /beta_uci|betauci/i\n currgroup.betaucicol = i\n elsif column_type =~ /beta_lci|betalci/i\n currgroup.betalcicol = i\n elsif column_type =~ /beta/i or column_type =~ /^es$/i\n currgroup.betacol = i\n elsif column_type =~ /^n$|^sample_size$/i\n currgroup.Ncol = i\n elsif column_type =~ /cafcases/i\n currgroup.cafcasescol = i\n elsif column_type =~ /cafcontrols/i\n currgroup.cafcontrolscol = i\n elsif column_type =~ /^maf|caf$/i\n currgroup.mafcafcol = i\n if column_type =~ /caf/i\n mafcoltitle = 'CAF'\n end\n elsif column_type =~ /or/i\n currgroup.orcol = i\n elsif column_type =~ /^rank$/i\n currgroup.rankcol = i\n elsif column_type =~ /upper_ci|uci/i\n currgroup.ucicol = i\n elsif column_type =~ /lower_ci|lci/i\n currgroup.lcicol = i\n elsif column_type =~ /cases/i\n currgroup.casescol = i\n elsif column_type =~ /controls/i\n currgroup.controlscol = i\n elsif column_type =~ /study/i\n currgroup.studycol = i\n elsif column_type =~ /^power$/i\n currgroup.powercol = i\n else\n currgroup.additional_cols[column_type]=i\n end\n end\n end\n\n unless (@snpid and @location and @chromnum) or (@snp1 and @snp2)\n puts \"ERROR: Need SNP, CHR, and POS or SNP1 and SNP2 columns in input file\"\n exit\n end\n\n # add groups to the grouplist\n grouporder.each do |g|\n namepcs = g.split /:/\n # add to default grouplist\n if namepcs.length == 1\n if !glisthash.has_key?(defaultkey)\n glisthash[defaultkey] = GroupList.new\n glisthash[defaultkey].mafcoltitle = mafcoltitle\n end\n glisthash[defaultkey].add_group(groups[g])\n else\n if !glisthash.has_key?(namepcs[1])\n glisthash[namepcs[1]] = GroupList.new\n glisthash[namepcs[1]].mafcoltitle = mafcoltitle\n end\n glisthash[namepcs[1]].add_group(groups[g])\n end\n end\n\n # need to match all colors when multiple grouplists\n if glisthash.length > 1\n # determine number of unique groups\n unique_names = Hash.new\n glisthash.each_value do |glist|\n glist.grouphash.each_key do |name|\n namepcs = name.split /:/\n unique_names[namepcs[0]] = 1\n end\n end\n colorhash = Hash.new\n unique_names.each_key do |name|\n\t\t\tputs name\n\t\t\tcolorstr = GroupList.get_next_color\n colorhash[name] = colorstr\n\t\t\tgroupcolors[name]=colorstr\n end\n\n glisthash.each_value do |glist|\n glist.grouphash.each do |name, group|\n namepcs = name.split /:/\n group.colorstr = colorhash[namepcs[0]]\n end\n end\n end\n\n\t# set group list colors for the tags (if any)\n\tif(snpTags)\n\t\tsnpTags.tags.each_key do |key|\n\t\t\tif(groupcolors.has_key?(key))\n\t\t\t\tsnpTags.tags[key]=groupcolors[key]\n\t\t\telse\n\t\t\t\tsnpTags.tags[key]=GroupList.get_next_color\n\t\t\tend\n\t\tend\n\tend\t\n\t\nend",
"def update_multiple\n submit_val = params[:applychange]\n @studentattendance_ids = params[:student_attendance_ids]\t\n @attends = params[:attends] \n @reasons = params[:reasons]\n @actions = params[:actions]\n @statuss = params[:statuss]\n @remarks = params[:remarks]\n @weeklytimetable_details_ids = params[:weeklytimetable_details_ids]\n @studentattendances = StudentAttendance.find(@studentattendance_ids) \n @studentattendances_group = @studentattendances.group_by{|x|x.student_id} \n \n if submit_val == I18n.t('student_attendance.apply_class_schedule')\n if @weeklytimetable_details_ids != nil\n @studentattendances_group.each do |student_id, studentattendances| \n studentattendances.each_with_index do |studentattendance, no|\n studentattendance.weeklytimetable_details_id = @weeklytimetable_details_ids[no.to_s]\n studentattendance.save\n end\n end\n end\n\n respond_to do |format|\n flash[:notice] = \"<b>#{(t 'student_attendance.class_schedule')}</b> #{(t 'student_attendance.selected_may_print')} <b>#{(t 'student_attendance.attendance_form')}</b>#{t('student_attendance.cw_date_timeslot')}<br>#{t('student_attendance.to_update')}<b>#{t('student_attendance.title').downcase}</b>#{t('student_attendance.check_uncheck_click')}<b>#{t('submit')}</b>.\"\n format.html {render :action => \"edit_multiple_intake\"}\n format.xml { head :ok }\n flash.discard\n end\n else\n #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n #start-for edit_multiple.html.erb--------\n if !@weeklytimetable_details_ids\n @next2 = 0\n @sa_sort_then_group = @studentattendances.sort_by{|y|y.student.name}.group_by{|x|x.student_id} \n @sa_sort_then_group.each do |student_id, studentattendances| \n studentattendances.sort_by{|u|u.weeklytimetable_detail.get_time_slot}.each_with_index do |studentattendance, no2|\n if @attends && @attends[(no2+@next2).to_s]!=nil\n studentattendance.attend = true\n else\n studentattendance.attend = false\n if @reasons && @reasons[(no2+@next2).to_s] != nil\n studentattendance.reason = @reasons[(no2+@next2).to_s]\n studentattendance.action = @actions[(no2+@next2).to_s]\n studentattendance.status = @statuss[(no2+@next2).to_s]\n studentattendance.remark = @remarks[(no2+@next2).to_s]\n end\n end\n studentattendance.save \n if no2 == studentattendances.count-1 #2 \n @next2 = @next2+no2+1 \n end\n end \n end\n end\n #end-for edit_multiple.html.erb--------\n #start-for edit_multiple_intake.html.erb--------\n @next = 0\n if @weeklytimetable_details_ids != nil\n @studentattendances_group.each do |student_id, studentattendances| \n studentattendances.each_with_index do |studentattendance, no|\n studentattendance.weeklytimetable_details_id = @weeklytimetable_details_ids[no.to_s]\n if @attends && @attends[(no+@next).to_s]!=nil #if @attends && @attends[no.to_s]!=nil\n studentattendance.attend = true\n else\n studentattendance.attend = false\n end\n studentattendance.save \n if no == studentattendances.count-1 #2 \n @next = @next+no+1 \n end \n end\n end\n end\n #end-for edit_multiple_intake.html.erb--------\n \n flash[:notice] = I18n.t('student_attendance.updated_attendance')\n redirect_to student_attendances_path\n #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n end\n end",
"def add_student (name,grade)\n if @roster[grade] == nil\n @roster[grade] = []\n @roster[grade] << name\n else \n @roster[grade] << name\n end \nend",
"def mod\n # get the grade params\n grade_params = Hash.new\n params.each{ |key, value|\n begin\n key = key.to_i\n if key.kind_of?(Fixnum) && key != 0\n grade_params[key] = value\n end\n rescue Error\n # ignore\n end\n }\n grade_params.each{ |key,value|\n as = AssignmentsStudents.find(key.to_i)\n as.grade = value\n as.save\n } \n redirect_to :action => 'index', :controller => 'assignments_students'\n end",
"def ldap_group_list=(value)\n # convert string into array.\n value = value.split(\"\\n\") if value.is_a?(String)\n\n @ldap_group_list = nil\n\n if value.is_a?(Array) && value.count > 0\n\n value = value.map{|v| v.to_s.upcase}.uniq\n\n # remove those missing from the new list.\n ldap_groups.where.not(name: value).delete_all\n\n # remove items already existing in the current list.\n value.delete_if {|v| ldap_groups.where(name: v).count != 0 }\n\n # add items missing from the current list.\n value.each do |new_group|\n ldap_groups << LdapAccessGroup.new(group: self, name: new_group)\n end\n\n else\n\n # clear the list.\n ldap_groups.delete_all\n end\n\n ldap_groups true\n end",
"def revise_groups(grouplist, opts = {})\n foreign_xref = opts[:xref]\n if grouplist.select {|r| !r['xref'] || !r['xref'][foreign_xref]}.any?\n raise \"At least one record is missing an xref.#{foreign_xref} value\"\n end\n\n changes = group_diffs(grouplist, opts)\n if opts[:additions]\n ab_changes = changes.map {|k,v| v.select {|chg| chg[1] == 'xref.ab'}}.map(&:first).compact\n matched_ab_uids = ab_changes.map {|ary| ary[2]}\n\n newuids = groups.map(&:uuid) - grouplist.map{|c| c['xref'] && c['xref'][xrefkey]} - matched_ab_uids\n\n adds = groups.select {|c| newuids.include?(c.to_hash['xref'][xrefkey])}\n\n {\n :changes => changes,\n :additions => adds.map(&:to_hash)\n }\n else\n changes\n end\n end",
"def assign_roles_manual\r\n\r\n\r\n @student_group = StudentGroup.find(params[:id])\r\n @rolelist=Role.find(:all, :conditions=>['case_study_id=?', @student_group.case_study_id])\r\n s=\"player\"\r\n\r\n #perform validation\r\n @tmp=Array.new\r\n @msg=1\r\n @flag=0\r\n\r\n @rolelist.count.times do |i|\r\n @tmp[i]=0\r\n end\r\n i=0\r\n @rolelist.each do |r|\r\n\r\n s=\"player\"+(r.id).to_s\r\n @name=params[s.to_sym]\r\n\r\n #@name=@name[@name.size-1].to_i\r\n @name=@name.partition(\" \")[2].to_i\r\n\r\n #@name=@name.partition(\" \")[2].to_s+\" \"\r\n @tmp.each do |tmp|\r\n if (tmp==@name)\r\n @flag=1\r\n end\r\n end\r\n @tmp << @name\r\n #@user=User.find(@name)\r\n end\r\n\r\n if (@flag==1)\r\n @msg=1\r\n redirect_to :action => 'create_games_manual', :id=>params[:id], :msg=>@msg\r\n else\r\n #this creates the game\r\n @make_game=Game.new\r\n @make_game.case_study_id=@student_group.case_study_id\r\n @make_game.student_group_id=@student_group.id\r\n @make_game.agreement_status=FALSE\r\n @make_game.status=TRUE\r\n @make_game.save\r\n\r\n\r\n @players=Array.new\r\n\r\n\r\n @rolelist.each do |r|\r\n s=\"player\"+(r.id).to_s\r\n @name=params[s.to_sym]\r\n @name=@name.partition(\" \")[2].to_i\r\n # @name=@name.partition(\" \")[2].to_s+\" \"\r\n #@name=@name[@name.size-1].to_i\r\n @user=User.find(@name)\r\n\r\n\r\n #This creates a new player\r\n @new_player=Player.new\r\n @new_player.user_id=@user.id\r\n @new_player.game_id=@make_game.id\r\n @new_player.role_id=r.id\r\n @new_player.save\r\n @student_routing=StudentRouting.new\r\n @student_routing.player_id=@new_player.id\r\n\r\n if @student_group.pre_questionnaire_id and @student_group.pre_questionnaire_id !=0\r\n @student_routing.pre_neg_required=true\r\n end\r\n if @student_group.post_questionnaire_id and @student_group.post_questionnaire_id !=0\r\n @student_routing.post_neg_required=true\r\n end\r\n if StudentGroupRule.first(:conditions => ['student_group_id=? and rule_id=?',@student_group.id,1])\r\n @student_routing.planning_required=true\r\n end\r\n\r\n @student_routing.save\r\n @players << @new_player\r\n #I am putting all allocated players(users ids of the players) in the database\r\n @tmp=Temp.new\r\n @tmp.user_id=@new_player.user_id\r\n @tmp.save\r\n end\r\n @x=Array.new\r\n @y=Array.new\r\n\r\n\r\n @players.each { |p| @x << p.user_id }\r\n #This stores info about unallocated users\r\n @tmps=Temp.find(:all)\r\n @leftover_students=Array.new\r\n @student_group_user=StudentGroupUser.find_all_by_student_group_id(@student_group.id)\r\n @student_group_user.each { |sgu| @y << sgu.user_id }\r\n @unallocated_students=@y-@x\r\n @tmps.each do |t|\r\n @unallocated_students.each do |ul|\r\n\r\n if (t.user_id==ul)\r\n @unallocated_students.delete(ul)\r\n end\r\n end\r\n end\r\n\r\n @unallocated_students.each do |ul|\r\n @u=User.find(ul)\r\n @leftover_students << @u\r\n end\r\n if (@leftover_students.count < @rolelist.count)\r\n Temp.destroy_all\r\n end\r\n\r\n\r\n # here all issues and scorecards are created\r\n @allissues=Issue.all(:conditions=>['case_study_id=?', @student_group.case_study_id])\r\n @allroles=Role.all(:conditions=>['case_study_id=?', @student_group.case_study_id])\r\n @allgames=Game.all(:conditions=>['student_group_id=?', @student_group.id])\r\n @allgames.each do |game|\r\n @allplayers=Player.all(:conditions=>['game_id=?', game.id])\r\n @allplayers.each do |player|\r\n @allissues.each do |issue|\r\n @player_scorecard=PlayerScorecard.new\r\n @player_scorecard.player_id=player.id\r\n @player_scorecard.issue_id=issue.id\r\n @player_scorecard.save\r\n end\r\n end\r\n end\r\n\r\n\r\n end\r\n redirect_to :action => 'create_games_manual', :id=>params[:id]\r\n\r\n end",
"def populate_groups_for_round i=@round\r\n temp_groups = []\r\n (1..@number_of_groups).each_entry do |x|\r\n temp_group = Group.new(:position => i, :day => x, :schedule_dataset => self)\r\n temp_groups.push(temp_group)\r\n end\r\n\r\n # Add seminarians who need to be assigned to a single day\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups)\r\n sem.add_to_group(possible_grps.first) if possible_grps.count == 1 && !possible_grps.first.full?\r\n end\r\n\r\n # Add seminarians with too many duplicates to a group with least number of seminarians\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).sort_by{|g| g.seminarians.count}\r\n sem.add_to_group(possible_grps.first) if sem.duplicate_days >= @duplicate_days_allowed && !possible_grps.first.full?\r\n end\r\n\r\n # Add at least one seminarian to each group\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).shuffle\r\n sem.add_to_group(possible_grps.first) if possible_grps.count < @number_of_groups && possible_grps.first.seminarians.count == 0\r\n end\r\n\r\n seminarians_left = seminarians_for_round(i)\r\n \r\n while seminarians_left.any? do\r\n\r\n #Find the smallest groups\r\n smallest_number = temp_groups.sort_by{|g| g.seminarians.count}.first.seminarians.count\r\n small_groups = temp_groups.select{|tg| tg.seminarians.count == smallest_number}\r\n\r\n best_match = nil\r\n best_score = 9000\r\n\r\n small_groups.shuffle.each do |group|\r\n seminarians_left.shuffle.each do |sem|\r\n \r\n #Find the best match of seminarians and small groups\r\n if sem.score_for_group(group) < best_score\r\n best_match = [sem, group]\r\n best_score = sem.score_for_group(group)\r\n end\r\n end\r\n end\r\n \r\n best_match.first.add_to_group(best_match.second) if best_match\r\n seminarians_left = seminarians_for_round(i)\r\n end\r\n \r\n temp_groups.each{|g| @groups.push(g)}\r\n end",
"def accountability_groups(students)\n\nthrowaway = []\nunit = []\ngroups = []\n\n3.times do\n\tthrowaway = students.dup\n\ti = 0\n\n\twhile(throwaway.size > 0) do\n\n\t\tunit << throwaway.sample(4) if throwaway.size % 4 == 0 \n\t\tunit << throwaway.sample(5) if throwaway.size % 4 != 0\n\t\tunit[i].each { |student| throwaway.delete(student) }\n\t\ti += 1\n\tend\n\n\tgroups << unit.dup\n\tunit.clear\nend\ngroups\nend",
"def add_student (name, grade)\n # @student_name = name\n # @grade = grade\n if @roster.include?(grade) \n @roster [grade] << name \n else\n @roster [grade] = [name]\n end\n end",
"def group=(new_group)\n if @group != new_group\n @dacl.reassign!(@group, new_group)\n @group = new_group\n end\n end"
] | [
"0.66360784",
"0.6237153",
"0.6188952",
"0.6026198",
"0.5886622",
"0.588282",
"0.5865376",
"0.5857002",
"0.5840385",
"0.57994574",
"0.5735701",
"0.5701173",
"0.5681672",
"0.5661645",
"0.564786",
"0.56250745",
"0.5588607",
"0.55875236",
"0.5578181",
"0.5568742",
"0.5551329",
"0.55512065",
"0.55501884",
"0.55435205",
"0.5515885",
"0.55080783",
"0.54831856",
"0.5468116",
"0.54428786",
"0.5436991",
"0.5436156",
"0.5430571",
"0.54113615",
"0.54089755",
"0.5400587",
"0.5396763",
"0.5388394",
"0.5371411",
"0.53600675",
"0.53272575",
"0.5307761",
"0.5301025",
"0.52847254",
"0.5278941",
"0.5277221",
"0.5272757",
"0.52724075",
"0.52723485",
"0.5265685",
"0.5262144",
"0.5259949",
"0.52571607",
"0.5252555",
"0.52441555",
"0.52413756",
"0.52331376",
"0.5231251",
"0.52304506",
"0.5225081",
"0.5222092",
"0.5220751",
"0.52161837",
"0.5214728",
"0.52053106",
"0.51966",
"0.5184775",
"0.5179523",
"0.5161419",
"0.5144785",
"0.5140931",
"0.51381665",
"0.51371163",
"0.5123979",
"0.5123979",
"0.5123979",
"0.5123979",
"0.511392",
"0.51057756",
"0.51055515",
"0.50980026",
"0.5088313",
"0.5082111",
"0.5079303",
"0.50773644",
"0.5069891",
"0.5068371",
"0.5067456",
"0.5067288",
"0.5065759",
"0.5057467",
"0.5057373",
"0.5050018",
"0.50486165",
"0.5044388",
"0.5040643",
"0.5039818",
"0.5027046",
"0.50238305",
"0.5019317",
"0.501866"
] | 0.6117647 | 3 |
def scream(words) words = words + "!!!!" return puts words end scream("Yippeee") In exercise 5, the method will print to screen, but should return nil. | def scream(words)
words = words + "!!!!"
puts words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scream(words) # Edited to output to STDOUT, returns nil (the last statement is 'puts words')\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\nwords = words + \"!!!!\"\nreturn #this makes the program return nothing.. because it has nothing next to the return method\nputs words\nend",
"def scream(words)\r\n words = words + \"!!!!\"\r\n return\r\n puts words\r\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n return\n puts words\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n\treturn\n\tputs words\nend",
"def scream(words)\n words=words+\"!!!!\"\n # return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return puts words\nend",
"def scream(words)\n words=words + \"!!!!\"\n #return\n puts words\nend",
"def scream words\n words = words + '!!!!'\n return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n return\nend",
"def scream(words)\n words = words + \"!!!!\"\n # return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n #return\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n # removed 'return'\n puts words\nend",
"def scream_a(words)\n words = words + \"!!!!!\"\n return\n puts words\nend",
"def scream_d(words)\n words = words + \"!!!!!\"\n #return\n #puts words\nend",
"def scream_c(words)\n #words = words + \"!!!!!\"\n return\n #puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n return words\nend",
"def scream(words)\n\twords = words + \"!!!!\"\n\tputs words\n\treturn\nend",
"def scream_b(words)\n words = words + \"!!!!!\"\n #return\n puts words\nend",
"def scream(words)\n puts words + \"!!!!\"\nend",
"def scream(word)\n word = word + \"!!!\"\n return puts \"#{word}\" #<--------\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words #this command returns nil, if 'p' over puts, =>Yippee!!!!\nend",
"def scream(words) \n\t\twords = words + \"!!!!\" \n\t\treturn\n\t\tputs words \n\tend",
"def scream(words)\r\n words = words + \"!!!!\"\r\n puts words\r\nend",
"def scream(words)\r\n words = words + \"!!!!\"\r\n puts words\r\nend",
"def scream(words)\n words = words + \"!!!\"\n puts words \nend",
"def scream(words)\n\twords = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n\n\twords = words + \"!!!\"\n\n puts words\n\nend",
"def scream(words)\n words += \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\" \n puts words\nend",
"def scream(words)\n words = words + \"!!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n\t#words\nend",
"def scream(words)\n words = words + '!!!!'\n puts words\nend",
"def scream(words)\n words = words + '!!!!'\n puts words\nend",
"def scream(word)\n words = words + \"!!!!\"\n puts words\nend",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n end",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n end",
"def scream(words)\n words = words + \"!!!!\"\n puts words\n end",
"def scream(words)\n words = words + \"!!!!\"\n return words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return words\nend",
"def scream(words)\n words = words + \"!!!!\"\n return words\nend",
"def yell(words)\n words = words + \"!!\"\n puts words\nend",
"def screams(words)\n words = words + \"!!!!\"\n puts words # last line evaluated\nend",
"def scream(words)\n words = words + \"!!!!!\"\n words\nend",
"def shout(word)\n# irb(main):012:1> \nreturn \"HOLA\"\n# irb(main):013:1> \nend",
"def say(words)\n puts words + \"!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(words)\n words = words + \"!!!!\"\nend",
"def scream(word)\n words = words + \"!!!!\"\nend",
"def scream(words)\n\twords = words + \"!!!!\"\nend",
"def scream(words)\n words = words + '!!!!'\nend",
"def joke1\n puts \"A peanut was walking down the street. He was a-salt-ed.\"\nend",
"def say(words)\n\tputs words\nend"
] | [
"0.8911424",
"0.88289773",
"0.875892",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719786",
"0.8719083",
"0.86863965",
"0.8631476",
"0.8600056",
"0.85801613",
"0.8578181",
"0.85728407",
"0.8542892",
"0.85354763",
"0.8523123",
"0.8506274",
"0.8493854",
"0.84702575",
"0.8349274",
"0.8337884",
"0.8335971",
"0.8280736",
"0.8265058",
"0.825925",
"0.82159066",
"0.817825",
"0.81764615",
"0.7956841",
"0.7956841",
"0.79566866",
"0.79151845",
"0.79142064",
"0.78989035",
"0.7874986",
"0.7865468",
"0.78453493",
"0.78360087",
"0.7824607",
"0.77844846",
"0.77844846",
"0.77663",
"0.77411634",
"0.7689726",
"0.7689726",
"0.7629967",
"0.7629967",
"0.7629967",
"0.74289614",
"0.74154574",
"0.73300916",
"0.7272597",
"0.7216886",
"0.71741575",
"0.71741575",
"0.71741575",
"0.71741575",
"0.71741575",
"0.7165086",
"0.7125479",
"0.7097758",
"0.68969434",
"0.6888598"
] | 0.7858081 | 64 |
current_organisation returns organisation obj for current organisation return nil if no current organisation defined | def current_organisation()
begin
organisation = (
Thread.current[:organisation_id].blank? ?
nil :
Organisation.find( Thread.current[:organisation_id] )
)
return organisation
rescue ActiveRecord::RecordNotFound
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_org\n current_user&.org\n end",
"def set_current_organisation( organisation )\n # able to handle organisation obj or organisation_id\n #case organisation\n # when Organisation then organisation_id = organisation.id\n # when Integer then organisation_id = organisation\n # when Array then organisation_id = organisation\n # else\n # raise ArgumentError, \"invalid organisation object or id\"\n #end\n #old_id = ( Thread.current[:organisation_id].nil? ? '%' : Thread.current[:organisation_id] )\n if organisation.is_a? Integer\n organisation = Organisation.where(id: organisation).first\n end\n \n Thread.current[:organisation_id] = organisation.present? ? organisation.root.subtree.map(&:id) : nil\n Thread.current[:current_organisation_id] = organisation.present? ? organisation.subtree.map(&:id) : nil\n Thread.current[:root_organisation_id] = organisation.present? ? organisation.root.id : nil\n #organisation = Organisation.find(organisation_id) rescue nil\n #Time.zone = organisation.time_zone || 'Singapore' rescue 'Singapore'\n end",
"def current_organisation_id()\n return Thread.current[:organisation_id]\n end",
"def current_id\n current_org&.id\n end",
"def current_organization\n Organization.find(params[:organization_id])\n end",
"def current_organization\n fog_model_interface.current_organization\n end",
"def organisation_name\n return if partnership?\n\n organisation.name\n end",
"def organization\n return @organization if @organization\n @organization = Organization.find(organization_id)\n end",
"def org\n user_id.present? ? User.includes(:org).find_by(id: user_id).org : nil\n end",
"def current_company\n current_user ? current_user.company : nil\n end",
"def organisation?\n session[:organisation] and session[:organisation].size > 0\n end",
"def organisation_name_fetch\n @organisation.try(:organisation_name)\n end",
"def org\n client.org(org_id)\n end",
"def org\n client.org(org_id)\n end",
"def organisation_details\n return blank_value unless organisation\n\n organisation.partnership? ? partner_names : organisation.name\n end",
"def org_id\n @org_id ||= query_org_id # lazy query org_id when not set by login response\n end",
"def show\n @organization = current_user.organization\n end",
"def set_organisation\n @organisation = Organisation.find(params[:organisation_id]) if params[:organisation_id]\n end",
"def organization\n capital_project.organization\n end",
"def organization\n id = if params[:organization_id]\n params[:organization_id]\n elsif params.dig(:q, :parent_id_eq)\n params[:q][:parent_id_eq]\n elsif params.dig(model.name.underscore.to_sym, :organization_id)\n params[model.name.underscore.to_sym][:organization_id]\n end\n Organization.where(id: id).first || @record&.organization || OpenStruct.new(id: nil)\n end",
"def organization\n self[:O]\n end",
"def org_name\n (org = self.organization) && org.name\n end",
"def current_company\n Company.find(1)\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def base_org\n if self.customization_of.present?\n return Template.where(family_id: self.customization_of).first.org\n else\n return self.org\n end\n end",
"def current_company\n @current_company = current_user.company\n end",
"def organisation=(new_org)\n org_id = new_org.id unless new_org.nil?\n end",
"def current_login\n current_company ? current_company : current_user.company\n end",
"def organization\n if documentable.respond_to? :organization\n documentable.organization\n else\n creator.organization\n end\n end",
"def current\n render jsonapi: current_organization, include: %i[primary_group terms_text_item most_used_templates]\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def org\n @org_resource ||= Org.new(@client)\n end",
"def org\n object.user.org&.handle\n end",
"def current_company\n if current_user.company_users != []\n session[:company_id] ||= current_user.company_users.first.company.id\n @current_company ||= Company.find(session[:company_id])\n else\n @current_company = nil\n end\n end",
"def parent\n raise \"undefined parent Organization\" unless organization?\n organization\n end",
"def organization\n id = Location.where(id: self.id).joins(:visits).select([:organization_id])\n Organization.where(id: id).select([:name]).first\n end",
"def set_organisation\n raise \"You must set the organisation\" if session[:organisation].blank?\n OrganisationSession.set session[:organisation]\n end",
"def get_company\n @company ||= current_company\n end",
"def org_name\n self.org.try(:name).to_s\n end",
"def current_company() # :doc:\n current_user.full?(&:company)\n end",
"def organization_id\n self.organization.id if self.organization && self.organization.is_a?(Organization)\n end",
"def check_org\n unless current_user.organisation == @division.organisation\n redirect_to current_user, :alert => \"Sorry, you are not authorised for that\"\n end\n end",
"def retrieve_organization(name = nil)\n name ||= organization_name\n org = Organization.find_by(name: name)\n halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \\\n if org.nil?\n return org\n end",
"def set_organization\n if current_user.is_admin?\n @organization = Organization.where(id: params[:id]).first\n else\n @organization = current_user.organizations.where(id: params[:id]).first\n end\n \n end",
"def current_company\n Company.find(:first)\nend",
"def project \n organizing_city.current_project\n end",
"def exchange_organization\n return @exchange_organization\n end",
"def set_organization\n @organization = current_user.organizations.where(id: params[:id]).first\n end",
"def current_user\n current_admin || current_nonprofit\n end",
"def requestor; organization; end",
"def institution_id\n\t\tif organisation.nil?\n\t\t\treturn nil\n\t\telse\n\t\t\treturn organisation.root.id\n\t\tend\n\tend",
"def authenticate_user!(options={})\n super(options)\n @organisation ||= current_user.organisation\n Organisation.current_id = @organisation.present? ? @organisation.subtree.map(&:id) : nil\n end",
"def associated_organisation_name_for_solr\n return FinderHelper.strip(role.organisation.organisation_name) if !role.organisation.blank?\n end",
"def core \n self.service.organization\n end",
"def current_project\n @current_project ||= session[:project_id] unless @current_project== false\n end",
"def get_contestorganization\n @contestorganization = Contestorganization.find_by_id(params[:id])\n return if check_nil_object(@contestorganization)\n end",
"def current_company\n @current_company = Company.find_by(id: session[:company_id])\n end",
"def current_user\n # Designer.first\n current_designer\n end",
"def associated_organization\n user_sports.first.user.organization \n end",
"def org_type\n\t\torg_type = organisation.organisation_type.name\n\t\treturn org_type\n\tend",
"def current_organization_or_survey_invitation\n @current_organization_or_survey_invitation ||= (login_from_session || login_from_cookie || login_from_survey_invitation || :false)\n end",
"def org_address\n company&.company_address\n end",
"def current_company\n if user_signed_in?\n @company = current_user.company\n @folders = @company.folders\n if current_user.admin?\n # excluding self\n @users = @company.users\n end\n end\n end",
"def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end",
"def update\n if !current_user.admin?\n head :forbidden\n else\n if @organisation.update(organisation_params)\n render json: @organisation.to_json, status: :ok\n else\n render json: @organisation.errors, status: :unprocessable_entity\n end\n end\n end",
"def org_name\n @org_name ||= opts[:org]&.resource&.name\n end",
"def get_organization_by_name(org_name)\n org = @client.organizations.find { |cc_org|\n cc_org.name == org_name\n }\n\n org\n rescue Exception => ex\n raise \"#{ex.inspect}, #{ex.backtrace}\"\n end",
"def org\n self.check.org\n end",
"def org\n self.check.org\n end",
"def organization\n if solo_run?\n # configurable fake organization name for chef-solo users\n Chef::Config[:data_collector][:organization]\n else\n Chef::Config[:chef_server_url].match(%r{/+organizations/+([^\\s/]+)}).nil? ? \"unknown_organization\" : $1\n end\n end",
"def rol\n if !current_login.nil?\n @user = User.find_by(User_Email: current_login[:email])\n @organization = Organization.find_by(Organization_Email: current_login[:email])\n end\n end",
"def require_org\n # If no working org is set, just use the first one in the visible list.\n # For non-admins this will be their one and only org.\n if working_org.nil?\n self.working_org = @visible_orgs[0]\n end\n true\n end",
"def org_id\n query('select id from Organization').first['Id']\n end",
"def current_user\n current_admin || current_consumer || current_employee\n end",
"def current_workplace\n if @workplace && current_admin\n @workplace.name\n else#fail safe\n end \n end",
"def organization\n @organization ||= Github::Organization.new(client, @options[:owner])\n end",
"def show\n render template: 'pages/404', status: 404 and return if @organisation.nil?\n organisations = Organisation.where(id: @organisation.id)\n if current_user\n @pending_org_admin = current_user.pending_org_admin? @organisation\n @editable = current_user.can_edit?(@organisation)\n @deletable = current_user.can_delete?(@organisation)\n @can_create_volunteer_op = current_user.can_create_volunteer_ops?(@organisation)\n @grabbable = current_user.can_request_org_admin?(@organisation)\n else\n @grabbable = true\n end\n add_breadcrumb @organisation.name, :organisation_path\n @can_propose_edits = current_user.present? && !@editable\n @markers = build_map_markers(organisations)\n @cat_name_ids = Category.name_and_id_for_what_who_and_how\n end",
"def current_commission\n @current_commission ||= current_location.try(:commission)\n end",
"def adopt_organization\n if external_id? && organization.blank?\n self.organization = Organization.where { |o| o.id.in(\n Registration.unscoped.where( :external_id => external_id ).\n select { organization_id } ) }.first\n end\n true\n end",
"def organization\n _get(\"/account/organization\") { |json| json }\n end",
"def user_or_org\n self.is_user? ? 'user' : 'organization'\n end",
"def wanted_org(name)\n debug(\"Name: #{name}\")\n r = Regexp.new(/(?<org_name>\\A[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)\\/*/)\n @wanted_org ||= r.match(name) && r.match(name)[:org_name]\n debug(\"Wanted org: #{@wanted_org}\")\n @wanted_org\n end",
"def autonomous_system_organization; end",
"def autonomous_system_organization; end",
"def autonomous_system_organization; end",
"def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end",
"def current_company\n @current_company = current_user.companies.find(params[:company_id])\n end",
"def get_organization\n return \"NSBE\" if affiliation == 1\n \"SHPE\"\n end",
"def unit_id\n\t\tif organisation.nil? || organisation.parent_id.nil?\n\t\t\treturn nil\n\t\telse\n\t\t\treturn organisation_id\n\t\tend\n\tend",
"def organization\n self.data_response.organization\n end",
"def set_organization\n if current_user\n current_organization = Organization.find(current_user.organization_id)\n set_current_tenant(current_organization)\n end\n end",
"def set_org\n @org = Organization.find(params[:id])\n end",
"def current_dojo\n\t\tdojo_students = self.dojo_students.select{|ds| ds.end_date.nil?}\n\t\treturn nil if dojo_students.empty?\n\t\tdojo_students.first.dojo\n\tend",
"def current_subcom\n @current_subcom ||= Subcommunity.find(params[:subcommunity_id])\n end",
"def company\n @company ||= research_param(:company) || company_list.first\n end",
"def organization; end",
"def organization; end",
"def organization; end"
] | [
"0.7711881",
"0.76772815",
"0.7624038",
"0.7284386",
"0.72407955",
"0.72248566",
"0.6995413",
"0.6935735",
"0.6915876",
"0.6709824",
"0.66519535",
"0.66405255",
"0.6632705",
"0.6632705",
"0.6558245",
"0.6423801",
"0.6405801",
"0.63878894",
"0.63841444",
"0.6370104",
"0.63510114",
"0.6331135",
"0.63295937",
"0.63252413",
"0.63252413",
"0.63252413",
"0.6306744",
"0.630659",
"0.6305112",
"0.6300225",
"0.6295731",
"0.62871283",
"0.6266095",
"0.62635744",
"0.6263534",
"0.6259828",
"0.62558484",
"0.6250637",
"0.62326163",
"0.6232412",
"0.6226153",
"0.6225733",
"0.6218134",
"0.62062114",
"0.6203882",
"0.6189283",
"0.6187366",
"0.61802",
"0.6109328",
"0.6106822",
"0.6103072",
"0.60625124",
"0.60624135",
"0.60587686",
"0.60332745",
"0.6023209",
"0.600586",
"0.5986136",
"0.59663916",
"0.5960578",
"0.59118336",
"0.5897669",
"0.5888594",
"0.5887665",
"0.5881742",
"0.5868937",
"0.58479726",
"0.5837503",
"0.5833786",
"0.5833751",
"0.5833751",
"0.58259964",
"0.5817456",
"0.5813142",
"0.580627",
"0.5794638",
"0.57904917",
"0.5786287",
"0.5781554",
"0.5776622",
"0.5768032",
"0.57606083",
"0.5753194",
"0.5750102",
"0.5743026",
"0.5743026",
"0.5743026",
"0.5737595",
"0.57244587",
"0.5716252",
"0.5706457",
"0.57033455",
"0.56904316",
"0.5665309",
"0.5658108",
"0.565607",
"0.56456274",
"0.56427056",
"0.56427056",
"0.56427056"
] | 0.8878894 | 0 |
current_organisation_id returns organisation_id for current organisation | def current_organisation_id()
return Thread.current[:organisation_id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_organisation()\n begin\n organisation = (\n Thread.current[:organisation_id].blank? ?\n nil :\n Organisation.find( Thread.current[:organisation_id] )\n )\n\n return organisation\n\n rescue ActiveRecord::RecordNotFound\n return nil\n end \n end",
"def current_id\n current_org&.id\n end",
"def current_organization\n Organization.find(params[:organization_id])\n end",
"def set_current_organisation( organisation )\n # able to handle organisation obj or organisation_id\n #case organisation\n # when Organisation then organisation_id = organisation.id\n # when Integer then organisation_id = organisation\n # when Array then organisation_id = organisation\n # else\n # raise ArgumentError, \"invalid organisation object or id\"\n #end\n #old_id = ( Thread.current[:organisation_id].nil? ? '%' : Thread.current[:organisation_id] )\n if organisation.is_a? Integer\n organisation = Organisation.where(id: organisation).first\n end\n \n Thread.current[:organisation_id] = organisation.present? ? organisation.root.subtree.map(&:id) : nil\n Thread.current[:current_organisation_id] = organisation.present? ? organisation.subtree.map(&:id) : nil\n Thread.current[:root_organisation_id] = organisation.present? ? organisation.root.id : nil\n #organisation = Organisation.find(organisation_id) rescue nil\n #Time.zone = organisation.time_zone || 'Singapore' rescue 'Singapore'\n end",
"def org_id\n @org_id ||= query_org_id # lazy query org_id when not set by login response\n end",
"def organization_id\n self.organization.id if self.organization && self.organization.is_a?(Organization)\n end",
"def org_id\n query('select id from Organization').first['Id']\n end",
"def institution_id\n\t\tif organisation.nil?\n\t\t\treturn nil\n\t\telse\n\t\t\treturn organisation.root.id\n\t\tend\n\tend",
"def current_org\n current_user&.org\n end",
"def org\n user_id.present? ? User.includes(:org).find_by(id: user_id).org : nil\n end",
"def set_organization\n @organization = current_user.organizations.where(id: params[:id]).first\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:organisation_id]) if params[:organisation_id]\n end",
"def organisation=(new_org)\n org_id = new_org.id unless new_org.nil?\n end",
"def authenticate_user!(options={})\n super(options)\n @organisation ||= current_user.organisation\n Organisation.current_id = @organisation.present? ? @organisation.subtree.map(&:id) : nil\n end",
"def current_organization\n fog_model_interface.current_organization\n end",
"def org\n client.org(org_id)\n end",
"def org\n client.org(org_id)\n end",
"def organisation_name\n return if partnership?\n\n organisation.name\n end",
"def full_org_id; (term_id && org_id) ? \"#{term_id}_#{org_id}\" : nil; end",
"def organization\n id = if params[:organization_id]\n params[:organization_id]\n elsif params.dig(:q, :parent_id_eq)\n params[:q][:parent_id_eq]\n elsif params.dig(model.name.underscore.to_sym, :organization_id)\n params[model.name.underscore.to_sym][:organization_id]\n end\n Organization.where(id: id).first || @record&.organization || OpenStruct.new(id: nil)\n end",
"def unit_id\n\t\tif organisation.nil? || organisation.parent_id.nil?\n\t\t\treturn nil\n\t\telse\n\t\t\treturn organisation_id\n\t\tend\n\tend",
"def set_organization\n if current_user.is_admin?\n @organization = Organization.where(id: params[:id]).first\n else\n @organization = current_user.organizations.where(id: params[:id]).first\n end\n \n end",
"def organization\n return @organization if @organization\n @organization = Organization.find(organization_id)\n end",
"def org_id\n\t\t\tOrganization.count + 1\n\t\tend",
"def organization\n id = Location.where(id: self.id).joins(:visits).select([:organization_id])\n Organization.where(id: id).select([:name]).first\n end",
"def group_org_id\n\t\t\tGroupOrganization.count + 1\n\t\tend",
"def current_company\n current_user ? current_user.company : nil\n end",
"def get_state_organization_id(id)\n return id if id.kind_of? String\n return DataUtility.get_local_education_agency_id(id)\n end",
"def show\n @organization = current_user.organization\n end",
"def calendar_id\t\t\n \t\t# calendar id returns nil if user doesn't exist\n \t\tcalendar unless !has_calendar? \n \tend",
"def organization( organisation_id )\n\n if( organisation_id.is_a?(String) && organisation_id.is_a?(Integer))\n raise ArgumentError.new(format('wrong type. \\'organisation_id\\' must be an String (for an Datasource name) ' \\\n 'or an Integer (for an Datasource Id), given \\'%s\\'', organisation_id.class.to_s))\n end\n raise ArgumentError.new('missing \\'organisation_id\\'') if( organisation_id.size.zero? )\n\n endpoint = format( '/api/orgs/%d', organisation_id ) if(organisation_id.is_a?(Integer))\n endpoint = format( '/api/orgs/name/%s', ERB::Util.url_encode( organisation_id ) ) if(organisation_id.is_a?(String))\n\n @logger.debug(\"Attempting to get existing data source Id #{organisation_id} (GET #{endpoint})\") if @debug\n\n get(endpoint)\n end",
"def set_org\n @org = Organization.find(params[:id])\n end",
"def set_organization_id\n self.organization_id = self.user.organization_id\n end",
"def parent\n raise \"undefined parent Organization\" unless organization?\n organization\n end",
"def current_id\n not_applicable\n end",
"def current_company\n if current_user.company_users != []\n session[:company_id] ||= current_user.company_users.first.company.id\n @current_company ||= Company.find(session[:company_id])\n else\n @current_company = nil\n end\n end",
"def current_company\n Company.find(1)\n end",
"def current_company\n @current_company = current_user.companies.find(params[:company_id])\n end",
"def id\n \"#{project.id}-#{current_user.id}\"\n end",
"def current_id\n current_user&.id\n end",
"def current_company\n @current_company = current_user.company\n end",
"def current_login\n current_company ? current_company : current_user.company\n end",
"def associated_organization\n user_sports.first.user.organization \n end",
"def find_organization\n @organization = Organization.find(params[:organization_id])\n end",
"def current_company\n Company.find(:first)\nend",
"def set_organisation\n raise \"You must set the organisation\" if session[:organisation].blank?\n OrganisationSession.set session[:organisation]\n end",
"def current_semester_id\n unless @current_semester_id\n cur_month = \"#{Date::MONTHNAMES[Time.now.month()]} #{Time.now.year()}\"\n @current_semester_id = Month.find_semester_id(cur_month)\n end\n @current_semester_id\n\n end",
"def current_company\n @current_company = Company.find_by(id: session[:company_id])\n end",
"def base_org\n if self.customization_of.present?\n return Template.where(family_id: self.customization_of).first.org\n else\n return self.org\n end\n end",
"def org_name\n (org = self.organization) && org.name\n end",
"def company_id\n e = Employee.find_by(user_id: id)\n e.company_id\n end",
"def set_organization\n # @org = Organization.find(params[:id])\n end",
"def organisation_details\n return blank_value unless organisation\n\n organisation.partnership? ? partner_names : organisation.name\n end",
"def organisation?\n session[:organisation] and session[:organisation].size > 0\n end",
"def set_organization\n @organization = Organization.custom_find(params[:id])\n end",
"def current\n render jsonapi: current_organization, include: %i[primary_group terms_text_item most_used_templates]\n end",
"def current_user_id\n 1\n end",
"def set_organization\n @signed_in = admin_signed_in?\n @organization = Organization.find(params[:id])\n end",
"def current_project\n @current_project ||= session[:project_id] unless @current_project== false\n end",
"def organization_id=(id)\n self.organization = Organization.find_by_id(id.to_i)\n end",
"def organisation_name_fetch\n @organisation.try(:organisation_name)\n end",
"def organization\n capital_project.organization\n end",
"def check_org\n unless current_user.organisation == @division.organisation\n redirect_to current_user, :alert => \"Sorry, you are not authorised for that\"\n end\n end",
"def requestor; organization; end",
"def project \n organizing_city.current_project\n end",
"def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end",
"def organization\n if documentable.respond_to? :organization\n documentable.organization\n else\n creator.organization\n end\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n if !current_user.soadmin && current_user.organization != @organization\n redirect_to current_user.organization\n end\n end",
"def id\n object.corporation_id\n end",
"def project_id\n project_id = @options[:project_id] || Git.get_config(KEY_PROJECT_ID, :inherited)\n\n if project_id.empty?\n project_id = choose do |menu|\n menu.prompt = 'Choose project associated with this repository: '\n\n PivotalTracker::Project.all.sort_by { |project| project.name }.each do |project|\n menu.choice(project.name) { project.id }\n end\n end\n\n Git.set_config(KEY_PROJECT_ID, project_id, :local)\n puts\n end\n\n project_id\n end",
"def set_organization\n if current_user\n current_organization = Organization.find(current_user.organization_id)\n set_current_tenant(current_organization)\n end\n end",
"def project_id\n return @project_id unless @project_id.nil?\n project_number = self.project_number || @workforce_pool_user_project\n\n # if we missing either project number or scope, we won't retrieve project_id\n return nil if project_number.nil? || @scope.nil?\n\n url = \"#{CLOUD_RESOURCE_MANAGER}#{project_number}\"\n response = connection.get url do |req|\n req.headers[\"Authorization\"] = \"Bearer #{@access_token}\"\n req.headers[\"Content-Type\"] = \"application/json\"\n end\n\n if response.status == 200\n response_data = MultiJson.load response.body, symbolize_names: true\n @project_id = response_data[:projectId]\n end\n\n @project_id\n end",
"def project_id\n return @project_id unless @project_id.nil?\n project_number = self.project_number || @workforce_pool_user_project\n\n # if we missing either project number or scope, we won't retrieve project_id\n return nil if project_number.nil? || @scope.nil?\n\n url = \"#{CLOUD_RESOURCE_MANAGER}#{project_number}\"\n\n response = connection.get url do |req|\n req.headers[\"Authorization\"] = \"Bearer #{@access_token}\"\n req.headers[\"Content-Type\"] = \"application/json\"\n end\n\n if response.status == 200\n response_data = MultiJson.load response.body, symbolize_names: true\n @project_id = response_data[:projectId]\n end\n\n @project_id\n end",
"def institution_id=(new_institution_id)\n\t\tif organisation.nil? then\n\t\t\tself.organisation_id = new_institution_id\n\t\tend\n\tend",
"def current_account\n @current_account ||= company.accounts.find_by(id: self.id)\n end",
"def myworkspace_id\n if framework.db.active\n myworkspace.id\n else\n nil\n end\n end",
"def current_user\n # Designer.first\n current_designer\n end",
"def adopt_organization\n if external_id? && organization.blank?\n self.organization = Organization.where { |o| o.id.in(\n Registration.unscoped.where( :external_id => external_id ).\n select { organization_id } ) }.first\n end\n true\n end",
"def set_org\n @org_id = request.headers[\"X-WWW-ORG-ID\"]\n end",
"def current_tenant_id\n self.class.current_tenant_id\n end",
"def current_subcom\n @current_subcom ||= Subcommunity.find(params[:subcommunity_id])\n end",
"def associated_organisation_name_for_solr\n return FinderHelper.strip(role.organisation.organisation_name) if !role.organisation.blank?\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def common_id\n securities.where('name' == 'common').first.id\n end",
"def set_organization\n @organization = Organization.friendly.find(params[:id])\n end",
"def set_organization\n @organization = Organization.friendly.find(params[:id])\n end",
"def company_id\n if @company.respond_to?(:to_hash)\n @company.fetch(:company_id) { @company }\n elsif @company.respond_to?(:company_id)\n @company.company_id\n else\n @company\n end\n end",
"def company_id\n self.dig_for_string(\"agentSummary\", \"office\", \"companyId\")\n end",
"def funder_id\n if self.template.nil? then\n return nil\n end\n return self.template.org\n end",
"def default_calendar_id\n @calendar_id ||= editable_calendars.first.calendar_id\n end",
"def org_name\n self.org.try(:name).to_s\n end",
"def update\n if !current_user.admin?\n head :forbidden\n else\n if @organisation.update(organisation_params)\n render json: @organisation.to_json, status: :ok\n else\n render json: @organisation.errors, status: :unprocessable_entity\n end\n end\n end",
"def organization\n self[:O]\n end"
] | [
"0.81824243",
"0.80198395",
"0.75833",
"0.75296277",
"0.7467459",
"0.729725",
"0.72417474",
"0.6995078",
"0.6897121",
"0.68032783",
"0.6752774",
"0.67313534",
"0.6719804",
"0.6719804",
"0.6719804",
"0.67147934",
"0.6714425",
"0.65651304",
"0.6557183",
"0.6556622",
"0.6556622",
"0.65336615",
"0.65015745",
"0.6494059",
"0.6466294",
"0.6452924",
"0.6447647",
"0.644753",
"0.6346456",
"0.63002986",
"0.62856984",
"0.6277819",
"0.6234373",
"0.62106794",
"0.61936677",
"0.6181177",
"0.6146613",
"0.6124581",
"0.6107828",
"0.6084876",
"0.60793054",
"0.6065231",
"0.60563177",
"0.6036746",
"0.60338444",
"0.6029121",
"0.60088384",
"0.59897906",
"0.5984582",
"0.5970282",
"0.5956921",
"0.59564316",
"0.5937079",
"0.592418",
"0.59145606",
"0.5895979",
"0.58710676",
"0.586299",
"0.5860347",
"0.5854874",
"0.58541566",
"0.5851663",
"0.5847668",
"0.5847486",
"0.584733",
"0.584322",
"0.58257854",
"0.581708",
"0.5810729",
"0.58072853",
"0.5804502",
"0.57974154",
"0.578991",
"0.57893354",
"0.5780002",
"0.5779336",
"0.57783794",
"0.5765238",
"0.57621837",
"0.57389283",
"0.57337654",
"0.5730224",
"0.5714075",
"0.5701316",
"0.5690358",
"0.5681507",
"0.5681343",
"0.5681343",
"0.5681343",
"0.5681343",
"0.56791097",
"0.5660368",
"0.5660368",
"0.5656093",
"0.5653146",
"0.56473684",
"0.5646226",
"0.564196",
"0.56400937",
"0.56399345"
] | 0.83400047 | 0 |
set_current_organisation modellevel ability to set the current organisation NOTE: USE WITH CAUTION normally this should NEVER be done from the models ... it's only useful and safe WHEN performed at the start of a background job (DelayedJobperform) | def set_current_organisation( organisation )
# able to handle organisation obj or organisation_id
#case organisation
# when Organisation then organisation_id = organisation.id
# when Integer then organisation_id = organisation
# when Array then organisation_id = organisation
# else
# raise ArgumentError, "invalid organisation object or id"
#end
#old_id = ( Thread.current[:organisation_id].nil? ? '%' : Thread.current[:organisation_id] )
if organisation.is_a? Integer
organisation = Organisation.where(id: organisation).first
end
Thread.current[:organisation_id] = organisation.present? ? organisation.root.subtree.map(&:id) : nil
Thread.current[:current_organisation_id] = organisation.present? ? organisation.subtree.map(&:id) : nil
Thread.current[:root_organisation_id] = organisation.present? ? organisation.root.id : nil
#organisation = Organisation.find(organisation_id) rescue nil
#Time.zone = organisation.time_zone || 'Singapore' rescue 'Singapore'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_organisation\n @organisation = Organisation.find(params[:organisation_id]) if params[:organisation_id]\n end",
"def set_organisation\n raise \"You must set the organisation\" if session[:organisation].blank?\n OrganisationSession.set session[:organisation]\n end",
"def set_organization\n if current_user\n current_organization = Organization.find(current_user.organization_id)\n set_current_tenant(current_organization)\n end\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def set_organisation\n @organisation = Organisation.find(params[:id])\n end",
"def update\n if !current_user.admin?\n head :forbidden\n else\n if @organisation.update(organisation_params)\n render json: @organisation.to_json, status: :ok\n else\n render json: @organisation.errors, status: :unprocessable_entity\n end\n end\n end",
"def organisation=(new_org)\n org_id = new_org.id unless new_org.nil?\n end",
"def set_organization\n if current_user.is_admin?\n @organization = Organization.where(id: params[:id]).first\n else\n @organization = current_user.organizations.where(id: params[:id]).first\n end\n \n end",
"def update\n setup_super_admin_email if params[:organisation]\n path = organisation_path(params[:id])\n check_privileges(:can_edit?, path, @organisation); return if performed?\n @organisation.update_attributes_with_superadmin(organisation_params)\n @organisation.check_geocode\n rendering('Organisation was successfully updated.', 'edit')\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n if !current_user.soadmin && current_user.organization != @organization\n redirect_to current_user.organization\n end\n end",
"def set_current_company\n if current_user.present? && !UserCompany.where(:user_id=>current_user.id).blank?\n userCompany = UserCompany.find_by_user_id(current_user.id)\n @company = Company.find(userCompany.company_id)\n end\n end",
"def autonomous_system_organization; end",
"def autonomous_system_organization; end",
"def autonomous_system_organization; end",
"def set_organization\n # @org = Organization.find(params[:id])\n end",
"def set_project_level\n @project_level = ProjectLevel.find(params[:id])\n end",
"def set_project_control\n @project_control = ProjectControl.find(params[:id]) if current_user.has_role?(:vendor, ProjectControl.find(params[:id])) || current_user.has_role?(:sponsor, ProjectControl.find(params[:id])) ||\n current_user.has_role?(:admin, ProjectControl.find(params[:id]))\n end",
"def set_organization\n @signed_in = admin_signed_in?\n @organization = Organization.find(params[:id])\n end",
"def current_organisation()\n begin\n organisation = (\n Thread.current[:organisation_id].blank? ?\n nil :\n Organisation.find( Thread.current[:organisation_id] )\n )\n\n return organisation\n\n rescue ActiveRecord::RecordNotFound\n return nil\n end \n end",
"def set_organization\n @organization = current_user.organizations.where(id: params[:id]).first\n end",
"def assign_default_project \n if current_user \n current_project = self\n current_user.save\n end\n end",
"def move_to(org)\n self.organisation = org\n self.save\n end",
"def set_org\n @org = Organization.find(params[:id])\n end",
"def current_company=(company_obj)\n self.current_company_id = company_obj.id\n self.save\n end",
"def set_role\n @role = Role.find_by_actor_id_and_project_id(current_actor.id, @project.id)\n if @role\n @role_level = (RoleLevel.find(@role.role_level_id)).name\n else\n @role_level = ''\n end\n end",
"def set_org_role\n @org_role = OrgRole.find(params[:id])\n end",
"def after_update_org\n\n controller = PublicActivity.get_controller\n\n # Return if seeding or nothing changes\n return if !controller || self.changed.blank?\n\n current_user = PublicActivity.get_controller.current_user\n\n activity = self.create_activity :update, owner: current_user,trackable: self, params: {:detail => I18n.t('logs.update_org', org_name: self.name)}\n activity.organization_id = current_user.organization_id\n activity.save\n end",
"def set_current_user\n @current_user = current_student || current_admin\n end",
"def set_role\n self.role = 'developer'\n end",
"def set_company!\n if session[:current_company_id].nil?\n redirect_to platform_index_path\n end\n end",
"def authenticate_user!(options={})\n super(options)\n @organisation ||= current_user.organisation\n Organisation.current_id = @organisation.present? ? @organisation.subtree.map(&:id) : nil\n end",
"def current_organisation_id()\n return Thread.current[:organisation_id]\n end",
"def current_company\n @current_company = current_user.company\n end",
"def current_organization\n fog_model_interface.current_organization\n end",
"def set_organization_id\n self.organization_id = self.user.organization_id\n end",
"def set_organization_theme\n @organization_theme = if current_manager\n current_manager.organization.organization_theme\n else\n OrganizationTheme.find(params[:id])\n end\n end",
"def update_role\n organisation_change_notice = nil\n @role = Role.find(params[:id])\n \n\tprev_organisation = @role.organisation\n \n\t# if the editing user does have permission to publish CRM, set the role status to 'Pending'\n\t@role.status_id = Status::PENDING.status_id if !PrivilegesHelper.has_permission?(@login, 'CAN_PUBLISH_CRM')\n\t\n\tis_contributor = @role.is_contributor\n\tis_contributor = params[:role][:is_contributor] if (@role.contributor.blank? && !params[:role][:is_contributor].blank?) || (! @role.contributor.blank? && @role.contributor_info_empty?)\n\t\n\t@role.send('is_contributor=', is_contributor)\n\tparams[:role][:is_contributor] = is_contributor\n\t\n\tif !params[:role][:role_type_id].blank? && @role.is_a_contributor? && !RoleType.contributor_role_types.include?(RoleType.find(params[:role][:role_type_id]))\n \n\t flash[:error] = \"An error has occured. You cannot change the role type to a non-contributor type if 'Contributor' field is checked.\"\n\t \n\t redirect_to :action => 'edit', :id => @role\n\t\n\telse\n\t\t\t\n\t if @role.update_attributes(params[:role])\n\n\t if ! @role.person_id.blank? && !params[:role][:organisation_id].blank?\n\t\t # create default_contactinfos\n\t\t # for every person's contactinfo and appropriate\n\t\t # organisation contactinfo\n\t\t @role.default_contactinfos_update\n\t end \n\t \t \n organisation_change_notice=\"\"\n # role has been assigned an organisation\n if ! @role.person_id.blank? && !params[:role][:organisation_id].blank?\n\t \n\t # destroy marketing categorisation of the person from the db\n\t # as person gets marketing categorisation of the organisation\n\t @role.role_categorizations.each do |rc|\n\t \t rc.destroy\n\t end\n\t \n organisation_change_notice = \"<br/> The organisation has been changed. Please check and update the contact information and make sure that it is consistent.\"\n end\n \n # delete default_contactinfo if organisation was previously\n # assigned to a role together with person but has been deleted\n if @role.organisation_id.blank? && !@role.person_id.blank? && !prev_organisation.blank?\n # do we need to default it to 'Person' or 'preferred' contact infos????\n \t # if yes, just call @role.default_contactinfos_update instead of the line below\n\t\t @role.delete_default_contactinfos(prev_organisation.organisation_id)\n end\n \n # update all role role_contactinfos for\n # solr indexing\n RoleContactinfo.index_objects(@role.role_contactinfos)\n \n # update all communications for\n # solr indexing\n Communication.index_objects(@role.communications)\n \n # update appropriate person if any\n # for solr idexing\n if ! @role.person.blank?\n @role.person.save\n end\n\n # destroy contributor record if 'is_contributor' of the role set to false\n @role.contributor.destroy_self if ! @role.contributor.blank? && ! @role.is_a_contributor?\n\n flash[:notice] = 'Role was successfully updated.' + organisation_change_notice\n redirect_to :action => 'edit', :id => @role\n else\n @person = @role.person\n @organisation = @role.organisation unless @role.organisation.blank?\n render :action => 'edit', :id => @role\n end\n \n\tend\n \n end",
"def set_project\n @project = current_user.whole_projects.find(params[:project_id])\n end",
"def set_organization\n @organization = Organization.custom_find(params[:id])\n end",
"def override_enable_job_applications_for_local_authority!\n return if params[:current_organisation].nil?\n return unless params[:current_organisation].local_authority? && enable_job_applications.nil?\n\n self.enable_job_applications = false\n end",
"def set_office\n @project_state = ProjectState.find(params[:id])\n end",
"def set_group_organization\n @group_organization = GroupOrganization.find(params[:id])\n end",
"def set_current_tenant_if_necessary\n if !self.user.current_tenant\n self.user.current_tenant = self.tenant\n self.user.save\n end\n end",
"def set_authorize_org\n @org = Org.find(params[:id])\n authorize(@org)\n end",
"def set_location(civicrm_model)\n # Split in case suffix is in postal code\n zip = self.postal_code.split('-')[0]\n alf_zip = ALF::Zipcode.where('ZIP', zip).first\n alf_country = ALF::Country.where('country_id', self.country)\n\n # Country\n if alf_country.present?\n country = CIVICRM::Country.where(iso_code: alf_country.country_code).take\n if country.present?\n civicrm_model.country_id = country.id\n end\n end\n\n if alf_zip.present?\n # City\n civicrm_model.city = alf_zip.City\n\n # State\n state = CIVICRM::StateProvice.where(abbreviation: alf_zip.State).take\n if state.present?\n civicrm_model.state_province_id = state.id\n end\n\n # County\n county = CIVICRM::County.where('lower(name) = ?', alf_zip.County.downcase).take\n if county.present?\n civicrm_model.county_id = county.id\n end\n end\n\n # Set zip codes\n civicrm_model.postal_code = self.postal_code.split('-')[0]\n civicrm_model.postal_code_suffix = self.postal_code.split('-')[1]\n\n civicrm_model\n end",
"def current_org\n current_user&.org\n end",
"def set_orging\n @orging = Orging.find(params[:id])\n end",
"def set_organization\n @organization = Spree::Organization.find(params[:id])\n end",
"def create\n # model filters for logged in users, but we check here if that user is an superadmin\n # TODO refactor that to model responsibility?\n org_params = OrganisationParams.build params\n\n unless current_user.try(:superadmin?)\n flash[:notice] = PERMISSION_DENIED\n redirect_to organisations_path and return false\n end\n @organisation = Organisation.new(org_params)\n if @organisation.save\n redirect_to @organisation, notice: 'Organisation was successfully created.'\n else\n render :new\n end\n end",
"def set_project\n @project = Project.find(params[:id])\n\t if !@current_user.is_admin? && @project.user != @current_user\n\t\t redirect_to not_found_path\n\t end\n\n end",
"def organization; end",
"def organization; end",
"def organization; end",
"def amplify\n unless self.edited_by_user\n update_record_via_era_commons_username_map\n if [\"staging\", \"production\"].include?(Rails.env)\n update_record_via_bcsec\n end\n set_department_and_school\n end\n self\n end",
"def set_project\n\n end",
"def set_project\n\n end",
"def set_project\n @project = Project.includes([:elements, clusters: :elements]).find(params[:project_id])\n if current_user.nil? or @project.user_id != current_user.id\n render status: :unprocessable_entity\n end\n end",
"def check_org\n unless current_user.organisation == @division.organisation\n redirect_to current_user, :alert => \"Sorry, you are not authorised for that\"\n end\n end",
"def set_organisation_session(organisation)\n session[:organisation] = {:id => organisation.id, :name => organisation.name }\n set_organisation\n end",
"def set_ModAgency(value)\n set_input(\"ModAgency\", value)\n end",
"def set_sourcing_org\n @sourcing_org = SourcingOrg.find(params[:id])\n end",
"def set_organization\n\t @organization = Organization.find(params[:id])\n\tend",
"def update\n params[:organisation][:superadmin_email_to_add] = params[:organisation_superadmin_email_to_add] if params[:organisation]\n update_params = OrganisationParams.build params\n return false unless user_can_edit? @organisation\n if @organisation.update_attributes_with_superadmin(update_params)\n redirect_to @organisation, notice: 'Organisation was successfully updated.'\n else\n render action: \"edit\"\n end\n end",
"def set_org\n @org = Org.find_by_permalink(params[:org_id])\n raise ActiveRecord::RecordNotFound unless @org\n end",
"def set_org\n @org = Org.find_by_permalink(params[:org_id])\n raise ActiveRecord::RecordNotFound unless @org\n end",
"def set_org\n @org = Org.find_by_permalink(params[:org_id])\n raise ActiveRecord::RecordNotFound unless @org\n end",
"def set_org\n @org = Org.find_by_permalink(params[:org_id])\n raise ActiveRecord::RecordNotFound unless @org\n end",
"def set_current_user\n Authorization.current_user = current_user\n end",
"def set_current_user\n Authorization.current_user = current_user\n end",
"def user_has_role_in_company?\n \tif current_org_person.typ_position.blank?\n \t\tstore_location\n \tredirect_to edit_org_person_path(current_org_person.id), flash: {warning: \"You need to be approved by the company you have been assigned to first to access the requested page.\"}\n \tend \n end",
"def set_college_level\n @college_level = CollegeLevel.all\n end",
"def set_global_current_user\n Current.user = current_user\n end",
"def set_office_target_collaboration\n @office_target_collaboration = OfficeTargetCollaboration.find(params[:id])\n end",
"def set_organization\n @organization = Organization.includes(:notes=>[:user]).friendly.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_organization\n @organization = Organization.find(params[:id])\n end",
"def set_user_project\n @project = current_user.projects.friendly.find_by(id: params[:id]) || Project.friendly.find(params[:id])\n end",
"def requestor; organization; end",
"def set_office_location\n @office_location = @company.office_locations.find(params[:id])\n end",
"def set_current_tenant!\n # Raise an exception if the current tenant is blank\n raise \"No tenant found for '#{url_identifier}' url identifier\" if current_tenant.blank?\n Roomer.current_tenant = current_tenant\n end",
"def set_organization\n @organization = Organization.friendly.find(params[:id])\n end",
"def set_organization\n @organization = Organization.friendly.find(params[:id])\n end",
"def update\n respond_to do |format|\n if update_organisation\n format.html { redirect_to @organisation, notice: 'Organisation was successfully updated.' }\n format.json { render :show, status: :ok, location: @organisation }\n else\n format.html { render :edit }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_project\n @group = Group.find(params[:group_id]) if params[:group_id]\n @project = Project.find(params[:id])\n @group = @project.group if @group.nil?\n @office = Office.find(params[:office_id]) if params[:office_id]\n\n @groups = Group.all\n @offices = Office.all\n @projects = Project.all\n\n @people = User.on_project(@project).in_office(@office).of_group(@group)\n end",
"def set_org\n @org_id = request.headers[\"X-WWW-ORG-ID\"]\n end",
"def update\n @organization = Organization.find(params[:id])\n\n if current_user.has_role?('admin')\n @organization.is_pending = false\n end\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to(@organization) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_laboratory\n authorize current_admin, policy_class: LaboratoryPolicy\n @laboratory = Laboratory.find(params[:id])\n end",
"def set_user\n @clinician = current_user\n end",
"def set_user_organization\n @user_organization = UserOrganization.find(params[:id])\n end",
"def set_user_organization\n @user_organization = UserOrganization.find(params[:id])\n end",
"def set_user_competency_level\n @user_competency_level = UserCompetencyLevel.find(params[:id])\n end",
"def require_org\n # If no working org is set, just use the first one in the visible list.\n # For non-admins this will be their one and only org.\n if working_org.nil?\n self.working_org = @visible_orgs[0]\n end\n true\n end",
"def set_main_company\n @main_company = MainCompany.find(params[:id])\n end",
"def set_project\n @project = current_user.projects.find(params[:project_id])\n end",
"def current_id\n current_org&.id\n end",
"def set_season\n @season = Season.find(params[:id])\n unless @logged_in.update_site?\n @season.readonly!\n end\n end"
] | [
"0.6453708",
"0.64062",
"0.62416416",
"0.6211622",
"0.6211622",
"0.6211622",
"0.6205148",
"0.60366184",
"0.58874464",
"0.57556295",
"0.57506716",
"0.5725723",
"0.5718173",
"0.56490356",
"0.56490356",
"0.56490356",
"0.5634117",
"0.56214094",
"0.5598364",
"0.5596463",
"0.5570601",
"0.555981",
"0.55546784",
"0.555164",
"0.55192035",
"0.5510688",
"0.5507012",
"0.54735184",
"0.543112",
"0.5423565",
"0.54196393",
"0.5403995",
"0.5374056",
"0.53707993",
"0.5368451",
"0.53683",
"0.53498507",
"0.5335381",
"0.5330416",
"0.531393",
"0.5308045",
"0.5301508",
"0.5265785",
"0.5257677",
"0.52550507",
"0.5254957",
"0.52130145",
"0.52129483",
"0.5197979",
"0.51963913",
"0.51939034",
"0.51924133",
"0.5191742",
"0.5191742",
"0.5191742",
"0.5189378",
"0.5188961",
"0.5188961",
"0.5179469",
"0.51665455",
"0.516429",
"0.5163587",
"0.5129645",
"0.5123441",
"0.51232684",
"0.51105183",
"0.51105183",
"0.51105183",
"0.51105183",
"0.5108648",
"0.5108648",
"0.5102141",
"0.51020646",
"0.5101073",
"0.5100713",
"0.5097041",
"0.50949407",
"0.50949407",
"0.50949407",
"0.50949407",
"0.5081661",
"0.5080787",
"0.50796074",
"0.507795",
"0.5071489",
"0.5071489",
"0.5070551",
"0.50669193",
"0.5054953",
"0.50541544",
"0.50533026",
"0.5048381",
"0.50470954",
"0.50470954",
"0.5042367",
"0.5040955",
"0.503661",
"0.5026125",
"0.5025717",
"0.5020873"
] | 0.72130495 | 0 |
where_restrict_organisation gens organisation restrictive where clause for each klass NOTE: subordinate join tables will not get the default scope by Rails theoretically, the default scope on the master table alone should be sufficient in restricting answers to the current_organisation alone .. HOWEVER, it doesn't feel right. adding an additional .where( where_restrict_organisations(klass1, klass2,...)) for each of the subordinate models in the join seems like a nice safety issue. | def where_restrict_organisation(*args)
args.map{|klass| "#{klass.table_name}.organisation_id = #{Thread.current[:organisation_id]}"}.join(" AND ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_filter_by_associations_window_function_limit_strategy(ds)\n ds.where(filter_by_associations_limit_key=>apply_window_function_eager_limit_strategy(associated_eager_dataset.select(*filter_by_associations_limit_alias_key)).select(*filter_by_associations_limit_aliases))\n end",
"def apply_filter_by_associations_distinct_on_limit_strategy(ds)\n k = filter_by_associations_limit_key \n ds.where(k=>apply_distinct_on_eager_limit_strategy(associated_eager_dataset.select(*k)))\n end",
"def apply_filter_by_associations_limit_strategy(ds)\n case filter_by_associations_limit_strategy\n when :distinct_on\n apply_filter_by_associations_distinct_on_limit_strategy(ds)\n when :window_function\n apply_filter_by_associations_window_function_limit_strategy(ds)\n else\n ds\n end\n end",
"def filter_by_associations_conditions_dataset\n cached_fetch(:filter_by_associations_conditions_dataset) do\n ds = associated_eager_dataset.unordered\n ds = filter_by_associations_add_conditions_dataset_filter(ds)\n ds = apply_filter_by_associations_limit_strategy(ds)\n ds\n end\n end",
"def apply_filter_by_associations_limit_strategy(ds)\n case filter_by_associations_limit_strategy\n when :correlated_subquery\n apply_correlated_subquery_limit_strategy(ds)\n else\n super\n end\n end",
"def conditions\n return nil unless tree.columns.scope?\n\n assoc_scope = method(:association_scope)\n join_scope = method(:join_association_scope)\n\n Proc.new do |join_association|\n conditions = if join_association.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation)\n join_scope[join_association]\n elsif self.is_a?(ActiveRecord::Base)\n assoc_scope[self]\n else\n where(nil)\n end.where_values.reduce(:and)\n\n conditions.try(:to_sql)\n end\n end",
"def add_conditions(scope)\n unless @reflection.through_reflection.klass.descends_from_active_record?\n scope = scope.where(@reflection.through_reflection.klass.send(:type_condition))\n end\n\n scope = scope.where(@reflection.source_reflection.options[:conditions])\n scope.where(through_conditions)\n end",
"def filter_by_associations_add_conditions_dataset_filter(ds)\n k = filter_by_associations_conditions_associated_keys\n ds.select(*k).where(Sequel.negate(k.zip([])))\n end",
"def joins_on\n # join(relations).on(conditions)\n condition = deals.join(clients)\n .on(deals[:advertiser_id].eq(clients[:id]))\n workflow_criterions.each do |wc|\n case wc.field\n when 'currencies'\n condition = condition\n .join(currencies)\n .on(deals[:curr_cd].eq(currencies[:curr_cd]))\n when 'deal_type'\n condition = condition\n .join(values)\n .on(deals[:id].eq(values[:subject_id]))\n .join(options)\n .on(values[:option_id].eq(options[:id]))\n when 'deal_initiative'\n condition = condition\n .join(initiatives)\n .on(deals[:initiative_id].eq(initiatives[:id]))\n when 'teams'\n condition = condition\n .join(deal_members)\n .on(deal_members[:deal_id].eq(deals[:id]))\n .join(users)\n .on(users[:id].eq(deal_members[:user_id]))\n .join(teams)\n .on(teams[:id].eq(users[:team_id]).or(teams[:leader_id].eq(users[:id])))\n when 'client_segments'\n condition = condition\n .join(client_segments)\n .on(clients[:client_segment_id].eq(client_segments[:id]))\n when 'client_regions'\n condition = condition\n .join(client_regions)\n .on(clients[:client_region_id].eq(client_regions[:id]))\n when 'client_categories'\n condition = condition\n .join(client_categories)\n .on(clients[:client_category_id].eq(client_categories[:id]))\n when 'client_subcategories'\n condition = condition\n .join(client_subcategories)\n .on(clients[:client_subcategory_id].eq(client_subcategories[:id]))\n when 'share'\n condition = condition\n .join(deal_members)\n .on(deal_members[:deal_id].eq(deals[:id]))\n end\n case wc.base_object\n when 'Account Custom Fields'\n unless condition.to_sql.include?(\"INNER JOIN \\\"account_cfs\\\"\")\n condition = condition\n .join(account_cfs)\n .on(clients[:id].eq(account_cfs[:client_id]))\n end\n when 'Deal Custom Fields'\n unless condition.to_sql.include?(\"INNER JOIN \\\"deal_custom_fields\\\"\")\n condition = condition\n .join(deal_custom_fields)\n .on(deals[:id].eq(deal_custom_fields[:deal_id]))\n end\n when 'Deal Members'\n condition = condition\n .join(deal_members)\n .on(deal_members[:deal_id].eq(deals[:id]))\n .join(values)\n .on(values[:subject_id].eq(deal_members[:id]))\n .join(fields)\n .on(values[:field_id].eq(fields[:id]))\n .join(member_roles)\n .on(fields[:id].eq(member_roles[:field_id])) if wc.field.eql?('role')\n end\n end\n condition\n end",
"def where_permits( priv, keyword_args = {} )\n priv, association = disassemble_priv( priv )\n if association.nil?\n return <<-END_SQL\n (#{table_name}.id in\n #{self.ids_permitting_internal( priv, keyword_args )})\n END_SQL\n else\n klass = self.class_for_associate(association)\n fk = self.reflect_on_association(association).foreign_key.to_s\n return <<-END_SQL\n (#{table_name}.#{fk} in\n #{klass.ids_permitting_internal( priv, keyword_args )})\n END_SQL\n end\n end",
"def condition_parts(with_orgs=true)\n ### Subclass MUST respond with at least 1 non-nil AR::Relation object ###\n\n if with_orgs\n conditions = private_methods.grep(/_conditions$/)\n else\n conditions = (private_methods.grep(/_conditions$/) - [:organization_conditions])\n end\n conditions.map { |m| send(m) }.compact\n end",
"def optimize\n left_restriction.send(relation_method, right_restriction).restrict(partition.remainder)\n end",
"def default_where(klass)\n sql = ''\n arel_nodes = klass.scoped.with_default_scope.where_values.grep(Arel::Nodes::Equality)\n string_nodes = klass.scoped.with_default_scope.where_values.grep(String)\n\n unless arel_nodes.empty?\n sql += arel_nodes.inject(arel_nodes[0]) do |arel, equality|\n arel = arel.and(equality); arel\n end.to_sql\n end\n\n unless string_nodes.empty?\n sql += ' AND ' + string_nodes.map { |node| \"(#{node})\"}.join(' AND ')\n end\n\n sql\n end",
"def apply_agency_filter(organization_id,dayhome_query)\n \n \n dayhome_query = dayhome_query.joins(:organization)\n dayhome_query = dayhome_query.where(\"organizations.id = #{organization_id}\")\n dayhome_query\n end",
"def viewable_by(user, organization)\n group_ids = user.organization_group_ids(organization)\n joined = all.left_joins(roles: %i[users_roles groups_roles])\n joined.where(UsersRole.arel_table[:user_id].eq(user.id)).or(\n joined.where(GroupsRole.arel_table[:group_id].in(group_ids)),\n ).distinct # because of left joins\n end",
"def gemd_in_common_with(klass, user)\n Recommendable.query(klass, gemd_ids_in_common_with(klass, user))\n end",
"def query_scope\n record_class.public_send(include_strategy, included_associations)\n end",
"def options_for_association_conditions(association)\n case association.name\n when :frms\n # join with public if session is missing the usr_id\n ['frms.usr_id = ?', (session[:usr_id] || Usr.find_by_login('public').id)]\n when :prsna\n # join with public if session is missing the usr_id\n ['prsnas.usr_id = ?', (session[:usr_id] || Usr.find_by_login('public').id)]\n else\n super\n end\n end",
"def resolve_options(klass, options)\n # Factor in scope.\n if scope = klass.get_scope\n scope = scope.dup\n scond = scope.delete(:condition)\n scope.update(options)\n options = scope\n end\n\n if sql = options[:sql]\n sql = \"SELECT * FROM #{klass.table} \" + sql unless sql =~ /SELECT/i\n return sql\n end\n\n tables = [klass::table]\n\n if included = options[:include]\n join_conditions = []\n\n for name in [included].flatten\n if rel = klass.relation(name.to_s)\n target_table = rel[:target_class]::table\n tables << target_table\n\n if rel.is_a?(JoinsMany)\n tables << rel[:join_table]\n owner_key, target_key = nil\n klass.ogmanager.with_store do |s|\n owner_key, target_key = s.join_table_keys(klass, rel[:target_class])\n end\n join_conditions << \"#{rel.join_table}.#{owner_key}=#{klass.table}.#{rel.owner_class.primary_key} AND #{rel.join_table}.#{target_key}=#{rel.target_class.table}.#{rel.target_class.primary_key}\"\n else\n join_conditions << \"#{klass::table}.#{rel.foreign_key}=#{target_table}.#{rel.target_class.primary_key}\"\n end\n else\n raise \"Unknown relation name\"\n end\n end\n\n fields = options[:select] || tables.collect { |t| \"#{t}.*\" }.join(',')\n\n update_condition options, join_conditions.join(\" AND \")\n elsif fields = options[:select]\n fields = fields.map {|f| f.to_s}.join(\", \")\n else\n fields = \"*\"\n end\n\n if join_table = options[:join_table]\n tables << join_table\n update_condition options, options[:join_condition]\n end\n\n # Factor in scope in the conditions.\n update_condition(options, scond) if scond\n\n # where is just an alias, put to :condition\n update_condition(options, options.delete(:where))\n\n # add extra conditions\n update_condition(options, options.delete(:extra_condition))\n\n # rp: type is not set in all instances such as Class.first\n # so this fix goes here for now.\n if ogtype = options[:type] || (klass.schema_inheritance_child? ? \"#{klass}\" : nil)\n update_condition options, \"ogtype='#{ogtype}'\"\n end\n\n sql = \"SELECT #{fields} FROM #{tables.join(',')}\"\n\n if condition = options[:condition]\n # If an array is passed as a condition, use prepared\n # statement style escaping.\n if condition.is_a?(Array)\n condition = prepare_statement(condition)\n end\n\n sql << \" WHERE #{condition}\"\n end\n\n if group = options[:group] || options[:group_by]\n sql << \" GROUP BY #{group}\"\n end\n\n if order = options[:order] || options[:order_by]\n sql << \" ORDER BY #{order}\"\n end\n\n resolve_limit_options(options, sql)\n\n if extra = options[:extra] || options[:extra_sql]\n sql << \" #{extra}\"\n end\n\n return sql\n end",
"def find_right_models(klass, original_klass, join_model, join_alias)\n #debugger if 'titular' == klass\n #unless instance_variable_get(\"@#{klass}\".to_sym).blank?\n # instance_variable_get(\"@#{klass}\".to_sym)\n #else\n right_ids = find_right_ids(klass, join_model, join_alias)\n original_klass_model = original_klass.classify.constantize\n unless right_ids.empty?\n instance_variable_set \"@#{klass}\".to_sym, original_klass_model.find(right_ids)\n else\n []\n end\n #end\n end",
"def add_auth_config_conditions(query)\n arel_conditions = auth_configs.reduce(nil) do |conditions, ac|\n if conditions\n conditions.or(\n ac.assignment_to .arel_table.primary_key.not_eq(nil)\n )\n else\n ac.assignment_to.arel_table.primary_key.not_eq(nil)\n end\n end\n\n query\n .where(arel_conditions)\n .where(Permission.arel_table[:applies_to].in(applies_to))\n end",
"def claims_for_organisation(organisation_id)\n # NOTE: A transaction may not have a provider !!!\n query = Query.find_by_sql(\n \"select c.id claim_id, c.invoice_date, c.invoice_no,\n c.host_provider_id, hp.name host_provider_name,\n c.amount, c.comment, p.family_name, p.given_names, p.nhi_no,g.id programme_id, g.description programme_description, f.description fee_description\\n\"+ \n \"from claims c\\n\"+\n \" left join providers hp on hp.id = c.host_provider_id\\n\"+\n \" join patients p on p.id = c.patient_id\\n\"+\n \" join programmes g on g.id = c.programme_id\\n\"+\n \" join fee_schedules f on f.id = c.fee_schedule_id\\n\"+\n \"where c.organisation_id = #{organisation_id} and c.payment_run_id = #{self.id}\\n\"+\n \"order by c.invoice_date, c.id\" );\n query\n end",
"def filter_by_associations_conditions_expression(obj)\n ds = filter_by_associations_conditions_dataset.where(filter_by_associations_conditions_subquery_conditions(obj))\n {filter_by_associations_conditions_key=>ds}\n end",
"def scoped_records_arel(s)\n not_null_nodes = required_column_names.map do |c|\n s[c].not_eq(nil)\n end\n not_null_conds = not_null_nodes.shift\n not_null_nodes.each { |n| not_null_conds = not_null_conds.and(n) }\n result = s.project('*').where(not_null_conds)\n scope_nodes = sanitized_sandbox_scope.map do |scope_column, scope_def|\n tmp = []\n if scope_def['inclusion']\n inclusion_nodes = scope_def['inclusion'].map { |value| s[scope_column].eq(value) }\n tmp << inclusion_nodes.inject(&:or)\n end\n if scope_def['exclusion']\n exclusion_nodes = scope_def['exclusion'].map { |value| s[scope_column].not_eq(value) }\n tmp << exclusion_nodes.inject(&:or)\n end\n if scope_def['blank']\n tmp << s[scope_column].eq(nil)\n end\n tmp\n end.flatten\n scope_conds = scope_nodes.inject(&:and)\n result = result.where(scope_conds) if scope_conds\n result\n end",
"def by_organisation\n query = Query.find_by_sql(\n \"select o.id organisation_id, o.name organisation_name,o.residential_suburb organisation_suburb, o.not_gst_registered, sum(c.amount) sumamount\\n\"+\n \"from claims c\\n\"+\n \" join organisations o on o.id = c.organisation_id\\n\"+\n \"where c.payment_run_id = #{self.id}\\n\"+\n \"group by o.id, o.name,o.residential_suburb,o.not_gst_registered\\n\"+\n \"order by 2\")\n query\n end",
"def claims_paid_to_others_for_organisation_programme(cost_organisation_id,programme_id)\n query = Query.find_by_sql(\n \"select c.id claim_id, c.invoice_date, c.invoice_no, \\n\"+\n \" c.amount, c.comment, \\n\"+\n \" p.family_name, p.given_names, p.nhi_no,\\n\"+\n \" f.description fee_description,\\n\"+\n \" o.name organisation_name\\n\"+\n \"from claims c\\n\"+\n \" join patients p on p.id = c.patient_id\\n\"+\n \" join fee_schedules f on f.id = c.fee_schedule_id\\n\"+\n \" join organisations o on o.id = c.organisation_id\\n\"+\n \"where c.cost_organisation_id = #{cost_organisation_id} and c.payment_run_id = #{self.id} and c.programme_id = #{programme_id}\\n\"+\n \" and c.cost_organisation_id <> c.organisation_id and c.amount <> 0\\n\"+\n \"order by c.invoice_date, c.id\");\n query\n end",
"def associated_projects\n Project.includes(:assignments, :comments).where('id in (?) or id in (?) or id in (?)', project_ids, assigned_project_ids, commented_project_ids)\n end",
"def filter_by_associations_limit_strategy\n v = fetch(:filter_limit_strategy, self[:eager_limit_strategy])\n if v || self[:limit] || !returns_array?\n case v ||= self[:model].default_eager_limit_strategy\n when true, :union, :ruby\n # Can't use a union or ruby-based strategy for filtering by associations, switch to default eager graph limit\n # strategy.\n true_eager_graph_limit_strategy\n when Symbol\n v\n end\n end\n end",
"def where_clause\n parent_constraints = parent&.constraints || []\n (constraints - parent_constraints).to_where_clause\n end",
"def disgemd_in_common_with(klass, user)\n Recommendable.query(klass, disgemd_ids_in_common_with(klass, user))\n end",
"def scope\n assoc_scope = method(:association_scope)\n join_scope = method(:join_association_scope)\n\n ->(join_or_parent) {\n if join_or_parent.is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation)\n join_scope[join_or_parent]\n elsif join_or_parent.is_a?(ActiveRecord::Base)\n assoc_scope[join_or_parent]\n else\n where(nil)\n end.extending(Relation::Iterable)\n }\n end",
"def reduce_scope_by_authorization(scope)\n return scope unless must_match_user_roles?\n scope.scoped_by_user_roles allowed_roles, match_roles_on\n end",
"def projects_matching_filter\n # rubocop: disable CodeReuse/Finder\n projects_nested_in_group = Project.where(namespace_id: hierarchy_for_parent.base_and_descendants.select(:id))\n params_with_search = params.merge(search: params[:filter])\n\n ProjectsFinder.new(params: params_with_search,\n current_user: current_user,\n project_ids_relation: projects_nested_in_group).execute\n # rubocop: enable CodeReuse/Finder\n end",
"def subquery(definition, other_definition, conditions)\n validate_definition_instance(definition)\n validate_definition_instance(other_definition)\n [conditions].flatten.each { |c| validate_node_or_attribute(c) }\n\n current_model = definition.model\n #current_table = definition.table\n current_joins = definition.joins\n\n other_table = other_definition.table\n other_model = other_definition.model\n #other_joins = other_definition.joins\n\n # build an exist subquery to apply conditions that\n # refer to another table\n\n subquery = other_definition.table\n\n # add conditions to subquery\n [conditions].flatten.each do |c|\n subquery = subquery.where(c)\n end\n\n # add joins that provide other table access to current table\n\n\n which_joins = current_joins\n join_paths_index = nil\n join_path_current_index = nil\n join_path_other_index = nil\n which_joins.each_with_index do |item, index|\n join_path_current_index = item.find_index { |j| j[:join] == current_model }\n join_path_other_index = item.find_index { |j| j[:join] == other_model }\n if !join_path_current_index.nil? && !join_path_other_index.nil?\n join_paths_index = index\n break\n end\n end\n\n first_index = [join_path_current_index, join_path_other_index].min\n last_index = [join_path_current_index, join_path_other_index].max\n relevant_joins = which_joins[join_paths_index][first_index..last_index]\n\n\n relevant_joins.each do |j|\n join_table = j[:join]\n join_condition = j[:on]\n\n # assume this is an arel_table if it doesn't respond to .arel_table\n arel_table = join_table.respond_to?(:arel_table) ? join_table.arel_table : join_table\n\n if arel_table.name == other_table.name && !join_condition.nil?\n # add join as condition if this is the main table in the subquery\n subquery = subquery.where(join_condition)\n elsif arel_table.name != other_table.name && !join_condition.nil?\n # add full join if this is not the main table in the subquery\n subquery = subquery.join(arel_table).on(join_condition)\n end\n\n end\n\n subquery.project(1).exists\n end",
"def join_people_by_relationship_type\n\n sql = <<EOF\nselect supers.id, supers.name, subs.id, subs.name\nfrom person_associations pa\ninner join people as supers\n on supers.id = pa.source_id\ninner join people as subs\n on subs.id = pa.sink_id\nand association_type = 'direct_reporting'\norder by supers.id\nEOF\n\n r = ActiveRecord::Base.connection.execute(sql)\n end",
"def criteria(base, target)\n criterion = klass.scoped\n criterion.embedded = true\n criterion.documents = target\n criterion.parent_document = base\n criterion.association = self\n apply_ordering(criterion)\n end",
"def join_limit_to_assigned(assoc, current_user)\n assoc_name = assoc.resource_name.to_sym\n res = case assoc.access\n when 'limited'\n joins(assoc_name)\n when 'limited_if_none'\n left_joins(assoc_name)\n else\n all\n end\n\n res = res.only_created_by_current_user(current_user) if assoc_name == :master_created_by_user\n\n assoc = (new.send(assoc_name) if new.respond_to?(assoc_name))\n if assoc&.requires_assigned_user?\n table_name = ModelReference.record_type_to_ns_table_name(assoc_name)\n res = res.where(table_name => { AssignedToCol => current_user.id })\n end\n\n res\n end",
"def set_filtered_organizations\n scope = current_user.organizations.includes(:assignments, :group_assignments).filter_by_search(@query)\n\n scope = case @current_view_mode\n when \"Archived\" then scope.archived\n when \"Active\" then scope.not_archived\n else scope\n end\n\n @organizations = scope\n .order_by_sort_mode(@current_sort_mode)\n .order(:id)\n .page(params[:page])\n .per(12)\n end",
"def filter_by_associations_conditions_subquery_conditions(obj)\n key = qualify(associated_class.table_name, associated_class.primary_key)\n case obj\n when Array\n {key=>obj.map(&:pk)}\n when Sequel::Dataset\n {key=>obj.select(*Array(qualify(associated_class.table_name, associated_class.primary_key)))}\n else\n Array(key).zip(Array(obj.pk))\n end\n end",
"def options_for_association_conditions(association)\n if association.name == :grps\n # join with public if session is missing the usr_id\n ['grps.usr_id = ?', (session[:usr_id] || Usr.find_by_login('public').id)]\n else\n super\n end\n end",
"def filter_by_associations_add_conditions?\n self[:conditions] || self[:eager_block] || self[:limit]\n end",
"def predicate_visitor\n join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, association_joins, custom_joins)\n MetaWhere::Visitors::Predicate.new(join_dependency)\n end",
"def restrictions\n only = association.options[:only].to_a.collect(&:to_s)\n only.empty? ? table_columns : only\n end",
"def get_relation(params = {})\n # make params coming from Ext grid filters understandable by meta_where\n conditions = params[:filter] && convert_filters(params[:filter]) || {}\n\n relation = data_class.where(conditions)\n\n if params[:extra_conditions]\n extra_conditions = normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))\n relation = relation.extend_with_netzke_conditions(extra_conditions) if params[:extra_conditions]\n end\n\n if params[:query]\n # array of arrays of conditions that should be joined by OR\n query = ActiveSupport::JSON.decode(params[:query])\n meta_where = query.map do |conditions|\n normalize_and_conditions(conditions)\n end\n\n # join them by OR\n meta_where = meta_where.inject(meta_where.first){ |r,c| r | c } if meta_where.present?\n end\n\n relation = relation.where(meta_where)\n\n relation = relation.extend_with(config[:scope]) if config[:scope]\n\n relation\n end",
"def filter_by_associations_add_conditions?\n super || self[:order] || self[:eager_limit_strategy] || self[:filter_limit_strategy]\n end",
"def subject_object_scope(subject_query, object_query, target = 'Otu')\n a = subject_query\n b = object_query\n\n a_sql, b_sql = nil, nil\n\n if !a&.all(true).nil?\n a.project_id = project_id\n a_sql = a.all.to_sql\n end\n\n if !b&.all(true).nil?\n b.project_id = project_id\n b_sql = b.all.to_sql\n end\n\n\n\n return nil if a_sql.nil? and b_sql.nil?\n\n # Setup for \"WITH\" use\n t = []\n t.push 'a_objects AS (' + a_sql + ')' if a_sql\n t.push 'b_objects AS (' + b_sql + ')' if b_sql && (b_sql != a_sql)\n\n s = 'WITH ' + t.join(', ')\n\n # subject/object queries reference different params\n if a_sql && b_sql && (a_sql != b_sql)\n s << ' ' + ::BiologicalAssociation\n .joins(\"LEFT JOIN a_objects as a_objects1 on a_objects1.id = biological_associations.biological_association_subject_id AND biological_associations.biological_association_subject_type = '\" + target + \"'\")\n .joins(\"LEFT JOIN b_objects as b_objects1 on b_objects1.id = biological_associations.biological_association_object_id AND biological_associations.biological_association_object_type = '\" + target + \"'\")\n .where('a_objects1.id is not null').or('b_objects1.id is not null')\n .to_sql\n\n # subject/object queries reference same params\n elsif a_sql && b_sql\n s << ' ' + ::BiologicalAssociation\n .joins(\"LEFT JOIN a_objects as a_objects1 on a_objects1.id = biological_associations.biological_association_subject_id AND biological_associations.biological_association_subject_type = '\" + target + \"'\")\n .joins(\"LEFT JOIN a_objects as a_objects2 on a_objects2.id = biological_associations.biological_association_object_id AND biological_associations.biological_association_object_type = '\" + target + \"'\")\n .where('a_objects1.id is not null').or('a_objects2.id is not null')\n .to_sql\n\n # subject only\n elsif a_sql\n s << ' ' + ::BiologicalAssociation\n .joins(\"JOIN a_objects as a_objects1 on a_objects1.id = biological_associations.biological_association_subject_id AND biological_associations.biological_association_subject_type = '\" + target + \"'\")\n .to_sql\n\n # object_only\n else\n s << ' ' + ::BiologicalAssociation\n .joins(\"JOIN b_objects as b_objects1 on b_objects1.id = biological_associations.biological_association_object_id AND biological_associations.biological_association_object_type = '\" + target + \"'\")\n .to_sql\n end\n\n return ::BiologicalAssociation.from('(' + s + ') as biological_associations')\n end",
"def relation\n adapter = self\n join_list = nil\n scope = @model_class.where(nil).where do\n expression, join_list = adapter.send(:build_accessible_by_expression, self)\n expression\n end\n\n add_joins_to_scope(scope, join_list)\n end",
"def filter_by_associations_limit_strategy\n nil\n end",
"def as_conditions\n scope_options = @options.dup\n sorting = scope_options.delete(:sort)\n scope_options[:order_by] = sorting if sorting\n scope_options[:includes] = inclusions.map(&:name) if inclusions.any?\n { :where => @selector }.merge(scope_options)\n end",
"def related_assigned_donations\n scope = Donation.where(\"id != ?\", @donation.id).where(:donor_id => @donation.donor_id)\n if !@donation.bank_reference.blank?\n scope.where(:bank_reference => @donation.bank_reference)\n elsif !@donation.email.blank?\n scope.where(:email => @donation.email)\n else\n []\n end\n end",
"def belongable_abilities(klass, user, scope: nil)\n if scope.nil?\n user.belongable_belongings.each do |belonging|\n belongable_belonging(klass, belonging)\n end\n else\n user.belongable_belongings\n .where(scope: scope).each do |belonging|\n belongable_belonging(klass, belonging)\n end\n end\n end",
"def queries(with_orgs=true)\n condition_parts(with_orgs).reduce(:merge)\n end",
"def select_associations\n @associations.select { |assoc| @selects.map { |select_clause| select_clause.call(assoc) }.all? }\n end",
"def joins_with_conditions\n @memoized_joins ||= merge_joins(joins_without_conditions, conditions.joins)\n end",
"def dataset_to_select_tables(*tables)\n if @restricted_to_types && !@tables_restricting_type.values_at(*tables).any?\n super.filter(@qualified_type_column => @restricted_to_types)\n else\n super\n end\n end",
"def conditions_with_metawhere\n @conditions ||= interpolate_sql(association_class.send(:sanitize_sql, @reflection.options[:conditions])) if @reflection.options[:conditions]\n end",
"def restrict(relation, where)\n is_relation!(relation)\n relation.restrict(&where)\n end",
"def filter_by_milestones_projects_and_customers\n res = []\n\n if milestone_ids.any? and !milestone_ids.include?(ALL_MILESTONES)\n res << \"tasks.milestone_id IN (#{ milestone_ids.join(\", \") })\"\n end\n\n if customer_ids.any? and !customer_ids.include?(ALL_CUSTOMERS)\n res << \"projects.customer_id IN (#{ customer_ids.join(\", \") })\"\n end\n\n if project_ids.any? and !project_ids.include?(ALL_PROJECTS)\n res << \"tasks.project_id IN (#{ project_ids.join(\", \") })\"\n end\n\n if res.any?\n return \"(#{ res.join(\" OR \") }) AND \"\n else\n return \"\"\n end\n end",
"def shared_contributions\n Contribution.find(:all,\n :select => \"contributions.*\",\n :joins => \"JOIN policies p on (contributions.policy_id = p.id) JOIN permissions e on (p.id = e.policy_id)\",\n :conditions => [ \"e.contributor_id=? AND e.contributor_type = 'Network'\", id ])\n end",
"def claims_for_organisation_grouped_by_programme(organisation_id)\n query = Query.find_by_sql(\n \"select c.id claim_id, c.invoice_date, c.invoice_no,\n c.host_provider_id, hp.name host_provider_name,\n c.amount, c.comment, p.family_name, p.given_names, p.nhi_no,g.id programme_id, g.description programme_description, f.description fee_description\\n\"+ \n \"from claims c\\n\"+\n \" left join providers hp on hp.id = c.host_provider_id\\n\"+\n \" join patients p on p.id = c.patient_id\\n\"+\n \" join programmes g on g.id = c.programme_id\\n\"+\n \" join fee_schedules f on f.id = c.fee_schedule_id\\n\"+\n \"where c.organisation_id = #{organisation_id} and c.payment_run_id = #{self.id}\\n\"+\n \"order by g.id, c.invoice_date, c.id\" );\n query.in_groups_by(&:programme_id )\n end",
"def criteria(base, id_list = nil)\n query_criteria(id_list || base.send(foreign_key))\n end",
"def access_control_conditions\n \n conditions = []\n \n if connected_user\n conditions << Conditions::JoinComparison.new('$and', \n [Conditions::Comparison.new(:permission_owner, '$eq', connected_user.username),\n Conditions::Comparison.new(:permission_modifier_owner, '$in', [2,6])])\n \n if connected_user.usergroups.length > 0\n conditions << Conditions::JoinComparison.new('$and',\n [Conditions::Comparison.new(:permission_group, '$in', connected_user.usergroups.map {|item| item.group}),\n Conditions::Comparison.new(:permission_modifier_group, '$in', [2,6])]) \n end\n \n end\n \n conditions << Conditions::Comparison.new(:permission_modifier_all, '$in', [2,6]) \n\n if conditions.length > 1\n conditions = Conditions::JoinComparison.new('$or', conditions)\n else \n conditions.first\n end\n \n end",
"def show_only_managed_collections_for_non_admins(solr_parameters)\n return if current_ability.admin?\n clauses = [\n '-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(depositor: current_user_key),\n '-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: Hyrax.config.admin_set_model, creator: current_user_key)\n ]\n solr_parameters[:fq] ||= []\n solr_parameters[:fq] += [\"(#{clauses.join(' OR ')})\"]\n end",
"def get_inclusions_and_where_clauses(params, query_spec)\n result = emit_inclusion_and_filter_details(params, query_spec)\n inclusions = result.keys - [:self]\n where_clause_filters = result.values.flatten\n\n [inclusions, where_clause_filters]\n end",
"def conditions(extra_conditions = nil)\n time_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"TimeRange\" }\n status_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"Status\" }\n property_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"PropertyValue\" }\n customer_qualifiers = qualifiers.select { |q| q.qualifiable_type == \"Customer\" }\n standard_qualifiers = (qualifiers - property_qualifiers - status_qualifiers -\n customer_qualifiers - time_qualifiers)\n\n res = conditions_for_standard_qualifiers(standard_qualifiers)\n res += conditions_for_property_qualifiers(property_qualifiers)\n res << conditions_for_status_qualifiers(status_qualifiers)\n res << conditions_for_customer_qualifiers(customer_qualifiers)\n res << conditions_for_time_qualifiers(time_qualifiers)\n res << conditions_for_keywords\n res << extra_conditions if extra_conditions\n res << user.user_tasks_sql\n res << unread_conditions(user) if unread_only?\n\n res = res.select { |c| !c.blank? }\n res = res.join(\" AND \")\n\n return res\n end",
"def last_chain_scope(scope, *args)\n # 5.0 table, reflection, owner, association_klass\n # 5.1 table, reflection, owner\n # 5.2 reflection, owner\n\n reflection = args.size.eql?(2) ? args[0] : args[1]\n return super unless reflection.connected_through_array?\n\n table = args[0] if args.size > 2\n keys = args.size.eql?(4) ? reflection.join_keys(args[3]) : reflection.join_keys\n owner = args.size.eql?(2) ? args[1] : args[2]\n\n value = transform_value(owner[keys.foreign_key])\n constraint, binds = build_id_constraint(reflection, keys, value, table, true)\n\n if Torque::PostgreSQL::AR521\n scope.where!(constraint)\n else\n klass = ::ActiveRecord::Relation::WhereClause\n scope.where_clause += klass.new([constraint], binds)\n scope\n end\n end",
"def filter_by_associations_limit_strategy\n super if self[:order] || offset || self[:eager_limit_strategy] || self[:filter_limit_strategy]\n end",
"def general_user_organizations_with_protocols\n Protocol.joins(:project_roles).where(project_roles: { identity_id: @id } ).where.not(project_roles: { project_rights: 'none' }).map(&:organizations).flatten.uniq\n end",
"def managing_course_offerings\n # It seems like I should have been able to do this through the\n # course_offerings association directly somehow, but writing\n # course_offerings.joins(...) resulted in a double-join. This seems\n # to work correctly instead.\n CourseOffering.joins(:course_enrollments => :course_role).where(\n course_enrollments: { user_id: id },\n course_roles: { can_manage_course: true })\n end",
"def queryable\n crit = Threaded.current_scope(self) || Criteria.new(self)\n crit.embedded = true if (crit.klass.embedded? && !crit.klass.cyclic?)\n crit\n end",
"def apply_scopes(*)\n relation = super\n relation = relation.accessible_by(current_ability) if scope_accessible?\n relation\n end",
"def relation\n # base query relation for asset\n base_rel = TransamAsset.where(\"transam_assets.organization_id\": organization_list || [])\n\n join_tables = {}\n where_sqls = {}\n field_pairs = {}\n query_filters.each do |filter|\n query_field = filter.query_field\n # exclude organization_id as its handled above\n next unless query_field || query_field.name == 'organization_id'\n unless query_field.pairs_with.blank?\n field_pairs[query_field.name] = query_field.pairs_with\n end\n\n where_sqls_for_one_filter = []\n query_field.query_asset_classes.each do |asset_class|\n asset_table_name = asset_class.table_name\n unless join_tables.keys.include?(asset_table_name) || asset_class.transam_assets_join.blank?\n join_tables[asset_table_name] = asset_class.transam_assets_join\n end\n\n query_field_name = \"#{asset_table_name}.#{query_field.name}\"\n query_filter_type = query_field.filter_type\n\n filter_value = filter.value\n # wrap values\n if filter.op == 'like'\n filter_value = \"'%#{filter.value}%'\"\n elsif ['date', 'text'].include?(query_filter_type) and filter.op != 'in' # if coming from a list expect quotes to already be added\n filter_value = \"'#{filter.value}'\"\n end\n\n filter_op = filter.op\n if filter_op == 'in' \n if filter_value.blank?\n filter_op = 'is'\n filter_value = 'NULL'\n else\n filter_value = \"(#{filter_value})\"\n end\n end\n\n #if query_filter_type == 'text'\n #query_field_name = \"lower(#{query_field_name})\"\n #filter_value = \"lower(#{filter_value})\"\n #end\n\n where_clause_str = \"#{query_field_name} #{filter_op} #{filter_value}\"\n unless query_field.column_filter.blank? || query_field.column_filter_value.blank?\n where_clause_str = \"(#{query_field_name} #{filter_op} #{filter_value} AND #{query_field.column_filter} = '#{query_field.column_filter_value}')\"\n end\n where_sqls_for_one_filter << where_clause_str\n end\n\n where_sqls[query_field.name] = where_sqls_for_one_filter.join(\" OR \")\n end\n\n # deal with field_pairs: if both the main field and pairs_with field are filters, then they should be a OR sql relation\n # e.g., manufacturer_id in (1,2) OR other_manufacturer in ('A', 'B')\n field_pairs.each do |main_field, pairs_with|\n main_field_sql = where_sqls[main_field]\n pairs_with_sql = where_sqls[pairs_with]\n next if main_field_sql.blank? || pairs_with_sql.blank? \n where_sqls[main_field] = \"(#{main_field_sql}) OR (#{pairs_with_sql})\"\n where_sqls.delete(pairs_with) # delete pairs_with sql\n end\n\n select_sqls = []\n column_filters = {}\n query_fields.each do |field|\n unless field.column_filter.blank? || field.column_filter_value.blank?\n if column_filters[field.column_filter]\n column_filters[field.column_filter] << field.column_filter_value unless column_filters[field.column_filter].include?(field.column_filter_value)\n else\n column_filters[field.column_filter] = [field.column_filter_value]\n end\n end\n\n query_field_name = field.name\n field_association = field.query_association_class\n if field_association\n association_table_name = field_association.table_name\n association_id_field_name = field_association.id_field_name\n association_display_field_name = field_association.display_field_name\n use_field_name = field_association.use_field_name\n end\n\n field.query_asset_classes.each do |qac|\n asset_table_name = qac.table_name\n table_join = qac.transam_assets_join\n\n unless join_tables.keys.include?(asset_table_name) || table_join.blank?\n join_tables[asset_table_name] = table_join\n end\n\n unless association_table_name.blank?\n as_table_name = \"#{asset_table_name}_#{association_table_name}\"\n as_table_name += \"_#{query_field_name}\" if use_field_name\n # select value from association table\n unless join_tables.keys.include?(as_table_name)\n join_tables[as_table_name] = \"left join #{association_table_name} as #{as_table_name} on #{as_table_name}.#{association_id_field_name} = #{asset_table_name}.#{query_field_name}\"\n end\n\n unless field.column_filter.blank? || field.column_filter_value.blank?\n select_sqls << \"IF(#{field.column_filter} = '#{field.column_filter_value}',#{as_table_name}.#{association_display_field_name}, '') as #{asset_table_name}_#{query_field_name}\"\n else\n select_sqls << \"#{as_table_name}.#{association_display_field_name} as #{asset_table_name}_#{query_field_name}\"\n end\n else\n # select value directly from asset_table\n\n output_field_name = field.display_field.blank? ? \"#{asset_table_name}.#{query_field_name}\" : \"#{asset_table_name}.#{field.display_field}\"\n\n unless field.column_filter.blank? || field.column_filter_value.blank?\n select_sqls << \"IF(#{field.column_filter} = '#{field.column_filter_value}',#{output_field_name}, '') as #{asset_table_name}_#{query_field_name}\"\n else\n select_sqls << \"#{output_field_name} as #{asset_table_name}_#{query_field_name}\"\n end\n\n end\n end\n end \n\n # joins\n join_tables.each do |table_name, join_sql|\n base_rel = base_rel.joins(join_sql)\n end\n\n # wheres\n if where_sqls.any?\n base_rel = base_rel.where(where_sqls.map{ |field_name, field_sql| \"(\" + field_sql + \")\" }.join(\" AND \"))\n end\n\n # apply column filters\n if column_filters.any?\n base_rel = base_rel.where(column_filters.map{ |column_filter, column_filter_values| \"#{column_filter} in (\" + column_filter_values.map{|v| \"'#{v}'\"}.join(',') + \")\" }.join(\" OR \"))\n end\n\n # selects\n if select_sqls.any?\n base_rel = base_rel.select(\"transam_assets.id\", select_sqls.join(\", \"))\n end\n\n # return base query relation\n puts base_rel.to_sql\n base_rel\n end",
"def apply_query_methods(relation, params, only = nil)\n # Simple options\n # Add the limit option (numeric value).\n relation = relation.limit(params[:limit]) if (only.nil? || only.include?(:limit)) && params[:limit].present?\n # Add the offset option (numeric value).\n relation = relation.offset(params[:offset]) if (only.nil? || only.include?(:offset)) && params[:offset].present?\n # Add the distinct (previously uniq) option (boolean value).\n relation = relation.distinct(params[:distinct]) if (only.nil? || only.include?(:distinct)) && params[:distinct].present?\n\n # Conditions\n # Build and apply the where conditions.\n relation = build_and_apply_conditions(relation, :where, params[:where]) if (only.nil? || only.include?(:where)) && params[:where].present?\n # Build and apply the having conditions.\n if (only.nil? || only.include?(:having)) && params[:having].present?\n relation = build_and_apply_conditions(relation, :having, params[:having])\n # relation the database columns used in the having clause to the group clause or else an exception will occur.\n having_columns = params[:having].select { |column, value| value.present? }.keys\n relation = relation.group('id') if having_columns.present?\n end\n\n # Associations\n # Add the eager_load option (string value).\n relation = relation.eager_load(*params[:eager_load]) if (only.nil? || only.include?(:eager_load)) && params[:eager_load].present? # We only test the list argument type were we supply a list of strings. This is equivalent to calling the method with a single, list or array of strings/symbols.\n # Add the includes option (string value).\n relation = relation.includes(*params[:includes]) if (only.nil? || only.include?(:includes)) && params[:includes].present? # We only test the list argument type were we supply a list of strings. This is equivalent to calling the method with a single, list or array of strings/symbols.\n # Add the joins option (string value).\n relation = relation.joins(*params[:joins].map(&:to_sym)) if (only.nil? || only.include?(:joins)) && params[:joins].present? # We only test the list argument type were we supply a list of symbols (since strings are used as plain SQL and thus we know this is not safe). This is equivalent to calling the method with a single, list or array of symbols.\n # Add the preload option (string value).\n relation = relation.preload(*params[:preload]) if (only.nil? || only.include?(:preload)) && params[:preload].present? # We only test the list argument type were we supply a list of strings. This is equivalent to calling the method with a single, list or array of strings/symbols.\n\n # Others\n params[:create_with] = params[:create_with].reject { |k,v| v.blank? } # Remove blank values, so create_with will not be unnecessary set.\n relation = relation.create_with(params[:create_with]) if (only.nil? || only.include?(:create_with)) && params[:create_with].present?\n\n relation\n end",
"def build_where(opts, other = [])\n case opts\n when String, Array\n #TODO: Remove duplication with: /activerecord/lib/active_record/sanitization.rb:113\n values = Hash === other.first ? other.first.values : other\n\n values.grep(ActiveRecord::Relation) do |rel|\n self.bind_values += rel.bind_values\n end\n\n [@klass.send(:sanitize_sql, other.empty? ? opts : ([opts] + other))]\n when Hash\n attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)\n\n attributes.values.grep(ActiveRecord::Relation) do |rel|\n self.bind_values += rel.bind_values\n end\n\n PredicateBuilder.build_from_hash(klass, attributes, table)\n else\n [opts]\n end\n end",
"def claims_for_organisation_programme(organisation_id,programme_id)\n query = Query.find_by_sql(\n \"select c.id claim_id, c.invoice_date, c.invoice_no, c.payment_run_id,\\n\"+\n \" c.claim_status_id, cs.description claim_status_description,\\n\"+\n \" c.host_provider_id, hp.name host_provider_name,\\n\"+\n \" c.amount, c.comment, \\n\"+\n \" p.family_name, p.given_names, p.nhi_no,\\n\"+\n \" f.description fee_description \\n\"+\n \"from claims c\\n\"+\n \" join patients p on p.id = c.patient_id\\n\"+\n \" join fee_schedules f on f.id = c.fee_schedule_id\\n\"+\n \" join claim_statuses cs on cs.id = c.claim_status_id\\n\"+\n \" left join providers hp on hp.id = c.host_provider_id\\n\"+\n \"where c.organisation_id = #{organisation_id} and c.payment_run_id = #{self.id} and c.programme_id = #{programme_id}\\n\"+\n # Dont do this as confusing including held items on report. \n # \"UNION\\n\"+\n # \"select c.id claim_id, c.invoice_date, c.invoice_no, c.payment_run_id,\\n\"+\n # \" c.claim_status_id, cs.description claim_status_description,\\n\"+\n # \" c.host_provider_id, hp.name host_provider_name,\\n\"+\n # \" c.amount, c.comment, \\n\"+\n # \" p.family_name, p.given_names, p.nhi_no,\\n\"+\n # \" f.description fee_description \\n\"+\n # \"from claims c\\n\"+\n # \" join patients p on p.id = c.patient_id\\n\"+\n # \" join fee_schedules f on f.id = c.fee_schedule_id\\n\"+\n # \" join claim_statuses cs on cs.id = c.claim_status_id\\n\"+\n # \" left join providers hp on hp.id = c.host_provider_id\\n\"+\n # \"where c.organisation_id = #{organisation_id} and c.programme_id = #{programme_id}\\n\"+\n # \" and c.invoice_date >= #{Query.connection.quote(Query.connection.quoted_date(self.cut_off_date.last_month))}\\n\"+\n # \" and c.invoice_date < #{Query.connection.quote(Query.connection.quoted_date(self.cut_off_date))}\\n\"+\n # \" and c.payment_run_id <= 1\\n\"+\n # \" and c.claim_status_id <> #{ClaimStatus::DELETED}\\n\"+\n \"order by c.invoice_date, c.id\");\n query\n end",
"def to_scope\r\n\r\n table_name = @model.table_name\r\n\r\n @filtering_attributes.select { |attr|\r\n @filtering_values.key?(attr)\r\n }.reduce(@model.scoped) { |model_scope, attr|\r\n\r\n filtering_value = @filtering_values[attr]\r\n\r\n filtering_column_type = @model.attribute_type(attr)\r\n\r\n column_sql = %'\"#{ table_name }\".\"#{ attr }\"'\r\n\r\n case filtering_column_type\r\n when :string\r\n case filtering_value\r\n when Set\r\n model_scope.where(\"#{ column_sql } IN (?)\", filtering_value)\r\n else\r\n model_scope.where(\"#{ column_sql } LIKE ?\", filtering_value)\r\n end\r\n\r\n when :boolean\r\n model_scope.where(\"#{ column_sql } = ?\", filtering_value)\r\n\r\n when :integer\r\n case filtering_value\r\n when Hash\r\n new_model_scope = model_scope\r\n if filtering_value.key?(:min)\r\n unless filtering_value[:min] == -Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value[:min])\r\n end\r\n end\r\n if filtering_value.key?(:max)\r\n unless filtering_value[:max] == Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value[:max])\r\n end\r\n end\r\n new_model_scope\r\n when Set\r\n model_scope.where(\"#{ column_sql } IN (?)\", filtering_value)\r\n when Range\r\n new_model_scope = model_scope\r\n unless filtering_value.first == -Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value.first)\r\n end\r\n unless filtering_value.last == Float::INFINITY\r\n new_model_scope =\r\n if filtering_value.exclude_end?\r\n model_scope.where(\"#{ column_sql } < ?\", filtering_value.last)\r\n else\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value.last)\r\n end\r\n end\r\n new_model_scope\r\n else\r\n model_scope.where(\"#{ column_sql } = ?\", filtering_value)\r\n end\r\n\r\n when :date\r\n case filtering_value\r\n when Hash\r\n new_model_scope = model_scope\r\n if filtering_value.key?(:from)\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value[:from])\r\n end\r\n if filtering_value.key?(:until)\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value[:until])\r\n end\r\n new_model_scope\r\n when Set\r\n model_scope.where(\"#{ column_sql } IN (?)\", filtering_value)\r\n when Range\r\n new_model_scope = model_scope\r\n unless filtering_value.first == -Float::INFINITY\r\n new_model_scope =\r\n model_scope.where(\"#{ column_sql } >= ?\", filtering_value.first)\r\n end\r\n unless filtering_value.last == Float::INFINITY\r\n new_model_scope =\r\n if filtering_value.exclude_end?\r\n model_scope.where(\"#{ column_sql } < ?\", filtering_value.last)\r\n else\r\n model_scope.where(\"#{ column_sql } <= ?\", filtering_value.last)\r\n end\r\n end\r\n new_model_scope\r\n else\r\n model_scope.where(\"#{ column_sql } = ?\", filtering_value)\r\n end\r\n else\r\n model_scope\r\n end\r\n }\r\n end",
"def query\n @klass.where(:_id.in => only_saved_ids)\n end",
"def conditions_for_customer_qualifiers(customer_qualifiers)\n ids = customer_qualifiers.map { |q| q.qualifiable.id }\n ids = ids.join(\",\")\n\n if !ids.blank?\n res = \"projects.customer_id in (#{ ids })\"\n res += \" or task_customers.customer_id in (#{ ids })\"\n return \"(#{ res })\"\n end\n end",
"def find_conditionals_of(dependent_object)\n condition_classes_of(dependent_object).map do |condition_name|\n Course::Condition.find_by_sql(<<-SQL)\n SELECT * FROM course_conditions cc\n INNER JOIN course_condition_#{condition_name.demodulize.downcase.pluralize} ccs\n ON cc.actable_type = '#{condition_name}'\n AND cc.actable_id = ccs.id\n AND ccs.#{dependent_object.class.name.demodulize.downcase}_id = #{dependent_object.id}\n WHERE course_id = #{dependent_object.course_id}\n SQL\n end.flatten.map(&:conditional)\n end",
"def selected_filter_conditions(filter_class)\n\n @conditions = \"\"\n @included = []\n\n #pass in existing filters\n if params[:selected_filters]\n @selected_filters = params[:selected_filters] \n else \n @selected_filters = {} \n end\n\n #intialise hashes to store filters\n filter_class.filters.each do |j_f|\n @selected_filters[j_f] = {} if !defined?(@selected_filters[j_f]) || @selected_filters[j_f] == nil \n end\n\n @filtered = params[:filter]\n\n #new filter passed in - add or remove from existing as needed\n if @filtered\n\n if params[:remove]\n @selected_filters[@filtered].delete(params[:id])\n else\n @filter_id = params[:id]\n @filter_name = params[:name]\n @selected_filters[@filtered] = {params[:id] => params[:name]}\n end\n\n end\n\n #build up list of conditions to filter results\n if @selected_filters != {}\n @selected_filters.each do |filter, values|\n\n if values != {}\n\t @included << filter.to_sym\n @conditions += \" AND \" if @conditions != \"\"\n @ids = []\n \n values.each do | v | \n @ids << v[0]\n end\n \n @conditions += \"#{filter}.id IN (#{@ids})\"\n\t end \n end\n end\n\n end",
"def school_search_relation(params) \n query = []\n query << \"rollcall_schools.display_name in (:school)\" if params[:school].present?\n \n district_zip_query = [] # district and zip are non exclusive, included in the complete query via an or\n district_zip_query << \"sd.name in (:school_district)\" if params[:school_district].present?\n district_zip_query << \"rollcall_schools.postal_code in (:zip)\" if params[:zip].present?\n \n dz_school_type_query = []\n dz_school_type_query << \"(#{district_zip_query.join(' or ')})\" unless district_zip_query.blank? # The or part of district and zip\n dz_school_type_query << \"rollcall_schools.school_type in (:school_type)\" if params[:school_type].present? # School type modifies district and zip (or runs on its own)\n \n query << \"(#{dz_school_type_query.join(' and ')})\" unless dz_school_type_query.blank? # That entire sub-statement is anded together and added to the complete query\n\n self.schools.where(query.join(' or '), params).reorder('rollcall_schools.display_name')\n end",
"def liked_in_common_with(klass, user)\n klass.where(:ids => liked_ids_in_common_with(klass, user))\n end",
"def criteria(metadata, object, type = nil)\n\n path_info = relation_path_info(metadata)\n\n initial = {key: [metadata.foreign_key], selector: object}\n\n path_info.drop(1).reverse_each do |info|\n\n if info[:macro] == :embeds_one\n initial = embeds_one_criteria(initial, relation_info)\n else\n initial = embeds_many_criteria(initial, info)\n initial[:selector] = initial[:selector].selector\n end\n end\n\n if path_info.first[:macro] == :embeds_one\n initial = embeds_one_criteria(initial, path_info.first)\n metadata.klass.where(initial[:key].join(\".\") => initial[:selector])\n else\n embeds_many_criteria(initial, path_info.first)[:selector]\n end\n end",
"def scope_condition\n self.class.send( :sanitize_sql_hash_for_conditions, { :owner_type => owner_type, :owner_id => owner_id } )\n end",
"def to_find_conditions(join_association = {})\n return nil if operator.nil?\n \n op, arg_format, values = operator, \"?\", [operand]\n op, arg_format, values = case operator\n when :<=> then [ \"BETWEEN\", \"? AND ?\", [ operand.first, operand.last ] ]\n when :=~ then\n case operand\n when String then [ \"LIKE\", arg_format, values ]\n when Regexp then [ \"REGEXP\", arg_format, values.map(&:source) ]\n end\n when :==, :=== then\n case operand\n when Array then [ \"IN\", \"(?)\", values ]\n when Range then [ \"IN\", \"(?)\", values ]\n when Condition then [ \"=\", operand.full_name, [] ]\n when nil then [ \"IS\", \"NULL\", [] ]\n else [ \"=\", arg_format, values ]\n end\n when :contains then [ \"LIKE\", arg_format, values.map{|v| \"%#{v}%\" } ]\n else\n case operand\n when Condition then [ op, oprand.full_name, [] ]\n else [ op, arg_format, values ]\n end\n end\n sql = \"#{full_name} #{op} #{arg_format}\"\n sql = \"NOT (#{sql})\" if @negative\n [ sql, *values ]\n end",
"def all_permitting( priv, keyword_args = {} )\n perm_conds = where_permits( priv, :user => keyword_args.delete(:user) ) \n self.applying_deprecated_query_args( keyword_args ).where( perm_conds )\n end",
"def restrict(*args, &block)\n DerivedRelvar.new(@db, relvar_def, underlying_table.filter(*args, &block))\n end",
"def self_and_descendants\n nested_set_scope.where(\"#{self.class.table_name}.lft >= ? AND #{self.class.table_name}.rgt <= ?\", lft, rgt)\n end",
"def get_relation(params = {})\n @arel = data_class.arel_table\n\n relation = data_class.scoped\n\n relation = apply_column_filters(relation, params[:filter]) if params[:filter]\n\n if params[:extra_conditions]\n extra_conditions = normalize_extra_conditions(ActiveSupport::JSON.decode(params[:extra_conditions]))\n relation = relation.extend_with_netzke_conditions(extra_conditions) if params[:extra_conditions]\n end\n\n query = params[:query] && ActiveSupport::JSON.decode(params[:query])\n\n if query.present?\n # array of arrays of conditions that should be joined by OR\n and_predicates = query.map do |conditions|\n predicates_for_and_conditions(conditions)\n end\n\n # join them by OR\n predicates = and_predicates[1..-1].inject(and_predicates.first){ |r,c| r.or(c) }\n end\n\n relation = relation.where(predicates)\n\n relation = relation.extend_with(config[:scope]) if config[:scope]\n\n relation\n end",
"def association_join_with_paranoid\n return @join if @join\n result = association_join_without_paranoid\n if reflection.klass.paranoid?\n aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine)\n pb = ActiveRecord::PredicateBuilder.new(arel_engine)\n result.concat(pb.build_from_hash(reflection.klass.paranoid_condition, aliased_table))\n end\n result\n end",
"def get_relation(params = {})\n @arel = @model_class.arel_table\n\n relation = @model_class.scoped\n\n relation = apply_column_filters(relation, params[:filter]) if params[:filter]\n\n query = params[:query] && ActiveSupport::JSON.decode(params[:query])\n\n if query.present?\n # array of arrays of conditions that should be joined by OR\n and_predicates = query.map do |conditions|\n predicates_for_and_conditions(conditions)\n end\n\n # join them by OR\n predicates = and_predicates[1..-1].inject(and_predicates.first){ |r,c| r.or(c) }\n end\n\n relation = relation.where(predicates)\n\n relation = relation.extend_with(params[:scope]) if params[:scope]\n\n relation\n end",
"def find_people_who_work_for_organisation_by_solr(person_query, organisation_query, person_options, organisation_options)\n # FIXME: Should only request the organisation ID field because that's all we need for this search...\n organisation_options[:rows] = Organisation.count\n\t\n contacts, paginator = solr_query(organisation_query, organisation_options)\n\n organisation_ids = contacts[:docs].collect{|c| c.objectData.organisation_id }\n\t\n\t#logger.debug \"DEBUG: find people who work for organisation by solr: organisation_ids #{organisation_ids.length} #{organisation_ids.join(',')}\"\n\n\t return [{:docs => [], :total => 0}, nil] if organisation_ids.empty?\n\n organisation_ids_s = organisation_ids.join(' OR ')\n person_query << ' AND organisations_for_solr_t:(' + organisation_ids_s + ')'\n \n contacts, paginator = solr_query(person_query, person_options)\n end",
"def include_eager_conditions?(options)\n # look in both sets of conditions\n conditions = [scope(:find, :conditions), options[:conditions]].inject([]) do |all, cond|\n case cond\n when nil then all\n when Array then all << cond.first\n else all << cond\n end\n end\n return false unless conditions.any?\n conditions.join(' ').scan(/([\\.\\w]+)\\.[\\[\"]?\\w+[\\]\"]?/).flatten.any? do |condition_table_name|\n condition_table_name != table_name\n end\n end",
"def bt_scope_conditions\n table = self.class.arel_table\n self.class.bt_scope_columns.map do |key_attr|\n table[key_attr].eq(self[key_attr])\n end.inject do |memo, condition|\n memo.and(condition)\n end\n end",
"def build_relation(*where_conditions)\n relation = @model_class.where(*where_conditions)\n relation = relation.includes(joins).references(joins) if joins.present?\n relation\n end",
"def build_relation(*where_conditions)\n relation = @model_class.where(*where_conditions)\n relation = relation.includes(joins).references(joins) if joins.present?\n relation\n end",
"def tasks_by_filters\n to_include = [ :users, :tags, :sheets, :todos, :dependencies, \n :milestone, :notifications, :watchers, \n :customers ]\n to_include << { :work_logs => :user }\n to_include << { :company => :properties }\n to_include << { :project => :customer }\n to_include << { :task_property_values => { :property_value => :property } }\n to_include << { :dependants => [:users, :tags, :sheets, :todos, \n { :project => :customer }, :milestone ] }\n\n conditions = filter\n conditions += \" AND tasks.project_id in (#{ @select_project_ids })\"\n conditions += \" AND #{ @extra_conditions }\" if !@extra_conditions.blank?\n\n Task.find(:all, \n :conditions => [ conditions ],\n :include => to_include, \n :limit => 250,\n :order => \"tasks.id desc\")\n end",
"def filter_by_params(clinics, gestational_age, naf_only, medicaid_only)\n filtered_clinics = clinics.keep_if do |clinic|\n gestational_age < (clinic.gestational_limit || 1000) &&\n (naf_only ? clinic.accepts_naf : true) &&\n (medicaid_only ? clinic.accepts_medicaid : true)\n end\n filtered_clinics\n end",
"def apply_filters(query, options)\n if @model_ids && options[:mview]\n query = query.where(model_id: @model_ids)\n elsif @model_ids\n query = query.where('scenarios.model_id' => @model_ids)\n end\n query = query.where(scenario_id: @scenario_ids) if @scenario_ids\n query = query.where(indicator_id: @indicator_ids) if @indicator_ids\n query = query.where(location_id: @location_ids) if @location_ids\n query = query.joins(:indicator).where(indicators: {subcategory_id: apply_category_filter}) if @category_ids\n puts query.to_sql.inspect\n query\n end",
"def by_gl_account_no_then_organisation\n query = Query.find_by_sql(\n \"select c.fee_schedule_id, f.gl_account_no,p.description programme_description, f.description, o.id organisation_id, o.name organisation_name, o.not_gst_registered, sum(c.amount) sumamount\\n\"+\n \"from claims c\\n\"+\n \" left join fee_schedules f on f.id = c.fee_schedule_id\\n\"+\n \" left join programmes p on p.id = c.programme_id\\n\"+\n \" join organisations o on o.id = c.organisation_id\\n\"+\n \"where c.payment_run_id = #{self.id}\\n\"+\n \"group by c.fee_schedule_id, f.gl_account_no,p.description, f.description, o.id, o.name, o.not_gst_registered \\n\"+\n \"order by 2,3,1,6 desc\\n\" );\n query.in_groups_by(&:fee_schedule_id)\n end"
] | [
"0.5719611",
"0.5646677",
"0.55646676",
"0.55289453",
"0.5404927",
"0.5376554",
"0.5335817",
"0.53332233",
"0.5321977",
"0.52638996",
"0.524178",
"0.5206978",
"0.52049476",
"0.52001715",
"0.51796716",
"0.5166633",
"0.5142932",
"0.5134657",
"0.5118139",
"0.5098712",
"0.50682074",
"0.5046214",
"0.50456405",
"0.5044127",
"0.5040788",
"0.50377554",
"0.49942467",
"0.49938324",
"0.49637187",
"0.49627075",
"0.49445936",
"0.49363527",
"0.49322742",
"0.49127424",
"0.49062026",
"0.48883593",
"0.4885194",
"0.48851272",
"0.48820344",
"0.48755547",
"0.4875352",
"0.48719287",
"0.487008",
"0.48647532",
"0.4860944",
"0.48501533",
"0.4844566",
"0.48345324",
"0.48269445",
"0.48116243",
"0.47880185",
"0.47816238",
"0.47812557",
"0.47656044",
"0.47549784",
"0.47499317",
"0.47434708",
"0.47421902",
"0.47420007",
"0.474033",
"0.4734178",
"0.47323924",
"0.4732282",
"0.47297558",
"0.47172388",
"0.47108877",
"0.4710357",
"0.47094443",
"0.47023284",
"0.46875978",
"0.4674551",
"0.46685392",
"0.46671623",
"0.46661016",
"0.46618593",
"0.46548548",
"0.46536392",
"0.46376717",
"0.46348268",
"0.46226332",
"0.4617767",
"0.4617087",
"0.4614405",
"0.46142182",
"0.4614204",
"0.46131742",
"0.46112555",
"0.46105647",
"0.46054214",
"0.46037528",
"0.45991048",
"0.45833936",
"0.458157",
"0.45701498",
"0.45603347",
"0.45603347",
"0.45578548",
"0.45545188",
"0.45503417",
"0.4545011"
] | 0.8168442 | 0 |
Raise translation missing errors in controllers too | def t(key, options = {})
options[:raise] = true
translate(key, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i18n\n begin\n render :text=>I18n.translate(params[:id], :raise => I18n::MissingTranslationData)\n rescue I18n::MissingTranslationData\n render :text=>\"No translation for #{params[:id]}\", :status => 404\n end\n end",
"def translated_message\n lookups = []\n lookups << :\"activemodel.errors.template.message\"\n lookups << :\"activerecord.errors.template.message\"\n lookups << :\"case_form.errors.template.message\"\n lookups << \"There were problems with the following fields:\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def replace_with_translation_keys(model_errors)\n return model_errors if internationalized?\n deep_translation_replace(model_errors)\n end",
"def record_not_found_message\n resource_name&.present? ? I18n.t(:x_not_found, name: resource_name&.singularize&.titleize) : I18n.t(:not_found)\n end",
"def missing_translation\n render :template => \"blog_posts/missing_translation\"\n end",
"def translations; end",
"def silence_errors\n require 'fast_gettext/translation_repository/base'\n translation_repositories[text_domain] ||= TranslationRepository::Base.new('x', :path => 'locale')\n end",
"def not_found\n super(t('messages.employee.errors.find'))\n end",
"def translated?\n texts = errors.values.flatten.map(&:message)\n texts.select { |text| text.start_with?(\"translation missing\") }.empty?\n end",
"def validate_translations\n# logger.debug \"***** validates question translations\"\n if self.dataset.default_language.present?\n# logger.debug \"***** - default is present; text = #{self.text_translations[self.dataset.default_language]}\"\n if self.text_translations[self.dataset.default_language].blank?\n# logger.debug \"***** -- text not present!\"\n errors.add(:base, I18n.t('errors.messages.translation_default_lang',\n field_name: self.class.human_attribute_name('text'),\n language: Language.get_name(self.dataset.default_language),\n msg: I18n.t('errors.messages.blank')) )\n end\n end\n end",
"def validate\n untranslated = self.get_untranslated_keys\n untranslated.each { |key|\n puts \"WARNING: \\\"#{key['id']}\\\" is not translated in #{key['untranslated']} languages\"\n }\n end",
"def load_translations_and_collect_file_errors(files); end",
"def not_found\n super(t('messages.list_item.errors.find'))\n end",
"def express_error_context resource\n I18n.t \"errors.action.#{params[:controller]}.#{params[:action]}.#{resource.class.model_name.i18n_key}\",\n default: \"Couldn't #{params[:action]} the #{resource.class.to_s.downcase}\"\n end",
"def use_i18n; end",
"def temporary_patch_delete_me_later\n # This is a temporary patch to fix an issue with one of the pt-BR translations\n # in the DMPRoadmap translation.io\n #\n # It overrides the application_controller.rb :success_message function\n format(_('Successfully %{action} the %{object}.'), object: obj_name_for_display(obj), action: action || 'save')\n end",
"def translated_header_message\n lookups = []\n lookups << :\"activemodel.errors.template.header_message\"\n lookups << :\"activerecord.errors.template.header_message\"\n lookups << :\"case_form.errors.template.header_message\"\n lookups << \"Some errors prohibited this object from being saved\"\n I18n.t(lookups.shift, :default => lookups)\n end",
"def flash_error(message_key,*strs)\r\n flash[:error] = sprintf(I18n.t(message_key),*strs)\r\n end",
"def ensure_non_primary_language_request(language=nil)\n checker = TranslationChecker.new(\n polymorphic_controlled_resourse,\n action_name,\n language\n )\n\n if checker.for_primary_language?\n raise JsonApiController::AccessDenied, no_resources_error_message\n end\n end",
"def init_translations; end",
"def message_for(key,options={})\n handwritten_message || I18n.translate(key, {:scope => 'activerecord.errors.messages'}.merge(options))\n end",
"def translate_exception(e, message)\n case e.message\n when /violation of FOREIGN KEY constraint/\n InvalidForeignKey.new(message, e)\n when /violation of PRIMARY or UNIQUE KEY constraint/\n RecordNotUnique.new(message, e)\n else\n super\n end\n end",
"def localize(key, error_msg='__localization_missing__', args={}, locale=nil)\n return if reserved_keys.include? key\n\n # Set a temporary Locale to support the localized_in method\n #\n unless locale.nil?\n @original_locale = Locale.code\n Locale.set_code(locale)\n end\n localized = localizations[key] || error_msg\n # Get translations from another country but in the same language if Globalite can't find a translation for my locale\n #\n if localized == error_msg\n locales.each do |t_locale|\n if t_locale.to_s.include?(\"#{current_language.to_s}-\") && t_locale != Locale.code\n localized = @@locales[t_locale][key] || error_msg\n end\n end\n end\n localized = interpolate_string(localized.dup, args.dup) if localized.class == String && localized != error_msg\n\n # let's handle pluralization if needed\n # the translation must include pluralize{count, singular string} to be translated\n # the translator can also pass the plural form if needed:\n # pluralize{3, goose, geese}\n localized = localized.gsub( /pluralize\\{(.*)\\}/){ |erb| pluralize(Regexp.last_match(1)) } if localized.is_a?(String) && (localized=~ /pluralize\\{(.*)\\}/)\n\n # Set the locale back to normal\n #\n unless locale.nil?\n Locale.code = @original_locale\n end\n\n return localized\n end",
"def view_error_text(object, error_key, options = {})\n raise Exception.new(\"Parameter string_name may not be blank\") if error_key.blank?\n \n controller ||= options[:controller] ||= self.controller_name\n\n # If you are on the production server, you can only see strings set to live\n # mode. If you are on a development or staging server, you can see draft or ready status\n language_id = get_current_language_id(options)\n\n # First, try to look up the string in the specified controller\n # Note: we get the one with the highest version number\n translation = I18n::SingletonTranslationKey.translate( :klass => object, \n :language => language_id,\n :key => error_key )\n \n # Model errors are bound directly to an error we do not want to look for this key on the global level \n \n # if we found something, we're good\n return translation.text if translation && translation.text\n\n # if not, we can optionally return an empty string\n if options[:missing_ok] == true\n return \"\"\n else\n # Rather than fail if we can not find the translation, put the key in place of\n # the translation and log a tranlsation error in the i18n.log which is defined in\n # config/initializers/i18n_logger.rb\n language = Language.find(language_id)\n I18N_LOGGER.error \"view_text_lookup: Unable to locate string '#{error_key}' \" +\n \"for language #{language.language} that belongs to object #{object}\"\n return \"trasnlation-missing: #{error_key} - lang: #{language_id}\"\n end\n end",
"def test_lookup_given_nil_as_a_key_returns_nil\n assert_nil I18n.backend.send(:lookup, :en, nil)\n end",
"def translation_path\n self.class.translation_path or self.class.controller_path.gsub(\"/\", \".\")\n end",
"def translate(key, options = {})\n options = options.dup\n if options.has_key?(:default)\n remaining_defaults = Array(options.delete(:default)).compact\n options[:default] = remaining_defaults unless remaining_defaults.first.kind_of?(Symbol)\n end\n\n # If the user has explicitly decided to NOT raise errors, pass that option to I18n.\n # Otherwise, tell I18n to raise an exception, which we rescue further in this method.\n # Note: `raise_error` refers to us re-raising the error in this method. I18n is forced to raise by default.\n if options[:raise] == false\n raise_error = false\n i18n_raise = false\n else\n raise_error = options[:raise] || ActionView::Base.raise_on_missing_translations\n i18n_raise = true\n end\n\n if html_safe_translation_key?(key)\n html_safe_options = options.dup\n options.except(*I18n::RESERVED_KEYS).each do |name, value|\n unless name == :count && value.is_a?(Numeric)\n html_safe_options[name] = ERB::Util.html_escape(value.to_s)\n end\n end\n translation = I18n.translate(scope_key_by_partial(key), html_safe_options.merge(raise: i18n_raise))\n if translation.respond_to?(:map)\n translation.map { |element| element.respond_to?(:html_safe) ? element.html_safe : element }\n else\n translation.respond_to?(:html_safe) ? translation.html_safe : translation\n end\n else\n I18n.translate(scope_key_by_partial(key), options.merge(raise: i18n_raise))\n end\n rescue I18n::MissingTranslationData => e\n if remaining_defaults.present?\n translate remaining_defaults.shift, options.merge(default: remaining_defaults)\n else\n raise e if raise_error\n\n keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])\n title = +\"translation missing: #{keys.join('.')}\"\n\n interpolations = options.except(:default, :scope)\n if interpolations.any?\n title << \", \" << interpolations.map { |k, v| \"#{k}: #{ERB::Util.html_escape(v)}\" }.join(\", \")\n end\n\n return title unless ActionView::Base.debug_missing_translation\n\n content_tag(\"span\", keys.last.to_s.titleize, class: \"translation_missing\", title: title)\n end\n end",
"def twitter_failure\n\t if I18n.locale == :en\n\t \tflash[:notice] = \"Failed to connect to Twitter\"\n\t else I18n.locale == :ar\n\t \tflash[:notice] = \"فشل التواصل مع تويتر بنجاح\"\n\t end\n\t redirect_to root_url\n\tend",
"def language_exists\n if language.nil?\n errors.add(:base,\"Language Doesn't Exist\")\n throw :abort\n end\n end",
"def translation_class(model, locale: I18n.locale)\n translation_exists?(model, locale: locale) ? nil : 'translation-missing'\n end",
"def error(message)\n case message\n when /no_update/i\n message = t('messages.error', :confirmation => t('messages.no_update_confirmation'), :check_again => t('messages.check_again'), :try_again => t('messages.try_again'))\n when /no_create/i\n message = t('messages.error', :confirmation => t('messages.no_create_confirmation'), :check_again => t('messages.check_again'), :try_again => t('messages.try_again'))\n end\n flash[:error] = message\n end",
"def load_translations\n super(@load_paths)\n end",
"def load_translations\n super(@load_paths)\n end",
"def eol_lang_error_messages_for(*params)\n options = params.extract_options!.symbolize_keys\n object = options.delete(:object)\n objects = object ? [object].flatten : params.collect {|object_name| instance_variable_get(\"@#{object_name}\") }.compact\n count = objects.inject(0) {|sum, obj| sum + obj.errors.count }\n unless count.zero?\n html = {}\n [:id, :class].each do |key|\n if options.include?(key)\n value = options[key]\n html[key] = value unless value.blank?\n else\n html[key] = 'errorExplanation'\n end\n end\n options[:header_message] = I18n.t(:validation_error) unless options.include?(:header_message)\n options[:message] ||= I18n.t(:validation_following_fields) unless options.include?(:message)\n\n # Translate error messages\n error_messages = objects.map do |obj|\n obj.errors.map do |field, error|\n # Try translating the field name\n field = ActiveRecord::Base.human_attribute_name(field)\n\n # Make two versions of the error message:\n # Example: is too short (minimum 3 characters)\n # 1) is too short (minimum %d characters)\n # Use this to map with default_error_messages_inverted\n # 2) is too short (minimum {n} characters)\n # Use this for Gibberish to translate with variables\n error_attributes = error.scan(/\\d+/)\n error_default = error.gsub(/\\d+/,\"%d\")\n error_translate = error.gsub(/\\d+/,\"{n}\") #\n\n if error =~ /^\\^/\n error_display = error[1..-1]\n else\n error_display = \"#{field == 'Base' ? '' : field} #{error}\"\n end\n content_tag(:li, error_display)\n end\n end\n\n contents = ''\n contents << content_tag(options[:header_tag] || :h2, options[:header_message]) unless options[:header_message].blank?\n contents << content_tag(:p, options[:message]) unless options[:message].blank?\n contents << content_tag(:ul, raw(error_messages.flatten.join))\n content_tag(:div, raw(contents), html)\n else\n ''\n end\n end",
"def N_(*args)\r\n LocalizeActiveScaffold.dont_translate(args[0].to_s)\r\n end",
"def i18n\n return unless defined?(I18n)\n I18n.config.exception_handler = ->(exception, _locale, _key, _options) do\n raise exception.respond_to?(:to_exception) ? exception.to_exception : exception\n end\n end",
"def label_translation; end",
"def record_missing(locale, s)\n @missing_translations ||= Set.new\n entry = [ locale, s ]\n return if @missing_translations.include?(entry)\n @missing_translations << entry\n logger.warn \"Missing translation: [#{locale}] #{s.inspect}\"\n end",
"def translation_scope\n \"kiqr.#{controller_name}\"\n end",
"def inject_i18n_translations(params, required_params)\n reject_unnecessary_i18n_params!(params, required_params)\n required_params_to_check = required_params\n return unless required_params_to_check\n\n required_params_to_check.each do |required_param|\n if required_param.to_s =~ /i18n_(.+)/\n params[required_param] ||= I18nRoutable.translate_segment($1, params[:locale])\n end\n end\n end",
"def translated_error_message(identifier)\n return default_translated_error_message(identifier) if utility.nil?\n I18n.t(\n \"errors.messages.#{utility_class_name}.#{identifier}\",\n default: default_translated_error_message(identifier)\n )\n end",
"def unknown_string\n t('Unknown')\n end",
"def flash_error_messages_for(*params)\n options = params.extract_options!.symbolize_keys\n\n if object = options.delete(:object)\n objects = [object].flatten\n else\n objects = params.collect {|object_name| instance_variable_get(\"@#{object_name}\") }.compact\n end\n\n objects.compact!\n\n count = objects.inject(0) {|sum, object| sum + object.errors.count }\n unless count.zero?\n I18n.with_options :locale => options[:locale], :scope => [:activerecord, :errors, :template] do |locale|\n error_messages = objects.sum {|object| object.errors.full_messages.map {|msg| content_tag(:li, ERB::Util.html_escape(msg)) } }.join\n @template.content_for :form_errors, \" due to the following error#{'s' if count > 1}: #{@template.content_tag(:ul, error_messages)}\"\n end\n end\n end",
"def failure\n origin_locale = get_origin_locale(request, available_locales())\n I18n.locale = origin_locale if origin_locale\n error_message = params[:error_reason] || \"login error\"\n kind = request.env[\"omniauth.error.strategy\"].name.to_s || \"Facebook\"\n flash[:error] = t(\"devise.omniauth_callbacks.failure\",:kind => kind.humanize, :reason => error_message.humanize)\n redirect_to search_path\n end",
"def full_message\n if @model\n if field\n if i18n_set? \"#{i18n_scope}.models.#{@model}.#{field}.#{code}\", t\n I18n.t(\"#{i18n_scope}.models.#{@model}.#{field}.#{code}\", t)\n elsif i18n_set?(\"#{i18n_scope}.field.#{code}\", t)\n I18n.t(\"#{i18n_scope}.field.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n else\n if i18n_set? \"#{i18n_scope}.models.#{@model}.#{code}\", t\n I18n.t(\"#{i18n_scope}.models.#{@model}.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n end\n elsif @controller && @action\n if field && i18n_set?(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{field}.#{code}\", t)\n I18n.t(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{field}.#{code}\", t)\n elsif i18n_set?(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{code}\", t)\n I18n.t(\"#{i18n_scope}.controllers.#{@controller}.#{@action}.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n elsif field && i18n_set?(\"#{i18n_scope}.field.#{code}\", t)\n I18n.t(\"#{i18n_scope}.field.#{code}\", t)\n elsif i18n_set? \"#{i18n_scope}.#{code}\", t\n I18n.t(\"#{i18n_scope}.#{code}\", t)\n else\n code.to_s\n end\n end",
"def get_translate(locale, key)\r\n I18n.t!(key, :locale => locale)\r\n rescue\r\n nil\r\n end",
"def fillin_translations\n collection_types = Hyrax::CollectionType.all\n collection_types.each do |c|\n next unless c.title =~ /^translation missing/\n oldtitle = c.title\n c.title = I18n.t(c.title.gsub(\"translation missing: en.\", ''))\n c.save\n Rails.logger.debug \"#{oldtitle} changed to #{c.title}\"\n end\n end",
"def t(key, default = '')\n c = I18n.t(key)\n if c.match(/translation missing/i)\n c = I18n.t(key, locale: 'en') \n # Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def t(key, default='')\n c = I18n.t(key)\n if c.match( 'translation missing' )\n c = I18n.t(key, locale: 'en') \n# Still not found. Return default if set\n c = default unless default.blank?\n end\n c\nend",
"def missing_translations\n @translations.select { |x, v| v.nil? or v.blank? }\n end",
"def set_notice(i18n)\n flash[:notice] = I18n.t(i18n)\n end",
"def i18n_set?(key, params = {})\n I18n.t key, params, :raise => true rescue false\n end",
"def error_messages(resource_name: , resource: , separator:)\n sanitize_and_translate(\n resource_name: resource_name ,\n resource:resource,\n given_messages: reject_notice_messages(messages: messages)\n ).flatten.join(separator).html_safe\n end",
"def supported_language_codes\n language_codes = TranslationsHelper.supported_language_codes\n\n if language_codes.empty?\n return_error_infos(400, 'Error no supported languages', 'TranslationError', nil)\n else\n render :status => 200, :json => { :language_codes => language_codes }\n end\n end",
"def auto_translate\n return unless MuckContents.configuration.enable_auto_translations\n begin\n translate(false)\n rescue => ex\n #TODO figure out a way to bubble up the error\n puts ex\n debugger\n # Translations failed, but update the default language\n translation = translation_for(self.locale)\n translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?\n end\n end",
"def not_found\n\n render_error( :not_found )\n\n end",
"def translation_scope\n \"order_details.notices\"\n end",
"def translate(klass, key, value)\n if defined?(I18n)\n super\n else\n value ? value.to_s.humanize.downcase : 'nil'\n end\n end",
"def fetch_translations(locale)\n self.translations ||= {}\n return if self.translations[locale]\n\n # Tml.logger.debug(\"Fetching translations for #{label}\")\n\n results = self.application.api_client.get(\n \"translation_keys/#{self.key}/translations\",\n {:locale => locale, :per_page => 10000},\n {:cache_key => Tml::TranslationKey.cache_key(locale, self.key)}\n ) || []\n\n update_translations(locale, results)\n\n self\n rescue Tml::Exception => ex\n self.translations = {}\n self\n end",
"def missing_translation_placeholder field\n evaluate_localization_option!(:placeholder, field)\n end",
"def lex_en_unknown; end",
"def enforce_available_locales!(locale); end",
"def error_handler\n flash[:notice] = \"Something went wrong here...\"\n end",
"def translate(key, **options)\n I18n.t key, **options.merge(scope: :quo_vadis, raise: true) rescue nil\n end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def language_cannot_be_changed\n if ! language_was.nil? && language_changed?\n errors.add(:language, I18n.t('messages.project_info.errors.language_changed'))\n end\n end",
"def not_found\n flash[:alert] = t('messages.project.errors.find')\n redirect_to projects_url\n end",
"def set_i18n\n if params[:locale]\n if I18n.available_locales.include?(params[:locale].to_sym)\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \"#{params[:locale]} not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def destroy\n begin\n @translation_language.destroy\n tflash('delete', :success, {:model=>@@model, :count=>1})\n respond_to do |format|\n format.html { redirect_to(translation_languages_path) }\n format.js {}\n end\n rescue StandardError => e\n @translation_language = nil\n flash[:error] = e.message\n respond_to do |format|\n format.js\n end\n end #rescue \n end",
"def translate(message)\n @messages[message] || message\n end",
"def test_unnamed_empty_route_with_prefix\n ActionController::Routing::Routes.draw { |map| map.connect '', :controller => 'people', :action => 'index' }\n config_default_locale_settings('en', true)\n ActionController::Routing::Translator.translate { |t| t['en'] = {}; t['es'] = {'people' => 'gente'} }\n \n assert_routing '/es', :controller => 'people', :action => 'index', :locale => 'es'\n assert_routing '/en', :controller => 'people', :action => 'index', :locale => 'en'\n end",
"def verificar_locale\n \n end",
"def create_translations\n end",
"def assert_no_missing_translations(msg = \"\")\n assert_select \"span[class=translation_missing]\", false, \"Missing translation #{msg}\"\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] = \n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def index\n\t\t@languages = Language.all\n\t\t@title = t(\"translate.title\")\n\t\trespond_with @languages\n\tend",
"def missing_localizations(org_base='en-US')\n @langs = {}\n @missing_localizations = {}\n @l_files = Dir[File.join( RAILS_ROOT, '/lang/ui', '*.yml')]\n @l_files.each do |file| \n if YAML.load_file(file)\n @langs[File.basename(file, '.*')] = YAML.load_file(file).symbolize_keys \n else\n p \"error with the following file: #{file}, the file might be empty\"\n end\n end\n @base_keys = @langs[org_base]\n unless @base_keys.blank?\n @langs.each_key do |@lang|\n @base_keys.each_key do |key|\n unless @langs[@lang].include?(key)\n @missing_localizations[@lang] ||= {}\n @missing_localizations[@lang] = @missing_localizations[@lang].merge({key.to_sym => @base_keys[key]})\n end\n end\n end\n else\n p \"your #{org_base} file seems empty\"\n end\n @missing_localizations\n end",
"def translatable\n self._translatable[base_name]\n end",
"def mass_copy_translations\n errors = ProjectTranslationsMassCopier.find_locale_errors(@project, params[:from_rfc5646_locale], params[:to_rfc5646_locale])\n\n if errors.blank?\n ProjectTranslationsMassCopier.perform_once(@project.id, params[:from_rfc5646_locale], params[:to_rfc5646_locale])\n flash[:success] = t('controllers.projects.mass_copy_translations.success',\n from: params[:from_rfc5646_locale], to: params[:to_rfc5646_locale])\n redirect_to setup_mass_copy_translations_project_url(@project)\n else\n flash.now[:alert] = [t('controllers.projects.mass_copy_translations.failure')] + errors\n render 'setup_mass_copy_translations'\n end\n end",
"def test_validates_length_of_within_finds_custom_model_key_translation\n I18n.backend.store_translations 'en-US', :active_record => {:error_messages => {:custom => {:topic => {:title => {:wrong_length => 'custom message'}}}}}\n I18n.backend.store_translations 'en-US', :active_record => {:error_messages => {:wrong_length => 'global message'}}\n \n Topic.validates_length_of :title, :is => 5\n @topic.valid?\n assert_equal 'custom message', @topic.errors.on(:title)\n end",
"def unimplemented\n i18n_setup(:elephas, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + \"/../../../locales/\")) if !@i18n\n raise ArgumentError.new(i18n.unimplemented)\n end",
"def one_locale_must_have_translations\n if (preferred_locales & configatron.full_locales).empty?\n errors.add(:preferred_locales_str, :one_must_have_translations, locales: configatron.full_locales.join(\",\"))\n end\n end",
"def set_i18n_locale_from_params\n if params[:locale]\n if I18n.available_locales.map(&:to_s).include?(params[:locale])\n I18n.locale = params[:locale]\n else\n flash.now[:notice] =\n \"#{params[:locale]} translation not available\"\n logger.error flash.now[:notice]\n end\n end\n end",
"def translate_label(text)\n I18n.t(\"backend.labels.#{text.to_s.downcase.gsub(/\\s/, \"_\")}\", :default => text.to_s.humanize)\n end",
"def base_errors_helper resource, for_bootstrap = true\n flash_one :error, express_base_errors(resource), for_bootstrap\n end",
"def index\n\t\trespond_with( {:error => 'You must provide a word.' }, :status => 422 ) # http 422 is unprocessible entity / malformed request\n\tend",
"def new\n respond_with(new_i18n_key)\n end",
"def controlled_scope\n if %i(update create).include?(action_name.to_sym)\n :translate\n else\n super\n end\n end",
"def rescue_undefined_method\n redirect_to(:action => \"index\")\n flash[:notice] = \"Sorry, something went wrong (undefined method). \" +\n \"Please try again.\"\n end",
"def handle_error(message = \"Sorry, something failed.\", view = 'new')\n flash.now[:alert] = message\n render view\n end",
"def translate(settings); end",
"def check_devise_resource_for_errors\n if (defined? resource) && resource && resource.errors.any?\n flash[:error] ||= resource.errors.full_messages.to_sentence << \".\"\n end\n end",
"def record_not_found\n render json: {error: I18n.t('errors.not_found')}.to_json, status: 404\n end",
"def add_missing_locales\n Locale::Info.three_languages['wee'] = Locale::Info::Language.new('', 'wee', 'I', 'L', 'Lower Sorbian')\n Locale::Info.three_languages['wen'] = Locale::Info::Language.new('', 'wen', 'I', 'L', 'Upper Sorbian')\n end"
] | [
"0.6910341",
"0.65263426",
"0.6345843",
"0.6310607",
"0.6286313",
"0.6267601",
"0.62420213",
"0.6116496",
"0.60855496",
"0.60322857",
"0.6016841",
"0.59965885",
"0.5939262",
"0.5896123",
"0.58781415",
"0.5869944",
"0.58476675",
"0.58470523",
"0.5843066",
"0.58353645",
"0.5817772",
"0.58164394",
"0.5789894",
"0.57681346",
"0.576431",
"0.5695587",
"0.56919396",
"0.56883174",
"0.56672245",
"0.5611505",
"0.5565292",
"0.5561346",
"0.5561346",
"0.5549626",
"0.55419356",
"0.552725",
"0.5512789",
"0.5502402",
"0.5498172",
"0.5490871",
"0.54785377",
"0.5461839",
"0.5445275",
"0.5443649",
"0.5440762",
"0.54362994",
"0.54324263",
"0.54112405",
"0.5410316",
"0.5408717",
"0.5404693",
"0.5398267",
"0.5377656",
"0.5375221",
"0.5373827",
"0.5373473",
"0.5373277",
"0.53652936",
"0.53629524",
"0.53601825",
"0.5354043",
"0.5353769",
"0.5344251",
"0.53281945",
"0.5326098",
"0.5326098",
"0.5326098",
"0.5326098",
"0.5326098",
"0.5326098",
"0.5326098",
"0.5326098",
"0.5320571",
"0.53169775",
"0.53146386",
"0.5304328",
"0.53016067",
"0.529974",
"0.52972764",
"0.52903104",
"0.5286928",
"0.5278066",
"0.5276098",
"0.5262449",
"0.52616286",
"0.52587414",
"0.5252496",
"0.5235845",
"0.52341413",
"0.5227856",
"0.5225224",
"0.5223604",
"0.521916",
"0.52184474",
"0.5210573",
"0.52091753",
"0.52077764",
"0.52047163",
"0.52039367",
"0.51980877",
"0.51977336"
] | 0.0 | -1 |
FIXTHIS could just take in options never gets called? | def contains?(variant, options = {})
find_line_item_by_variant(variant, options).present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def options=(_arg0); end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option; end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def options() end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options(opt); end",
"def options(opt); end",
"def options(*args, &block); end",
"def options; @opts end",
"def setup_options(options = T.unsafe(nil)); end",
"def options(opt)\n end",
"def process_options\n \n end",
"def verify_options_hook=(_arg0); end",
"def options; [] end",
"def verify_options_hook; end",
"def quoteoptions()\n fail \"Not yet implemented\"\n end"
] | [
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.744885",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.730953",
"0.7223779",
"0.7223779",
"0.7223779",
"0.7223779",
"0.7223779",
"0.7223779",
"0.7197194",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71898484",
"0.71741617",
"0.71741426",
"0.7060803",
"0.70593023",
"0.7036923",
"0.7019202",
"0.69990474",
"0.697179",
"0.69386244",
"0.6926181",
"0.6901799"
] | 0.0 | -1 |
I think the new line_item_options_match will cover this | def find_line_item_by_variant(variant, options = {})
ad_hoc_option_value_ids = ( !!options[:ad_hoc_option_values] ? options[:ad_hoc_option_values] : [] )
ad_hoc_option_value_customizations = ( !!options[:ad_hoc_option_value_customizations] ? options[:ad_hoc_option_value_customizations] : [] )
product_customizations = ( !!options[:product_customizations] ? options[:product_customizations].map{|ids| ids.first.to_i} : [] )
line_items.detect do |li|
li.variant_id == variant.id &&
matching_configurations(li.ad_hoc_option_values, ad_hoc_option_value_ids) &&
matching_customizations(li.product_customizations, product_customizations) &&
matching_ad_hoc_customizations(li.ad_hoc_option_values_line_items, ad_hoc_option_value_customizations)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_customizations_match(line_item, options)\n # comparing_form = line_item.order_form.attributes.dup\n # comparing_form.reject!{ |key| %w\"line_item_id id created_at updated_at\".include? key }\n #\n # #needs more special cases, we'll leave this for now and just always create a new line item\n # comparing_form == options\n false\n end",
"def validate_line_items\n \n end",
"def special_list_item_line(text)\n end",
"def match?(line_item)\n @variant_ids.include?(line_item.variant.id)\n end",
"def has_line_item?\n true\n end",
"def match?(line_item)\n @product_ids.include?(line_item.variant.product.id)\n end",
"def find_matching_line_item(other_order_line_item)\n order.line_items.detect do |my_li|\n my_li.variant == other_order_line_item.variant &&\n order.line_item_comparison_hooks.all? do |hook|\n order.send(hook, my_li, other_order_line_item.serializable_hash)\n end\n end\n end",
"def matching_opts(arg, list, i)\n\t\t# Returns field of all exactly or abbreviated matching options.\n\t\tm = @option.values.select { |o| o.match?(arg, list, i) == :exact }\n\t\tif m.empty?\n\t\t\t@option.values.select { |o| o.match?(arg, list, i) == :abbrev }\n\t\telse\n\t\t\tm\n\t\tend \n\tend",
"def saw_item(item); end",
"def extractable_options?; end",
"def _LineBlock\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_ItemsList)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_LineCommand)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_LineBlock unless _tmp\n return _tmp\n end",
"def create\n #raise params.to_yaml\n @line_item = @line_items.build(params[:line_item])\n option_selection = params[:line_item].delete(:option_selections_attributes)\n\n respond_to do |format|\n if @line_item.save\n @line_item.update_options(option_selection) #if option_selection.present?\n format.html { redirect_to @cart.shop, notice: t(\"line_items.create.notice_success\") }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def line_item_name line_item\n option_values_text = line_item.variant.option_values.map(&:presentation).join(\" \")\n [line_item.product.name, option_values_text].join(\" \")\n end",
"def add_to_line_item(variant, quantity, options = {})\n line_item = grab_line_item_by_variant(variant, false, options)\n\n line_item ||= order.line_items.new(\n quantity: 0,\n variant: variant,\n currency: order.currency\n )\n line_item.quantity += quantity.to_i\n line_item.options = ActionController::Parameters.new(options).permit(Spree::PermittedAttributes.line_item_attributes).to_h\n\n unless options.empty?\n product_customizations_values = options[:product_customizations] || []\n line_item.product_customizations = product_customizations_values\n product_customizations_values.each { |product_customization| product_customization.line_item = line_item }\n product_customizations_values.map(&:save) # it is now safe to save the customizations we built\n\n # find, and add the configurations, if any. these have not been fetched from the db yet. line_items.first.variant_id\n # we postponed it (performance reasons) until we actually know we needed them\n ad_hoc_option_value_ids = ( options[:ad_hoc_option_values].any? ? options[:ad_hoc_option_values] : [] )\n product_option_values = ad_hoc_option_value_ids.map do |cid|\n Spree::AdHocOptionValue.find(cid) if cid.present?\n end.compact\n line_item.ad_hoc_option_values = product_option_values\n\n offset_price = product_option_values.map(&:price_modifier).compact.sum + product_customizations_values.map {|product_customization| product_customization.price(variant)}.compact.sum\n\n line_item.price = variant.price_in(order.currency).amount + offset_price\n end\n\n if line_item.new_record?\n create_order_stock_locations(line_item, options[:stock_location_quantities])\n end\n\n line_item.target_shipment = options[:shipment]\n line_item.save!\n line_item\n end",
"def verify_options_hook; end",
"def legendary_item?(options)\n options[:name] == 'Eternal Ember' || options[:name] == 'Seething Cinder'\n end",
"def _match_arguments_optionals_before\n @optionals_before = {}\n tracker = {}\n\n @options.each do |option, _key|\n next unless option.is_argument\n\n if option.is_optional\n # setup tracker for optional group\n tracker[option.is_optional] = [] if tracker[option.is_optional].nil?\n\n # mark all optionals as not-included\n tracker[option.is_optional].push(\n included: false,\n name: option.name,\n )\n else\n @optionals_before[option.name] = tracker\n tracker = {}\n end\n end\n\n # make sure all optionals are accounted for in the map\n if tracker != {}\n # use a special key so we can handle it differently in the filling process\n @optionals_before[:REMAINING] = tracker\n @optionals_before_has_remaining = true\n end\n\n _match_arguments_options_before_matcher\n\n self\n end",
"def find_match_and_decrement_available(line_item)\n gs = Orders::LineItemPresenter.new(line_item).global_sku\n if rii = ReturnInventoryItem.where([\"upc= ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n elsif gs\n #do this check since global skus are jacked up and can't be trusted\n gs = GlobalSku.where(\n style_number: gs.style_number,\n product_name: gs.product_name,\n size: gs.size,\n color_id: gs.color_id,\n customisation_id: gs.customisation_id,\n height_value: gs.height_value,\n product_id: gs.product_id,\n ).first\n\n if rii = ReturnInventoryItem.where([\"upc = ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n end\n end\n rii\n end",
"def line_items_strict\n\t\tline_items.select do |x| \n\t\t\tinventory_units\n\t\t\t\t.uniq { |y| y.variant_id }\n\t\t\t\t.map { |z| z.variant_id }\n\t\t\t\t.include?(x.variant_id)\n\t\tend\n\tend",
"def _match_arguments_options_before_matcher\n # number of arguments that are needed to fill our mandatory argument options\n mandatories_matched = @optionals_before.size\n\n # there are optionals at the end of the options, don't match the void\n if @optionals_before_has_remaining\n mandatories_matched -= 1\n end\n\n total = 0\n\n # loop through optional map\n _each_optional_before_sorted do |before|\n # are there enough arguments left to fill this optional group\n if (total + before.size + mandatories_matched) <= @argument_values.size\n total += before.size\n\n before.each do |val|\n val[:included] = true\n end\n end\n end\n\n self\n end",
"def add_line_item(params)\r\n # Creates line items counter necessary for prefix.\r\n @LINE_ITEMS = 0 if !@LINE_ITEMS \r\n @LINE_ITEMS += 1 # VALUE REQUIRED IN:\r\n prefix = \"LV3_ITEM#{@LINE_ITEMS}_\" # USA | CANADA\r\n @PARAM_HASH[prefix + 'UNIT_COST'] = params[:unit_cost] # * *\r\n @PARAM_HASH[prefix + 'QUANTITY'] = params[:quantity] # * *\r\n @PARAM_HASH[prefix + 'ITEM_SKU'] = params[:item_sku] || '' # *\r\n @PARAM_HASH[prefix + 'ITEM_DESCRIPTOR'] = params[:descriptor] || '' # * *\r\n @PARAM_HASH[prefix + 'COMMODITY_CODE'] = params[:commodity_code] || '' # * *\r\n @PARAM_HASH[prefix + 'PRODUCT_CODE'] = params[:product_code] || '' # * \r\n @PARAM_HASH[prefix + 'MEASURE_UNITS'] = params[:measure_units] || '' # * *\r\n @PARAM_HASH[prefix + 'ITEM_DISCOUNT'] = params[:item_discount] || '' # *\r\n @PARAM_HASH[prefix + 'TAX_RATE'] = params[:tax_rate] || '' # * \r\n @PARAM_HASH[prefix + 'GOODS_TAX_RATE'] = params[:goods_tax_rate] || '' # *\r\n @PARAM_HASH[prefix + 'TAX_AMOUNT'] = params[:tax_amount] || '' # * \r\n @PARAM_HASH[prefix + 'GOODS_TAX_AMOUNT'] = params[:goods_tax_amount] || '' # *\r\n @PARAM_HASH[prefix + 'CITY_TAX_RATE'] = params[:city_tax_rate] || '' #\r\n @PARAM_HASH[prefix + 'CITY_TAX_AMOUNT'] = params[:city_tax_amount] || '' #\r\n @PARAM_HASH[prefix + 'COUNTY_TAX_RATE'] = params[:county_tax_rate] || '' #\r\n @PARAM_HASH[prefix + 'COUNTY_TAX_AMOUNT'] = params[:county_tax_amount] || '' #\r\n @PARAM_HASH[prefix + 'STATE_TAX_RATE'] = params[:state_tax_rate] || '' #\r\n @PARAM_HASH[prefix + 'STATE_TAX_AMOUNT'] = params[:state_tax_amount] || '' #\r\n @PARAM_HASH[prefix + 'CUST_SKU'] = params[:cust_sku] || '' #\r\n @PARAM_HASH[prefix + 'CUST_PO'] = params[:cust_po] || '' #\r\n @PARAM_HASH[prefix + 'SUPPLEMENTAL_DATA'] = params[:supplemental_data] || '' #\r\n @PARAM_HASH[prefix + 'GL_ACCOUNT_NUMBER'] = params[:gl_account_number] || '' #\r\n @PARAM_HASH[prefix + 'DIVISION_NUMBER'] = params[:division_number] || '' #\r\n @PARAM_HASH[prefix + 'PO_LINE_NUMBER'] = params[:po_line_number] || '' #\r\n @PARAM_HASH[prefix + 'LINE_ITEM_TOTAL'] = params[:line_item_total] || '' # * \r\n end",
"def compare_equal?(item, line_item)\n ![\n :ax_account_number,\n :ax_account_id,\n :ax_order_number,\n :ax_order_id,\n :email_address,\n :first_name,\n :last_name,\n :serial_number,\n :purch_order_form_num\n ].detect { |attr| item.send(attr) != line_item.send(attr) }\n end",
"def valid_options\n selected_options.grep_v(/\\Agroup_/)\n end",
"def line_items\n LineItem.where(description: self.descriptions.select(:value))\n end",
"def examine(item)\r\n \r\n end",
"def extractable_options?; true 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 process_options\n \n end",
"def line_item_from( variant_id = nil, options = {} )\n variant_id ? initialize_line_item_with_variant( variant_id, options ) : line_items.build\n end",
"def custom_item_form options\n group_html = \"<li id='#{options[:id]}' class='p'>\"\n group_html += options[:label] ? \"<label for='#{options[:id]}'>#{options[:label]}</label>\" : \"\"\n group_html += \"<div class='wrap-custom-html'>#{options[:html]}</div>\"\n group_html += options[:hint] ? \"<p class='inline-hints'>#{options[:hint]}</p>\" : \"\"\n group_html += \"</li>\"\n group_html.html_safe\n end",
"def test_build_line_items_from_hash\n # Create a new order and put just one line item.\n setup_new_order()\n @o.order_line_items << @li\n \n # Now try to feed it with others.\n @o.line_items = {\n items(:red_lightsaber).id => {'quantity' => 2},\n items(:towel).id => {'quantity' => 1},\n items(:blue_lightsaber).id => {'quantity' => \"\"}\n }\n \n assert_equal @o.items.size, 2\n end",
"def line_item_products\n self.line_items.map(&:sellable).map {|s| s.respond_to?(:product) ? s.product : s}.compact.reject {|p| !p.is_a?(Product)}\n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def process_options\n \n end",
"def set_option(value)\r\n\t\tif value.is_a? Array\r\n\t\t\tvalue.each do |cur_value|\r\n\t\t\t\to_v = OptionValue.find(cur_value)\r\n\t\t\t\tself.line_item_option_values << LineItemOptionValue.new(:option_value => cur_value, :extra_cost => o_v.extra_cost, :extra_weight => o_v.extra_weight)\r\n\t\t\tend\r\n\t\telse\r\n\t\t\to_v = OptionValue.find(value)\r\n\t\t\tself.line_item_option_values << LineItemOptionValue.new(:option_value => value, :extra_cost => o_v.extra_cost, :extra_weight => o_v.extra_weight)\r\n\t\tend\r\n\tend",
"def formated_matches\n @message = []\n @matches.each {|match| @message << menu_item_name(match) }\n ## Another check to see if matches came from rspec just using Fixnums or if it is a real menu\n if @message[0][0].is_a?(Fixnum)\n @message\n else\n @message.join(\"\\n\\n -----------------NEW SUGGESTION----------------------- \\n\\n\")\n end\n end",
"def select_items\n text = input\n case text\n\n when \"Plate.where(color:\\\"white\\\")\", \"Plate.where()\",\n \"Plate.where(:id=>1)\",\"Plate.where(:id=>1)[0]\",\n \"Plate.where({color:\\\"white\\\"})\", \"Plate.where({:id=>1})\", \"Plate.all\"\n\n res = true\n selections.each do |s|\n s.update(selected: true)\n end\n p \"he\"\n\n when \"Plate.where(id:1).first\", \"Plate.where(id:1)[0]\",\n \"Plate.where(:id=>1).first\",\"Plate.where(:id=>1)[0]\",\n \"Plate.where({:id=>1})[0]\", \"Plate.where({:id=>1}).first\",\n \"Plate.find_by(id:1)\", \"Plate.find_by(:id=>1)\", \"Plate.find(1)\"\n\n res = true\n selections.first.update(selected: true)\n when \"Plate.where(id:2).first\", \"Plate.where(id:2)[0]\",\n \"Plate.where(:id=>2).first\",\"Plate.where(:id=>2)[0]\",\n \"Plate.where({:id=>2})[0]\", \"Plate.where({:id=>2}).first\",\n \"Plate.find_by(id:2)\", \"Plate.find_by(:id=>2)\", \"Plate.find(2)\"\n\n res = true\n selections.second.update(selected: true)\n\n when \"Plate.where({:id=>2})\", \"Plate.where(id:2)\", \"Plate.where({:id=>2})\",\n \"Plate.where(id:2)\", \"Plate.where(:id=>2)\"\n\n collection_returned = true\n res = false\n else\n res = false\n end\n\n end",
"def check_line_item_in_inventory(line_item)\n # feature flipper\n if Features.inactive?(:refulfill)\n return true\n end\n found = false\n\n if rii = find_match_and_decrement_available(line_item)\n if line_item.order.shipping_address.country.name == 'United States' && rii.vendor == 'bergen'\n line_item.return_inventory_item = rii\n line_item.refulfill_status = 'new'\n found = true\n line_item.save\n elsif line_item.order.shipping_address.country.name == 'Australia' && rii.vendor == 'next'\n line_item.return_inventory_item = rii\n line_item.refulfill_status = 'new'\n found = true\n line_item.save\n end\n end\n found\n end",
"def validate_options; end",
"def initialize_line_item_with_variant( variant_id, options = {} )\n init_quantity = options[ :quantity ].to_i\n init_quantity = 1 if init_quantity == 0\n \n duplicate_line_item = line_items.where( variant_id: variant_id ).first\n duplicate_line_item.quantity += init_quantity and return duplicate_line_item if duplicate_line_item\n\n line_items.build variant_id: variant_id, quantity: init_quantity\n end",
"def _process_options(options); end",
"def _process_options(options); end",
"def options_with_position(options, position_in); end",
"def add_options; end",
"def alternatives; end",
"def parse_options; end",
"def parse_options; end",
"def test_line_items\n @products = {'1' => {'quantity' => 1} }\n @order.line_items = @products\n # Test adding one line item\n assert_equal @order.order_line_items.length, 1\n assert_equal @order.get_line_item_quantity(1), 1\n # Test adding one line item with a bigger quantity\n @products['1'] = {'quantity' => 2}\n @order.line_items = @products\n # Test some of our other line item methods\n assert_equal @order.has_line_item?(1), true\n assert_equal @order.has_line_item?(2), false\n assert_equal @order.get_line_item_quantity(1), 2\n\t\t# Assert money is correct\n\t\t@soap = Product.find(1)\n\t\tassert_equal @order.get_line_item_total(1), (@soap.price*2)\n\t\t# Is the total correct?\n\t\tassert_equal @order.line_items_total, (@soap.price*2)\n\t\t# Reset all line items\n\t\t@order.line_items = {}\n\t\tassert_equal @order.order_line_items.length, 0\n end",
"def process\n begin\n aux_option = remove_unwanted_chars(@_option)\n\n # unprocessed option list\n option_list = aux_option.split(%r{\\*/|\\];})\n\n option_list.each do |op|\n begin\n if op.to_s.index('=[') != nil\n ntec_option = NtecOption.new\n ntec_option.options = []\n\n # get option name\n ntec_option.name = op[0..op.index('=[')-1].strip\n\n # get unprocessed option\n unprocessed_option = op[op.index('=[')+2..op.length]\n\n # process option\n if (unprocessed_option.to_s.index('],')) == nil\n\n #removes [] if its just like this data=[[zczczxc]];\n unprocessed_option = process_item_list(unprocessed_option)\n\n ntec_option.options.push(unprocessed_option.strip) # return just one item...\n else\n # split option list [A], [b], [C]\n option_items = unprocessed_option.split(%r{\\],})\n\n option_items.each do |item|\n aux_item = item.strip\n\n if aux_item != ''\n processed_item = process_item_list(aux_item)\n ntec_option.options.push(processed_item)\n end\n end\n end\n @ntec_option_list.push(ntec_option)\n end\n\n rescue Exception => e\n puts 'Error processing option: ' + e.message\n end\n end\n\n rescue Exception => e\n throw 'Error processing options: ' + e.message\n end\n end",
"def draw_advanced(rect, item) end",
"def same_as?(l2)\r\n\t\t# comparing self.option_values with l2.option_values _should_ work, but doesn't. If you\r\n\t\t# instead compare the .line_item_option_values, it works...\r\n\t\t#\r\n\t\t# Does this mean has_many :through is a horrible hack? Maybe...\r\n\t\tself.product.id == l2.product.id && self.line_item_option_values == l2.line_item_option_values\r\n\tend",
"def element_options\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 25)\n return_value = ElementOptionsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n char_literal118 = nil\n char_literal120 = nil\n char_literal121 = nil\n char_literal123 = nil\n char_literal125 = nil\n qid119 = nil\n option122 = nil\n option124 = nil\n\n tree_for_char_literal118 = nil\n tree_for_char_literal120 = nil\n tree_for_char_literal121 = nil\n tree_for_char_literal123 = nil\n tree_for_char_literal125 = nil\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__71\")\n stream_T__89 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__89\")\n stream_T__88 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__88\")\n stream_qid = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule qid\")\n stream_option = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule option\")\n begin\n # at line 283:2: ( '<' qid '>' -> ^( OPTIONS qid ) | '<' option ( ';' option )* '>' -> ^( OPTIONS ( option )+ ) )\n alt_59 = 2\n look_59_0 = @input.peek(1)\n\n if (look_59_0 == T__88) \n look_59_1 = @input.peek(2)\n\n if (look_59_1 == TOKEN_REF) \n look_59_2 = @input.peek(3)\n\n if (look_59_2.between?(T__89, T__90)) \n alt_59 = 1\n elsif (look_59_2 == LABEL_ASSIGN) \n alt_59 = 2\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 59, 2)\n raise nvae\n end\n elsif (look_59_1 == RULE_REF) \n look_59_3 = @input.peek(3)\n\n if (look_59_3.between?(T__89, T__90)) \n alt_59 = 1\n elsif (look_59_3 == LABEL_ASSIGN) \n alt_59 = 2\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 59, 3)\n raise nvae\n end\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 59, 1)\n raise nvae\n end\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 59, 0)\n raise nvae\n end\n case alt_59\n when 1\n # at line 283:4: '<' qid '>'\n char_literal118 = match(T__88, TOKENS_FOLLOWING_T__88_IN_element_options_1949) \n if @state.backtracking == 0\n stream_T__88.add(char_literal118)\n end\n @state.following.push(TOKENS_FOLLOWING_qid_IN_element_options_1951)\n qid119 = qid\n @state.following.pop\n if @state.backtracking == 0\n stream_qid.add(qid119.tree)\n end\n char_literal120 = match(T__89, TOKENS_FOLLOWING_T__89_IN_element_options_1953) \n if @state.backtracking == 0\n stream_T__89.add(char_literal120)\n end\n # AST Rewrite\n # elements: qid\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 283:21: -> ^( OPTIONS qid )\n # at line 283:24: ^( OPTIONS qid )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(@adaptor.create_from_type!(OPTIONS, \"OPTIONS\"), root_1)\n\n @adaptor.add_child(root_1, stream_qid.next_tree)\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end\n when 2\n # at line 284:4: '<' option ( ';' option )* '>'\n char_literal121 = match(T__88, TOKENS_FOLLOWING_T__88_IN_element_options_1971) \n if @state.backtracking == 0\n stream_T__88.add(char_literal121)\n end\n @state.following.push(TOKENS_FOLLOWING_option_IN_element_options_1973)\n option122 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add(option122.tree)\n end\n # at line 284:15: ( ';' option )*\n loop do #loop 58\n alt_58 = 2\n look_58_0 = @input.peek(1)\n\n if (look_58_0 == T__71) \n alt_58 = 1\n\n end\n case alt_58\n when 1\n # at line 284:16: ';' option\n char_literal123 = match(T__71, TOKENS_FOLLOWING_T__71_IN_element_options_1976) \n if @state.backtracking == 0\n stream_T__71.add(char_literal123)\n end\n @state.following.push(TOKENS_FOLLOWING_option_IN_element_options_1978)\n option124 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add(option124.tree)\n end\n\n else\n break #loop 58\n end\n end\n char_literal125 = match(T__89, TOKENS_FOLLOWING_T__89_IN_element_options_1982) \n if @state.backtracking == 0\n stream_T__89.add(char_literal125)\n end\n # AST Rewrite\n # elements: option\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 284:33: -> ^( OPTIONS ( option )+ )\n # at line 284:36: ^( OPTIONS ( option )+ )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(@adaptor.create_from_type!(OPTIONS, \"OPTIONS\"), root_1)\n\n # at line 284:46: ( option )+\n unless stream_option.has_next?\n raise ANTLR3::RewriteEarlyExit\n end\n\n while stream_option.has_next?\n @adaptor.add_child(root_1, stream_option.next_tree)\n\n end\n\n stream_option.reset\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 25)\n\n end\n \n return return_value\n end",
"def make_option_list\n end",
"def make_option_list\n end",
"def selected_options; end",
"def selected_options; end",
"def applicable?(line)\n uncolored_line = color.uncolor(line.chomp)\n case selector\n when String\n uncolored_line.include?(selector)\n when Regexp\n selector.match(uncolored_line)\n when Symbol\n SPECIAL_SELECTORS[selector].match(uncolored_line)\n else\n false\n end\n end",
"def option_type; end",
"def order_opts(order, payment_method, stage)\n items = order.line_items.map do |item|\n price = (item.price * 100).to_i # convert for gateway\n { :name => item.variant.product.name,\n :description => (item.variant.product.description[0..120] if item.variant.product.description),\n :sku => item.variant.sku,\n :quantity => item.quantity,\n :amount => price,\n :weight => item.variant.weight,\n :height => item.variant.height,\n :width => item.variant.width,\n :depth => item.variant.weight }\n end\n\n credits = order.adjustments.map do |credit|\n if credit.amount < 0.00\n { :name => credit.label,\n :description => credit.label,\n :sku => credit.id,\n :quantity => 1,\n :amount => (credit.amount*100).to_i }\n end\n end\n\n credits_total = 0\n credits.compact!\n if credits.present?\n items.concat credits\n credits_total = credits.map {|i| i[:amount] * i[:quantity] }.sum\n end\n\n if params[:host_with_port].nil?\n params[:host_with_port] = request.host_with_port\n end\n\n opts = { :return_url => request.protocol + params[:host_with_port] + \"/confirm/\" + \"orders/#{order.number}/checkout/paypal_confirm?payment_method_id=#{payment_method}\",\n :cancel_return_url => request.protocol + params[:host_with_port] + \"/\" + \"orders/#{order.number}/edit\",\n :order_id => order.number,\n :custom => order.number,\n :items => items,\n :subtotal => ((order.item_total * 100) + credits_total).to_i,\n :tax => ((order.adjustments.map { |a| a.amount if ( a.source_type == 'Order' && a.label == 'Tax') }.compact.sum) * 100 ).to_i,\n :shipping => ((order.adjustments.map { |a| a.amount if a.source_type == 'Shipment' }.compact.sum) * 100 ).to_i,\n :money => (order.total * 100 ).to_i }\n\n # add correct tax amount by subtracting subtotal and shipping otherwise tax = 0 -> need to check adjustments.map\n opts[:tax] = (order.total*100).to_i - opts.slice(:subtotal, :shipping).values.sum\n\n if stage == \"checkout\"\n opts[:handling] = 0\n\n opts[:callback_url] = spree_root_url + \"paypal_express_callbacks/#{order.number}\"\n opts[:callback_timeout] = 3\n elsif stage == \"payment\"\n #hack to add float rounding difference in as handling fee - prevents PayPal from rejecting orders\n #because the integer totals are different from the float based total. This is temporary and will be\n #removed once Spree's currency values are persisted as integers (normally only 1c)\n opts[:handling] = (order.total*100).to_i - opts.slice(:subtotal, :tax, :shipping).values.sum\n end\n\n opts\n end",
"def test_show_if_has_line_item\n assert_equal @order.has_line_item?(@order.order_line_items.find_by_name(items(:towel).name).id), true\n\n # Create a new order and put just one line item.\n new_order_line_item = OrderLineItem.for_product(items(:small_stuff))\n new_order = Order.new\n new_order.order_line_items << new_order_line_item\n assert new_order.save\n \n # Search for an existent line item of ANOTHER order.\n assert_equal @order.has_line_item?(new_order.order_line_items.find_by_name(items(:small_stuff).name).id), false\n end",
"def element_options\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n return_value = ElementOptionsReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n char_literal118 = nil\n char_literal120 = nil\n char_literal121 = nil\n char_literal123 = nil\n char_literal125 = nil\n qid119 = nil\n option122 = nil\n option124 = nil\n\n tree_for_char_literal118 = nil\n tree_for_char_literal120 = nil\n tree_for_char_literal121 = nil\n tree_for_char_literal123 = nil\n tree_for_char_literal125 = nil\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__71\" )\n stream_T__89 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__89\" )\n stream_T__88 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__88\" )\n stream_qid = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule qid\" )\n stream_option = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule option\" )\n begin\n # at line 274:2: ( '<' qid '>' -> ^( OPTIONS qid ) | '<' option ( ';' option )* '>' -> ^( OPTIONS ( option )+ ) )\n alt_59 = 2\n look_59_0 = @input.peek( 1 )\n\n if ( look_59_0 == T__88 )\n look_59_1 = @input.peek( 2 )\n\n if ( look_59_1 == TOKEN_REF )\n look_59_2 = @input.peek( 3 )\n\n if ( look_59_2.between?( T__89, T__90 ) )\n alt_59 = 1\n elsif ( look_59_2 == LABEL_ASSIGN )\n alt_59 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 59, 2 )\n end\n elsif ( look_59_1 == RULE_REF )\n look_59_3 = @input.peek( 3 )\n\n if ( look_59_3.between?( T__89, T__90 ) )\n alt_59 = 1\n elsif ( look_59_3 == LABEL_ASSIGN )\n alt_59 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 59, 3 )\n end\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 59, 1 )\n end\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 59, 0 )\n end\n case alt_59\n when 1\n # at line 274:4: '<' qid '>'\n char_literal118 = match( T__88, TOKENS_FOLLOWING_T__88_IN_element_options_1944 )\n if @state.backtracking == 0\n stream_T__88.add( char_literal118 )\n end\n @state.following.push( TOKENS_FOLLOWING_qid_IN_element_options_1946 )\n qid119 = qid\n @state.following.pop\n if @state.backtracking == 0\n stream_qid.add( qid119.tree )\n end\n char_literal120 = match( T__89, TOKENS_FOLLOWING_T__89_IN_element_options_1948 )\n if @state.backtracking == 0\n stream_T__89.add( char_literal120 )\n end\n # AST Rewrite\n # elements: qid\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 274:21: -> ^( OPTIONS qid )\n # at line 274:24: ^( OPTIONS qid )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( @adaptor.create_from_type( OPTIONS, \"OPTIONS\" ), root_1 )\n\n @adaptor.add_child( root_1, stream_qid.next_tree )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n when 2\n # at line 275:4: '<' option ( ';' option )* '>'\n char_literal121 = match( T__88, TOKENS_FOLLOWING_T__88_IN_element_options_1966 )\n if @state.backtracking == 0\n stream_T__88.add( char_literal121 )\n end\n @state.following.push( TOKENS_FOLLOWING_option_IN_element_options_1968 )\n option122 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add( option122.tree )\n end\n # at line 275:15: ( ';' option )*\n while true # decision 58\n alt_58 = 2\n look_58_0 = @input.peek( 1 )\n\n if ( look_58_0 == T__71 )\n alt_58 = 1\n\n end\n case alt_58\n when 1\n # at line 275:16: ';' option\n char_literal123 = match( T__71, TOKENS_FOLLOWING_T__71_IN_element_options_1971 )\n if @state.backtracking == 0\n stream_T__71.add( char_literal123 )\n end\n @state.following.push( TOKENS_FOLLOWING_option_IN_element_options_1973 )\n option124 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add( option124.tree )\n end\n\n else\n break # out of loop for decision 58\n end\n end # loop for decision 58\n char_literal125 = match( T__89, TOKENS_FOLLOWING_T__89_IN_element_options_1977 )\n if @state.backtracking == 0\n stream_T__89.add( char_literal125 )\n end\n # AST Rewrite\n # elements: option\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 275:33: -> ^( OPTIONS ( option )+ )\n # at line 275:36: ^( OPTIONS ( option )+ )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( @adaptor.create_from_type( OPTIONS, \"OPTIONS\" ), root_1 )\n\n # at line 275:46: ( option )+\n stream_option.has_next? or raise ANTLR3::RewriteEarlyExit\n\n while stream_option.has_next?\n @adaptor.add_child( root_1, stream_option.next_tree )\n\n end\n stream_option.reset\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n end\n \n return return_value\n end",
"def variant_options(v, options={})\n #content_tag(:ul, :class => \"list\")\n # v.options_text\n #we have hide additional price shown in varians\n # if variant_price v\n # v.options_text.to_s + \" \" + (variant_price v).to_s\n # else\n v.options_text\n # end\n end",
"def get_licence_step1_per_item\n a = @dc[:description] + @dc[:rights]\n a.each{|desc|\n # It is important to test for abbreviations in the correct order\n # (as per the LICENCE_KEYS array).\n LICENCE_KEYS.each{|k| return k.to_s.upcase.gsub(\"_\", \"-\") if\n desc.match(LICENCE_ABBR_REGEX_LIST[k]) || desc.match(LICENCE_URL_REGEX_LIST[k])}\n }\n nil\n end",
"def options(opt); end",
"def options(opt); end",
"def include_line_items?\n scope && scope[:include_line_items]\n end",
"def trinket_item?(options)\n options[:slot] == 'trinket'\n end",
"def extra_item?\n false\n end",
"def order_opts(order)\n items = order.line_items.map do |item|\n tax = paypal_variant_tax(item.price, item.variant)\n price = (item.price * 100).to_i # convert for gateway\n tax = (tax * 100).to_i # truncate the tax slice\n { :name => item.variant.product.name,\n :description => item.variant.product.description[0..120],\n :sku => item.variant.sku,\n :qty => item.quantity, \n :amount => price - tax, \n :tax => tax,\n :weight => item.variant.weight,\n :height => item.variant.height,\n :width => item.variant.width,\n :depth => item.variant.weight }\n end\n\n opts = { :return_url => request.protocol + request.host_with_port + \"/orders/#{order.number}/paypal_finish\",\n :cancel_return_url => \"http://\" + request.host_with_port + \"/orders/#{order.number}/edit\",\n :order_id => order.number,\n :custom => order.number,\n\n :items => items,\n }\n opts\n end",
"def test_truth\n assert_kind_of LineItem, line_items(:first)\n end",
"def draw_advanced(rect, item)\n end",
"def item_quality_decreases_with_age?(item)\r\n !item_matcher?(item, 'Aged Brie') && !item_matcher?(item, 'Backstage passes to a TAFKAL80ETC concert')\r\n end",
"def update_line(line_text)\n updated_line_text = line_text\n # replace outlook list format with textile list format:\n updated_line_text.gsub!(/^[\\u00b7] /,\"* \") # middot - middle dot\n updated_line_text.gsub!(/^[\\u2022] /,\"* \") # bull - bullet\n updated_line_text.gsub!(/^o /,\"** \") # second level bullet\n updated_line_text.gsub!(/^[\\u00A7] /,\"*** \") # 3rd level bullet (section entity)\n \n updated_line_text.gsub!(/^[0-9]+\\. /, \"# \")\n \n updated_line_text\n end",
"def options\n self.items\n itemsArr = @items.keys\n @options = []\n for i in 1..(items.length) do\n @options = @options + itemsArr.combination(i).to_a\n end\n @options\n end",
"def option_tag(text); end",
"def item_paths_match?(item)\n if item[:paths]\n\n item[:paths].each do |path|\n if path.kind_of?(Array)\n # IF path matches perfectly\n request_type_option = path[1] || \"\"\n if ((@current_path == path[0].chomp('/') and @request_type == request_type_option.downcase) or \n # OR IF * wildcard is used and path matches\n (path[0] =~ /\\*$/ and @current_path =~ /^#{path[0].chomp('*')}(.+)?$/)) and \n # all listed request params match\n params_match?(path)\n return true \n end\n else\n return true if @current_path == path\n end\n end\n\n end\n return false\n end",
"def set_item_options user_options\n puts \"========= Setting product options\"\n @b.div(id: \"j-product-info-sku\").dls.each_with_index do |option, index|\n selected = user_options[index]\n if selected.nil?\n option.a.click\n else\n option.as[selected-1].click\n end\n end\n end",
"def line_item_label\n $tracer.trace(__method__)\n #unit_test_no_generate: line_item_label, tr.className(create_ats_regex_string(\"ats-lineitemrow\"))\n return ToolTag.new(tr.className(create_ats_regex_string(\"ats-lineitemrow\")), __method__, self)\n end",
"def line_items_for_compute(order, options={})\n if calculable.is_a?(Spree::Promotion)\n line_items = if calculable.product\n order.line_items.joins(:variant).where(:variants => {product_id: calculable.product})\n elsif calculable.store\n order.line_items.where(:store_id => calculable.store)\n else\n order.line_items\n end\n \n if self.is_a?(Spree::Calculator::FreeShipping)\n puts \"free shipping\"\n line_items\n else\n puts \"not free shipping\"\n line_items.order('spree_line_items.price DESC').not_on_sale\n end\n else\n puts \"all line items\"\n order.line_items\n end\n end",
"def parse_additional_options(opts)\n end",
"def parse_additional_options(opts)\n end",
"def options_spec\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 7)\n return_value = OptionsSpecReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n __OPTIONS28__ = nil\n char_literal30 = nil\n char_literal31 = nil\n option29 = nil\n\n tree_for_OPTIONS28 = nil\n tree_for_char_literal30 = nil\n tree_for_char_literal31 = nil\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__71\")\n stream_T__72 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__72\")\n stream_OPTIONS = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token OPTIONS\")\n stream_option = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule option\")\n begin\n # at line 140:4: OPTIONS ( option ';' )+ '}'\n __OPTIONS28__ = match(OPTIONS, TOKENS_FOLLOWING_OPTIONS_IN_options_spec_659) \n if @state.backtracking == 0\n stream_OPTIONS.add(__OPTIONS28__)\n end\n # at file 140:12: ( option ';' )+\n match_count_13 = 0\n loop do\n alt_13 = 2\n look_13_0 = @input.peek(1)\n\n if (look_13_0 == TOKEN_REF || look_13_0 == RULE_REF) \n alt_13 = 1\n\n end\n case alt_13\n when 1\n # at line 140:13: option ';'\n @state.following.push(TOKENS_FOLLOWING_option_IN_options_spec_662)\n option29 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add(option29.tree)\n end\n char_literal30 = match(T__71, TOKENS_FOLLOWING_T__71_IN_options_spec_664) \n if @state.backtracking == 0\n stream_T__71.add(char_literal30)\n end\n\n else\n match_count_13 > 0 and break\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n\n eee = EarlyExit(13)\n\n\n raise eee\n end\n match_count_13 += 1\n end\n\n char_literal31 = match(T__72, TOKENS_FOLLOWING_T__72_IN_options_spec_668) \n if @state.backtracking == 0\n stream_T__72.add(char_literal31)\n end\n # AST Rewrite\n # elements: OPTIONS, option\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 140:30: -> ^( OPTIONS ( option )+ )\n # at line 140:33: ^( OPTIONS ( option )+ )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_OPTIONS.next_node, root_1)\n\n # at line 140:43: ( option )+\n unless stream_option.has_next?\n raise ANTLR3::RewriteEarlyExit\n end\n\n while stream_option.has_next?\n @adaptor.add_child(root_1, stream_option.next_tree)\n\n end\n\n stream_option.reset\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 7)\n\n end\n \n return return_value\n end",
"def load_raw_line opts = OPTS_REGEX.keys\n self.raw_line.chomp!\n opts.each do |xfield|\n pattern = OPTS_REGEX[xfield]\n did_set = raw_setter xfield, pattern\n #puts did_set\n end\n end",
"def contains?(variant, options = {})\n find_line_item_by_variant(variant, options).present?\n end",
"def line_item(item)\n {\n Name: item.product.name,\n Number: item.variant.sku,\n Quantity: item.quantity,\n Amount: {\n currencyID: item.order.currency,\n value: item.price\n },\n ItemCategory: 'Physical'\n }\n end",
"def dummy_line_item\n li = LineItemBuilder.new([self]).spree_line_items.first\n return unless li\n\n li.order = dummy_order\n li.validate\n li.freeze\n end",
"def test_add_option03d\n assert_nothing_raised( Exception ) {\n ArgumentManager.add_option(\n [ 'l' ],\n :type => :integer,\n :mandatory => true\n )\n }\n end",
"def test_parse04a\n ArgumentManager.add_option([ 'u-opt' ], :type => :string, :mandatory => true, :df_str => 'foo' )\n \n assert_raise( RuntimeError ) {\n options = ArgumentManager.parse( [] )\n }\n end",
"def select options\n # Count through current choice in layer\n # 0=method, 1=argument set, 2..=mock decisions\n index = @index\n @index += 1\n\n if not @layer[index]\n # Add other options to queue\n (1...options.length).each do |idx|\n new_layer = @layer.clone\n new_layer << idx\n new_item = @item.clone\n new_item[-1] = new_layer\n @queue.unshift(new_item)\n end\n @layer << 0\n end\n\n options[@layer[index]]\n end",
"def has_line_items?\n line_items.any?\n end",
"def test_match_variant\n parser = CEdictParser.new(Rails.root.join(\"data/cedict/test_data/cedict_parser_match_variant_only.txt\").to_s)\n entries = parser.run\n assert_equal(13,entries.count)\n assert_equal(1,parser.variant_only_entries.count)\n assert_equal(1,parser.variant_entries.count)\n end",
"def process_items(items)\n if items\n\n # We begin here with no IPs set. This is used to determin if we are\n # setting the primary address, or simply providing an alias to an\n # already existing interface.\n ipset = false\n ip6set = false\n\n # Process each one of the line items\n items.each do |i|\n # Return the dynamic address assignemnt if found\n if i =~ %r{^(dhcp|inet6 autoconf)$}\n yield i\n # yield up/down if found\n elsif i =~ %r{^(up|down)$}\n yield i\n # Yield the command string in full\n elsif i =~ %r{^!}\n yield i\n else\n begin\n ip = IPAddress i\n if ip.ipv6?\n line = ['inet6']\n line << 'alias' if ip6set\n line << ip.compressed\n line << ip.prefix\n ip6set = true\n elsif ip.ipv4?\n line = ['inet']\n line << 'alias' if ipset\n line << ip.address\n line << ip.netmask\n line << 'NONE'\n ipset = true\n end\n if line\n yield line.join(' ')\n else\n puts line\n puts 'line not found'\n end\n rescue ArgumentError\n # In the case we have received something we don't know how to\n # handle, and is not an IP address as caught here in the else, then\n # we just send it back unmodified.\n yield i\n end\n end\n end\n end\n end",
"def accept_list_item_end list_item\n end",
"def test_items()\n @items.select do |i|\n i.identifier =~ test_re\n end\n end",
"def get_options\n if parts = @text.match(/([\\d]*) (.*)/)\n return parts[1].strip, parts[2].split(\",\").map(&:strip)\n end\n end",
"def get_options; end",
"def test_add_option04b\n assert_nothing_raised {\n ArgumentManager.add_option(\n [ 't' ],\n :type => :string\n )\n }\n end",
"def process_line(line)\n # skip current line unless in correct format:\n # all restaurant IDs are integers, all item names are lower case letters and underscores,\n # and the price is a decimal number, all separated by commas with any surrounding whitespace\n return unless line =~ /^\\d+\\s*,\\s*\\d+\\.\\d{2}\\s*,\\s*([a-z_]+\\s*,\\s*)*[a-z_]+$/\n entry_items = line.gsub(/\\s+/,'').split(',')\n\n restaurant_id = entry_items.shift\n entry_price = entry_items.shift\n\n encoded_entry = encode_entry(entry_items)\n return unless encoded_entry > 0 #if encoded_entry equals 0 then no items matched the desired so why bother\n\n update_min_entry_price(restaurant_id, entry_price, encoded_entry)\n end",
"def options_spec\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n return_value = OptionsSpecReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n __OPTIONS28__ = nil\n char_literal30 = nil\n char_literal31 = nil\n option29 = nil\n\n tree_for_OPTIONS28 = nil\n tree_for_char_literal30 = nil\n tree_for_char_literal31 = nil\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__71\" )\n stream_T__72 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__72\" )\n stream_OPTIONS = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token OPTIONS\" )\n stream_option = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule option\" )\n begin\n # at line 131:4: OPTIONS ( option ';' )+ '}'\n __OPTIONS28__ = match( OPTIONS, TOKENS_FOLLOWING_OPTIONS_IN_options_spec_654 )\n if @state.backtracking == 0\n stream_OPTIONS.add( __OPTIONS28__ )\n end\n # at file 131:12: ( option ';' )+\n match_count_13 = 0\n while true\n alt_13 = 2\n look_13_0 = @input.peek( 1 )\n\n if ( look_13_0 == TOKEN_REF || look_13_0 == RULE_REF )\n alt_13 = 1\n\n end\n case alt_13\n when 1\n # at line 131:13: option ';'\n @state.following.push( TOKENS_FOLLOWING_option_IN_options_spec_657 )\n option29 = option\n @state.following.pop\n if @state.backtracking == 0\n stream_option.add( option29.tree )\n end\n char_literal30 = match( T__71, TOKENS_FOLLOWING_T__71_IN_options_spec_659 )\n if @state.backtracking == 0\n stream_T__71.add( char_literal30 )\n end\n\n else\n match_count_13 > 0 and break\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n eee = EarlyExit(13)\n\n\n raise eee\n end\n match_count_13 += 1\n end\n\n char_literal31 = match( T__72, TOKENS_FOLLOWING_T__72_IN_options_spec_663 )\n if @state.backtracking == 0\n stream_T__72.add( char_literal31 )\n end\n # AST Rewrite\n # elements: OPTIONS, option\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 131:30: -> ^( OPTIONS ( option )+ )\n # at line 131:33: ^( OPTIONS ( option )+ )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_OPTIONS.next_node, root_1 )\n\n # at line 131:43: ( option )+\n stream_option.has_next? or raise ANTLR3::RewriteEarlyExit\n\n while stream_option.has_next?\n @adaptor.add_child( root_1, stream_option.next_tree )\n\n end\n stream_option.reset\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 7 )\n\n end\n \n return return_value\n end"
] | [
"0.6987668",
"0.6207636",
"0.590106",
"0.5772114",
"0.5678291",
"0.56076723",
"0.5562139",
"0.54378706",
"0.54196066",
"0.5405235",
"0.53974706",
"0.5396856",
"0.53934205",
"0.53560835",
"0.53523767",
"0.534459",
"0.532823",
"0.5300918",
"0.5289832",
"0.5265834",
"0.52484924",
"0.5244487",
"0.5243681",
"0.5242681",
"0.523211",
"0.52230746",
"0.52177674",
"0.52126235",
"0.52059394",
"0.51811576",
"0.5161019",
"0.51455295",
"0.51369864",
"0.51369864",
"0.51369864",
"0.51124704",
"0.50852025",
"0.5069355",
"0.5063275",
"0.5053326",
"0.5048702",
"0.50455415",
"0.50455415",
"0.50292313",
"0.5016483",
"0.5003543",
"0.49957275",
"0.49957275",
"0.49930435",
"0.49894184",
"0.49887183",
"0.49846575",
"0.49801457",
"0.4978177",
"0.4978177",
"0.4975274",
"0.4975274",
"0.49694914",
"0.49631",
"0.49489465",
"0.49384034",
"0.49339297",
"0.49309835",
"0.49302578",
"0.4927931",
"0.49263173",
"0.49210352",
"0.492074",
"0.4916549",
"0.49165317",
"0.49080825",
"0.49032414",
"0.48869178",
"0.48848575",
"0.48837042",
"0.48766315",
"0.48747787",
"0.48659632",
"0.48659348",
"0.4863382",
"0.48600715",
"0.48600715",
"0.4852293",
"0.4847635",
"0.48468256",
"0.4845407",
"0.4838492",
"0.48357558",
"0.4834111",
"0.4831638",
"0.48279002",
"0.4827167",
"0.48246795",
"0.48237658",
"0.48160517",
"0.4815068",
"0.48111007",
"0.48075595",
"0.4801587",
"0.48010117"
] | 0.59335464 | 2 |
produces a list of [customizable_product_option.id,value] pairs for subsequent comparison def customization_pairs(product_customizations) pairs= product_customizations.map(&:customized_product_options).flatten.map do |m| [m.customizable_product_option.id, m.value.present? ? m.value : m.customization_image.to_s ] end Set.new pairs end | def destroy_or_save(line_item, line_item_quantity)
line_item_quantity.zero? ? line_item.destroy! : line_item.save!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customization_pairs(product_customizations)\n pairs = product_customizations.map(&:customized_product_options).flatten.map do |m|\n [m.customizable_product_option.id, m.value.present? ? m.value : m.customization_image.to_s ]\n end\n\n Set.new pairs\n end",
"def customization_pairs(product_customizations)\n pairs= product_customizations.map(&:customized_product_options).flatten.map do |m|\n [m.customizable_product_option.id, m.value.present? ? m.value : m.customization_image.to_s ]\n end\n\n Set.new pairs\n end",
"def get_variants_by_color(products)\n variants = []\n\n products.each do |product|\n optionType = product.option_types.select { |type| type.presentation == \"Color\" }\n optionTypeId = optionType.length > 0 ? optionType.first.id : nil\n colors = []\n\n if optionTypeId\n product.variants.each do |var|\n var.option_values.each do |opt|\n if opt.option_type_id == optionTypeId\n unless colors.include?(opt.presentation)\n isFeatured = product.property(\"featured\") && (product.property(\"featured\") == opt.presentation) ? 1 : 0\n featuredImage = nil\n mainImage = nil\n\n var.images.each do |image|\n if image.alt == \"featured\"\n featuredImage = image\n else\n mainImage = image\n end\n end\n\n if mainImage.nil?\n mainImage = var.images[0]\n end\n\n if featuredImage.nil?\n featuredImage = isFeatured ? var.images[1] : nil\n end\n\n variant = {\n \"name\" => var.name,\n \"color\" => opt.presentation,\n \"price\" => var.price,\n \"image\" => mainImage,\n \"isFeatured\" => isFeatured,\n \"featuredImage\" => featuredImage,\n \"object\" => var\n }\n\n # move the featured variant to the beginning of the array\n if (isFeatured > 0)\n variants.unshift(variant)\n else\n variants.push(variant)\n end\n \n colors.push(opt.presentation)\n end\n end\n end\n end\n else\n isFeatured = product.property(\"featured\") ? 1 : 0\n variant = {\n \"name\" => product.name,\n \"color\" => nil,\n \"price\" => product.price,\n \"image\" => product.variants[0].images[0],\n \"isFeatured\" => isFeatured,\n \"featuredImage\" => isFeatured ? product.variants[0].images[1] || nil : nil,\n \"object\" => product\n }\n variants.push(variant)\n end\n end\n\n variants\n end",
"def option_types_version_ids(product_id:)\n if status[:option_types_and_values]\n status[:option_types_and_values].collect do |item|\n item[:option_type_version_id] if item[:product_id] == product_id\n end.compact\n else\n []\n end\n end",
"def product_property_and_property_version_ids(product_id:)\n if status[:product_properties]\n version_ids = status[:product_properties].collect do |item|\n item.select {|key, value| key.match /_version_id$/} if item[:product_id] == product_id\n end.compact\n\n version_ids\n else\n []\n end\n end",
"def product_colors(product)\n return product.color.split(',').map(&:to_s)\n end",
"def options_hash\n the_hash = self.product_id.to_s + self.is_discount.to_s\n \n self.options.order(:option_group_id).each do |o|\n the_hash += \"#{o.option_group_id}#{o.value}#{o.price}\"\n end\n \n the_hash\n end",
"def product_info\n {\n product_name: {\n default_value: 'similarity detection reference tool'\n },\n product_version: '1.0',\n description: {\n default_value: 'LTI 2.1 tool provider reference implementation'\n },\n product_family: {\n code: 'similarity detection reference tool',\n vendor: {\n code: 'Instructure.com',\n vendor_name: {\n default_value: 'Instructure'\n },\n description: {\n default_value: 'Canvas Learning Management System'\n }\n }\n }\n }\n end",
"def get_variant_properties_from_product\n vpv = []\n self.variant_variant_property_values.each do |vvpv|\n if !vvpv.variant_property_value.nil?\n vpv << vvpv.variant_property_value.variant_property_id\n end\n end\n self.product.variant_properties.each do |vp|\n self.variant_variant_property_values.build(:variant_property_value => vp.variant_property_values.first) unless vpv.include?(vp.id)#self.variant_variant_property_values.map(&:variant_property_value_id).include?(vp.variant_property_values.first.id)\n end\n end",
"def product_properties_version_ids(product_id:)\n if status[:product_properties]\n status[:product_properties].collect do |item|\n item[:product_property_version_id] if item[:product_id] == product_id\n end.compact\n else\n []\n end\n end",
"def comparisons_ids_with_descriptions(comparisons)\n selected_ids = comparisons.select { |comparison| comparison.description.present? }.collect(&:id)\n\n { comparisonsIdsWithDescription: selected_ids }\n end",
"def products_brands(products)\n products.map{|product| product['brand']}.uniq\nend",
"def alternatives\n self.product_suggestions.collect{|ps| ps.suggested_product}\n end",
"def build_option_types(option_types)\n\n optiontype_vlist_map = {}\n\n option_types.each do |ostr|\n\n oname, value_str = ostr.split(name_value_delim)\n\n option_type = option_type_klass.where(:name => oname).first\n\n unless option_type\n option_type = option_type_klass.create(:name => oname, :presentation => oname.humanize)\n\n unless option_type\n logger.warm(\"WARNING: OptionType #{oname} NOT found and could not create - Not set Product\")\n next\n end\n logger.info \"Created missing OptionType #{option_type.inspect}\"\n end\n\n # OptionTypes must be specified first on Product to enable Variants to be created\n product_load_object.option_types << option_type unless product_load_object.option_types.include?(option_type)\n\n # Can be simply list of OptionTypes, some or all without values\n next unless(value_str)\n\n optiontype_vlist_map[option_type] ||= []\n\n # Now get the value(s) for the option e.g red,blue,green for OptType 'colour'\n optiontype_vlist_map[option_type] += value_str.split(',').flatten\n end\n\n\n # A single Variant can have MULTIPLE Option Types and the Syntax supports this combining\n #\n # So we need the LONGEST set of OptionValues - to use as the BASE for combining with the rest\n #\n # mime_type:png,PDF; print_type:colour\n #\n # This means create 2 Variants\n # 1 mime_type:png && print_type:colour\n # 1 mime_type:PDF && print_type:colour\n #\n # And we want to identify this \"mime_type:png,PDF\" as the longest to combine with the smaller print_type list\n\n sorted_map = optiontype_vlist_map.sort_by { |ot, ov| ov.size }.reverse\n\n sorted_map\n\n end",
"def variant_combinations\n combinations = []\n 0.upto(2 ** FIELD_VARIANTS.length - 1) do |b|\n combinations << combination = []\n FIELD_VARIANTS.each_with_index do |variant, i|\n combination << variant if b & 1<<i > 0\n end\n end\n combinations\n end",
"def properties_version_ids(product_id:)\n if status[:product_properties]\n status[:product_properties].collect do |item|\n item[:property_version_id] if item[:product_id] == product_id\n end.compact\n else\n []\n end\n end",
"def products\n @product_map.keys\n end",
"def compare(base_data, external_data)\n external_data[:product].each do |ex_prd|\n base_prd_id = base_data[:product_matched][ex_prd[:id]]\n changed = nil\n\n if base_prd_id\n # Product exists\n base_prd = base_data[:product].find {|p| p[:id] == base_prd_id }\n changed = field_compare(base_prd, ex_prd, base_data[:category_matched])\n @result[:update] << changed if changed\n else\n # Product is new\n changed = ex_prd.dup\n @result[:new] << changed\n end\n\n next unless changed\n # Product Special Rules\n has_dummy_variant = ex_prd[:variants].any? {|v| v[:option_values].empty? }\n changed.delete(:variants) if has_dummy_variant\n changed[:ex_options] = ex_prd[:variants].map {|i| [i[:sku], i[:option_values].first[:label]] }.to_h if changed[:variants]\n changed[:categories] = external_data[:category].find {|c| c[:id] == changed[:categories] }&.dig(:name)\n changed[:inventory_tracking] = if ex_prd[:variants].all? {|i| i[:inventory_level].nil? }\n 'none'\n elsif ex_prd[:variants].size == 1\n 'product'\n else\n 'variant'\n end\n changed[:inventory_level] = 0\n changed[:inventory_level] = ex_prd[:variants].first[:inventory_level] if changed[:inventory_tracking] == 'product'\n end\n @result[:update].each {|i| clean_fields(i) }\n @result\n end",
"def compute_matching_product(among_products) among_products.select { |product| concern?(product, among_products) } end",
"def reqd_params_only_result\n combinations = []\n reqd_params = get_reqd_params_and_values\n # logger.info \"===============\"+reqd_params.to_s\n reqd_params.each do |k, v|\n if(!v.nil? || k.empty?) \n v.each do |i|\n v[v.index(i)] = k.to_s + \"=\" + v[v.index(i)]\n end\n end \n combinations << v\n end\n # @combinations = @combinations.first.product(*@combinations[1..-1]).map(&:join)\n variations(combinations) unless !combinations\nend",
"def real_variants\n Product.where(openerp_id: product_variants.collect(&:openerpid)).order('id ASC').uniq\n end",
"def mixed_combinations\n combination_generator.mixed_combinations\n end",
"def add_options_variants\n # TODO smart column ordering to ensure always valid by time we get to associations\n begin\n save_if_new\n rescue => e\n raise ProductLoadError.new(\"Cannot add OptionTypes/Variants - Save failed on parent Product\")\n end\n # example : mime_type:jpeg;print_type:black_white|mime_type:jpeg|mime_type:png, PDF;print_type:colour\n\n variants = get_each_assoc\n\n logger.info \"add_options_variants #{variants.inspect}\"\n\n # example line becomes :\n # 1) mime_type:jpeg|print_type:black_white\n # 2) mime_type:jpeg\n # 3) mime_type:png, PDF|print_type:colour\n\n variants.each do |per_variant|\n option_types = per_variant.split(Delimiters::multi_facet_delim) # => [mime_type:jpeg, print_type:black_white]\n optiontype_vlist_map = {}\n\n option_types.each do |ostr|\n\n oname, value_str = ostr.split(Delimiters::name_value_delim)\n\n option_type = @@option_type_klass.where(:name => oname).first\n\n unless option_type\n option_type = @@option_type_klass.create( :name => oname, :presentation => oname.humanize)\n # TODO - dynamic creation should be an option\n\n unless option_type\n puts \"WARNING: OptionType #{oname} NOT found and could not create - Not set Product\"\n next\n end\n puts \"Created missing OptionType #{option_type.inspect}\"\n end\n\n # OptionTypes must be specified first on Product to enable Variants to be created\n # TODO - is include? very inefficient ??\n @product.option_types << option_type unless @product.option_types.include?(option_type)\n\n # Can be simply list of OptionTypes, some or all without values\n next unless(value_str)\n\n optiontype_vlist_map[option_type] = []\n\n # Now get the value(s) for the option e.g red,blue,green for OptType 'colour'\n optiontype_vlist_map[option_type] = value_str.split(',')\n end\n next if(optiontype_vlist_map.empty?) # only option types specified - no values\n # Now create set of Variants, some of which maybe composites\n # Find the longest set of OVs to use as base for combining with the rest\n sorted_map = optiontype_vlist_map.sort_by { |k,v| v.size }.reverse\n # [ [mime, ['pdf', 'jpeg', 'gif']], [print_type, ['black_white']] ]\n lead_option_type, lead_ovalues = sorted_map.shift\n lead_ovalues.each do |ovname|\n ov_list = []\n ovname.strip!\n ov = @@option_value_klass.find_or_create_by_name_and_option_type_id(ovname, lead_option_type.id, :presentation => ovname.humanize)\n ov_list << ov if ov\n\n # Process rest of array of types => values\n sorted_map.each do |ot, ovlist|\n ovlist.each do |for_composite|\n for_composite.strip!\n ov = @@option_value_klass.find_or_create_by_name_and_option_type_id(for_composite, ot.id, :presentation => for_composite.humanize)\n ov_list << ov if(ov)\n end\n end\n\n unless(ov_list.empty?)\n puts \"Creating Variant from OptionValue(s) #{ov_list.collect(&:name).inspect}\"\n i = @product.variants.size + 1\n variant = @product.variants.create sku: \"#{@product.sku}_#{i}\",\n price: @product.price,\n weight: @product.weight,\n height: @product.height,\n width: @product.width,\n depth: @product.depth\n variant.option_values << ov_list if variant\n puts \"Created #{variant.class} : #{variant.inspect}\" if verbose\n end\n end\n end\n end",
"def combos\n self.option_prices\n combinations = @option_prices.select{|k,v| v == to_cents(@budget)}.keys\n unless combinations.empty? then combinations else \"No exact price matches\" end\n end",
"def available_values(product = nil)\r\n\t\tif !product.nil?\r\n\t\t\tpo = ProductOption.find(:first, :conditions => [ 'product_id = ? AND option_id = ?', product.id, self.id ])\r\n\t\t\tif po.nil? or po.values.nil?\r\n\t\t\t\tvalues\r\n\t\t\telse\r\n\t\t\t\tpo.values.collect { |x| values.find(x) }\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tvalues\r\n\t\tend\r\n\tend",
"def available_values(product = nil)\r\n\t\tif !product.nil?\r\n\t\t\tpo = ProductOption.find(:first, :conditions => [ 'product_id = ? AND option_id = ?', product.id, self.id ])\r\n\t\t\tif po.nil? or po.values.nil?\r\n\t\t\t\tvalues\r\n\t\t\telse\r\n\t\t\t\tpo.values.collect { |x| values.find(x) }\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tvalues\r\n\t\tend\r\n\tend",
"def created_product_options\n product_options.select {|o| !o.new_record? }\n end",
"def available_values(product = nil)\r\n\t\t\tif !product.nil?\r\n\t\t\t\tpo = ProductOption.find(:first, :conditions => [ \"product_id = ? AND option_id = ?\", product.id, self.id ])\r\n\t\t\t\tif po.nil? or po.values.nil?\r\n\t\t\t\t\tvalues\r\n\t\t\t\telse\r\n\t\t\t\t\tpo.values.collect { |x| values.find(x) }\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\tvalues\r\n\t\t\tend\r\n\t\tend",
"def same_as?(l2)\r\n\t\tself.product.id == l2.product.id && self.option_values == l2.option_values\r\n\tend",
"def opt_params_only_result\n combinations = []\n final_list = []\n final_comb = []\n opt_param_values = get_opt_params_and_values \n opt_params = get_opt_param_names\n \n opt_param_values.each do |k, v|\n v.each do |i|\n v[v.index(i)] = k.to_s + \"=\" + v[v.index(i)]\n end\n combinations << v\n end\n\n(1..combinations.size).each do |c|\n logger.info c.to_s\n final_list << combinations[c-1].combination(1).to_a\n arr = []\nend\n\n # final_list << combinations.each_index.flat_map{|i| combinations[0].product(*combinations[1..i])}\n final_list << progressive_product(combinations)\n final_list.each_index {|i| final_list[i].each {|k| final_comb << final_list[i][final_list[i].index(k)] }}\n final_comb.flatten(1)\n\nend",
"def get_original_combination\n nil\n end",
"def set_ids products\n products.each do |k, sp|\n size= Size.find_by_name sp[:size]\n color = Color.find_by_name sp[:color]\n if !size.nil? && !color.nil?\n p= Product.where(\"reference = ? and size_id = ? and color_id = ?\", sp[:reference], size.id, color.id)[0]\n sp[:product_id] = p.id if !p.nil?\n end\n end\n end",
"def variants_multiply_properties(list)\n return if list.empty?\n keys = list.first.keys\n raise \"Must have same properties\" unless list.collect { |h| h.keys }.uniq.length == keys.length\n raise \"Must have unique list\" unless list.uniq.length == list.length\n self.variants = self.variants.collect do |vd|\n list.collect do |h|\n v = vd.dup\n if num = keys.delete('supplier_num')\n v.supplier_num = num\n elsif post = keys.delete('postfix')\n v.supplier_num += post\n else\n v.supplier_num += keys.collect { |k| \"-#{h[k]}\" }.join\n end\n v.properties = v.properties.merge(h)\n v\n end\n end.flatten\n end",
"def chosen\n the_set = []\n self.itemlist.each { |k,v| the_set << self.object(k).chosen }\n the_set\n end",
"def extract_image_relations\n relation_array = {}\n self.find_by_terms(:vra_image,:relationSet,:relation_imageOf, :relation_relids).each do |relation_imageOf| \n ::Solrizer::Extractor.insert_solr_field_value(relation_array, \"relation_imageOf_tesim\", relation_imageOf.text) \n end\n self.find_by_terms(:vra_image,:relationSet,:relation_preferred, :relation_relids).each do |relation_preferred| \n ::Solrizer::Extractor.insert_solr_field_value(relation_array, \"relation_preferred_tesim\", relation_preferred.text) \n end\n return relation_array\n end",
"def map_marketing_data(products, marketing_data)\n products.map do |product|\n marketing = marketing_data[product['identifier']]\n\n begin\n\n if marketing\n product['acumenAttributes']['product_marketing_id'] = marketing['id']\n\n product['publisher'] = {\n '@type': 'Organization',\n 'name' => marketing['publisher']\n };\n product['description'] = marketing['description_long']\n product['abstract'] = marketing['description_short']\n product['keywords'] = marketing['meta_keywords']\n product['text'] = marketing['excerpt']\n\n if marketing['age_lowest'] && marketing['age_highest']\n product['typicalAgeRange'] = \"#{marketing['age_lowest']}-#{marketing['age_highest']}\"\n end\n\n #---------- Product Page Attributes ----------#\n if marketing['grade_lowest'] || marketing['grade_highest']\n # educationalUse? educationalAlignment?\n product['additionalProperty'].push({\n '@type' => 'PropertyValue',\n 'name' => 'Grade',\n 'propertyID' => 'grade_range',\n 'minValue' => marketing['grade_lowest'],\n 'maxValue' => marketing['grade_highest'],\n 'value' => \"#{marketing['grade_lowest']}-#{marketing['grade_highest']}\",\n })\n end\n\n if marketing['awards']\n product['additionalProperty'].push({\n '@type' => 'PropertyValue',\n 'propertyID' => 'awards',\n 'name' => 'Awards',\n 'value' => marketing['awards'],\n })\n end\n\n #---------- Acumen Specific Properties ----------#\n product['acumenAttributes']['extent_unit'] = marketing['extent_unit']\n product['acumenAttributes']['extent_value'] = marketing['extent_value']\n product['acumenAttributes']['info_text_01'] = marketing['info_text_01'] # editorial_reviews\n product['acumenAttributes']['info_text_02'] = marketing['info_text_02'] # product_samples\n product['acumenAttributes']['info_alpha_07'] = marketing['info_alpha_07'] # video_urls\n product['acumenAttributes']['meta_description'] = marketing['meta_description']\n product['acumenAttributes']['religious_text_identifier'] = marketing['religious_text_identifier']\n product['acumenAttributes']['status'] = marketing['status']\n\n product['gtin12'] = marketing['upc']\n product['numberOfPages'] = marketing['pages']\n\n product['height'] = get_quantitative_value(\n marketing['height'], marketing['dimensions_unit_measure']\n )\n product['width'] = get_quantitative_value(\n marketing['width'], marketing['dimensions_unit_measure']\n )\n product['depth'] = get_quantitative_value(\n marketing['thickness'], marketing['dimensions_unit_measure']\n )\n if product['weight']['value'] == '0'\n product['weight'] = get_quantitative_value(\n marketing['weight'], marketing['weight_unit_measure']\n )\n end\n end\n\n rescue => error\n issue_error(AcumenAgentError.new(\n 'map_marketing_data',\n 'Failed to map marketing data for product',\n { id: product['identifier'], sku: marketing['sku'] },\n error,\n ))\n end\n\n product\n end\n\n return products\n end",
"def line_item_products\n self.line_items.map(&:sellable).map {|s| s.respond_to?(:product) ? s.product : s}.compact.reject {|p| !p.is_a?(Product)}\n end",
"def doPair(needsToBePlaintiff, needsToBeDefense)\n proposed_pairings = []\n (1...needsToBeDefense.length).each do |i|\n proposed_pairings << [needsToBePlaintiff[i], needsToBeDefense[i]]\n end\n return proposed_pairings\n end",
"def merge_comps( original, override )\n override.each do |k,v|\n if original.has_key? k\n original[k] = v\n else\n original << [k,v]\n end\n end\n end",
"def product_customizations_match(line_item, options)\n # comparing_form = line_item.order_form.attributes.dup\n # comparing_form.reject!{ |key| %w\"line_item_id id created_at updated_at\".include? key }\n #\n # #needs more special cases, we'll leave this for now and just always create a new line item\n # comparing_form == options\n false\n end",
"def option_sets_for_instances\n opt_sets = enabled_questionings.map do |qing|\n if qing.default.present? && qing.default =~ ODK::DynamicPatternParser::VALUE_REGEX\n referenced_option_sets(qing)\n end\n end\n opt_sets.flatten.compact.uniq\n end",
"def products\n @products ||= rules.of_type('Promotion::Rules::Product').map(&:products).flatten.uniq\n end",
"def pairs\n @pieces.combination(2).to_a\n end",
"def pairs\n @pieces.combination(2).to_a\n end",
"def each_product_pair(other)\n if block_given?\n self.each do |this|\n other.each do |that|\n yield [this, that]\n end\n end\n else\n enum_for(:each_product_pair, other)\n end\n end",
"def products\n @products.map{|prouduct, num| (1..num).map{|i| prouduct}}.flatten\n end",
"def attribute_values\n super.merge('product_id' => @source.concept_product.product.product_id)\n end",
"def edit\n\t\t# @product = Product.new\n\t\tputs params\n @comparison = Comparison.find(params[:id])\n\t\t# @products_hash = Hash.new\n # @tributes_all_hash = Hash.new\n @user = current_user\n\t\t@user.comparisons += [@comparison]\n\t\t# @product = Product.create(url: session[0][:url_hash][:url])\n\t\t# @product = Product.create(url: session[1][:url_hash][:url])\n\t\tputs 'showing the count below 888888888888888888888888888888888888888888888888'\n\t\tputs @comparison.products.count\n\t\tunless @comparison.products.count > 1\n\t\t\tsession[:url_hash].each do |a|\n\t\t\t\t# because this returns the numerical key as a string instead of a key and \"flattens\" the hash\n\t\t\t\t# we loop to access the actual hash that has the url value.\n\t\t\t\tputs 'showing the session a below 888888888888888888888888888888888888888888888888'\n\t\t\t\tputs a\n\t\t\t\ta.each do |b|\n\t\t\t\t\tif b.is_a? Hash\n\t\t\t\t\t\tputs 'showing the session b below 888888888888888888888888888888888888888888888888'\n\t\t\t\t\t\tputs b\n\t\t\t\t\t\t# so b here is {:url => \"google.com\"} for instance.\n\t\t\t\t\t\t# we push because @comparison.products is an array\n\t\t\t\t\t\t@product = Product.create(url: b[:url])\n\t\t\t\t\t\t@comparison.products.push(@product)\n\t\t\t\t\t\t# crunchm!!!!!!!!!\n\t\t\t\t\t\tcrunchm(@comparison, @product, b[:url])\n\t\t\t\t\t\t# puts \"CRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHM\"\n\t\t\t\t\t\t# # puts @crunchm.keys\n\t\t\t\t\t\t# puts \"CRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHMCRUNCHM\"\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t# @comparison.tributes.push()\n\t\t\t\t\t\t\n\t\t\t\t\t\t# parseAmazon (b[:url])\n\t\t\t\t\t\t# p = Product.create (url: b[:url], name: name_from_nokogiri)\n\t\t\t\t\t\t# tributes_from_nokogiri.each do |tribute|\n\t\t\t\t\t\t# t = Tribute.create ( tribute attributes )\n\t\t\t\t\t\t# p.tributes.push(t)\n\t\t\t\t\t\t# end\n\t\t\t\t\t\t\n\t\t\t\t\t\t# end\n\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\telse \n\t\t\tsession[:url_hash].each do |a|\n\t\t\t\t# because this returns the numerical key as a string instead of a key and \"flattens\" the hash\n\t\t\t\t# we loop to access the actual hash that has the url value.\n\t\t\t\tputs 'showing the session a below 888888888888888888888888888888888888888888888888'\n\t\t\t\tputs a\n\t\t\t\ta.each do |b|\n\t\t\t\t\tif b.is_a? Hash\n\t\t\t\t\t\tputs 'showing the session b below 888888888888888888888888888888888888888888888888'\n\t\t\t\t\t\tputs b\n\t\t\t\t\t\t@product = Product.new(url: b[:url])\n\t\t\t\t\t\t# so b here is {:url => \"google.com\"} for instance.\n\t\t\t\t\t\t# we push because @comparison.products is an array\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\t\n\t\t# @product = Product.new(url: 'just a placeholder for now')\n\t\tputs 'looks like it fails right here 888888888888888888888888888'\n\t\t@crunchm = create_table_hash(@comparison)\n\t\tputs 'looks like it fails right here 888888888888888888888888888'\n\t\t@products = current_comparison.products.all\t\t\n\tend",
"def filter_options(attr_class_option_ids)\n sql = %{\n SELECT DISTINCT CASE WHEN attributable_type=:product THEN\n attributable_id ELSE product_id END AS p_id\n FROM product_attributes pa\n JOIN attribute_options ao ON ao.id=pa.value_id\n LEFT JOIN product_search_products psp\n ON psp.search_product_id=attributable_id\n AND pa.attributable_type=:search_product\n WHERE attributable_type IN (:product, :search_product)\n AND value_type=:attribute_options\n AND ao.attribute_class_option_id IN (:attr_class_option_ids)\n }\n query = sanitize_sql_array [sql,\n {\n product: SitescanCommon::Product,\n search_product: SitescanCommon::SearchProduct,\n attribute_options: SitescanCommon::AttributeOption,\n attr_class_option_ids: attr_class_option_ids\n }]\n connection.select_values query\n end",
"def fenix_product_options_types(p)\n values=p.option_types.to_a.map! do |ot|\n \"#{ot.presentation}\"\n end\n values.to_sentence({ words_connector: \", \", two_words_connector: \", \" })\n end",
"def fenix_product_options_types(p)\n values=p.option_types.to_a.map! do |ot|\n \"#{ot.presentation}\"\n end\n values.to_sentence({ words_connector: \", \", two_words_connector: \", \" })\n end",
"def combinations\n self.locations.product(self.criterias)\n end",
"def set_viewable\n viewable_id = params[:image][:viewable_id]\n\n if viewable_id.is_a?(Hash)\n @product.errors.add(:attachment, 'Erro')\n option_values_array = viewable_id.map {|option_type, option_values| option_values.map(&:to_i) }\n option_values_combinations = option_values_array.shift\n option_values_array.each do |option_value|\n option_values_combinations = option_values_combinations.product(option_value)\n end\n option_values_combinations = option_values_combinations.map(&:flatten) if option_values_combinations.count > 1\n\n @product.variants.each do |variant|\n option_values_combinations.each do |ov_combination|\n variant_option_ids = variant.option_values.pluck(:id)\n\n if ([ov_combination].flatten - variant_option_ids).empty?\n create_image(variant, permitted_resource_params)\n end\n end\n end\n else\n viewable_id = params[:master_option] if params[:master_option]\n @image.viewable_type = 'Spree::Variant'\n @image.viewable_id = viewable_id\n end\n end",
"def handle_customization\n @order = current_order(false)\n # Process if we got customization data from the product or cart page\n if params[:customization] # && params[:elected_engraving] == 'true'\n # Find line item that can be customized, and set its preferred_customization_data\n begin\n params[:customization][:data].each do |id, text|\n line_item = (id == 'new') ? @order.line_items.last : @order.line_items.where(id: id).first\n line_item.preferred_customization = text.to_json if line_item.product.engravable?\n end\n rescue Exception => e\n # Don't do anything for now\n Rails.logger.warn \"Failed updating line item with customization data. Order #{@order.number}\"\n end\n else # Check if a customizable SKU has been added without the customizatiob data in the form\n # Find line item that can be customized, and set its preferred_customization_data\n begin\n line_item = @order.line_items.last\n line_item.preferred_customization = {'line1' => '', 'line2' => '', 'line3' => ''}.to_json if line_item.product.engravable?\n rescue Exception => e\n # Don't do anything for now\n Rails.logger.warn \"Failed updating line item with customization data. Order #{@order.number}\"\n end \n end\n end",
"def diff_digests(old_products, new_products)\n # create maps of product sets\n old_map, new_map = [old_products, new_products].map do |products|\n return [] unless products\n Hash[*products.flat_map { |d| [d.product, d] }]\n end\n\n build_diff(new_map, old_map)\n end",
"def order_options_calculation\n options = possible_discounts.permutation.to_a.uniq\n option_result = []\n\n options.map do |discount_set|\n set_discounts_used = []\n extra_discounts_used = []\n extra_products = []\n discount_price = 0\n products_all = ordered_products_total_arr\n\n discount_set.map do |discount|\n discount_products = discount[0..discount.length - 2]\n discount_info = discount.last\n discount_id = discount_info.slice(0, discount_info.length - 1)\n\n while discount_veryfication(discount_products, products_all, 0)\n if discount_info.last == 'e'\n extra_products.push(discount[0])\n extra_discounts_used.push(discount)\n discount_price += (Product.where(id: discount[0])[0][:price] * (discount.length - 1))\n elsif discount_info.last == 's'\n discount_price += Discount.where(id: discount_id)[0][:price]\n set_discounts_used.push(discount)\n end\n\n discount_products.map do |product|\n products_all.delete_at(products_all.index(product))\n end\n end\n end\n normal_price = regular_price(products_all)\n total_price = (discount_price + normal_price).round(2)\n option_result.push([set_discounts_used, extra_discounts_used, products_all, extra_products, total_price])\n end\n option_result\n end",
"def filtered_search_product_ids(filter_params)\n\n # Select ids of attributes linked to search product.\n search_product_attribute = SitescanCommon::AttributeClass\n .where(depend_link: true)\n\n # Set condition to select product attributes related to search product.\n sql = where( attributable_type: SitescanCommon::SearchProduct )\n\n ids = nil\n\n # If the filter contains one or more options.\n if filter_params[:o]\n\n # Select classs attribute ids related to the filter options.\n sr_opt_attr_ids = search_product_attribute\n .joins(:attribute_class_options)\n .where(attribute_class_options: { id: filter_params[:o] }).ids\n\n # For each class attribute select product attribute ids.\n sr_opt_attr_ids.each do |attr_id|\n\n # Select options ids related to the class attribute.\n search_product_option_ids = SitescanCommon::AttributeClassOption\n .where(attribute_class_id: attr_id, id: filter_params[:o]).ids\n\n # Select Search products ids filtered by option or list of options.\n # Options which belong to same list type attribute conjuct with\n # OR logical condition.\n sr_opt_ids = sql.joins(%{ JOIN attribute_options ao\n ON ao.id=product_attributes.value_id\n AND value_type='#{ SitescanCommon::AttributeOption.to_s }' AND\n attribute_class_option_id IN (#{search_product_option_ids.join ','})})\n .pluck :attributable_id\n\n # Attributes conjuct with AND logical condition.\n ids = if ids then ids & sr_opt_ids else sr_opt_ids end\n end\n end\n\n # If filter has nubmer attributes.\n if filter_params[:n]\n filter_numbers = search_product_attribute.ids & filter_params[:n].keys\n filter_numbers.each do |key, value|\n unless key == 0\n num_condition = []\n num_condition << 'value>=:min' if value[:min]\n num_condition << 'value<=:max' if value[:max]\n num_condition << 'attribute_class_id=:attr_cls_id'\n sr_num_ids = sql.join( %{ JOIN attribute_numbers an\n ON an.id=product_attributes.value_id\n AND value_type='#{SitescanCommon::AttributeNumber.to_s}' } )\n .where(num_condition.join ' AND ', value.merge(attr_cls_id: key))\n .pluck :attributable_id\n ids = if ids\n ids & sr_num_ids\n else\n sr_num_ids\n end\n end\n end\n end\n ids\n end",
"def matching_products\n if compute_on_promotion?\n calculable.promotion.rules.map do |rule|\n rule.respond_to?(:products) ? rule.products : []\n end.flatten\n end\n end",
"def product_memberships\n super.reject { |pm| pm.concept_product.nil? }\n end",
"def hash\n [name, product_ids_any, product_ids_all, quantity_exact, quantity_min, quantity_max, all_products].hash\n end",
"def get_product_service_map(product,service) \n if product == nil && service == nil \n return Hash.new\n end\n productArr = product.split(\",\")\n if service == nil\n serviceArr = []\n else \n serviceArr = service.split(\",\")\n end\n size = productArr.size\n ps_hash = Hash.new\n if serviceArr.size !=0 && serviceArr.size != productArr.size\n puts \"--product --service wrong argument\"\n return nil\n end\n if serviceArr.size == productArr.size\n 0.upto(size-1) do |i|\n p = productArr[i]\n if ps_hash.has_key?(p)\n temparray = ps_hash[p]\n else\n temparray = Array.new\n end\n temparray.push(serviceArr[i])\n ps_hash[p]=temparray.uniq\n end\n else\n # serviceArr.size == 0\n 0.upto(size-1) do |i|\n p = productArr[i]\n ps_hash[p]=[]\n end\n end\n return ps_hash\n end",
"def option_types(product_id:)\n version_ids = option_types_version_ids(product_id: product_id)\n\n versions = PaperTrail::Version.where(id: version_ids)\n versions.map(&:reify)\n end",
"def option_selects\n content_profile_entries.map do |cpe|\n [cpe.description, cpe.id, {'data-description': \"#{cpe.content_type}:#{cpe.topic_type}\"} ]\n end\n end",
"def get_all_product_codes(products)\n types = []\n products.each do |product|\n types.push(product[:product_id])\n end\n types\n end",
"def set_pallet_format_product\n\n\tpallet_format_product = PalletFormatProduct.find_by_pallet_format_product_code(self.pallet_format_product_code)\n\t if pallet_format_product != nil \n\t\t self.pallet_format_product = pallet_format_product\n\t\t return true\n\t else\n\t\terrors.add_to_base(\"combination of: 'pallet_format_product_code' is invalid- it must be unique\")\n\t\t return false\n\tend\nend",
"def ensure_variant_and_color_code\n flush_variants\n if product_code\n variant_ids = ProductProduct.search([['default_code', 'ilike', \"FN-#{product_code.split(\"-\")[0]}\"]])\n variant_codes = ProductProduct.find(variant_ids).collect(&:default_code)\n\n variant_codes.each_with_index do |code, index|\n product_variants.create(openerpid: variant_ids[index], \n default_code: code,\n color_code_id: ensure_color_code(code)) \n end\n end\n end",
"def sku_combination_creation\n end",
"def same_as?(l2)\r\n\t\t# comparing self.option_values with l2.option_values _should_ work, but doesn't. If you\r\n\t\t# instead compare the .line_item_option_values, it works...\r\n\t\t#\r\n\t\t# Does this mean has_many :through is a horrible hack? Maybe...\r\n\t\tself.product.id == l2.product.id && self.line_item_option_values == l2.line_item_option_values\r\n\tend",
"def products\n @products ||= hash[\"Products\"].map { |p| Merchant::Product.new p }\n end",
"def mixed_pairs\nend",
"def modify_image_product_code(image_id, product_code=[])\n modify_image_attribute(image_id, 'productCodes', nil, :product_code => product_code.to_a)\n end",
"def recipe_options\n \trecipes.map do |recipe| \n \t\t[recipe.name, recipe.id]\n \tend\n end",
"def concat_pro_ser(product_service_map,pro2,ser2)\n temp_map = product_service_map\n all = Array.new\n size = pro2.size\n 0.upto(size-1){ |i| \n p = pro2[i]\n s = ser2[i]\n if temp_map.has_key?(p)\n temparray = temp_map[p]\n else\n temparray = Array.new\n end\n temparray.push(ser2[i])\n temp_map[p]=temparray.uniq\n }\n #puts \"\\n\"\n show_info(\"exclude_p/s:\\n#{temp_map}\")\n return temp_map\n end",
"def preferred_code(preferred_code_sets, codes_attribute=:codes, value_set_map=nil)\n codes_value = send(codes_attribute)\n preferred_code_sets = value_set_map ? (preferred_code_sets & value_set_map.collect{|cs| cs[\"set\"]}) : preferred_code_sets\n matching_code_sets = preferred_code_sets & codes_value.keys \n if matching_code_sets.present?\n if value_set_map\n matching_code_sets.each do |matching_code_set|\n matching_codes = codes_value[matching_code_set] & value_set_map.collect{|cs| cs[\"set\"] == matching_code_set ? cs[\"values\"] : []}.flatten.compact\n if matching_codes.present?\n return {'code' => matching_codes.first, 'code_set' => matching_code_set}\n end\n end\n # we did not find a matching preferred code... we cannot write this out to QRDA\n return nil\n else\n code_set = matching_code_sets.first\n {'code' => codes_value[code_set].first, 'code_set' => code_set}\n end\n else\n nil\n end\n end",
"def expected_results_with_all_supplemental_codes\n # Since this is a CMS IG requirement, only do this for CVU+ or C3 tests\n return expected_results unless product.cvuplus? || product.c3_test?\n\n required_codes = { 'PAYER' => %w[1 2 6 349], 'SEX' => %w[M F], 'RACE' => %w[2106-3 2076-8 2054-5 2028-9 1002-5 2131-1],\n 'ETHNICITY' => %w[2135-2 2186-5] }.freeze\n new_hash = expected_results\n new_hash.each do |_measure_id, pop_set_hash|\n pop_set_hash.each do |_pop_set_id, pop_set|\n sup_data = pop_set['supplemental_data']\n %w[IPP DENOM NUMER NUMEX DENEX DENEXCEP MSRPOPL MSRPOPLEX].each do |pop_key|\n next unless pop_set[pop_key]\n\n sup_data[pop_key] = { 'RACE' => {}, 'ETHNICITY' => {}, 'SEX' => {}, 'PAYER' => {} } unless sup_data[pop_key]\n required_codes.each do |sup_data_type, codes|\n codes.each do |code|\n sup_data[pop_key][sup_data_type][code] = 0 unless sup_data[pop_key][sup_data_type][code]\n end\n end\n end\n end\n end\n new_hash\n end",
"def preferred_representation_ids\n Array.wrap(preferred_representations).uniq.delete_if(&:empty?)\n end",
"def colour_association(array)\n array.map{|pair| Hash[pair.first, pair.last]}\nend",
"def prod_dev_pair()\n return is_prod? ? [self, complement] : [complement, self]\n end",
"def filter_data\n @data.map do |currency|\n currency.select { |attribute,_|\n selected_attributes.include? attribute.to_s\n }\n end\n end",
"def for_display(product)\n if product.bundle? || product.composite? || product.package?\n [aggregate_price(product), nil]\n else\n if special = special_price(product)\n [special, regular_price(product)]\n else\n [regular_price(product), nil]\n end\n end\n end",
"def option_list(label_attribute = 'name')\n countries.map { |country| [country[label_attribute], country['code']] }\n end",
"def add_product_codes *product_codes\n client_opts = {}\n client_opts[:image_id] = self.id\n client_opts[:product_codes] = product_codes.flatten\n client.modify_image_attribute(client_opts)\n nil\n end",
"def get_pallet_format_product_codes\n pallet_format_products = PalletFormatProduct.find_by_sql(\"SELECT distinct pallet_format_product_code from pallet_format_products\")\n result = package_result_set(pallet_format_products)\n send_response(result)\n end",
"def translation_codes(preferred_code_sets,value_set_map=nil)\n tx_codes = []\n matching_codes = value_set_map ? codes_in_code_set(value_set_map) : codes\n matching_codes.each_pair do |code_set, code_list|\n code_list.each do |code|\n tx_codes << {'code' => code, 'code_set' => code_set}\n end\n end\n\n tx_codes - [preferred_code(preferred_code_sets, :codes, value_set_map)]\n end",
"def get_addons\n res = product_options.map { |po| po.name }.join(', ')\n unless res.blank?\n res = \"(#{res})\"\n end\n res\n end",
"def possible_attributes\n custom_keys = valid_criteria.keys.sort\n klass = population.populatable.class.reflect_on_association(population.starting_set.try(:to_sym)).try(:class_name).try(:constantize) rescue nil\n p_codes = []; ap_codes = []\n if klass\n p_codes = klass::PLACEHOLDER_CODES || [] rescue []\n ap_codes = []\n for assoc in (klass::PLACEHOLDER_ASSOCIATIONS || [] rescue [])\n aklass = klass.reflect_on_association(assoc.to_sym).try(:class_name).try(:constantize)\n ap_codes << aklass::PLACEHOLDER_CODES.collect{|c| \"#{assoc}.#{c}\"} if aklass rescue nil\n end\n end\n all_keys = ((custom_keys + p_codes).flatten.sort + ap_codes.sort).flatten.compact.uniq.map{|k| [k.gsub(\"_\", \" \").gsub(\".\", \" → \"), k]}\n end",
"def unique_products\n @products.uniq\n end",
"def build_variants_from_option_values_hash\n ensure_option_types_exist_for_values_hash\n values = option_values_hash.values\n values = values.inject(values.shift) { |memo, value| memo.product(value).map(&:flatten) }\n\n values.each do |ids|\n variants.create(\n option_value_ids: ids\n )\n end\n save\n end",
"def products\n @products ||= rules.of_type('Spree::Promotion::Rules::Product').map(&:products).flatten.uniq\n end",
"def generateCompareMmr_s (list)\r\n hash = Hash.new\r\n list.each{|value|\r\n val = value.split('_')\r\n key = val[0]+\"_\"+val[1]+\"_\"+val[2]\r\n if hash[key]\r\n hash[key] = hash[key]+\"$(\"+'\"'+\"select[name='\"+value+\"'\"+\"]\"+'\"'+\").val() == \"+'\"'+'\"'+\"||\"\r\n else\r\n hash[key] = \"$(\"+'\"'+\"select[name='\"+value+\"'\"+\"]\"+'\"'+\").val() == \"+'\"'+'\"'+\"||\"\r\n end\r\n }\r\n return hash\r\n end",
"def preferred_code(preferred_code_sets, codes_attribute=:codes)\n codes_value = send(codes_attribute)\n matching_code_sets = preferred_code_sets & codes_value.keys\n if matching_code_sets.present?\n code_set = matching_code_sets.first\n {'code' => codes_value[code_set].first, 'code_set' => code_set}\n else\n nil\n end\n end",
"def parse_custom_data(product, orig_data)\n data = {}\n\n orig_data.deep_stringify_keys!\n\n shop.fetch('product_parse_config').each do |import_map|\n raw_value = product.dig(*import_map['from'].split('.')).presence\n\n unless raw_value\n begin\n groups = product\n .fetch('variantgroups', {})\n .fetch('items', [])\n .detect do |v|\n text = v['text'].to_s.downcase\n text == import_map['from'].to_s.downcase\n end\n\n variant_groups = Hash[\n groups\n .fetch('variants', {})\n .fetch('items', [])\n .collect { |g| [g['id'], g['text']] }\n ]\n\n variations = product\n .fetch('variants', {})\n .fetch('items', [])\n .collect { |v| v['id'] }\n\n matching_variant = (variant_groups.keys & variations).first\n\n raw_value = variant_groups[matching_variant]\n rescue NoMethodError\n Arctic.logger.warn \"Unable to find varant data matching ImportMap #{import_map}\"\n end\n end\n\n if import_map['regex']\n parsed_value = raw_value.to_s.scan(Regexp.new(import_map['regex'])).flatten.first\n else\n parsed_value = raw_value\n end\n\n data[import_map['to']] = parsed_value if parsed_value\n end\n\n data\n end",
"def related_products( options = {} )\n #data_source = ( options[:data_source] || self.current_piece.current_data_source )\n data_filter = ( options[:data_filter] || self.current_piece.data_filter )\n\n current_product = (self.running_data_item_by_class( Products::WrappedProduct ) || self.current_page_tag.product_tag )\n if current_product\n case data_filter\n when Spree::PageLayout::DataSourceFilterEnum.next\n item = Spree::Classification.where( taxon_id: current_product.accurate_taxon_tag.id, product_id: current_product.id ).first.try(:lower_item).try(:product)\n item.present? ? Products.new( self.page_generator, [item], current_product.accurate_taxon_tag ) : []\n when Spree::PageLayout::DataSourceFilterEnum.previous\n item = Spree::Classification.where( taxon_id: current_product.accurate_taxon_tag.id, product_id: self.page_generator.resource.id ).first.try(:higher_item).try(:product)\n item.present? ? Products.new( self.page_generator, [item], current_product.accurate_taxon_tag ) : []\n else\n products( current_product.accurate_taxon_tag, { search:{ without_ids: [current_product.id]} } )\n end\n else\n []\n end\n end",
"def product_photo\n photos = []\n self.products.each do |product|\n photos << product.photo\n end\n return photos.sample\n end",
"def other_products_purchased(purchased_item, other_line_items)\n similar_products = []\n other_products = []\n\n # extract an array of all the other purchase order ids minus this purchase order\n # that had a line item for the same purchased_item\n other_purchase_order_ids = other_line_items.collect{|line_item| line_item.purchase_order_id if line_item.purchase_order_id != self.id}.flatten.compact.uniq\n if other_purchase_order_ids.present?\n other_purchase_orders = PurchaseOrder.find other_purchase_order_ids\n\n # now extract all the other products purchased\n other_purchase_orders.each do |po|\n other_line_item_products = po.line_items.collect{|line_item| line_item.stuffed_animal_id.present? ? ((line_item.stuffed_animal_id != purchased_item.id) ? line_item.stuffed_animal : nil) : ((line_item.accessory_id != purchased_item.id) ? line_item.accessory : nil)}.flatten.compact\n other_products += other_line_item_products\n end\n end\n\n return other_products\n end",
"def create_configurable_product\n sku = value('sku')\n\n # set the default configurable product attributes\n configurable_product = Gemgento::Product.not_deleted.find_or_initialize_by(sku: sku)\n configurable_product.magento_id = existing_magento_id(sku)\n\n configurable_product.magento_type = 'configurable'\n configurable_product.product_attribute_set = product_attribute_set\n configurable_product.status = value('status', :boolean)\n configurable_product.stores << store unless configurable_product.stores.include?(store)\n configurable_product.sync_needed = false\n configurable_product.save\n\n # add the configurable attributes\n configurable_attributes.each do |configurable_attribute|\n configurable_product.configurable_attributes << configurable_attribute unless configurable_product.configurable_attributes.include? configurable_attribute\n end\n\n # associate all simple products with the new configurable product\n self.simple_products.each do |simple_product|\n configurable_product.simple_products << simple_product unless configurable_product.simple_products.include?(simple_product)\n end\n\n # set the additional configurable product details\n set_attribute_values(configurable_product)\n\n configurable_product.visibility = self.configurable_product_visibility.to_i\n configurable_product.sync_needed = true\n\n if configurable_product.save\n # add the images\n create_images(configurable_product) if include_images?\n set_default_config_inventories(configurable_product) if self.set_default_inventory_values?\n end\n \n set_categories(configurable_product)\n \n return configurable_product\n end",
"def product_tags\n self.tag_list.join(\", \")\n end",
"def thumbnail_options\n asset_sizes = thumbnail_sizes.collect{|k,v| \n size_id = k\n size_description = \"#{k}: \"\n size_description << (v.is_a?(Array) ? v.join(' as ') : v)\n [size_description, size_id] \n }.sort_by{|pair| pair.last.to_s}\n asset_sizes.unshift ['Original (as uploaded)', 'original']\n asset_sizes\n end",
"def product_tags=(values)\n self.tag_list = values\n end",
"def option_values_version_ids(variant_id:)\n if status[:option_types_and_values]\n status[:option_types_and_values].collect do |item|\n item[:option_value_version_id] if item[:variant_id] == variant_id\n end.compact\n else\n []\n end\n end",
"def brands_array\n ($products_hash['items'].map { |toy| toy['brand'] }).uniq\nend"
] | [
"0.9526344",
"0.9512058",
"0.5494813",
"0.5373909",
"0.5344353",
"0.5288939",
"0.5255836",
"0.5206483",
"0.5201266",
"0.51862",
"0.5159777",
"0.5141207",
"0.50949556",
"0.508601",
"0.50718814",
"0.5064807",
"0.5036138",
"0.50183845",
"0.49604815",
"0.49518102",
"0.49469858",
"0.49405402",
"0.49343887",
"0.49310336",
"0.4930469",
"0.4930469",
"0.4926149",
"0.4908375",
"0.48995546",
"0.48975673",
"0.48730668",
"0.48622826",
"0.48565933",
"0.48352686",
"0.47885713",
"0.4778127",
"0.47757134",
"0.47520632",
"0.47488913",
"0.47343886",
"0.47282985",
"0.4716888",
"0.47093353",
"0.47093353",
"0.47090355",
"0.469844",
"0.46924663",
"0.46799967",
"0.4671205",
"0.466401",
"0.466401",
"0.4663375",
"0.4661197",
"0.4656306",
"0.46551704",
"0.46522105",
"0.46475875",
"0.46474725",
"0.46436387",
"0.46406132",
"0.4635992",
"0.46313247",
"0.46308303",
"0.46306768",
"0.4630154",
"0.46292663",
"0.46215397",
"0.46056843",
"0.46031705",
"0.46022308",
"0.46009043",
"0.45901045",
"0.45892972",
"0.4588669",
"0.4586558",
"0.458417",
"0.45834234",
"0.45816842",
"0.456706",
"0.45646992",
"0.45568386",
"0.45517123",
"0.45463535",
"0.45360678",
"0.4529613",
"0.4526373",
"0.4525983",
"0.45256343",
"0.45255914",
"0.45178145",
"0.45167705",
"0.4515576",
"0.45150378",
"0.45106196",
"0.45073918",
"0.45022994",
"0.45004836",
"0.45000082",
"0.44965863",
"0.44965294",
"0.44950268"
] | 0.0 | -1 |
Pass target to the scope handler of the specified type and name. If `name` is not specified then `:default` name is used. If `type` is not specified then we try to infer the type from the target class. | def apply_scope(target, type:, name: :default, scope_options: nil)
raise ActionPolicy::UnknownScopeType.new(self.class, type) unless
self.class.scoping_handlers.key?(type)
raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless
self.class.scoping_handlers[type].key?(name)
mid = :"__scoping__#{type}__#{name}"
scope_options ? send(mid, target, **scope_options) : send(mid, target)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_name(name, type)\n @names[name.to_sym] = type unless name.nil?\n end",
"def authorization_scope_type_for(policy, target)\n policy.resolve_scope_type(target)\n end",
"def target\n @target ||= case scope\n when '#'\n klass\n when '.'\n klass && klass.class_eval{class << self; self; end}\n end\n end",
"def call_scope_by_type(type, scope, target, value, options) #:nodoc:\n if type == :boolean\n target.send(scope)\n elsif value && options.key?(:using)\n value = value.values_at(*options[:using])\n target.send(scope, *value)\n else\n target.send(scope, value)\n end\n end",
"def method_missing(name, *args, &block)\n if scopes.include?(name)\n scopes[name].call(self, *args)\n elsif klass\n target.send(name, *args, &block)\n else\n @parent.fuse(@conditions); @parent.send(name, *args, &block)\n end\n end",
"def for(type_name)\n raise NameError, \"No handler for type #{type_name}\" unless types[type_name]\n types[type_name]\n end",
"def target(*args)\n if args.blank?\n const_defined?(:Target) ? const_get(:Target) : (@target || name[0..-5].classify.constantize)\n else\n self.target = args.first\n end\n end",
"def bind(arg_name, klass)\n @bindings[arg_name] = klass\n end",
"def target_type(target_type)\n return if target_type.nil?\n return unless [String, Symbol].include?(target_type.class)\n target_type = target_type.to_sym if target_type.instance_of? String\n return unless TARGET_TYPES.include? target_type\n @_target_type = target_type\n end",
"def target_type(_target_type)\n return if _target_type.nil?\n return unless _target_type.instance_of?(String) || _target_type.instance_of?(Symbol)\n _target_type = _target_type.to_sym if _target_type.instance_of? String\n return unless TARGET_TYPES.include? _target_type\n @_target_type = _target_type\n end",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def target_class_name\n options[:class_name] || name.to_s.classify\n end",
"def target(name, options = {})\n parent = @target_definition\n @target_definitions[name] = @target_definition = TargetDefinition.new(name, parent, self, options)\n yield\n ensure\n @target_definition = parent\n end",
"def type_name *args\n (@type_names ||= { })[args] ||=\n _type_name(args)\n end",
"def for_target(target)\n @target_name = target[:target_name].to_s\n return self\n end",
"def target_name(*args)\n if args.blank?\n (const_defined?(:TargetName) ? const_get(:TargetName) : (@target_name || target_model.name.underscore.titleize)).to_s\n else\n self.target_name = args.first\n end\n end",
"def to(target, rel_type = @method_id)\n @dir = :outgoing\n\n if Class === target || String === target\n # handle e.g. has_n(:friends).to(class)\n @target_name = target\n @rel_type = \"#{@source_class}##{rel_type}\".to_sym\n elsif Symbol === target\n # handle e.g. has_n(:friends).to(:knows) or to(\"Person#friends\")\n @target_name = target.to_s.split(\"#\")[0] if target.to_s.include?(\"#\")\n @rel_type = target.to_sym\n else\n raise \"Expected a class or a symbol for, got #{target}/#{target.class}\"\n end\n self\n end",
"def quoted_scope(name = nil, type: nil)\n schema, name = extract_schema_qualified_name(name)\n type =\n case type # rubocop:disable Style/HashLikeCase\n when \"BASE TABLE\"\n \"'r','p'\"\n when \"VIEW\"\n \"'v','m'\"\n when \"FOREIGN TABLE\"\n \"'f'\"\n end\n scope = {}\n scope[:schema] = quote(schema || shard.name)\n scope[:name] = quote(name) if name\n scope[:type] = type if type\n scope\n end",
"def bound_name?(name)\n type = @names[name.to_sym]\n if type.nil?\n @parent&.bound_name?(name)\n else\n type\n end\n end",
"def target_klass\n target_klass_name.constantize\n end",
"def target_name(target_name = nil)\n @target_name = target_name unless target_name.nil?\n \n return 'default' if @target_name.nil?\n @target_name\n end",
"def target_symbol(*args)\n if args.blank?\n (const_defined?(:TargetSymbol) ? const_get(:TargetSymbol) : (@target_symbol || target_model.name.underscore)).to_sym\n else\n self.target_symbol = args.first\n end\n end",
"def target(name, options = {})\n parent = @target_definition\n @target_definitions[name] = @target_definition = TargetDefinition.new(name, options[:exclusive] ? nil : parent, options[:include_headers_for] ? @target_definitions[options[:include_headers_for]] : nil)\n yield\n ensure\n @target_definition = parent\n end",
"def target(name, &block)\n t = TargetDef.new(name)\n @targets.push(t)\n\n block.call(t)\n end",
"def target_type=(value)\n @target_type = value\n end",
"def target_def; target.name; end",
"def []=(name, type)\n @names[name.to_sym] = type\n end",
"def scope\n klass\n end",
"def scope_type(node); end",
"def from(target, rel_type=@method_id)\n @dir = :incoming\n\n case target\n when /#/\n @target_name, _ = target.to_s.split(\"#\")\n @rel_type = target\n when Class, String\n @target_name = target.to_s\n @rel_type = \"#{@target_name}##{rel_type}\".to_sym\n when Symbol\n @target_name = nil\n @rel_type = target.to_sym\n else\n raise \"Expected a class or a symbol for, got #{target}/#{target.class}\"\n end\n self\n end",
"def look_for_type(target_type, ignoring = [], &blk)\n each_sexp do |elem|\n elem.look_for_type(target_type, ignoring, &blk) unless ignoring.include?(elem.type)\n end\n blk.call(self) if type == target_type\n end",
"def get_target(name)\n t = Param.get(:targets)\n (t && t.kind_of?(Hash)) ? t[name.to_s.to_sym] : nil\n end",
"def requested_type\n return @requested_type if defined?(@requested_type)\n\n opts = @scope.opts[:type_routing]\n @requested_type = accept_response_type if opts[:use_header]\n @requested_type ||= opts[:default_type]\n end",
"def resolve_name(target)\n if target == self\n return \"you\".freeze\n end\n if can_see?(target)\n return target.name\n else\n return target.indefinite_name\n end\n end",
"def get_class_from_scope(scope, name)\n klass = scope\n name = name.to_s.sub(%r{^Backup::Config::DSL::}, \"\")\n name.split(\"::\").each do |chunk|\n klass = klass.const_get(chunk)\n end\n klass\n end",
"def applies_type?(scope, type); end",
"def set_type_name\n @type_name = TypeName.find(params[:id])\n end",
"def target_class\n options[:class] || target_class_name.constantize\n end",
"def scope(name = nil)\n raise 'Must specify name if no children have been defined yet' unless name || last_child\n name ||= last_child.name\n @outgoing_scopes[name]\n end",
"def scope(name, scope=nil, &block)\n raise ArgumentError, \"Dangerous scope name: a :#{name} method is already defined. Please, use another one.\" \\\n if respond_to?(name)\n proc = case\n when block_given?\n block\n when scope.is_a?(Flex::Scope)\n lambda {scope}\n when scope.is_a?(Proc)\n scope\n else\n raise ArgumentError, \"Scope object or Proc expected (got #{scope.inspect})\"\n end\n metaclass = class << self; self end\n metaclass.send(:define_method, name) do |*args|\n scope = proc.call(*args)\n raise Scope::Error, \"The scope :#{name} does not return a Flex::Scope object (got #{scope.inspect})\" \\\n unless scope.is_a?(Flex::Scope)\n scope\n end\n scope_methods << name\n end",
"def type(type = nil)\n @type = type if type\n @type || name.split('::').last.gsub(/Resource$/, '').underscore\n end",
"def route(name, namespace=nil)\n scope.send(roda_class.named_route(name, namespace), self)\n end",
"def name_search( type, search_for, order_by = 'name' )\n self.send(type.to_sym, { namesearch: search_for, order: order_by })\n end",
"def name_for(t, default_name)\n key = @types.key(t)\n if key.nil?\n if @references.empty?\n default_name\n else\n @references.each_pair do |ref_key, ref|\n ref_name = ref.type_set.name_for(t, nil)\n return \"#{ref_key}::#{ref_name}\" unless ref_name.nil?\n end\n default_name\n end\n else\n key\n end\n end",
"def scope_for(finder, options = {})\n return finder unless options.keys.include? @named_scope\n value = options.delete(@named_scope)\n finder.send(@named_scope, value)\n end",
"def target_name=(new_value)\n @target_name = new_value unless const_defined?(:TargetName)\n end",
"def set_nametype\n @nametype = Nametype.find(params[:id])\n end",
"def scope name, body=nil, &block\n block ||= body\n dataset_module{define_method(name, &block)}\n end",
"def to(target, rel_type = @method_id)\n @dir = :outgoing\n\n case target\n when /#/\n @target_name, _ = target.to_s.split(\"#\")\n @rel_type = target.to_sym\n when Class, String\n @target_name = target.to_s\n @rel_type = \"#{@source_class}##{rel_type}\".to_sym\n when Symbol\n @target_name = nil\n @rel_type = target.to_sym\n else\n raise \"Expected a class or a symbol for, got #{target}/#{target.class}\"\n end\n self\n end",
"def method_missing(name, *args, &block)\n @target.send(name, *args, &block)\n end",
"def type_name\n @type_name ||= name.underscore\n end",
"def autonotify(name = nil, &block)\n # Not needed to describe the type\n nil\n end",
"def type_name_resolver; end",
"def target_name\n self.class.target_name\n end",
"def method_missing(name, *args)\n if scopes[name].nil?\n super\n else\n execute_scope(name, *args)\n end\n end",
"def bind(type, name, options = {}, &block)\n case type\n when :role then bind_role(name, options, &block)\n when :cluster_role then bind_cluster_role(name, options, &block)\n else\n fail ArgumentError, \"bind type must be :role or :cluster_role. Is: #{type}\"\n end\n end",
"def set_default_handler(name)\n @default_handler = name\n end",
"def transform_QualifiedName(o, scope)\n Types::TypeFactory.host_class(o.value)\n end",
"def scope(scope_name, &block)\n scope_obj = LocatorScope.new(self)\n scope_obj.scoped_locator = send \"#{scope_name}_locator\"\n scope_obj.run(&block)\n end",
"def model name, **params\n # <<- CLOSURE_SCOPE\n current = @current # closure scope\n params = @environs.merge params if @environs\n filled_or_maybe = optionality(params)\n params[:class] ||= name.to_s.gsub(/(?:\\A|_)./) { |m| m[-1].upcase }\n # CLOSURE_SCOPE\n\n schema do\n __send__(current, name).__send__(filled_or_maybe, model?: params[:class])\n end\n\n define_helper_methods name\n end",
"def policy_scope(target, options={})\n policy(target, options).scope\n end",
"def request_type(*args)\n type\n end",
"def scopeName _args\n \"scopeName _args;\" \n end",
"def method_missing(name, *arguments)\n str_name = name.to_s\n\n if str_name =~ /\\w+\\?/ && Types::NAMES.include?(str_name.chop)\n klass_name = str_name.sub(/\\?/, '').capitalize\n self.class.class_name == klass_name\n else\n raise NoMethodError, \"undefined method: #{name}\"\n end\n end",
"def target\n resource or raise TargetNotFound.new (@options[:class_name] || @target_name.to_s.camelize), namespace\n end",
"def from(*args)\n @dir = :incoming\n\n if (args.size > 1)\n # handle specified (prefixed) relationship, e.g. has_n(:known_by).from(clazz, :type)\n @rel_type = \"#{@target_class}##{args[1]}\"\n @target_class = args[0]\n @relationship_name = args[1]\n elsif (Symbol === args[0])\n # handle unspecified (unprefixed) relationship, e.g. has_n(:known_by).from(:type)\n @rel_type = args[0]\n else\n raise \"Expected a symbol for, got #{args[0]}\"\n end\n self\n end",
"def type_name=(val)\n self['type_name'] = val\n end",
"def klazz\n params[:type].camelize.constantize\n end",
"def assign_type_for(name, associated)\n type = associated ? associated.class.name : nil\n\n send(\"#{name}_type=\", type)\n end",
"def __on(type_name, &block)\n __node(\"... on #{type_name}\", {}, &block)\n end",
"def namespace(name, opts = {}, &block)\n raise MissingBlock, :namespace unless block_given?\n\n namespaces << name\n\n create_method(name) do\n key = \"@#{name}\"\n\n if instance_variable_defined?(key)\n ns = instance_variable_get(key)\n else\n ns = instance_variable_set(key, {})\n end\n\n unless ns[current_handler]\n mod = Module.new do\n class << self\n attr_accessor :current_handler\n end\n extend ActionMethods\n end\n\n mod.current_handler = current_handler\n\n mod.instance_eval(&block)\n\n klass = \"#{self.name}::#{current_handler.to_s.camelize}::#{name.to_s.camelize}\"\n klass_opts = with_handler.config.merge(opts)\n ns[current_handler] = Runner.new(name, klass.constantize, mod, klass_opts)\n end\n\n ns[current_handler]\n end\n end",
"def target(name, options = nil)\n if options\n raise Informative, \"Unsupported options `#{options}` for \" \\\n \"target `#{name}`.\"\n end\n\n parent = current_target_definition\n definition = TargetDefinition.new(name, parent)\n self.current_target_definition = definition\n yield if block_given?\n ensure\n self.current_target_definition = parent\n end",
"def method_missing(name, *args, &block)\n target.send(name, *args, &block)\n end",
"def noun_class(name)\n self.send(name)\n end",
"def infer_type( name )\n as_string = name.to_s\n parts = as_string.split(\"_\")\n if( [\"reg\" , \"obj\" , \"tmp\" , \"self\" , \"const\", \"1\" , \"2\"].include?( parts.last ) )\n parts.pop\n as_string = parts.join(\"_\")\n end\n as_string = \"word\" if as_string == \"name\"\n as_string = \"message\" if as_string == \"next_message\"\n as_string = \"message\" if as_string == \"caller\"\n sym = as_string.camelise.to_sym\n clazz = Parfait.object_space.get_class_by_name(sym)\n raise \"Not implemented/found object #{name}:#{sym}\" unless clazz\n return clazz.instance_type\n end",
"def stradivari_scope(name, *args, &block)\n callable, options = stradivari_scope_options(*args, &block)\n\n scope(name, callable)\n options[:type] ||= :string\n stradivari_scopes.store(name.to_sym, options)\n end",
"def target\n type = target_type\n type ? @references[\"#{target_type}#{target_id}\"] : nil\n end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def setTargetName(text)\n @targetNameEntry.enterText(text) if not text.nil?\n # press TAB on keyboard to set the target name\n type(waitForObject(@targetNameEntry.symbolicName), \"<Tab>\")\n return self\n end",
"def handler\n @handler ||= Type.for(type).new(type_options)\n rescue StandardError => ex\n raise ex, \"#{name}: #{ex.message}\"\n end",
"def search_class\n klass = if args[1]\n target.eval(args[1])\n else\n target_self\n end\n\n klass.is_a?(Module) ? klass : klass.class\n end",
"def register_handler(name, opts = {}, &block)\n klass = opts.delete(:class_name) || \"::#{name.to_s.camelize}\"\n create_handler_predicate_method name\n handlers[name] = Runner.new(name, klass.to_s.constantize, self, opts, &block)\n end",
"def type_name_params\n params.require(:type_name).permit(:type_id, :name)\n end",
"def dispatch(name = :default, &block)\n target_queue = @dispatcher[name] ||= Pigeon::Dispatcher.new(name == :default ? nil : 1)\n \n target_queue.perform(&block)\n end",
"def set_type\n @type = controller_name.classify\n end",
"def set_type\n @type = controller_name.classify\n end",
"def method_missing(name, *args, &block)\n target.send(name, *args, &block)\n end",
"def use_named_scope(&block)\n lang_eval { @use_named_scope_block = block }\n nil\n end",
"def route_to(klass_or_name, action)\n RouteToMatcher.new(klass_or_name, action)\n end",
"def visit(binding_type)\n key = binding_type.class\n method = @@dispatch_map[key]\n raise \"unexpected binding type: #{key}\" unless method\n send(method, binding_type)\n end",
"def helpers( target, &block )\n if target.is_a? String\n target = Object.const_get target.capitalize\n end\n target.class_eval &block\n end",
"def injected_param(type, name, injection_name = '')\n @injections << [type, name, injection_name]\n # mark what should be picked for this position when dispatching\n @weaving << [@injections.size() -1]\n end",
"def define_scope_method(name)\n singleton_class.class_eval do\n ruby2_keywords(\n define_method(name) do |*args|\n scoping = _declared_scopes[name]\n scope = instance_exec(*args, &scoping[:scope])\n extension = scoping[:extension]\n to_merge = scope || queryable\n criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)\n criteria.extend(extension)\n criteria\n end\n )\n end\n end",
"def pkg_default_target_func(name, target)\n case target\n when /fetch/i\n return Proc.new {\n $pkglist[name].pkg_fetch\n }\n when /configure/i\n return Proc.new {\n $pkglist[name].pkg_configure\n }\n when /export/i\n return Proc.new {\n $pkglist[name].pkg_export\n }\n when /build/i\n return Proc.new {\n $pkglist[name].pkg_build\n }\n when /install/i\n return Proc.new {\n $pkglist[name].pkg_install\n }\n when /update/i\n return Proc.new {\n $pkglist[name].pkg_update\n }\n when /clean/i\n return Proc.new {\n $pkglist[name].pkg_clean\n }\n else\n syserr \"Undefined target #{target} for package #{name.to_s}\"\n raise\n end\n end",
"def scope_name name\n name.to_s.pluralize.to_sym\n end",
"def scoped(scope = {}, &block)\n ActiveRecord::NamedScope::Scope.new(self, scope, &block)\n end",
"def compute_type(type_name)\n if type_name.start_with?(\"::\")\n # If the type is prefixed with a scope operator then we assume that\n # the type_name is an absolute reference.\n type_name.constantize\n else\n type_candidate = @_type_candidates_cache[type_name]\n if type_candidate && type_constant = type_candidate.safe_constantize\n return type_constant\n end\n\n # Build a list of candidates to search for\n candidates = []\n name.scan(/::|$/) { candidates.unshift \"#{$`}::#{type_name}\" }\n candidates << type_name\n\n candidates.each do |candidate|\n constant = candidate.safe_constantize\n if candidate == constant.to_s\n @_type_candidates_cache[type_name] = candidate\n return constant\n end\n end\n\n raise NameError.new(\"uninitialized constant #{candidates.first}\", candidates.first)\n end\n end",
"def name\n type.to_s.capitalize\n end",
"def nametype_params\n params.require(:nametype).permit(:name, :name_type_authority_id)\n end",
"def method_missing(name, *args, &block)\n @klass.send(name, *args, &block)\n end"
] | [
"0.5854092",
"0.54851234",
"0.54614395",
"0.5429654",
"0.5369638",
"0.53256947",
"0.52948576",
"0.5201738",
"0.5185947",
"0.5157362",
"0.51186293",
"0.50766975",
"0.5053053",
"0.5030344",
"0.500551",
"0.4995355",
"0.49022508",
"0.48995999",
"0.48943287",
"0.48399782",
"0.48347542",
"0.48181865",
"0.48013762",
"0.47965032",
"0.4788069",
"0.4781321",
"0.4778214",
"0.4777023",
"0.4762054",
"0.47612897",
"0.4753182",
"0.4741846",
"0.47317243",
"0.4722234",
"0.47201493",
"0.4717804",
"0.47151953",
"0.46825206",
"0.4673563",
"0.46505925",
"0.46160984",
"0.4596029",
"0.459074",
"0.4575775",
"0.45702457",
"0.45696375",
"0.45637092",
"0.45604226",
"0.45447648",
"0.45383683",
"0.45383066",
"0.4532588",
"0.45324427",
"0.45098972",
"0.45028698",
"0.44977504",
"0.44890964",
"0.44845408",
"0.4484151",
"0.4483172",
"0.44642368",
"0.4456132",
"0.44507933",
"0.44447282",
"0.44367257",
"0.44232464",
"0.44206747",
"0.44200847",
"0.4415325",
"0.44087476",
"0.43972126",
"0.4397095",
"0.4395825",
"0.4395766",
"0.43953976",
"0.43937862",
"0.43906638",
"0.43902332",
"0.43884712",
"0.43845454",
"0.43809673",
"0.4378842",
"0.43782938",
"0.43772432",
"0.4369603",
"0.4369603",
"0.4364412",
"0.43631107",
"0.43571126",
"0.4354107",
"0.43534097",
"0.43526077",
"0.43509334",
"0.4347459",
"0.43466175",
"0.43423393",
"0.43369243",
"0.43312123",
"0.4320172",
"0.43179026"
] | 0.7343106 | 0 |
Define scope type matcher. Scope matcher is an object that implements `===` (_case equality_) or a Proc. When no type is provided when applying a scope we try to infer a type from the target object by calling matchers one by one until we find a matching type (i.e. there is a matcher which returns `true` when applying it to the target). | def scope_matcher(type, class_or_proc)
scope_matchers << [type, class_or_proc]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applies_type?(scope, type); end",
"def type_matcher(mod)\n TypeMatcher.new(mod)\n end",
"def scope_type(node); end",
"def call_scope_by_type(type, scope, target, value, options) #:nodoc:\n if type == :boolean\n target.send(scope)\n elsif value && options.key?(:using)\n value = value.values_at(*options[:using])\n target.send(scope, *value)\n else\n target.send(scope, value)\n end\n end",
"def scope_match(&block)\n return @scope_match if block.nil?\n @scope_match = block\n end",
"def authorization_scope_type_for(policy, target)\n policy.resolve_scope_type(target)\n end",
"def apply_scope(target, type:, name: :default, scope_options: nil)\n raise ActionPolicy::UnknownScopeType.new(self.class, type) unless\n self.class.scoping_handlers.key?(type)\n\n raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless\n self.class.scoping_handlers[type].key?(name)\n\n mid = :\"__scoping__#{type}__#{name}\"\n scope_options ? send(mid, target, **scope_options) : send(mid, target)\n end",
"def has_scope(scope_group, *scopes)\n options = scopes.extract_options!\n options.symbolize_keys!\n options.assert_valid_keys(:type, :if, :unless, :default, :as, :using, :allow_blank)\n\n if options.key?(:using)\n if options.key?(:type) && options[:type] != :hash\n raise \"You cannot use :using with another :type different than :hash\"\n else\n options[:type] = :hash\n end\n\n options[:using] = [*options[:using]]\n end\n\n self.scopes_configuration ||= {}\n self.scopes_configuration[scope_group] ||= {}\n\n scopes.each do |scope|\n self.scopes_configuration[scope_group][scope] ||= {\n :as => scope,\n :type => :default\n }\n self.scopes_configuration[scope_group][scope].merge!(options)\n end\n end",
"def applies?(scope, path, type); end",
"def scope(name, scope=nil, &block)\n raise ArgumentError, \"Dangerous scope name: a :#{name} method is already defined. Please, use another one.\" \\\n if respond_to?(name)\n proc = case\n when block_given?\n block\n when scope.is_a?(Flex::Scope)\n lambda {scope}\n when scope.is_a?(Proc)\n scope\n else\n raise ArgumentError, \"Scope object or Proc expected (got #{scope.inspect})\"\n end\n metaclass = class << self; self end\n metaclass.send(:define_method, name) do |*args|\n scope = proc.call(*args)\n raise Scope::Error, \"The scope :#{name} does not return a Flex::Scope object (got #{scope.inspect})\" \\\n unless scope.is_a?(Flex::Scope)\n scope\n end\n scope_methods << name\n end",
"def set_scope_class\n klass = self.class::Scope\n klass.send(:include, ScopeMethods)\n @scope_class = klass.new(@scope, @search_attributes)\n end",
"def class_scope?\n @type == :class || @type == :module\n end",
"def class_scope?\n @type == :class or @type == :module\n end",
"def has_scope?( scope )\n scope_names.include?( scope )\n end",
"def requested_type\n return @requested_type if defined?(@requested_type)\n\n opts = @scope.opts[:type_routing]\n @requested_type = accept_response_type if opts[:use_header]\n @requested_type ||= opts[:default_type]\n end",
"def scope\n finder_or_run(:scope)\n end",
"def verify_scope(scope)\n self.user_scope.each do |sym|\n raise RuntimeError, \"Expected to be passed a scope containing the key '#{sym.to_s}'\" unless scope.has_key? sym\n end\n scope\n end",
"def apply_to_scope(scope)\n scope\n end",
"def valid_scope?\n scope.to_s == self.class.scope.to_s\n end",
"def scope!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 2)\n\n type = SCOPE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 8:9: 'scope'\n match(\"scope\")\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__, 2)\n\n end",
"def valid_scope(valid_scopes, scope)\n\t\tend",
"def match(env, target)\n target_type = target.kind_of?(Type) ? target : target.pione_type(env)\n while target_type do\n return true if self == target_type\n target_type = target_type.parent_type\n end\n return false\n end",
"def scope(scope, &block)\n @scopes[scope] ||= []\n @scopes[scope] << block\n end",
"def resolved_scope(scope)\n scoper_object(scope).resolve\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def add_type_filter(criteria)\n unless params[:type_uri].blank?\n @type_filter = params[:type_uri]\n @type = RdfType.find(@type_filter) rescue nil\n criteria.where(\"?uri a <#{@type_filter}>\")\n end\n criteria\n end",
"def scope scope = nil, &proc\n @scope = (proc || scope) if (scope || proc) && configurable?\n @setup[:scope] ||= @scope ||\n (@controller.ctrl.slice.view.scope if @controller)\n end",
"def favorites_by_type(favoritable_type, options = {})\n if options.key?(:multiple_scopes) == false\n options[:parameter] = favoritable_type\n validate_scopes(__method__, options)\n elsif options[:multiple_scopes]\n results = {}\n options[:scope].each do |scope|\n favorites_scope = favorites_scoped(\n scope: scope, multiple_scopes: false\n ).for_favoritable_type(favoritable_type)\n results[scope] = apply_options_to_scope(\n favorites_scope, options\n )\n end\n results\n else\n favorites_scope = favorites_scoped(\n scope: options[:scope], multiple_scopes: false\n ).for_favoritable_type(favoritable_type)\n apply_options_to_scope(\n favorites_scope, options\n )\n end\n end",
"def update_scope\n @scope = params[:scope] || params[:q] || {}\n end",
"def scope\n klass\n end",
"def grammar_type_to_rule_properties_scope\n defined?(@@grammar_type_to_rule_properties_scope) ? @@grammar_type_to_rule_properties_scope : @@grammar_type_to_rule_properties_scope= Array.typed(AttributeScope).new([nil, self.attr_predefined_lexer_rule_properties_scope, self.attr_predefined_rule_properties_scope, self.attr_predefined_tree_rule_properties_scope, self.attr_predefined_rule_properties_scope])\n end",
"def scoped(scope = {}, &block)\n ActiveRecord::NamedScope::Scope.new(self, scope, &block)\n end",
"def favorited_type(favoritable, options = {})\n if options.key?(:multiple_scopes) == false\n options[:parameter] = favoritable\n validate_scopes(__method__, options)\n elsif options[:multiple_scopes]\n results = {}\n options[:scope].each do |scope|\n if Favorite.unblocked.send(scope + '_list').for_favoritor(self)\n .for_favoritable(favoritable).count.positive?\n results[scope] = true\n elsif Favorite.blocked.send(scope + '_list').for_favoritor(self)\n .for_favoritable(favoritable).count.positive?\n results[scope] = false\n else\n results[scope] = nil\n end\n end\n results\n elsif Favorite.unblocked.send(options[:scope] + '_list')\n .for_favoritor(self).for_favoritable(favoritable).count\n .positive?\n true\n elsif Favorite.blocked.send(options[:scope] + '_list')\n .for_favoritor(self).for_favoritable(favoritable).count\n .positive?\n false\n end\n end",
"def favorites_by_type favoritable_type, options = {}\n if options.key?(:multiple_scopes) == false\n options[:parameter] = favoritable_type\n validate_scopes __method__, options\n elsif options[:multiple_scopes] == true\n results = {}\n options[:scope].each do |scope|\n favorites_scope = favorites_scoped(scope).for_favoritable_type favoritable_type\n results[scope] = favorites_scope = apply_options_to_scope favorites_scope, options\n end\n return results\n else\n favorites_scope = favorites_scoped(options[:scope]).for_favoritable_type favoritable_type\n return favorites_scope = apply_options_to_scope(favorites_scope, options)\n end\n end",
"def uses_defn?(scope)\n if scope.iter? or scope.module?\n true\n elsif scope.class? and %w(Object BasicObject).include?(scope.name)\n true\n else\n false\n end\n end",
"def scope\n read_attr :scope, :to_sym\n end",
"def quoted_scope(name = nil, type: nil)\n schema, name = extract_schema_qualified_name(name)\n type =\n case type # rubocop:disable Style/HashLikeCase\n when \"BASE TABLE\"\n \"'r','p'\"\n when \"VIEW\"\n \"'v','m'\"\n when \"FOREIGN TABLE\"\n \"'f'\"\n end\n scope = {}\n scope[:schema] = quote(schema || shard.name)\n scope[:name] = quote(name) if name\n scope[:type] = type if type\n scope\n end",
"def be_kind_of(klass)\n Matchy::Expectations::BeKindOfExpectation.new(klass, self)\n end",
"def scoped_by(name, options = {})\n options[:scope] ||= :reference\n if scope_class = self.class.scope_types[options[:scope]]\n @scopes[name] = scope_class.new(@model, name, options)\n end\n end",
"def is_sphinx_scope?(scope_name)\n klass.sphinx_scopes.include?(scope_name.to_sym)\n end",
"def has_type?(type_sym)\n each_term do |term|\n if is?(term, type_sym)\n return true\n end\n end\n \n false\n end",
"def identifyScope(theLine, currentScope)\n\n\ttheText = theLine[:text];\n\tnewScope = currentScope;\n\t\n\tif (theText =~ /^enum /)\n\t\tnewScope = :enum;\n\t\n\telsif (theText =~ /^struct /)\n\t\tnewScope = :struct;\n\t\n\telsif (theText =~ /^class /)\n\t\tnewScope = :class;\n\t\n\telsif (theText =~ /^(\\w+)::\\1\\(/)\n\t\tnewScope = :constructor;\n\t\n\telsif (theText == \"{\")\n\t\tif (currentScope == :global)\n\t\t\tnewScope = :function;\n\t\tend\n\t\n\telsif (theText == \"}\")\n\t\tnewScope = :global;\n\tend\n\t\n\treturn newScope;\n\nend",
"def register_spec_type *args, &block\n if block then\n matcher, klass = block, args.first\n else\n matcher, klass = *args\n end\n TYPES.unshift [matcher, klass]\n end",
"def enter(other_type_defn)\n case other_type_defn\n when nil\n # The type wasn't found, who cares\n Scope.new(@query, nil)\n when @type\n # The condition is the same as current, so reuse self\n self\n when GraphQL::UnionType, GraphQL::InterfaceType\n # Make a new scope of the intersection between the previous & next conditions\n new_types = @query.possible_types(other_type_defn) & concrete_types\n Scope.new(@query, new_types)\n when GraphQL::BaseType\n # If this type is valid within the current scope,\n # return a new scope of _exactly_ this type.\n # Otherwise, this type is out-of-scope so the scope is null.\n if concrete_types.include?(other_type_defn)\n Scope.new(@query, other_type_defn)\n else\n Scope.new(@query, nil)\n end\n else\n raise \"Unexpected scope: #{other_type_defn.inspect}\"\n end\n end",
"def is?(term, type_sym)\n return term[:type] == type_sym\n end",
"def _find_non_empty_scope(type, local_scope, *additional_possibilities)\n found = [\n local_scope[:\"#{type}s\"],\n [local_scope[type.to_sym]],\n ::Guard.scope[:\"#{type}s\"],\n additional_possibilities.flatten\n ]\n found.compact.detect { |a| !Array(a).compact.empty? }\n end",
"def has_scopes(*scopes)\n self.scope_class_methods = self.scope_class_methods +\n Array.wrap(scopes).map(&:to_sym)\n end",
"def set_scope(val)\n @scope = val\n build_path_query\n @scope\n end",
"def scope\n @scope ||= {}\n end",
"def scope\n @scope ||= {}\n end",
"def scope_by(&block)\n raise 'Cannot define scope after scope has been called.' if @scope\n\n @scope_block = block\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 4)\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token SCOPE\")\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token ACTION\")\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule id\")\n begin\n # at line 122:4: 'scope' id ACTION\n string_literal19 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_557) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal19)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_attr_scope_559)\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id20.tree)\n end\n __ACTION21__ = match(ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_561) \n if @state.backtracking == 0\n stream_ACTION.add(__ACTION21__)\n end\n # AST Rewrite\n # elements: ACTION, id, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 122:22: -> ^( 'scope' id ACTION )\n # at line 122:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_SCOPE.next_node, root_1)\n\n @adaptor.add_child(root_1, stream_id.next_tree)\n @adaptor.add_child(root_1, stream_ACTION.next_node)\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 4)\n\n end\n \n return return_value\n end",
"def has_scope?(**scopes_hash)\n scopes_hash.detect do |section, scopes|\n test_scopes = case\n when scopes.is_a?(String); scopes.split(',')\n when scopes.is_a?(Array); scopes\n else raise \"Scope must be a string or array\"\n end\n test_scopes.detect do |scope|\n all_scopes[section.to_s].to_a.include?(scope.to_s)\n end\n end\n end",
"def is_type?\n @predicate.to_s == \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\"\n end",
"def search(scope, _criteria)\n scope\n end",
"def scope\n @scope ||= TestScope.new(self)\n end",
"def rule_scope_spec\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n return_value = RuleScopeSpecReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal62 = nil\n __ACTION63__ = nil\n string_literal64 = nil\n char_literal66 = nil\n char_literal68 = nil\n string_literal69 = nil\n __ACTION70__ = nil\n string_literal71 = nil\n char_literal73 = nil\n char_literal75 = nil\n id65 = nil\n id67 = nil\n id72 = nil\n id74 = nil\n\n tree_for_string_literal62 = nil\n tree_for_ACTION63 = nil\n tree_for_string_literal64 = nil\n tree_for_char_literal66 = nil\n tree_for_char_literal68 = nil\n tree_for_string_literal69 = nil\n tree_for_ACTION70 = nil\n tree_for_string_literal71 = nil\n tree_for_char_literal73 = nil\n tree_for_char_literal75 = nil\n stream_T__80 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__80\" )\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token T__71\" )\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token SCOPE\" )\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token ACTION\" )\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule id\" )\n begin\n # at line 177:2: ( 'scope' ACTION -> ^( 'scope' ACTION ) | 'scope' id ( ',' id )* ';' -> ^( 'scope' ( id )+ ) | 'scope' ACTION 'scope' id ( ',' id )* ';' -> ^( 'scope' ACTION ( id )+ ) )\n alt_29 = 3\n look_29_0 = @input.peek( 1 )\n\n if ( look_29_0 == SCOPE )\n look_29_1 = @input.peek( 2 )\n\n if ( look_29_1 == ACTION )\n look_29_2 = @input.peek( 3 )\n\n if ( look_29_2 == SCOPE )\n alt_29 = 3\n elsif ( look_29_2 == AT || look_29_2 == T__78 )\n alt_29 = 1\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 29, 2 )\n end\n elsif ( look_29_1 == TOKEN_REF || look_29_1 == RULE_REF )\n alt_29 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 29, 1 )\n end\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 29, 0 )\n end\n case alt_29\n when 1\n # at line 177:4: 'scope' ACTION\n string_literal62 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1030 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal62 )\n end\n __ACTION63__ = match( ACTION, TOKENS_FOLLOWING_ACTION_IN_rule_scope_spec_1032 )\n if @state.backtracking == 0\n stream_ACTION.add( __ACTION63__ )\n end\n # AST Rewrite\n # elements: ACTION, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 177:19: -> ^( 'scope' ACTION )\n # at line 177:22: ^( 'scope' ACTION )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_ACTION.next_node )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n when 2\n # at line 178:4: 'scope' id ( ',' id )* ';'\n string_literal64 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1045 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal64 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_rule_scope_spec_1047 )\n id65 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id65.tree )\n end\n # at line 178:15: ( ',' id )*\n while true # decision 27\n alt_27 = 2\n look_27_0 = @input.peek( 1 )\n\n if ( look_27_0 == T__80 )\n alt_27 = 1\n\n end\n case alt_27\n when 1\n # at line 178:16: ',' id\n char_literal66 = match( T__80, TOKENS_FOLLOWING_T__80_IN_rule_scope_spec_1050 )\n if @state.backtracking == 0\n stream_T__80.add( char_literal66 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_rule_scope_spec_1052 )\n id67 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id67.tree )\n end\n\n else\n break # out of loop for decision 27\n end\n end # loop for decision 27\n char_literal68 = match( T__71, TOKENS_FOLLOWING_T__71_IN_rule_scope_spec_1056 )\n if @state.backtracking == 0\n stream_T__71.add( char_literal68 )\n end\n # AST Rewrite\n # elements: id, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 178:29: -> ^( 'scope' ( id )+ )\n # at line 178:32: ^( 'scope' ( id )+ )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n # at line 178:42: ( id )+\n stream_id.has_next? or raise ANTLR3::RewriteEarlyExit\n\n while stream_id.has_next?\n @adaptor.add_child( root_1, stream_id.next_tree )\n\n end\n stream_id.reset\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n when 3\n # at line 179:4: 'scope' ACTION 'scope' id ( ',' id )* ';'\n string_literal69 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1070 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal69 )\n end\n __ACTION70__ = match( ACTION, TOKENS_FOLLOWING_ACTION_IN_rule_scope_spec_1072 )\n if @state.backtracking == 0\n stream_ACTION.add( __ACTION70__ )\n end\n string_literal71 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1076 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal71 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_rule_scope_spec_1078 )\n id72 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id72.tree )\n end\n # at line 180:14: ( ',' id )*\n while true # decision 28\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == T__80 )\n alt_28 = 1\n\n end\n case alt_28\n when 1\n # at line 180:15: ',' id\n char_literal73 = match( T__80, TOKENS_FOLLOWING_T__80_IN_rule_scope_spec_1081 )\n if @state.backtracking == 0\n stream_T__80.add( char_literal73 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_rule_scope_spec_1083 )\n id74 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id74.tree )\n end\n\n else\n break # out of loop for decision 28\n end\n end # loop for decision 28\n char_literal75 = match( T__71, TOKENS_FOLLOWING_T__71_IN_rule_scope_spec_1087 )\n if @state.backtracking == 0\n stream_T__71.add( char_literal75 )\n end\n # AST Rewrite\n # elements: id, ACTION, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 181:3: -> ^( 'scope' ACTION ( id )+ )\n # at line 181:6: ^( 'scope' ACTION ( id )+ )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_ACTION.next_node )\n # at line 181:23: ( id )+\n stream_id.has_next? or raise ANTLR3::RewriteEarlyExit\n\n while stream_id.has_next?\n @adaptor.add_child( root_1, stream_id.next_tree )\n\n end\n stream_id.reset\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n\n end\n \n return return_value\n end",
"def scope(scope_name)\n Scope.new(@backend, @name, scope_name)\n end",
"def type_qualifier\n @_type_qualifier ||= begin\n error_check(INVALID_OPERATION) if @kernel.context.platform.version_number < 1.2\n ptr = MemoryPointer::new( :cl_kernel_arg_type_qualifier )\n error = OpenCL.clGetKernelArgInfo(@kernel, @index, TYPE_QUALIFIER, ptr.size, ptr, nil)\n error_check(error)\n TypeQualifier::new( ptr.read_cl_kernel_arg_type_qualifier )\n end\n end",
"def rule_scope_spec\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 13)\n return_value = RuleScopeSpecReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal62 = nil\n __ACTION63__ = nil\n string_literal64 = nil\n char_literal66 = nil\n char_literal68 = nil\n string_literal69 = nil\n __ACTION70__ = nil\n string_literal71 = nil\n char_literal73 = nil\n char_literal75 = nil\n id65 = nil\n id67 = nil\n id72 = nil\n id74 = nil\n\n tree_for_string_literal62 = nil\n tree_for_ACTION63 = nil\n tree_for_string_literal64 = nil\n tree_for_char_literal66 = nil\n tree_for_char_literal68 = nil\n tree_for_string_literal69 = nil\n tree_for_ACTION70 = nil\n tree_for_string_literal71 = nil\n tree_for_char_literal73 = nil\n tree_for_char_literal75 = nil\n stream_T__80 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__80\")\n stream_T__71 = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token T__71\")\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token SCOPE\")\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token ACTION\")\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule id\")\n begin\n # at line 186:2: ( 'scope' ACTION -> ^( 'scope' ACTION ) | 'scope' id ( ',' id )* ';' -> ^( 'scope' ( id )+ ) | 'scope' ACTION 'scope' id ( ',' id )* ';' -> ^( 'scope' ACTION ( id )+ ) )\n alt_29 = 3\n look_29_0 = @input.peek(1)\n\n if (look_29_0 == SCOPE) \n look_29_1 = @input.peek(2)\n\n if (look_29_1 == ACTION) \n look_29_2 = @input.peek(3)\n\n if (look_29_2 == SCOPE) \n alt_29 = 3\n elsif (look_29_2 == AT || look_29_2 == T__78) \n alt_29 = 1\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 29, 2)\n raise nvae\n end\n elsif (look_29_1 == TOKEN_REF || look_29_1 == RULE_REF) \n alt_29 = 2\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 29, 1)\n raise nvae\n end\n else\n @state.backtracking > 0 and raise(ANTLR3::Error::BacktrackingFailed)\n nvae = NoViableAlternative(\"\", 29, 0)\n raise nvae\n end\n case alt_29\n when 1\n # at line 186:4: 'scope' ACTION\n string_literal62 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1035) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal62)\n end\n __ACTION63__ = match(ACTION, TOKENS_FOLLOWING_ACTION_IN_rule_scope_spec_1037) \n if @state.backtracking == 0\n stream_ACTION.add(__ACTION63__)\n end\n # AST Rewrite\n # elements: SCOPE, ACTION\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 186:19: -> ^( 'scope' ACTION )\n # at line 186:22: ^( 'scope' ACTION )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_SCOPE.next_node, root_1)\n\n @adaptor.add_child(root_1, stream_ACTION.next_node)\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end\n when 2\n # at line 187:4: 'scope' id ( ',' id )* ';'\n string_literal64 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1050) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal64)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_rule_scope_spec_1052)\n id65 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id65.tree)\n end\n # at line 187:15: ( ',' id )*\n loop do #loop 27\n alt_27 = 2\n look_27_0 = @input.peek(1)\n\n if (look_27_0 == T__80) \n alt_27 = 1\n\n end\n case alt_27\n when 1\n # at line 187:16: ',' id\n char_literal66 = match(T__80, TOKENS_FOLLOWING_T__80_IN_rule_scope_spec_1055) \n if @state.backtracking == 0\n stream_T__80.add(char_literal66)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_rule_scope_spec_1057)\n id67 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id67.tree)\n end\n\n else\n break #loop 27\n end\n end\n char_literal68 = match(T__71, TOKENS_FOLLOWING_T__71_IN_rule_scope_spec_1061) \n if @state.backtracking == 0\n stream_T__71.add(char_literal68)\n end\n # AST Rewrite\n # elements: id, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 187:29: -> ^( 'scope' ( id )+ )\n # at line 187:32: ^( 'scope' ( id )+ )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_SCOPE.next_node, root_1)\n\n # at line 187:42: ( id )+\n unless stream_id.has_next?\n raise ANTLR3::RewriteEarlyExit\n end\n\n while stream_id.has_next?\n @adaptor.add_child(root_1, stream_id.next_tree)\n\n end\n\n stream_id.reset\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end\n when 3\n # at line 188:4: 'scope' ACTION 'scope' id ( ',' id )* ';'\n string_literal69 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1075) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal69)\n end\n __ACTION70__ = match(ACTION, TOKENS_FOLLOWING_ACTION_IN_rule_scope_spec_1077) \n if @state.backtracking == 0\n stream_ACTION.add(__ACTION70__)\n end\n string_literal71 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_rule_scope_spec_1081) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal71)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_rule_scope_spec_1083)\n id72 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id72.tree)\n end\n # at line 189:14: ( ',' id )*\n loop do #loop 28\n alt_28 = 2\n look_28_0 = @input.peek(1)\n\n if (look_28_0 == T__80) \n alt_28 = 1\n\n end\n case alt_28\n when 1\n # at line 189:15: ',' id\n char_literal73 = match(T__80, TOKENS_FOLLOWING_T__80_IN_rule_scope_spec_1086) \n if @state.backtracking == 0\n stream_T__80.add(char_literal73)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_rule_scope_spec_1088)\n id74 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id74.tree)\n end\n\n else\n break #loop 28\n end\n end\n char_literal75 = match(T__71, TOKENS_FOLLOWING_T__71_IN_rule_scope_spec_1092) \n if @state.backtracking == 0\n stream_T__71.add(char_literal75)\n end\n # AST Rewrite\n # elements: ACTION, SCOPE, id\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 190:3: -> ^( 'scope' ACTION ( id )+ )\n # at line 190:6: ^( 'scope' ACTION ( id )+ )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_SCOPE.next_node, root_1)\n\n @adaptor.add_child(root_1, stream_ACTION.next_node)\n # at line 190:23: ( id )+\n unless stream_id.has_next?\n raise ANTLR3::RewriteEarlyExit\n end\n\n while stream_id.has_next?\n @adaptor.add_child(root_1, stream_id.next_tree)\n\n end\n\n stream_id.reset\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 13)\n\n end\n \n return return_value\n end",
"def scope?\n # context = Ransack::Context.for klass\n # context.respond_to?(:ransackable_scope?) && context.ransackable_scope?(method.to_s, klass)\n false\n end",
"def scope_query(operand)\n @scope << operand.class\n end",
"def scope(object = nil)\n configure(:scope, object)\n end",
"def type(env = {})\n @then_expr.type env\n end",
"def scope\n scope!(operator) if @scopes.empty?\n scope!(\"AND\") if @scopes.last.is_a?(NestedScope)\n @scopes.last\n end",
"def rdf_type_predicate\n RDF::URI(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\")\n end",
"def selected_scope\n (params[:scope] || :default).to_sym\n end",
"def define_scope_method(name)\n singleton_class.class_eval do\n ruby2_keywords(\n define_method(name) do |*args|\n scoping = _declared_scopes[name]\n scope = instance_exec(*args, &scoping[:scope])\n extension = scoping[:extension]\n to_merge = scope || queryable\n criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)\n criteria.extend(extension)\n criteria\n end\n )\n end\n end",
"def in_scope?(request_scope)\n [*request_scope].all?(&scopes.method(:include?))\n end",
"def environment(type, &blk)\n types = [type].flatten.collect { |t| t.to_sym }\n blk.call if types.include?(Goliath.env.to_sym)\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token SCOPE\" )\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token ACTION\" )\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule id\" )\n begin\n # at line 113:4: 'scope' id ACTION\n string_literal19 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_552 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal19 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_attr_scope_554 )\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id20.tree )\n end\n __ACTION21__ = match( ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_556 )\n if @state.backtracking == 0\n stream_ACTION.add( __ACTION21__ )\n end\n # AST Rewrite\n # elements: SCOPE, id, ACTION\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 113:22: -> ^( 'scope' id ACTION )\n # at line 113:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_id.next_tree )\n @adaptor.add_child( root_1, stream_ACTION.next_node )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n end\n \n return return_value\n end",
"def set_scope(scope)\n run_callbacks :set_scope do\n self.scope = scope\n end\n end",
"def it_scope\n @it_scope ||= Example::Scope.new(self)\n end",
"def scope\n record.class\n end",
"def of_type(type)\n ->(node) { node.is_a?(type) }\nend",
"def scope_from_params(params)\n return default_scope if params[:scope].blank?\n scope = params[:scope].is_a?(Array) ? params[:scope] : params[:scope].split(',')\n scope = scope.map(&:downcase).map(&:strip)\n return scope & default_scope\n end",
"def scope\n if tree.columns.scope?\n tree.base_class.where Hash[tree.columns.scope.map { |column| [column, record[column]] }]\n else\n tree.base_class.where(nil)\n end\n end",
"def create_matcher(type, name, &block)\n matcher = StepMatcher.new(name, &block)\n @hash_of_lists_of_matchers[type] << matcher\n matcher\n end",
"def scope=(new_scope)\n case new_scope\n when Array\n @scope = new_scope.join(' ')\n when String\n @scope = new_scope\n when nil\n @scope = ''\n else\n raise TypeError, \"Expected Array or String, got #{new_scope.class}\"\n end\n end",
"def scope_callback(block, scope=nil)\n scope ? lambda { send(scope).instance_eval(&block) } : block\n end",
"def scope &block\n env.scope(&block)\n end",
"def scope &block\n env.scope(&block)\n end",
"def scope &block\n env.scope(&block)\n end",
"def resolve(scope)\n scope\n end",
"def look_for_type(target_type, ignoring = [], &blk)\n each_sexp do |elem|\n elem.look_for_type(target_type, ignoring, &blk) unless ignoring.include?(elem.type)\n end\n blk.call(self) if type == target_type\n end",
"def massage_scope!(set)\n set[\"scope\"] ||= {}\n set[\"scope\"][\"path\"] ||= \"\"\n return unless set[\"scope\"][\"type\"] && !set[\"scope\"][\"collection\"]\n\n set[\"scope\"][\"collection\"] = set[\"scope\"][\"type\"]\n end",
"def will_be?(type)\n single_class <= type\n end",
"def scope\n @attributes[:scope]\n end",
"def type_pred\n (->(type, x) { @container.is_a? type }).curry\n end",
"def valid_criteria_type # :nodoc:\n {\n 'between' => 'between',\n 'not between' => 'notBetween',\n 'equal to' => 'equal',\n '=' => 'equal',\n '==' => 'equal',\n 'not equal to' => 'notEqual',\n '!=' => 'notEqual',\n '<>' => 'notEqual',\n 'greater than' => 'greaterThan',\n '>' => 'greaterThan',\n 'less than' => 'lessThan',\n '<' => 'lessThan',\n 'greater than or equal to' => 'greaterThanOrEqual',\n '>=' => 'greaterThanOrEqual',\n 'less than or equal to' => 'lessThanOrEqual',\n '<=' => 'lessThanOrEqual'\n }\n end",
"def scope= new_scope\n case new_scope\n when Array\n new_scope.each do |scope|\n if scope.include? \" \"\n raise ArgumentError,\n \"Individual scopes cannot contain the space character.\"\n end\n end\n @scope = new_scope\n when String\n @scope = new_scope.split \" \"\n when nil\n @scope = nil\n else\n raise TypeError, \"Expected Array or String, got #{new_scope.class}\"\n end\n end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def check_resolved_type(type, object, ctx = :__undefined__)\n if ctx == :__undefined__\n # Old method signature\n ctx = object\n object = type\n type = nil\n end\n\n if object.is_a?(GraphQL::Schema::Object)\n object = object.object\n end\n\n if type.respond_to?(:graphql_definition)\n type = type.graphql_definition\n end\n\n # Prefer a type-local function; fall back to the schema-level function\n type_proc = type && type.resolve_type_proc\n type_result = if type_proc\n type_proc.call(object, ctx)\n else\n yield(type, object, ctx)\n end\n\n if type_result.respond_to?(:graphql_definition)\n type_result = type_result.graphql_definition\n end\n\n if type_result.nil?\n nil\n elsif !type_result.is_a?(GraphQL::BaseType)\n type_str = \"#{type_result} (#{type_result.class.name})\"\n raise \"resolve_type(#{object}) returned #{type_str}, but it should return a GraphQL type\"\n else\n type_result\n end\n end",
"def favorited_by_type(favoritable_type, options = {})\n if options.key?(:multiple_scopes) == false\n options[:parameter] = favoritable_type\n validate_scopes(__method__, options)\n elsif options[:multiple_scopes]\n results = {}\n options[:scope].each do |scope|\n favoritables = favoritable_type.constantize.joins(:favorited)\n favoritables = favoritables.where(\n 'favorites.blocked': false,\n 'favorites.favoritor_id': id,\n 'favorites.favoritor_type': parent_class_name(self),\n 'favorites.favoritable_type': favoritable_type,\n 'favorites.scope': scope\n )\n if options.key?(:limit)\n favoritables = favoritables.limit options[:limit]\n end\n if options.key?(:includes)\n favoritables = favoritables.includes options[:includes]\n end\n results[scope] = favoritables\n end\n results\n else\n favoritables = favoritable_type.constantize.joins(:favorited)\n favoritables = favoritables.where(\n 'favorites.blocked': false,\n 'favorites.favoritor_id': id,\n 'favorites.favoritor_type': parent_class_name(self),\n 'favorites.favoritable_type': favoritable_type,\n 'favorites.scope': options[:scope]\n )\n if options.key? :limit\n favoritables = favoritables.limit options[:limit]\n end\n if options.key? :includes\n favoritables = favoritables.includes options[:includes]\n end\n favoritables\n end\n end",
"def search_for_type(type)\n q = type\n # search for tweets containing type or #type\n # save them to DB if request is valid (ie not an exception)\n end"
] | [
"0.6947657",
"0.6124443",
"0.5949851",
"0.58142024",
"0.56766033",
"0.5673048",
"0.5441659",
"0.53827775",
"0.5366719",
"0.5353178",
"0.5302973",
"0.5300918",
"0.5299004",
"0.5231972",
"0.52060634",
"0.5149539",
"0.5135744",
"0.5116606",
"0.51091224",
"0.5091886",
"0.5006744",
"0.49135333",
"0.48937026",
"0.48188126",
"0.48121616",
"0.48121616",
"0.48121616",
"0.48121616",
"0.48121616",
"0.48121616",
"0.48037237",
"0.47834802",
"0.4783371",
"0.4774902",
"0.4770767",
"0.4764511",
"0.4758576",
"0.47324643",
"0.47144914",
"0.47038245",
"0.46993205",
"0.46826765",
"0.4682423",
"0.46751195",
"0.46658796",
"0.4660289",
"0.46461585",
"0.46342888",
"0.4631157",
"0.46277097",
"0.46178296",
"0.46107575",
"0.46102163",
"0.46051192",
"0.46051192",
"0.4600044",
"0.45661372",
"0.45621893",
"0.45621496",
"0.4559669",
"0.4557142",
"0.45513538",
"0.45494968",
"0.4547585",
"0.4536598",
"0.45287248",
"0.45143887",
"0.45128557",
"0.45117265",
"0.45061004",
"0.45037982",
"0.45003486",
"0.44863486",
"0.4476847",
"0.44757396",
"0.44757256",
"0.44683993",
"0.44491106",
"0.4436811",
"0.44254717",
"0.44223547",
"0.44187102",
"0.44173154",
"0.44145793",
"0.44029364",
"0.44022864",
"0.44022864",
"0.44022864",
"0.43893427",
"0.43825075",
"0.43755364",
"0.43709692",
"0.4361671",
"0.43513057",
"0.43373358",
"0.43372616",
"0.43305057",
"0.43297786",
"0.43291783",
"0.43286425"
] | 0.7371604 | 0 |
POST /promotions POST /promotions.json | def create
@promotion = Promotion.new(promotion_params)
@render_hidden_input = true if request.xhr?
respond_to do |format|
if @promotion.save
format.html { render :partial => "row_table", :locals => { :promotion => @promotion, :render_hidden_input => @render_hidden_input } }
else
format.json { render :json => { :errors => @promotion.errors }, :status => 409 }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_promotions\n @new_promotions ||= []\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def create\n @promotion = Promotion.new(params[:promotion])\n\n respond_to do |format|\n if @promotion.save\n\t\t@promotion.update_notification\n\t\t@promotion.push\n format.html { redirect_to promotions_path(:playerid=>current_player.playerid), notice: 'Promotion was successfully created.' }\n format.json { render json: @promotion, status: :created, location: @promotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @promotions = Promotion.all\n end",
"def index\n @promotions = Promotion.all\n end",
"def index\n @promotions = Promotion.all\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n\t\t@promotion.update_notification\n\t\t#@promotion.push\n format.html { redirect_to promotions_path(:playerid=>current_player.playerid), notice: 'Promotion was successfully created.' }\n format.json { render json: @promotion, status: :created, location: @promotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_many\n ids = []\n promotions_errors = []\n promotionable_ids = params.require(:promotionable_ids)\n promotionable_type = promotion_params[:promotionable_type]\n promotionable_ids.each do |id|\n promotion = Promotion.where(promotionable_id: id, promotionable_type: promotionable_type).first\n if promotion.blank?\n promotion = Promotion.new(promotionable_id: id, promotionable_type: promotionable_type)\n unless promotion.save\n promotions_errors << promotion.errors\n end\n end\n ids << promotion.id\n end\n @promotions = Promotion.find(ids)\n respond_to do |format|\n unless promotions_errors.count > 0\n format.json { render :index, status: :created, location: promotions_url }\n else\n format.json { render json: promotions_errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n authorize @promotion\n if @promotion.save\n render json: {promotion: @promotion, status: :created }\n else\n render json: {errors: @promotion.errors, status: :unprocessable_entity }, status: :unprocessable_entity\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n if @promotion.save\n render json: @promotion, status: :created, location: @promotion\n else\n render json: @promotion.errors, status: :unprocessable_entity\n end\n end",
"def existing_promotions\n @existing_promotions ||= []\n end",
"def index\n @promotions = current_shop_owner.promotions.all\n end",
"def index\n @title = t('admin.promotions.index.title')\n @promotions = ( @product ? @product.promotions : Promotion.all )\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @promotions }\n end\n end",
"def promotions\n @promotions ||= order.promotions\n end",
"def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end",
"def create\n @promotion = current_shop_owner.promotions.new(promotion_params.merge(customer_ids: customer_ids))\n\n # @promotion.translate(@promotion.body)\n\n# make notes that belong to the current shop owner\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to shop_owner_promotion_path(current_shop_owner,@promotion), notice: 'Promotion was successfully created.' }\n # send_text.promotion\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post()\n # construct arguments to fetch\n args = {\n method: 'post',\n credentials: 'include',\n headers: {'Content-Type' => 'application/json'},\n body: {\n project: @ppmc.id,\n ids: @ppmc.mentors.join(','),\n action: 'add',\n targets: ['ldap', 'ppmc', 'committer']\n }.inspect\n }\n\n @disabled = true\n Polyfill.require(%w(Promise fetch)) do\n @create_disabled = true\n fetch(\"actions/ppmc\", args).then {|response|\n content_type = response.headers.get('content-type') || ''\n if response.status == 200 and content_type.include? 'json'\n response.json().then do |json|\n self.update(json)\n end\n else\n alert \"#{response.status} #{response.statusText}\"\n end\n @create_disabled = false\n }.catch {|error|\n alert error\n @create_disabled = false\n }\n end\n end",
"def create\n @puntuation = Puntuation.new(puntuation_params)\n\n respond_to do |format|\n if @puntuation.save\n @voted_contribution = Contribution.find(@puntuation.contribution_id)\n @voted_contribution.increment!(:puntuation, 1)\n format.html { redirect_to :back }\n format.json { render :show, status: :created, location: @puntuation }\n else\n format.html { render :new }\n format.json { render json: @puntuation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pending_promotions\n @pending_promotions ||= []\n end",
"def create\n @promocion = Promocion.new(params[:promocion])\n\n respond_to do |format|\n if @promocion.save\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully created.' }\n format.json { render json: @promocion, status: :created, location: @promocion }\n else\n format.html { render :action => \"new\" }\n format.json { render json: @promocion.errors }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promotion = Promotion.new(params[:promotion])\n\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render json: @promotion, status: :created, location: @promotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promocion = Promocion.new(promocion_params)\n\n respond_to do |format|\n if @promocion.save\n format.html { redirect_to @promocion, notice: 'Promocion ha sido creado.' }\n format.json { render :show, status: :created, location: @promocion }\n else\n format.html { render :new }\n format.json { render json: @promocion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n\n\n @promotion = Promotion.new(promotion_params)\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to adminpromotions_path, notice: 'Test was successfully created.' }\n format.json { render :show, status: :created, location: @adminpromotion }\n else\n format.html { render :new }\n format.json { render json: @adminpromotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def promotion_params\n params.require(:promotion).permit(:title, :resume, :origin, :url, :text, :sended_at, :promoter)\n end",
"def promoter_params\n params.require(:promoter).permit(:name, :email, :password, :company_name, :phone_number, :picture_upload, station_ids: [])\n end",
"def create\n @title = t('admin.promotions.new.title')\n @promotion = Promotion.new params[:promotion]\n @promotion.state = 'not-published'\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to ['admin', @promotion], notice: 'Promotion was successfully created.' }\n format.json { render json: @promotion, status: :created, location: @promotion }\n else\n format.html { render action: 'new' }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_promotions?\n !new_promotions.empty?\n end",
"def create\r\n @promotion = Promotion.new(params[:promotion])\r\n\r\n respond_to do |format|\r\n if @promotion.save\r\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\r\n format.json { render json: @promotion, status: :created, location: @promotion }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def list(from_date: nil, to_date: nil, continuation_token: nil, headers: {})\n payload = {\n fromDate: from_date,\n toDate: to_date,\n continuationtoken: continuation_token\n }.select { |_, v| !v.nil? }\n\n @client.rest_get_with_token('/promotions', payload, headers)\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n check_unlimited\n @promotion.advertiser = current_advertiser\n \n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully created.' }\n format.json { render :show, status: :created, location: @promotion }\n else\n format.html { render :new }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def promotion_params\n params.require(:promotion).permit!\n end",
"def promotion_params\n params.require(:promotion).permit(:title, :description, :due_date,\n photos_attributes: [:id, :photo, :_destroy])\n end",
"def create\n @promotion = Promotion.new(promotion_params)\n\n respond_to do |format|\n if @promotion.save\n format.html {redirect_to @promotion, notice: 'Promotion was successfully created.'}\n format.json {render :show, status: :created, location: @promotion}\n else\n format.html {render :new}\n format.json {render json: @promotion.errors, status: :unprocessable_entity}\n end\n end\n end",
"def api_promotions_get(params, opts = {})\n data, _status_code, _headers = api_promotions_get_with_http_info(params, opts)\n return data\n end",
"def promotion_params\n params.require(:promotion).permit(:promotionable_id, :promotionable_type)\n end",
"def pushbullet_params\n params.require(:pushbullet).permit(:token, :email, :motivo)\n end",
"def create\n @promotion_tag = PromotionTag.new(promotion_tag_params)\n\n respond_to do |format|\n if @promotion_tag.save\n format.html { redirect_to @promotion_tag, notice: 'Promotion tag was successfully created.' }\n format.json { render action: 'show', status: :created, location: @promotion_tag }\n else\n format.html { render action: 'new' }\n format.json { render json: @promotion_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def existing_promotions?\n !existing_promotions.empty?\n end",
"def promotion_params\n params.require(:promotion).permit(:english_promo, :body, :send_time)\n end",
"def create\n\t\tsuper\n\t\tif params[\"requestPromotion\"] == 'true'\n\t\t\tuser = User.where(:email => params[\"email\"]).first\n\t\t\trequest = PromotionRequest.create!(\n\t\t\t\t:user => user\n\t\t\t)\n\n\t\t\t@recipients = Professor.where(:toBeNotified => true)\n\t\t\t@recipients.each do |recipient|\n\t\t\t\tputs \"Sending an email about new account\"\n\t\t\t\tNotifyProfessorsOfPromotionRequestMailer.with(request: request, recipient: recipient).notify_professors_of_promotion_request.deliver_now\n\t\t\tend\n\t\tend\n\tend",
"def create\n id = current_user.uid\n @percorso = Percorso.find(params[:percorso])\n @partecipanti = Partecipanti.new(percorso: @percorso.id, utente: id)\n\n respond_to do |format|\n if @partecipanti.save\n conn = Bunny.new\n conn.start\n ch = conn.create_channel\n x = ch.topic(\"#{@percorso.id}\")\n queue = ch.queue(\"#{@percorso.id}#{id}\")\n queue.bind(x, :routing_key => \"all\")\n queue.bind(x, :routing_key => \"#{id}\")\n ch.close\n conn.close\n format.html { redirect_to percorso_path(percorso), notice: 'Adesso fai parte di questo percorso!.' }\n format.js {}\n format.json { render :show, status: :created, location: @partecipanti }\n else\n format.html { render :new }\n format.json { render json: @partecipanti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #raise params.inspect\n params.delete :target_id if params[:target_id].to_s == \"\" \n #raise params.inspect\n\n respond_to do |format| \n if @provisioningobject.save \n if @provisioningobject.provisioningtime == Provisioningobject::PROVISIONINGTIME_IMMEDIATE\n if @provisioningobject.provision(:create, @async)\n if @async \n @notice = \"#{@provisioningobject.class.name} is being created (provisioning running in the background).\"\n else\n @notice = \"#{@provisioningobject.class.name} is provisioned.\"\n end\n else # if @provisioningobject.provision(:create, @async)\n @notice = \"#{@provisioningobject.class.name} could not be provisioned\"\n end\n else # if @provisioningobject.provisioningtime == Provisioningobject::PROVISIONINGTIME_IMMEDIATE\n # only save, do not provision:\n @notice = \"#{@provisioningobject.class.name} is created and can be provisioned ad hoc.\"\n end\n \n format.html { redirect_to @provisioningobject, notice: @notice }\n format.json { render :show, status: :created, location: @provisioningobject } \n else # if @provisioningobject.save\n format.html { render :new } \n format.json { render json: @provisioningobject.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @punishment = Punishment.new(punishment_params)\n\n respond_to do |format|\n if @punishment.save\n format.html { redirect_to @punishment, notice: 'Punishment was successfully created.' }\n format.json { render :show, status: :created, location: @punishment }\n else\n format.html { render :new }\n format.json { render json: @punishment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Create Nudge for issueing user\n @nudge = Nudge.new\n @nudge.user_id = params[:user_id]\n @nudge.pet_id = params[:pet_id]\n @nudge.group_id = Pet.find(params[:pet_id]).group.id\n @nudge.response = -1\n @nudge.nudge_token = @nudge.generate_token\n\n respond_to do |format|\n if @nudge.save\n # Create Nudge for group memebers\n Group.find(@nudge.group_id).users.each do |user|\n next if user.id == @nudge.user_id || user.device.nil?\n @nudge_member = Nudge.new\n @nudge_member.user_id = user.id\n @nudge_member.pet_id = params[:pet_id]\n @nudge_member.group_id = Pet.find(params[:pet_id]).group.id\n @nudge_member.response = 0\n @nudge_member.nudge_token = @nudge.nudge_token\n\n if @nudge_member.save\n # Send push notification\n @apn = Houston::Client.development\n device_token = User.find(@nudge_member.user_id).device.device_token\n notification = Houston::Notification.new(device: device_token)\n notification.alert = User.find(@nudge.user_id).first_name + ': Has ' + Pet.find(@nudge.pet_id).name + ' been fed?'\n notification.category = 'fed.category'\n notification.content_available = true\n notification.sound = 'sosumi.aiff'\n notification.custom_data = { nudge_id: @nudge.id, nudge_token: @nudge.nudge_token }\n @apn.push(notification)\n end\n end\n format.json { render :show, status: :created, location: @nudge }\n else\n format.json { render json: @nudge.errors, status: :unprocessable_entity }\n end \n end\n end",
"def create\n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @item_producto = @producto.item_productos.find(params[:item_producto_id])\n @opinion = @item_producto.opinions.build(opinion_params)\n respond_to do |format|\n if @opinion.save\n format.html { redirect_to empresa_producto_item_producto_opinions_path, notice: 'Item producto was successfully created.' }\n format.json { render :show, status: :created, location: @opinion }\n else\n format.html { render :new }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def probando_params\n params.require(:probando).permit(:user_id, :post_id, :parragraph, :number)\n end",
"def create\n @promotersbind = Promotersbind.new(params[:promotersbind])\n\n respond_to do |format|\n if @promotersbind.save\n format.html { redirect_to @promotersbind, :notice => 'Promotersbind was successfully created.' }\n format.json { render :json => @promotersbind, :status => :created, :location => @promotersbind }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @promotersbind.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_pm(args = {})\n args[:archetype] = \"private_message\"\n args =\n API\n .params(args)\n .required(:title, :raw, :target_recipients, :archetype)\n .optional(:category, :created_at, :api_username)\n post(\"/posts\", args.to_h)\n end",
"def create\n @property = Property.new(params[:property])\n\n respond_to do |format|\n if @property.save\n users = User.all\n users.each { |u|\n options = {\n :registration_id => u.registration_id,\n :message => \"New property added to Property Market!\",\n :id => @property.id,\n :name => @property.name,\n :ptype => @property.ptype,\n :collapse_key => @property.id.to_s\n }\n puts options.inspect\n response = SpeedyC2DM::API.send_notification(options)\n puts response.inspect\n }\n \n\n \n format.html { redirect_to @property, notice: 'Property was successfully created.' }\n format.json { render json: @property, status: :created, location: @property }\n else\n format.html { render action: \"new\" }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end",
"def processed_promos\n respond_to do |format|\n @taken_promos = TakenPromo.get_taken_promos_for_user current_user\n format.html { }\n end\n end",
"def mottovote_params\n params.require(:mottovote).permit(:user_id, :motto_id, :note)\n end",
"def promotion_params\n params.require(:promotion).permit(:title, :body, :start_at, :expire_at)\n end",
"def create_potions\n potion = Potion.create(name: 'Basic Healing Potion', heal_amount: 10, cost: 10, :merchant_id => self.id)\n\n potion1 = Potion.create(name: 'Superior Healing Potion', heal_amount: 25, cost: 20, :merchant_id => self.id)\n\n potion2 = Potion.create(name: 'Full Heal Potion', heal_amount: 50, cost: 45, :merchant_id => self.id )\n\n end",
"def pending_promotions?\n !pending_promotions.empty?\n end",
"def create\n params[:mentions].each do |men_params|\n men_params = men_params.permit(:ticker_id, :positive_count, :negative_count, :neutral_count)\n @mention = Mention.new(men_params)\n @mention.save\n end\n respond_to do |format|\n msg = { :status => :ok, :message => \"Success!\", :html => '<b></b>' }\n format.html do\n redirect_to '/'\n end\n format.json { render :json => msg }\n end\n end",
"def promotion_params\n params.require(:promotion).permit(:title, :image, :image_cache, :body, :start_date, :end_date, :sent)\n end",
"def create\n if params[:propietario]\n @negocio_propio = Negocio.find(params[:negocio_id])\n @propietario = Usuario.find(params[:usuario_id])\n authorize! :update, @propietario\n if @propietario.negocios_propios << @negocio_propio\n render json: @propietario.negocios_propios, status: :created\n else\n render json: @propietario.negocios_propios.errors, status: :unprocessable_entity\n end\n else\n @negocio = Negocio.new(parametros_negocio)\n authorize! :create, Negocio\n if @negocio.save\n render json: @negocio, status: :created\n else\n render json: @negocio.errors, status: :unprocessable_entity\n end\n end\n end",
"def send(p)\n options = {} \n\n p.each do |k,v|\n\n case k\n when :reply_path\n # Automatically request delivery receipt if reply path is set\n options[sym_to_param(:confirm_delivery)] = 'on'\n options[sym_to_param(k)] = v\n when :scheduled_for\n # Set timestamp correctly for :scheduled_for\n options[sym_to_param(k)] = v.strftime('%Y%m%d%H%M%S')\n else\n options[sym_to_param(k)] = v\n end\n\n end\n\n res = self.class.post('/submit_sm', :basic_auth => @auth, :body => JSON.dump(options))\n\n responses = []\n res['sms'].each do |r|\n responses << Dialogue::Toolkit::Sms::Response.new(r)\n end\n\n responses\n end",
"def destroy_many\n promotionable_ids = params.require(:promotionable_ids)\n promotionable_type = promotion_params[:promotionable_type]\n @promotions = Promotion.where(promotionable_id: promotionable_ids, promotionable_type: promotionable_type)\n @promotions.destroy_all\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Promotions where successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @promotions = Promotion.where(active: true)\n @all_promotions = Promotion.all\n respond_to do |format|\n format.html \n format.json { render json: @all_promotions }\n end\n end",
"def create\n @motto = Motto.new(motto_params)\n\n respond_to do |format|\n if @motto.save\n format.html { redirect_to @motto, notice: 'Motto was successfully created.' }\n format.json { render :show, status: :created, location: @motto }\n else\n format.html { render :new }\n format.json { render json: @motto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mad_mimi_email = MadMimiEmail.new\n @mimi = MadMimi.new('sarahsponda902@gmail.com', 'df65cf0a215c2b3028fa7eaf89a6f2ba')\n @promotions = @mimi.promotions\n @emails = User.where(:notify => true).map(&:email)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mad_mimi_email }\n end\n end",
"def provision\n @order = Order.new\n 1.times {@order.order_details.build}\n respond_to do |format|\n format.html # provision.html.erb\n format.json { render json: @order }\n end\n end",
"def index\n if @customer.nil?\n @promotions = Promotion.all\n else \n @promotions = @customer.promotions\n end\n render 'promotions/promotions', :locals => { :promotions => @promotions }\n end",
"def create\n @poem = Poem.new(poem_params)\n @poem.user = current_user\n\n if params[:tags_id].present?\n arr = params[:tags_id].split(',')\n @poem.tags = Tag.find(arr)\n end\n\n respond_to do |format|\n if @poem.save\n format.html { redirect_to @poem, notice: 'Poem was successfully created.' }\n format.json { render :show, status: :created, location: @poem }\n else\n format.html { render :new }\n format.json { render json: @poem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @opinion = current_user.opinions.build(opinion_params)\n\n respond_to do |format|\n if @opinion.save\n format.html { redirect_to root_path, notice: 'Opinion was successfully created.' }\n format.json { render :show, status: :created, location: @opinion }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_promotions_list\n # get params for paging\n unless params[:id].blank?\n @client_id = params[:id]\n else\n @client_id = @clients[0].id\n end\n\n rows = Array.new\n rows = get_rows(Promotion.get_by_client(@client_id).active.\n order_id_desc.page(params[:page]).per(params[:rp]), @client_id)\n count = Promotion.get_by_client(@client_id).active.order_by_promotion_name.count\n\n render json: {page: params[:page], total: count, rows: rows}\n end",
"def create\n @admin_promo = Admin::Promo.new(admin_promo_params)\n\n respond_to do |format|\n if @admin_promo.save\n format.html { redirect_to session['previous_url'] || admin_promos_path, notice: 'Promozioni è stato creato con successo.' }\n format.json { render :show, status: :created, location: @admin_promo }\n else\n format.html { render :new }\n format.json { render json: @admin_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_prowl(options)\n uri = URI.parse(\"https://prowl.weks.net/publicapi/add\")\n https = Net::HTTP.new(uri.host, uri.port)\n # We have to use SSL\n https.use_ssl = true\n # Avoid to get warning\n https.verify_mode = OpenSSL::SSL::VERIFY_NONE\n req = Net::HTTP::Post.new(uri.path)\n # Default options for notifications\n options = {:apikey => $configure[:prowl][:apikey], :application => \"Twitter\", :priority => 0}.merge(options)\n req.set_form_data(options)\n https.request(req)\nend",
"def create\n @poem = @user.poems.build(params[:poem])\n @poem.user = current_user\n\n respond_to do |format|\n if @poem.save\n format.html { redirect_to user_poems_path, notice: 'Poem was successfully created.' }\n format.json { render json: @poem, status: :created, location: @poem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @poem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def puntuation_params\n params.require(:puntuation).permit(:user_id, :contribution_id)\n end",
"def post_commit(commit_obj)\n return if commit_obj.empty?\n uri = URI.parse(\"http://gitsvn.bioconductor.org/git-push-hook\")\n json = commit_obj.to_json\n response = Net::HTTP.post_form(uri, {\"payload\" => json})\nend",
"def create\n @przedmiot = Przedmiot.new(params[:przedmiot])\n @przedmiot.user_id = current_user.id\n respond_to do |format|\n if @przedmiot.save\n format.html { redirect_to @przedmiot, notice: 'Przedmiot został dodany.' }\n format.json { render json: @przedmiot, status: :created, location: @przedmiot }\n else\n format.html { render action: \"new\" }\n format.json { render json: @przedmiot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def promotion_params\n params.require(:promotion).permit(:start_date, :end_date, :promotable_id, :promotable_type, :active, :priority, :image)\n end",
"def create\n @proposta = Propostum.new(propostum_params)\n\n respond_to do |format|\n if @proposta.save\n format.html { redirect_to @proposta, notice: 'Propostum was successfully created.' }\n format.json { render :show, status: :created, location: @proposta }\n else\n format.html { render :new }\n format.json { render json: @proposta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @punish = Punish.new(punish_params)\n\n respond_to do |format|\n if @punish.save\n format.html { redirect_to @punish, notice: 'Punish was successfully created.' }\n format.json { render :show, status: :created, location: @punish }\n else\n format.html { render :new }\n format.json { render json: @punish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def checkout_promotions\n @checkout_promotions ||= Promotion.active.code_based\n end",
"def index\n @product_promotions = ProductPromotion.all\n end",
"def push_notifications\n # post \"/push\" do\n Webpush.payload_send(\n message: params[:message],\n endpoint: params[:subscription][:endpoint],\n p256dh: params[:subscription][:keys][:p256dh],\n auth: params[:subscription][:keys][:auth],\n vapid: {\n subject: \"mailto:sender@example.com\",\n public_key: ENV['VAPID_PUBLIC_KEY'],\n private_key: ENV['VAPID_PRIVATE_KEY']\n }\n )\n end",
"def index\n @promotions = Promotion.paginate(:page => params[:page], :per_page => 10)\n .order(\"due_date DESC\")\n end",
"def create\n @opnion = Opnion.new(opnion_params)\n\n respond_to do |format|\n if @opnion.save\n format.html { redirect_to @opnion, notice: 'Opnion was successfully created.' }\n format.json { render :show, status: :created, location: @opnion }\n else\n format.html { render :new }\n format.json { render json: @opnion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @promos = Promos.new(params[:promos])\n\n respond_to do |format|\n if @promos.save\n flash[:notice] = 'Promos was successfully created.'\n format.html { redirect_to(@promos) }\n format.xml { render :xml => @promos, :status => :created, :location => @promos }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @micropot = Micropot.new(micropot_params)\n\n respond_to do |format|\n if @micropot.save\n format.html { redirect_to @micropot, notice: 'Micropot was successfully created.' }\n format.json { render :show, status: :created, location: @micropot }\n else\n format.html { render :new }\n format.json { render json: @micropot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_preferences(params)\n mhv_params = MessagingPreference.new(params).mhv_params\n perform(:post, 'preferences/notification', mhv_params, token_headers)\n get_preferences\n # NOTE: email_address might return an MHV error for any validations we have not handled, these will result\n # in a mapped SM152 code in exceptions.en.yml\n end",
"def create\n @promo = Promo.new(params[:promo])\n\n respond_to do |format|\n if @promo.save\n format.html { redirect_to @promo, notice: 'Promo was successfully created.' }\n format.json { render json: @promo, status: :created, location: @promo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @proverb = Proverb.new(proverb_params)\n\n respond_to do |format|\n if @proverb.save\n format.html { redirect_to @proverb, notice: \"Proverb was successfully created.\" }\n format.json { render :show, status: :created, location: @proverb }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @proverb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_promoter\n @promoter = Promoter.find(params[:id])\n end",
"def create\n @promotion_demotion = PromotionDemotion.new(params[:promotion_demotion])\n\n respond_to do |format|\n if @promotion_demotion.save\n format.html { redirect_to :back, notice: 'Promotion demotion was successfully created.' }\n format.json { render json: @promotion_demotion, status: :created, location: @promotion_demotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @promotion_demotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @home_promotion = Home::Promotion.new(params[:home_promotion])\n\n respond_to do |format|\n if @home_promotion.save\n format.html { redirect_to @home_promotion, notice: 'Promotion was successfully created.' }\n format.json { render json: @home_promotion, status: :created, location: @home_promotion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @home_promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def poem_params\n params.require(:poem).permit(:title, :content, :metaphor)\n end",
"def create\n @reply_puntuation = ReplyPuntuation.new(reply_puntuation_params)\n\n respond_to do |format|\n if @reply_puntuation.save\n format.html { redirect_to :back }\n format.json { render :show, status: :created, location: @reply_puntuation }\n else\n format.html { render :new }\n format.json { render json: @reply_puntuation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n msg=Message.new\n pick_list=PickListService.covert_order_to_pick_list(params[:user_id], params[:order_ids])\n if pick_list\n msg.result = true\n msg.content = pick_list\n end\n render json: msg\n end",
"def post_notification(attributes)\n begin\n response = notifications_api.post(encode_json(attributes))\n [parse_json(response), nil]\n rescue RestClient::UnprocessableEntity => e\n [parse_json(e.response), InvalidNotification]\n rescue RestClient::Unauthorized\n [{}, Unauthorized]\n end\n end",
"def mass_create\n requests = []\n group_invite_params[:mass_requests].each do |element|\n requests << @current_user.requests_as_sender.new(:group_id => element[:group_id], :receiver_id => element[:receiver_id], :status => \"pending\")\n end\n\n @invites = Request.import requests\n\n if @invites\n render json: requests, status: :created\n else\n render json: requests.errors, status: :unprocessable_entity\n end\n end",
"def micropot_params\n params.require(:micropot).permit(:content, :user_id)\n end",
"def create\n megam_rest.post_node(to_hash)\n end",
"def create\n @opinion = current_user.opinions.build(opinion_params)\n\n respond_to do |format|\n if @opinion.save\n format.html { redirect_to index, notice: 'Opinion was successfully created.' }\n format.json { render :index, status: :created, location: @opinion }\n else\n format.html { render :new }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @notion = Notion.new(notion_params)\n\n respond_to do |format|\n if @notion.save\n format.html { redirect_to @notion, notice: 'Notion was successfully created.' }\n format.json { render :show, status: :created, location: @notion }\n else\n format.html { render :new }\n format.json { render json: @notion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.sponsors = params[:sponsors]\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'El pedido se creó correctamente.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.61129576",
"0.6003724",
"0.5930134",
"0.5900632",
"0.5900632",
"0.5900632",
"0.5849472",
"0.5800277",
"0.5748506",
"0.573991",
"0.5670667",
"0.56652546",
"0.558862",
"0.555045",
"0.55195886",
"0.5505017",
"0.550316",
"0.54850113",
"0.5484974",
"0.54847103",
"0.5421864",
"0.5421864",
"0.54196906",
"0.5390764",
"0.53843445",
"0.5363325",
"0.53338623",
"0.531593",
"0.53054243",
"0.5297711",
"0.52477556",
"0.5224716",
"0.5205923",
"0.5193097",
"0.518293",
"0.51127243",
"0.50919914",
"0.50887096",
"0.50870943",
"0.5086982",
"0.50786006",
"0.500472",
"0.49753878",
"0.49730098",
"0.4964586",
"0.49475074",
"0.4936315",
"0.49311116",
"0.49273953",
"0.49121204",
"0.48951322",
"0.48948458",
"0.48944592",
"0.48924777",
"0.48905078",
"0.4885196",
"0.48849952",
"0.4882702",
"0.48824364",
"0.48820168",
"0.48814005",
"0.4880526",
"0.48796606",
"0.4873605",
"0.48707312",
"0.48684344",
"0.48610532",
"0.48559853",
"0.48546627",
"0.484262",
"0.48392084",
"0.48369813",
"0.48362684",
"0.4829033",
"0.48280835",
"0.48196465",
"0.48168412",
"0.48157403",
"0.48056325",
"0.4805014",
"0.47941688",
"0.47881487",
"0.47874516",
"0.4783799",
"0.47748217",
"0.47732842",
"0.4771353",
"0.4762637",
"0.4759165",
"0.4756687",
"0.47543696",
"0.47515893",
"0.47503495",
"0.47443962",
"0.4741165",
"0.47406417",
"0.4740009",
"0.4737261",
"0.4732928",
"0.4727693",
"0.47262377"
] | 0.0 | -1 |
PATCH/PUT /promotions/1 PATCH/PUT /promotions/1.json | def update
respond_to do |format|
if @promotion.update(promotion_params)
format.html { render :partial => "row_table", :locals => {:promotion => @promotion} }
else
format.json { render :json => { :errors => @promotion.errors }, :status => 409 }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @promoter.update(promoter_params)\n format.html { redirect_to root_url, notice: 'Promoter was successfully updated.' }\n format.json { render :show, status: :ok, location: @promoter }\n else\n format.html { render :edit }\n format.json { render json: @promoter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n if @promotion.update(promotion_params)\n head :no_content\n else\n render json: @promotion.errors, status: :unprocessable_entity\n end\n end",
"def update\n @promocion = Promocion.find(params[:id])\n logger.debug \"-------------------------------------------------------\"\n logger.debug params[:promocion][:formadepago_ids]\n logger.debug \"-------------------------------------------------------\"\n if (params[:promocion][:comercializable_ids] == nil)\n params[:promocion][:comercializable_ids] = []\n end\n\n if (params[:promocion][:formadepago_ids] == nil)\n params[:promocion][:formadepago_ids] = []\n end\n\n respond_to do |format|\n if @promocion.update_attributes(params[:promocion])\n format.html { redirect_to @promocion, :notice => 'Promocion was successfully updated.' }\n format.json { render json: @promocion}\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @promocion.errors }\n end\n end\n end",
"def update\n @promotion = Promotion.find(promotion_params[:id])\n authorize @promotion\n if @promotion.update(promotion_params)\n render json: { status: :ok, promotion: @promotion }\n else\n render json: { errors: @promotion.errors, status: :unprocessable_entity }\n end\n end",
"def update\n respond_to do |format|\n if @proverb.update(proverb_params)\n format.html { redirect_to @proverb, notice: \"Proverb was successfully updated.\" }\n format.json { render :show, status: :ok, location: @proverb }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @proverb.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n respond_to do |format|\n if @promotion.update_attributes(params[:promotion])\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(params[:id])\n\n respond_to do |format|\n if @promotion.update_attributes(params[:promotion])\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n if @promos.update_attributes(params[:promos])\n flash[:notice] = 'Promos was successfully updated.'\n format.html { redirect_to(@promos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n #raise params.inspect\n params.delete :target_id if params[:target_id].to_s == \"\" \n #raise params.inspect\n\n respond_to do |format| \n if !@provisioningobject.provisioned? && @provisioningobject.update(provisioningobject_params) \n if @provisioningobject.provisioningtime == Provisioningobject::PROVISIONINGTIME_IMMEDIATE\n if @provisioningobject.provision(:create, @async)\n if @async \n @notice = \"#{@provisioningobject.class.name} is being created (provisioning running in the background).\"\n else\n @notice = \"#{@provisioningobject.class.name} is provisioned.\"\n end\n else # if @provisioningobject.provision(:create, @async)\n @notice = \"#{@provisioningobject.class.name} could not be provisioned\"\n end\n else # if @provisioningobject.provisioningtime == Provisioningobject::PROVISIONINGTIME_IMMEDIATE\n # only save, do not provision:\n @notice = \"#{@provisioningobject.class.name} is created and can be provisioned ad hoc.\"\n @provisioningobject.update_attribute(:status, \"not provisioned\")\n end\n \n format.html { redirect_to @provisioningobject, notice: @notice }\n format.json { render :show, status: :created, location: @provisioningobject } \n else # if @provisioningobject.save\n flash[:error] = \"#{@provisioningobject.class.name} could not be updated (already provisioned?)\"\n format.html { render :edit } \n format.json { render json: @provisioningobject.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n if params[:product_id]\n @promotions = Product.find(params[:product_id]).promotions\n else\n @promotions = Promotion.all\n end\n\n render json: @promotions\n end",
"def patch!\n request! :patch\n end",
"def update\r\n @promotion = Promotion.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @promotion.update_attributes(params[:promotion])\r\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @title = t('admin.promotions.edit.title')\n @promotion = Promotion.find(params[:id])\n params[:promotion][:state] = 'not-published'\n\n respond_to do |format|\n if @promotion.update_attributes(params[:promotion])\n format.html { redirect_to ['admin', @promotion], notice: 'Promotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion.attributes = promotion_params\n check_unlimited\n respond_to do |format|\n if @promotion.save\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { render :show, status: :ok, location: @promotion }\n else\n format.html { render :edit }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @promotion.update(promotion_params)\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @promocion.update(promocion_params)\n format.html { redirect_to @promocion, notice: 'Promocion ha sido actualizado.' }\n format.json { render :show, status: :ok, location: @promocion }\n else\n format.html { render :edit }\n format.json { render json: @promocion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n begin\n remember_event\n @promoter = Promoter.update(params['id'], params['promoter'])\n if @promoter.errors.empty?\n if @event\n redirect_to(edit_admin_promoter_path(@promoter, :event_id => @event.id))\n else\n redirect_to(edit_admin_promoter_path(@promoter))\n end\n else\n render(:action => :edit)\n end\n rescue Exception => e\n logger.error(e)\n flash['warn'] = e.message\n render(:action => :edit)\n end\n end",
"def update\n respond_to do |format|\n if @promotion.update(promotion_params)\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { render :show, status: :ok, location: @promotion }\n else\n format.html { render :edit }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @promotion.update(promotion_params)\n format.html { redirect_to @promotion, notice: 'Promotion was successfully updated.' }\n format.json { render :show, status: :ok, location: @promotion }\n else\n format.html { render :edit }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n respond_to do |format|\n if @promotion.update(promotion_params)\n format.html { redirect_to shop_owner_promotion_path(current_shop_owner,@promotion), notice: 'Promotion was successfully updated.' }\n format.json { render :show, status: :ok, location: @promotion }\n else\n format.html { render :edit }\n format.json { render json: @promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @promotion.update(promotion_params)\n format.html {redirect_to @promotion, notice: 'Promotion was successfully updated.'}\n format.json {render :show, status: :ok, location: @promotion}\n else\n format.html {render :edit}\n format.json {render json: @promotion.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n respond_to do |format|\n if @procedure.update(procedure_params)\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n end\n end\n end",
"def update\n @propose = Propose.find(params[:id])\n\n respond_to do |format|\n if @propose.update_attributes(params[:propose])\n format.html { redirect_to @propose, notice: 'Propuesta actualizada' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @propose.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @command.update(command_params)\n format.json { render :json => @command }\n else\n format.json { render json: @command.errors, status: 401 }\n end\n end\n end",
"def patch\n end",
"def update\n @round_robin_promo = RoundRobinPromo.find(params[:id])\n\n respond_to do |format|\n if @round_robin_promo.update_attributes(params[:round_robin_promo])\n format.html { redirect_to @round_robin_promo, notice: 'Round robin promo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @round_robin_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @item_producto = @producto.item_productos.find(params[:item_producto_id])\n @opinion = @item_producto.opinions.find(params[:id])\n respond_to do |format|\n if @opinion.update(opinion_params)\n format.html { redirect_to empresa_producto_item_producto_opinions_path, notice: 'Item producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @opinion }\n else\n format.html { render :edit }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotersbind = Promotersbind.find(params[:id])\n\n respond_to do |format|\n if @promotersbind.update_attributes(params[:promotersbind])\n format.html { redirect_to @promotersbind, :notice => 'Promotersbind was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @promotersbind.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @propuestum.update(propuestum_params)\n format.html { redirect_to @propuestum, notice: 'Propuestum was successfully updated.' }\n format.json { render :show, status: :ok, location: @propuestum }\n else\n format.html { render :edit }\n format.json { render json: @propuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promo = Promo.find(params[:id])\n\n respond_to do |format|\n if @promo.update_attributes(params[:promo])\n format.html { redirect_to @promo, notice: 'Promo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @promulher_form.update(promulher_form_params)\n format.html { redirect_to @promulher_form, notice: 'Promulher form was successfully updated.' }\n format.json { render :show, status: :ok, location: @promulher_form }\n else\n format.html { render :edit }\n format.json { render json: @promulher_form.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @title = t('admin.promotions.index.title')\n @promotions = ( @product ? @product.promotions : Promotion.all )\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @promotions }\n end\n end",
"def update\n respond_to do |format|\n if @prominent.update(prominent_params)\n format.html { redirect_to @prominent, notice: 'Prominent was successfully updated.' }\n format.json { render :show, status: :ok, location: @prominent }\n else\n format.html { render :edit }\n format.json { render json: @prominent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @profissional.update(profissional_params)\n format.html { redirect_to @profissional, notice: 'Profissional was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @profissional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @adminpromotion.update(promotion_params)\n format.html { redirect_to adminpromotions_path, notice: 'Test was successfully updated.' }\n format.json { render :show, status: :ok, location: @adminpromotion }\n else\n format.html { render :edit }\n format.json { render json: @adminpromotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }\n format.xml { head :ok }\n format.json { head :ok }\n\n # RhoConnect server\n server = \"http://127.0.0.1:9292\"\n login = \"rhoadmin\"\n password = \"\"\n\n # Login to the RhoConnect server\n res = RestClient.post(\"#{server}/login\", { :login => login, :password => password }.to_json, :content_type => :json)\n\n # Get the token from the login response\n token = RestClient.post(\"#{server}/api/get_api_token\", '', { :cookies => res.cookies })\n\n # Send a ping message, which triggers a ping on the device\n ping_params = {\n :api_token => token,\n :user_id => [\"bhanu\"], # user_id that this message is for\n :sources => [\"Product\"], # sources we want to sync when this message is received\n :vibrate => \"2\",\n :message => \"#{params[:product][:name]} has been updated\",\n :sound => ''\n }\n\n RestClient.post(\"#{server}/api/ping\", ping_params.to_json, :content_type => :json)\n\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @proposal.update(proposal_params)\n format.html { redirect_to :back, notice: 'La proposition a été modifiée.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promocao = Promocao.find(params[:id])\n\n respond_to do |format|\n if @promocao.update_attributes(params[:promocao])\n format.html { redirect_to(@promocao, :notice => 'Promoção aletrada com sucesso!') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promocao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @proposition.update(proposition_params)\n format.html { redirect_to @proposition, notice: 'Proposition was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposition }\n else\n format.html { render :edit }\n format.json { render json: @proposition.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @poligono.update(poligono_params)\n format.html { redirect_to @poligono, notice: 'Poligono was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @poligono.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @orphan.update(orphan_params)\n format.html { redirect_to @orphan, notice: 'Orphan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @orphan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @person = @profissional.person\n if @person.update(profissional_params[:person_attributes])\n if profissional_params[:specialization].present?\n @profissional.update_attributes(:specialization => profissional_params[:specialization])\n format.html { redirect_to @profissional, notice: 'Profissional was successfully updated.' }\n format.json { render :show, status: :ok, location: @profissional }\n else\n format.html { render :edit }\n format.json { render json: @profissional.errors, status: :unprocessable_entity }\n end\n\n end\n end\n end",
"def update\n @promotion_box = PromotionBox.find(params[:id])\n\n respond_to do |format|\n if @promotion_box.update_attributes(params[:promotion_box])\n flash[:notice] = 'PromotionBox was successfully updated.'\n format.html { redirect_to admin_promotion_boxes_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promotion_box.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @opnion.update(opnion_params)\n format.html { redirect_to @opnion, notice: 'Opnion was successfully updated.' }\n format.json { render :show, status: :ok, location: @opnion }\n else\n format.html { render :edit }\n format.json { render json: @opnion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @produccion = Produccion.find(params[:id])\n\n respond_to do |format|\n if @produccion.update_attributes(params[:produccion])\n format.html { redirect_to @produccion, notice: 'Se ha modificado satisfactoriamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @produccion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def http_prop_patch(request, response)\n path = request.path\n\n begin\n prop_patch = @server.xml.expect('{DAV:}propertyupdate', request.body)\n rescue Tilia::Xml::ParseException => e\n raise Exception::BadRequest, e.message, nil, e\n end\n\n new_properties = prop_patch.properties\n\n result = @server.update_properties(path, new_properties)\n\n prefer = @server.http_prefer\n response.update_header('Vary', 'Brief,Prefer')\n\n if prefer['return'] == 'minimal'\n # If return-minimal is specified, we only have to check if the\n # request was succesful, and don't need to return the\n # multi-status.\n ok = true\n result.each do |_prop, code|\n ok = false if code.to_i > 299\n end\n\n if ok\n response.status = 204\n return false\n end\n end\n\n response.status = 207\n response.update_header('Content-Type', 'application/xml; charset=utf-8')\n\n # Reorganizing the result for generateMultiStatus\n multi_status = {}\n result.each do |property_name, code|\n if multi_status.key?(code)\n multi_status[code][property_name] = nil\n else\n multi_status[code] = { property_name => nil }\n end\n end\n multi_status['href'] = path\n\n response.body = @server.generate_multi_status([multi_status])\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end",
"def update\n respond_to do |format|\n if @proposta.update(propostum_params)\n format.html { redirect_to @proposta, notice: 'Propostum was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposta }\n else\n format.html { render :edit }\n format.json { render json: @proposta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @propperty.update(propperty_params)\n format.html { redirect_to @propperty, notice: 'Propperty was successfully updated.' }\n format.json { render :show, status: :ok, location: @propperty }\n else\n format.html { render :edit }\n format.json { render json: @propperty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @permissao.update(permissao_params)\n format.html { redirect_to @permissao, notice: 'As permissões do voluntário foram atualizadas.' }\n format.json { render :show, status: :ok, location: @permissao }\n else\n format.html { render :edit }\n format.json { render json: @permissao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @provincium.update(provincium_params)\n format.html { redirect_to @provincium, notice: 'Provincium was successfully updated.' }\n format.json { render :show, status: :ok, location: @provincium }\n else\n format.html { render :edit }\n format.json { render json: @provincium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tuhu_prodoct.update(tuhu_prodoct_params)\n format.html { redirect_to @tuhu_prodoct, notice: 'Prodoct was successfully updated.' }\n format.json { render :show, status: :ok, location: @tuhu_prodoct }\n else\n format.html { render :edit }\n format.json { render json: @tuhu_prodoct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @new_pro = NewPro.find(params[:id])\n\n respond_to do |format|\n if @new_pro.update_attributes(params[:new_pro])\n format.html { redirect_to @new_pro, notice: 'New pro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @new_pro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @proyectominero2.update(proyectominero2_params)\n format.html { redirect_to @proyectominero2, notice: 'Proyectominero2 was successfully updated.' }\n format.json { render :show, status: :ok, location: @proyectominero2 }\n else\n format.html { render :edit }\n format.json { render json: @proyectominero2.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_associative_criteria @copon, params.require(:copon)\n get_product(@copon, params.require(:copon)[:product])\n respond_to do |format|\n if @copon.update(copon_params)\n format.html { redirect_to @copon, notice: 'Copon was successfully updated.' }\n format.json { render :show, status: :ok, location: @copon }\n else\n format.html { render :edit }\n format.json { render json: @copon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n if @productonegocio.update_attributes(params[:productonegocio])\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @preparar_mate = @producto.preparar_mates.find(params[:id])\n respond_to do |format|\n if @preparar_mate.update(preparar_mate_params)\n format.html { redirect_to empresa_producto_preparar_mates_path, notice: 'Preparar mate was successfully updated.' }\n format.json { render :show, status: :ok, location: @preparar_mate }\n else\n format.html { render :edit }\n format.json { render json: @preparar_mate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @provision = Provision.find(params[:id])\n\n respond_to do |format|\n if @provision.update_attributes(params[:provision])\n format.html { redirect_to(@provision, :notice => 'Provision was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @provision.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def 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\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @processo = Processo.find(params[:id])\n\n if @processo.update(processo_params)\n head :no_content\n else\n render json: @processo.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @pot.update(pot_params)\n format.html { redirect_to @pot, notice: 'Pot was successfully updated.' }\n format.json { render :show, status: :ok, location: @pot }\n else\n format.html { render :edit }\n format.json { render json: @pot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion_type = PromotionType.find(params[:id])\n\n respond_to do |format|\n if @promotion_type.update_attributes(params[:promotion_type])\n format.html { redirect_to @promotion_type, notice: 'Promotion type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @promotion_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @micropot.update(micropot_params)\n format.html { redirect_to @micropot, notice: 'Micropot was successfully updated.' }\n format.json { render :show, status: :ok, location: @micropot }\n else\n format.html { render :edit }\n format.json { render json: @micropot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @property.update(property_params)\n # Remove all features by property objects\n @property.features_properties.delete_all\n\n # Get features parameter\n features = params[:features]\n\n # Verify whether features array comes in the parameters list\n if features.present?\n # Intantiate & create features by property\n features_property_create = FeaturesPropertyCreate.new(@property)\n features_property_create.create(features, params[:quantities])\n end\n\n # Remove all photos by property objects\n #@property.photos.delete_all\n\n # Get photos parameter\n photos = params[:photos]\n\n # Verify whether photos array comes in the parameters list\n if photos.present?\n # Intantiate & create photos by property\n photo_create = PhotoCreate.new(@property)\n photo_create.create(photos)\n end\n\n format.html { redirect_to @property, notice: 'Property was successfully updated.' }\n format.json { render :show, status: :ok, location: @property }\n else\n format.html { render :edit }\n format.json { render json: @property.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prodottos_operazione.update(prodottos_operazione_params)\n format.html { redirect_to @prodottos_operazione, notice: 'Prodottos operazione was successfully updated.' }\n format.json { render :show, status: :ok, location: @prodottos_operazione }\n else\n format.html { render :edit }\n format.json { render json: @prodottos_operazione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @proposal = Proposal.find(params[:id])\n\n unless current_user.proposals.map {|p| p.id.to_s} .include? @proposal.id.to_s\n redirect_to proposal_path, :flash => { :error => 'Sem permissão, proposta não é sua.'}\n return\n end\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @notion.update(notion_params)\n format.html { redirect_to @notion, notice: 'Notion was successfully updated.' }\n format.json { render :show, status: :ok, location: @notion }\n else\n format.html { render :edit }\n format.json { render json: @notion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cpanel_promotion.update(cpanel_promotion_params)\n format.html { redirect_to @cpanel_promotion, notice: 'Promotion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cpanel_promotion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @proffesion = Proffesion.find(params[:id])\n\n respond_to do |format|\n if @proffesion.update_attributes(params[:proffesion])\n flash[:notice] = 'Proffesion was successfully updated.'\n format.html { redirect_to(@proffesion) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @proffesion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @promotions = args[:promotions] if args.key?(:promotions)\n end",
"def update!(**args)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n @promotions = args[:promotions] if args.key?(:promotions)\n end",
"def update\n if current_user\n\tif ((current_user.username == 'Administrator') || (current_user.username =='Moderator'))\n \t\t@produkt = Produkt.find(params[:id])\n\t\t@produkt.rozmiarxs = params[:rozmiarxs]\n\t\t@produkt.rozmiars = params[:rozmiars]\n\t\t@produkt.rozmiarm = params[:rozmiarm]\n\t\t@produkt.rozmiarl = params[:rozmiarl]\n\t\t@produkt.rozmiarxl = params[:rozmiarxl]\n\t\t@produkt.rozmiarxxl = params[:rozmiarxxl]\n\n \t\trespond_to do |format|\n \t\t\tif @produkt.update_attributes(params[:produkt])\n \t\tformat.html { redirect_to @produkt, notice: 'Produkt uaktualniono.' }\n \t\tformat.json { head :no_content }\n \t\t\telse\n \t\tformat.html { render action: \"edit\" }\n \t\tformat.json { render json: @produkt.errors, status: :unprocessable_entity }\n \t\t\tend\n \t\tend\n\telse\n\tredirect_to (:produkts), :notice => \"Nie masz uprawnien do edycji produktu!\"\n\tend\n else\n\tredirect_to (:produkts), :notice => \"Nie masz uprawnien do edycji produktu!\"\n end\n end",
"def update\n respond_to do |format|\n if @motto.update(motto_params)\n format.html { redirect_to @motto, notice: 'Motto was successfully updated.' }\n format.json { render :show, status: :ok, location: @motto }\n else\n format.html { render :edit }\n format.json { render json: @motto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def update\n @pot = Pot.find(params[:id])\n\n respond_to do |format|\n if @pot.update_attributes(params[:pot])\n format.html { redirect_to @pot, notice: 'Pot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @probando.update(probando_params)\n format.html { redirect_to @probando, notice: 'Probando was successfully updated.' }\n format.json { render :show, status: :ok, location: @probando }\n else\n format.html { render :edit }\n format.json { render json: @probando.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @proposal = listing.proposals.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @provin.update(provin_params)\n format.html { redirect_to @provin, notice: 'Provin was successfully updated.' }\n format.json { render :show, status: :ok, location: @provin }\n else\n format.html { render :edit }\n format.json { render json: @provin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prospecto.update(prospecto_params)\n format.html { redirect_to @prospecto, notice: 'Prospecto was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospecto }\n else\n format.html { render :edit }\n format.json { render json: @prospecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_with []\n end",
"def edit\n assign_previous\n @event.promoter = Person.find(params[\"promoter_id\"]) if params[\"promoter_id\"].present? && current_person.administrator?\n end",
"def update\n @pv = Pv.new(pv_params)\n @pv.proyect = @proyect\n\n respond_to do |format|\n if @pv.update(pv_params)\n format.html { redirect_to proyect_pv_path(@proyect,@pv), notice: 'Propuesta de Valor ha sido actualizada.' }\n format.json { render :show, status: :ok, location: @pv }\n else\n format.html { render :edit }\n format.json { render json: @pv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_promo.update(admin_promo_params)\n format.html { redirect_to session['previous_url'] || admin_promos_path, notice: 'Promozioni è stato aggiornato con successo.' }\n format.json { render :show, status: :ok, location: @admin_promo }\n else\n format.html { render :edit }\n format.json { render json: @admin_promo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @punto.update(punto_params) and @punto.update_attributes(:modificador => current_user.id)\n format.html { redirect_to @punto, notice: 'Punto was successfully updated.' }\n format.json { render :show, status: :ok, location: @punto }\n else\n format.html { render :edit }\n format.json { render json: @punto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @promotion_tag.update(promotion_tag_params)\n format.html { redirect_to @promotion_tag, notice: 'Promotion tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @promotion_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prospie.update(prospie_params)\n format.html { redirect_to @prospie, notice: 'Prospie was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospie }\n else\n format.html { render :edit }\n format.json { render json: @prospie.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n @voprosy = Voprosy.find(params[:id])\n\n respond_to do |format|\n if @voprosy.update_attributes(params[:voprosy])\n format.html { redirect_to @voprosy, notice: 'Voprosy was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @voprosy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @poem = @user.poems.find(params[:id])\n\n respond_to do |format|\n if @poem.update_attributes(params[:poem])\n format.html { redirect_to user_poem_path(@poem.user, @poem), notice: 'Poem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @poligon.update(poligon_params)\n format.html { redirect_to poligons_path, notice: 'Poligon was successfully updated.' }\n format.json { render :show, status: :ok, location: @poligon }\n else\n format.html { render :edit }\n format.json { render json: @poligon.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.64262766",
"0.5897429",
"0.5888983",
"0.5867228",
"0.5845862",
"0.57179004",
"0.57116723",
"0.57031745",
"0.56938875",
"0.5689369",
"0.5674687",
"0.565174",
"0.56474644",
"0.5639727",
"0.56024885",
"0.560112",
"0.5590115",
"0.55484325",
"0.55484325",
"0.5515639",
"0.55057615",
"0.54738367",
"0.5472333",
"0.54710835",
"0.5456873",
"0.5450533",
"0.5450094",
"0.54181284",
"0.54086506",
"0.53852606",
"0.53719294",
"0.5371813",
"0.5357021",
"0.53529525",
"0.5349325",
"0.53214467",
"0.53150713",
"0.5307355",
"0.5288029",
"0.52852976",
"0.5280122",
"0.52794117",
"0.5275365",
"0.5274209",
"0.5274139",
"0.5273325",
"0.5269677",
"0.52456063",
"0.52450114",
"0.5244399",
"0.5227033",
"0.5226937",
"0.5225592",
"0.5225291",
"0.52227694",
"0.52174956",
"0.5215467",
"0.52130824",
"0.52092063",
"0.520841",
"0.52020156",
"0.5196827",
"0.51964486",
"0.51895994",
"0.5185397",
"0.51806957",
"0.5176655",
"0.51765114",
"0.5167514",
"0.5165763",
"0.5162576",
"0.5160841",
"0.5160381",
"0.51541096",
"0.5153738",
"0.5153738",
"0.5142821",
"0.5141965",
"0.51399744",
"0.5138917",
"0.51354045",
"0.5131215",
"0.5131167",
"0.51294583",
"0.5128799",
"0.5128633",
"0.51243544",
"0.5124085",
"0.5121121",
"0.5120714",
"0.51194984",
"0.5117617",
"0.51153624",
"0.5112268",
"0.51105267",
"0.51105267",
"0.51098776",
"0.51098776",
"0.5103924",
"0.5103813",
"0.5099702"
] | 0.0 | -1 |
DELETE /promotions/1 DELETE /promotions/1.json | def destroy
if @promotion.delete
render :nothing => true, :status => 200
else
render :nothing => true, :status => 503
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to promotions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to promotions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @promotion = Promotion.find(params[:id])\r\n @promotion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to promotions_url }\r\n format.json { head :ok }\r\n end\r\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to(promotions_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @promocion = Promocion.find(params[:id])\n @promocion.destroy\n\n respond_to do |format|\n format.html { redirect_to promocions_url }\n #format.json { head :ok }\n end\n end",
"def destroy\n #@promotion = Promotion.find(params[:id])\n @promotion.destroy\n respond_to do |format|\n format.html { redirect_to promotions_url, notice: 'Promotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy \n @promotion = Promotion.find(params[:id])\n @client_id = @promotion.client.id\n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to(promotions_url(:client_id => @client_id)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @round_robin_promo = RoundRobinPromo.find(params[:id])\n @round_robin_promo.destroy\n\n respond_to do |format|\n format.html { redirect_to round_robin_promos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vpn = Vpn.find(params[:id])\n checkaccountobject(\"vpns\",@vpn)\n @vpn.send_delete\n\n respond_to do |format|\n format.html { redirect_to vpns_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n\n BusinessPayment.find(:all, :conditions => {:promotion_id => @promotion.id}).each do |bp|\n bp.destroy\n end\n \n @promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_promotions_path }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promocion.destroy\n respond_to do |format|\n format.html { redirect_to promocions_url, notice: 'Promocion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion.destroy\n respond_to do |format|\n format.html { redirect_to promotions_url, notice: 'Promotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion.destroy\n respond_to do |format|\n format.html { redirect_to promotions_url, notice: 'Promotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion.destroy\n respond_to do |format|\n format.html { redirect_to promotions_url, notice: 'Promotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cpanel_promotion.destroy\n respond_to do |format|\n format.html { redirect_to cpanel_promotions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adminpromotion.destroy\n respond_to do |format|\n format.html { redirect_to adminpromotions_path, notice: 'Test was successfully destroyed.' }\n format.json { head :no_adminpromotion }\n end\n end",
"def destroy\n @promotion.destroy\n respond_to do |format|\n format.html {redirect_to promotions_url, notice: 'Promotion was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promotion.destroy\n\n head :no_content\n end",
"def destroy\n @promotion.destroy\n head :no_content\n end",
"def destroy\n @home_promotion = Home::Promotion.find(params[:id])\n @home_promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to home_promotions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prossumer.destroy\n head :no_content\n end",
"def destroy\n @promotion.destroy\n respond_to do |format|\n format.html { redirect_to shop_owner_promotions_path(current_shop_owner), notice: 'Promotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleteProductProvisioning( product_id, gen_id)\n params = Hash.new\n params['product_id'] = product_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/product/provisioning\",params)\n end",
"def destroy\n @proverb.destroy\n respond_to do |format|\n format.html { redirect_to proverbs_url, notice: \"Proverb was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_promotion = UserPromotion.find(params[:id])\n @user_promotion.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_promotions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @przedmiot = Przedmiot.find(params[:id])\n @przedmiot.destroy\n\n respond_to do |format|\n format.html { redirect_to przedmioty_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @produccion = Produccion.find(params[:id])\n @produccion.destroy\n\n respond_to do |format|\n format.html { redirect_to produccions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion_demotion = PromotionDemotion.find(params[:id])\n @promotion_demotion.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @propose = Propose.find(params[:id])\n @propose.destroy\n\n respond_to do |format|\n format.html { redirect_to proposes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion_box = PromotionBox.find(params[:id])\n @promotion_box.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_promotion_boxes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @provision = Provision.find(params[:id])\n @provision.destroy\n\n respond_to do |format|\n format.html { redirect_to(provisions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @promotion_tag.destroy\n respond_to do |format|\n format.html { redirect_to promotion_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @v1_message = V1::Message.find(params[:id])\n @v1_message.destroy\n\n head :no_content\n end",
"def destroy\n @promotion_type = PromotionType.find(params[:id])\n @promotion_type.destroy\n\n respond_to do |format|\n format.html { redirect_to promotion_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @command.destroy\n respond_to do |format|\n format.html { redirect_to commands_url, notice: 'La commande a été détruite.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @protein.destroy\r\n respond_to do |format|\r\n format.html { redirect_to proteins_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @promotion.destroy\n redirect_to promotions_url, notice: 'Promotion was successfully destroyed.'\n end",
"def destroy\n @produccion = Produccion.find(params[:id])\n @produccion.destroy\n\n respond_to do |format|\n format.html { redirect_to producciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mote = Mote.find(params[:id])\n @mote.destroy\n\n respond_to do |format|\n format.html { redirect_to motes_url }\n format.json { head :no_content }\n end\n end",
"def destroy_many\n promotionable_ids = params.require(:promotionable_ids)\n promotionable_type = promotion_params[:promotionable_type]\n @promotions = Promotion.where(promotionable_id: promotionable_ids, promotionable_type: promotionable_type)\n @promotions.destroy_all\n respond_to do |format|\n format.html { redirect_to after_destroy_path, notice: 'Promotions where successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pem = Pem.find(params[:id])\n @pem.destroy\n\n respond_to do |format|\n format.html { redirect_to pems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @protein = Protein.find(params[:id])\n @protein.destroy\n\n respond_to do |format|\n format.html { redirect_to proteins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @command.destroy\n respond_to do |format|\n msg = { :status => 'ok', message: 'Deleted Successfully'}\n format.json { render json: msg }\n end\n end",
"def destroy\n @admin_promo.destroy\n respond_to do |format|\n format.html { redirect_to session['previous_url'] || admin_promos_url, notice: 'Promozioni cancellata con successo!.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @proximity.destroy\n respond_to do |format|\n format.html { redirect_to proximities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n @promotion.destroy\n get_paginated_promotions\n respond_to do |format|\n format.js\n end\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @propuestum.destroy\n respond_to do |format|\n format.html { redirect_to propuesta_url, notice: 'Propuestum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_protein = RefProtein.find(params[:id])\n @ref_protein.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_proteins_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotersbind = Promotersbind.find(params[:id])\n @promotersbind.destroy\n\n respond_to do |format|\n format.html { redirect_to promotersbinds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @storepromotion.destroy\n respond_to do |format|\n format.html { redirect_to storepromotions_url, notice: 'Storepromotion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tuhu_prodoct.destroy\n respond_to do |format|\n format.html { redirect_to tuhu_prodocts_url, notice: 'Prodoct was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prob.destroy\n respond_to do |format|\n format.html { redirect_to probs_url, notice: 'Prob was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def destroy\n @promocao = Promocao.find(params[:id])\n @promocao.destroy\n\n respond_to do |format|\n format.html { redirect_to(promocoes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @preguntum = Preguntum.find(params[:id])\n @preguntum.destroy\n\n respond_to do |format|\n format.html { redirect_to pregunta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @verb.destroy\n\n head :no_content\n end",
"def destroy\n @po = Po.find(params[:id])\n @po.destroy\n\n respond_to do |format|\n format.html { redirect_to pos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @proffesion = Proffesion.find(params[:id])\n @proffesion.destroy\n\n respond_to do |format|\n format.html { redirect_to(proffesions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pto = Pto.find(params[:id])\n @pto.destroy\n\n respond_to do |format|\n format.html { redirect_to ptos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @proyectominero2.destroy\n respond_to do |format|\n format.html { redirect_to proyectominero2s_url, notice: 'Proyectominero2 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @protein_complex = ProteinComplex.find(params[:id])\n @protein_complex.destroy\n\n respond_to do |format|\n format.html { redirect_to protein_complexes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prob = Prob.find(params[:id])\n @prob.destroy\n\n respond_to do |format|\n format.html { redirect_to probs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pv.destroy\n respond_to do |format|\n format.html { redirect_to proyect_pvs_path(@proyect), notice: 'Propuesta de Valor ha sido eliminada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @progre = Progre.find(params[:id])\n @progre.destroy\n\n respond_to do |format|\n format.html { redirect_to(progres_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @permissao.destroy\n respond_to do |format|\n format.html { redirect_to permissoes_url, notice: 'As permissões do voluntário foram excluídas.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @motivonegativa = Motivonegativa.find(params[:id])\n @motivonegativa.destroy\n\n respond_to do |format|\n format.html { redirect_to(motivosnegativa_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @momsg = Momsg.find(params[:id])\n @momsg.destroy\n\n respond_to do |format|\n format.html { redirect_to momsgs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @mallet_command = MalletCommand.find(params[:id])\n @mallet_command.destroy\n\n respond_to do |format|\n format.html { redirect_to mallet_commands_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @promotion = Promotion.find(params[:id])\n\n if @promotion.destroy\n js_notify message: t('admin.promotions.destroy.success'), type: 'alert-error', time: 2500\n render nothing: true, content_type: 'text/html'\n else\n message = \"#{t('admin.promotions.destroy.error')}: #{@promotion.errors[:base].first}\"\n js_notify message: message, type: 'alert-info', time: 2500\n render nothing: true\n end\n end",
"def destroy\n @push_notification = PushNotification.find(params[:id])\n @push_notification.destroy\n\n respond_to do |format|\n format.html { redirect_to push_notifications_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle_ot_presupuesto.destroy\n respond_to do |format|\n format.html { redirect_to detalle_ot_presupuestos_url, notice: 'Detalle ot presupuesto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @produccion.destroy\n respond_to do |format|\n format.html { redirect_to produccions_url, notice: 'Produccion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n onevnet('delete', resource[:name])\n @property_hash.clear\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\n request(:delete)\n end",
"def destroy\n @policy = Policy.find(params[:id])\n @policy.destroy\n\n respond_to do |format|\n format.html { redirect_to motor_policies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @sivic_permissao.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_permissaos_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @proceso = Proceso.find(params[:id])\n @proceso.destroy\n\n respond_to do |format|\n format.html { redirect_to(procesos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @vpn = current_user.vpn\n @vpn.destroy\n\n respond_to do |format|\n format.html { redirect_to dashboard_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @puntuation.destroy\n @unvoted_contribution = Contribution.find(@puntuation.contribution_id)\n @unvoted_contribution.decrement!(:puntuation, 1)\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n Poem.find(params[:id]).destroy\n redirect_to(\"/users/#{current_user.id}\")\n end",
"def destroy\n @poligono.destroy\n respond_to do |format|\n format.html { redirect_to poligonos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @selective_process.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Prcoesso deletado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n # delete a specific message\n end",
"def destroy\n @motto.destroy\n respond_to do |format|\n format.html { redirect_to mottos_url, notice: 'Motto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pushup_reminder.destroy\n\n respond_to do |format|\n format.html { redirect_to pushup_reminders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @proposta.destroy\n respond_to do |format|\n format.html { redirect_to proposta_url, notice: 'Propostum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mutation = Mutation.find(params[:id])\n @mutation.destroy\n\n respond_to do |format|\n format.html { redirect_to mutations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @prodottos_operazione.destroy\n respond_to do |format|\n format.html { redirect_to controller: 'prodottos', action: 'show', id: @prodottos_operazione.id_prodotto }\n format.json { head :no_content }\n end\n end",
"def destroy\n @procedure.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end"
] | [
"0.6877458",
"0.6866245",
"0.68379396",
"0.67688173",
"0.66865426",
"0.66132736",
"0.6602949",
"0.6602193",
"0.6586116",
"0.65849304",
"0.651903",
"0.65147084",
"0.65147084",
"0.65147084",
"0.64873075",
"0.645483",
"0.6425896",
"0.641855",
"0.641855",
"0.6402804",
"0.6391263",
"0.6387325",
"0.6369579",
"0.63361764",
"0.6330172",
"0.63268244",
"0.6323475",
"0.631696",
"0.62657756",
"0.6264386",
"0.62559086",
"0.6240801",
"0.6234952",
"0.6228869",
"0.62259436",
"0.61881596",
"0.6184635",
"0.6166364",
"0.61361504",
"0.6135147",
"0.6133",
"0.6128991",
"0.6126967",
"0.61188114",
"0.6112693",
"0.610697",
"0.61053884",
"0.6096969",
"0.6089965",
"0.6088206",
"0.60829574",
"0.60705364",
"0.60658723",
"0.603835",
"0.6029944",
"0.60298234",
"0.6029106",
"0.60244244",
"0.60231495",
"0.6021971",
"0.60209876",
"0.6018981",
"0.6018207",
"0.6007295",
"0.60041386",
"0.60029644",
"0.6001934",
"0.60017973",
"0.599956",
"0.5998092",
"0.5997371",
"0.5996302",
"0.5993208",
"0.598977",
"0.59864604",
"0.5980307",
"0.59760654",
"0.5973317",
"0.5973204",
"0.59719765",
"0.5970823",
"0.5964884",
"0.5959175",
"0.5958411",
"0.59508497",
"0.594805",
"0.59456295",
"0.5942032",
"0.59419465",
"0.5940473",
"0.5940101",
"0.5937884",
"0.5936855",
"0.593445",
"0.5931139",
"0.5929886",
"0.5929337",
"0.59203386",
"0.59140426",
"0.5909935"
] | 0.60768455 | 51 |
Use callbacks to share common setup or constraints between actions. | def set_promotion
@promotion = Promotion.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def _handle_action_missing(*args); end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def duas1(action)\n action.call\n action.call\nend"
] | [
"0.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.53312254",
"0.53121567",
"0.52971965",
"0.52964705",
"0.52956307",
"0.52587366",
"0.52450675",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5237777",
"0.5233381",
"0.52325714",
"0.52288216",
"0.52229726",
"0.5218362",
"0.52142864",
"0.5207988",
"0.5206337",
"0.51762295",
"0.51745105",
"0.51728606",
"0.516616",
"0.5161016",
"0.5157393",
"0.5152562",
"0.51524293",
"0.5152397",
"0.5144533",
"0.513982",
"0.51342106",
"0.5113793",
"0.5113793",
"0.5113671",
"0.51092553",
"0.51062804",
"0.50921935",
"0.5088855",
"0.5082236",
"0.5079901",
"0.5066569",
"0.5055307",
"0.5053106",
"0.50499666",
"0.50499666",
"0.5035068",
"0.50258636",
"0.50220853",
"0.5015893",
"0.50134486",
"0.5001442",
"0.50005543",
"0.4998581",
"0.49901858",
"0.49901858",
"0.4986648",
"0.49809486",
"0.49792925",
"0.4978855",
"0.49685496",
"0.49656174",
"0.49576473",
"0.49563017",
"0.4955349",
"0.49536878",
"0.4952439",
"0.49460214",
"0.494239",
"0.49334687",
"0.49315962",
"0.49266812",
"0.49261138",
"0.4925925",
"0.4922542",
"0.4920779",
"0.49173284",
"0.49169463",
"0.4916256",
"0.49162322",
"0.49156886"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def promotion_params
params.require(:promotion).permit(:condition_id, :quota, :bin, :bank_id, :credit_card_id, :start_date, :end_date, :observations,:observationsb2c, :comerce_number, :active)
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 |
So we can construct these ourselves | def net_sales_as_decimal
net_sales[1..-1].to_d
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def initialize() end",
"def initialize\n \n end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def construct\n end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def constructor; end",
"def initialize\n\t\t\n\tend",
"def initialize(*rest) end",
"def code_of_conduct; end",
"def initialize\r\n\r\n end",
"def probers; end",
"def initialize\n \n end",
"def initialize(*_)\n super\n end",
"def transformations; end",
"def initialize(*)\n end",
"def initialize(*)\n end",
"def build(params); end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def initialize(*); end",
"def initialize\n # this hash maps models to layout names \n @special_layout = {\n Contribution => \"Language_contributors (table)\",\n MeaningsVerb => \"Verb_meanings (table)\",\n ExamplesVerb => \"Verb_examples (table)\",\n Languageref => \"Languages (Editors' layout)\",\n AlternationValuesExample => \"Alternation_value_examples (table)\",\n CodingFrameExample => \"Verb_coding_frame_examples (table)\",\n CodingFrameIndexNumbersMicrorole => \"Coding_frame_Microrole_index_numbers (table)\"\n }\n # this hash maps a model to a hash from property name to FileMaker field name\n @special_field_name = { # FileMaker field names must be in lowercase!\n Alternation => {\n 'coding_frames_text' => 'coding_frames_of_alternation',\n 'complexity' => 'simplex_or_complex'\n },\n GlossMeaning => {\n 'comment' => 'gloss_meaning_comments::comments'\n },\n Example => {\n 'person_id' => 'source_person_id'\n },\n Meaning => {\n 'meaning_list' => 'z_calc_meaning_list_core_extended_new_or_old'\n },\n Language=> {\n 'name_for_url' => 'z_calc_language_name_for_url'\n },\n Languageref=> {\n 'id' => 'language_id',\n 'name' => 'language_name',\n 'nodata' => 'z_calc_alternation_occurs_nodata_percent'\n },\n CodingFrame => {\n 'derived' => 'z_calc_basic_or_derived'\n },\n Person => {\n 'email' => 'email_address',\n 'affiliation' => 'academic affiliation',\n 'photo_url' => 'photo url'\n },\n Verb => {\n 'verb_type' => 'v_type'\n }\n }\n end",
"def initialize(*) \n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def formation; end",
"def initialize()\r\n\r\n end",
"def init\n\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize(p1,p2)\n ori_init\n push p1\n push p2\n self[0].id = 0\n self[0].mark_markup = $glob.x_markup\n self[1].id = 1\n self[1].mark_markup = $glob.o_markup \n @act_p = self[0]\n end",
"def initialize\n\n end",
"def initialize\n\n end",
"def build_vars\n\n end",
"def initialize(params={})\n # there has GOT to be some better way to clean this up ...\n params['categories'] = params.delete('challenge_categories__r') if params['challenge_categories__r']\n params['participants'] = params.delete('challenge_participants__r') if params['challenge_participants__r']\n params['community'] = params.delete('community__r') if params['community__r']\n params['terms_of_service'] = params.delete('terms_of_service__r') if params['terms_of_service__r']\n params['challenge_comments'] = params.delete('challenge_comments__r') if params['challenge_comments__r']\n params['challenge_reviewers'] = params.delete('challenge_reviewers__r') if params['challenge_reviewers__r']\n params['challenge_comment_notifiers'] = params.delete('challenge_comment_notifiers__r') if params['challenge_comment_notifiers__r']\n params['challenge_prizes'] = params.delete('challenge_prizes__r') if params['challenge_prizes__r']\n params['assets'] = params.delete('assets__r') if params['assets__r']\n params['platforms'] = params.delete('challenge_platforms__r') if params['challenge_platforms__r']\n params['technologies'] = params.delete('challenge_technologies__r') if params['challenge_technologies__r']\n\n # these fields need extra cleaning as they should only output arrays of strings\n # they also have an awful lot of duplication that can benefit with a bit of refactoring\n params['challenge_reviewers'] = params['challenge_reviewers'].map do |entry|\n entry['member__r']['name']\n end if params['challenge_reviewers']\n\n params['challenge_comment_notifiers'] = params['challenge_comment_notifiers'].map do |entry|\n entry['member__r']['name']\n end if params['challenge_comment_notifiers']\n\n params['challenge_prizes'] = params['challenge_prizes'].records.map do |entry|\n prize = \"$#{Integer(entry['prize'])}\" rescue entry['prize'].to_s\n { place: entry['place'].to_i.ordinalize, prize: prize, points: entry['points'] || '', value: entry['value'] || '' }\n end if params['challenge_prizes']\n\n # params['assets'] = params['assets'].map do |entry|\n # entry['filename']\n # end if params['assets']\n\n super(params)\n end",
"def attributes=(_arg0); end",
"def probers=(_arg0); end",
"def custom; end",
"def custom; end",
"def build=(_arg0); end",
"def pre_initialize; end",
"def initialize\n\n\n\n end",
"def wrapper; end",
"def builder; end",
"def builder; end",
"def builder; end",
"def initialize(*args); end",
"def initialize( * )\n super\n end",
"def initialize(a_1, a_2, a_3, b_1, b_2, b_3, c_1, c_2, c_3)\n @a_1 = a_1\n @a_2 = a_2\n @a_3 = a_3\n @b_1 = b_1\n @b_2 = b_2\n @b_3 = b_3\n @c_1 = c_1\n @c_2 = c_2\n @c_3 = c_3\n\n #on insere les variables qui seront modifiables dans les compartiments.\n @o = \" 1 2 3 \"\n @a = \" | | \"\n @b = \" a \" + @a_1 +\" | \"+ @a_2 +\" | \" + @a_3\n @c = \" ___|___|___ \"\n @d = \" | | \"\n @e = \" b \" + @b_1 +\" | \"+ @b_2 +\" | \" + @b_3\n @f = \" ___|___|___ \"\n @g = \" | | \"\n @h = \" c \" + @c_1 +\" | \"+ @c_2 +\" | \" + @c_3\n @i = \" | | \"\n\n end",
"def nesting() end",
"def initialize(args)\n\t\t\tsuper(args)\n\t\t\t\n\t\t\t@apply_to = args.fetch(:apply_to, [])\n\t\t\t@is_a = args.fetch(:is_a, nil)\n\t\t\t@mixins = args.fetch(:mixins, [])\n\t\t\t@class_uri = args.fetch(:class_uri, nil)\n\t\t\t@defining_slots = args.fetch(:defining_slots, [])\n\t\t\t@slot_usage = args.fetch(:slot_usage, [])\n\t\t\t@slots = args.fetch(:slots, [])\n\t\t\t@subclass_of = args.fetch(:subclass_of, nil)\n\t\t\t@union_of = args.fetch(:union_of, [])\n\n\t\t\t@apply_to = [@apply_to] unless @apply_to.is_a?(Array)\n\t\t\t@mixins = [@mixins] unless @mixins.is_a?(Array)\n\t\t\t@defining_slots = [@defining_slots] unless @defining_slots.is_a?(Array)\n\t\t\t@slot_usage = [@slot_usage] unless @slot_usage.is_a?(Array)\n\t\t\t@slots = [@slots] unless @slots.is_a?(Array)\n\t\t\t@union_of = [@union_of] unless @union_of.is_a?(Array)\n\t\t\t\n\t\t\t@apply_to = nil unless @apply_to.is_a?(Biolinkml::ClassDefinition)\n\t\t\t@is_a = nil unless @is_a.is_a?(Biolinkml::Definition)\n\t\t\t\n\t\t\t@apply_to.each do |a|\n\t\t\t\t@apply_to.delete(a) unless a.is_a?(Biolinkml::ClassDefinition)\n\t\t\tend\n\t\t\t@mixins.each do |a|\n\t\t\t\t@mixins.delete(a) unless a.is_a?(Biolinkml::ClassDefinition)\n\t\t\tend\n\t\t\t@defining_slots.each do |a|\n\t\t\t\t@defining_slots.delete(a) unless a.is_a?(Biolinkml::SlotDefinition)\n\t\t\tend\n\t\t\t@slot_usage.each do |a|\n\t\t\t\t@slot_usage.delete(a) unless a.is_a?(Biolinkml::SlotDefinition)\n\t\t\tend\n\t\t\t@slots.each do |a|\n\t\t\t\t@slots.delete(a) unless a.is_a?(Biolinkml::SlotDefinition)\n\t\t\tend\n\t\t\t@union_of.each do |a|\n\t\t\t\t@union_of.delete(a) unless a.is_a?(Biolinkml::ClassDefinition)\n\t\t\tend\n\t\t\t\n\t\t \t\t \n\t\tend",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize()\n\t\tend",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def parslet; end",
"def initialize\n end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def parts; end"
] | [
"0.66957146",
"0.61343545",
"0.6075207",
"0.6074894",
"0.6074894",
"0.6074894",
"0.6074894",
"0.6074894",
"0.6038585",
"0.6038585",
"0.6038585",
"0.6038585",
"0.59377253",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.5905793",
"0.58493745",
"0.5827725",
"0.5786787",
"0.5740173",
"0.5731151",
"0.5700736",
"0.5674221",
"0.56007355",
"0.5585406",
"0.5576047",
"0.5576047",
"0.5567331",
"0.553735",
"0.553735",
"0.55357295",
"0.55136526",
"0.54727906",
"0.5449539",
"0.5449539",
"0.54383457",
"0.5436698",
"0.5429198",
"0.5428684",
"0.5428684",
"0.5428684",
"0.53949106",
"0.5384445",
"0.5384445",
"0.5381905",
"0.53806",
"0.53756595",
"0.53728914",
"0.5370488",
"0.5370488",
"0.5366624",
"0.53656876",
"0.5358238",
"0.5356107",
"0.5353814",
"0.5353814",
"0.5353814",
"0.53516924",
"0.53497356",
"0.53350914",
"0.53295815",
"0.531723",
"0.5307809",
"0.5307809",
"0.5307809",
"0.5303674",
"0.53011423",
"0.53011423",
"0.53011423",
"0.53011423",
"0.53011423",
"0.53011423",
"0.53011423",
"0.5294928",
"0.5294928",
"0.5294928",
"0.5294928",
"0.52928025",
"0.52882653",
"0.52882653",
"0.52882653",
"0.52882653",
"0.52882653",
"0.52882653",
"0.52882653",
"0.52882653",
"0.5285654",
"0.5285654",
"0.5285654",
"0.5285654",
"0.5285654",
"0.5285654",
"0.5279292"
] | 0.0 | -1 |
Load from Link Records | def load(links, o = {})
i = 0.0
links.each do |l|
if l[1] >= l[2] && !o[:force]
info "Inconsistent Input #{l.inspect}, skipping..." if l[0] != 'e'
next
end
v[l[0]] = {} if !v[l[0]]
v[l[0]][l[1]] = {} if !v[l[0]][l[1]]
v[l[0]][l[2]] = {} if !v[l[0]][l[2]]
v[l[0]][l[2]][l[1]] = l[3].to_f
v[l[0]][l[1]][l[2]] = l[3].to_f
i += 1
end
#debug "[LinkFeatures::load] #{i} links loaded"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load record\n end",
"def load\n records.load\n end",
"def load\n records.__send__(:load)\n end",
"def load_record(rid, mid)\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_get_record_info\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n url_get_records = url_get_records.gsub '{mid}', mid.to_s\n url_get_records = url_get_records.gsub '{rid}', rid.to_s\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, {}, 'get'\n\n json = JSON.parse(response)\n record = json['record']\n\n unless record\n raise 'Record key doesn\\'t present in response from Dynamicloud server.'\n end\n\n Dynamicloud::API::DynamicloudHelper.normalize_record record\n end",
"def post_load(all_records)\n end",
"def load_records!\n record_paths.map do |path|\n Record.load_record! self, path\n end\n end",
"def load\n super\n slice_records!\n\n self\n end",
"def load(records, query)\n resources = super\n\n # Load embedded resources\n resources.each_with_index do |resource, index|\n resource.model.embedments.each do |name, relationship|\n unless (targets = records[index][name.to_s]).blank?\n relationship.set(resource, targets, true)\n end\n end\n end\n\n resources\n end",
"def load_record\n if persisted?\n @record = proxy.get_record(ref)\n # create proper variables from the underlying proxy structure\n @record = cast_attributes(@record)\n else\n @record = {}\n end\n rescue\n # TODO: Hmmmm, I should probably do something here\n raise\n end",
"def load_data(_records, _loader)\n raise \"Implement in child\"\n end",
"def load(records, query)\n if discriminator = properties(query.repository.name).discriminator\n records.each do |record|\n discriminator_key = discriminator.name.to_s\n discriminator_value = discriminator.type.load(record[discriminator_key], discriminator)\n\n record[discriminator_key] = discriminator_value\n end\n end\n\n resources = super\n\n # Load embedded resources\n resources.each_with_index do |resource, index|\n resource.model.embedments.each do |name, relationship|\n unless (targets = records[index][name.to_s]).blank?\n relationship.set(resource, targets, true)\n end\n end\n end\n\n resources\n end",
"def process_links(recs)\n links = retrieve_links(recs)\n return [] if links.blank?\n\n recs.each { |rec| rec.identifiers.update(links[rec.uid]) if rec.database == 'WOS' }\n rescue StandardError => e\n NotificationManager.error(e, \"Author: #{author.id}, process_links failed\", self)\n end",
"def load_from_record(api_object)\n record = api_object.at_xpath(\"api:records/api:record[@format='native']/api:native\")\n\n unless record \n raise ArgumentError,\n \"Object given did not contain the nodes expected of a publication record.\"\n end\n \n xpath_queries = {\n doc_type: \"../../../@type\",\n id: \"../../../@id\",\n publisher: \"api:field[@name='publisher']/api:text\",\n title: \"api:field[@name='title']/api:text\",\n volume: \"api:field[@name='volume']/api:text\",\n abstract: \"api:field[@name='abstract']/api:text\",\n issue: \"api:field[@name='issue']/api:text\",\n page_start: \"api:field[@name='pagination']/api:pagination/api:begin-page\",\n page_end: \"api:field[@name='pagination']/api:pagination/api:end-page\",\n pages: \"api:field[@name='pagination']/api:pagination/api:page-count\",\n number: \"api:field[@name='number']/api:text\",\n doi: \"api:field[@name='doi']/api:links/api:link[@type='doi']/@href\",\n journal: \"api:field[@name='journal']/api:text\",\n\n }\n\n # Loop through all the xpath queries.\n xpath_queries.each do |field, xpath|\n if element = record.at_xpath(xpath)\n send(\"#{field}=\", element.text)\n end\n end\n\n extract_author_list(record.at_xpath(\"api:field[@name='authors']\"))\n extract_date(record.at_xpath(\"api:field[@name='publication-date']\"))\n extract_subject(record.at_xpath(\"api:field[@name='keywords']\"))\n end",
"def record_for(link_def)\n data[link_def[\"type\"]][link_def[\"id\"]]\n end",
"def load(site, values)\n return nil if values.nil?\n if values['model'] != id\n site.models.find(values['model']).load(site, values)\n else\n record_class.new(self, site, values, false)\n end\n end",
"def record_for(link_def)\n data[link_def[\"type\"]][link_def[\"id\"]]\n end",
"def load(records, query)\n repository = query.repository\n fields = query.fields\n discriminator = properties(repository.name).discriminator\n no_reload = !query.reload?\n\n field_map = fields.map { |property| [ property, property.field ] }.to_hash\n\n records.map do |record|\n identity_map = nil\n key_values = nil\n resource = nil\n\n case record\n when Hash\n # remap fields to use the Property object\n record = record.dup\n field_map.each { |property, field| record[property] = record.delete(field) if record.key?(field) }\n\n model = discriminator && record[discriminator] || self\n\n resource = if (key_values = record.values_at(*key)).all?\n identity_map = repository.identity_map(model)\n identity_map[key_values]\n end\n\n resource ||= model.allocate\n\n fields.each do |property|\n next if no_reload && property.loaded?(resource)\n\n value = record[property]\n\n # TODO: typecasting should happen inside the Adapter\n # and all values should come back as expected objects\n if property.custom?\n value = property.type.load(value, property)\n end\n\n property.set!(resource, value)\n end\n\n when Resource\n model = record.model\n\n resource = if (key_values = record.key).all?\n identity_map = repository.identity_map(model)\n identity_map[key_values]\n end\n\n resource ||= model.allocate\n\n fields.each do |property|\n next if no_reload && property.loaded?(resource)\n\n property.set!(resource, property.get!(record))\n end\n end\n\n resource.instance_variable_set(:@repository, repository)\n resource.instance_variable_set(:@saved, true)\n\n if identity_map\n # defer setting the IdentityMap so second level caches can\n # record the state of the resource after loaded\n identity_map[key_values] = resource\n else\n resource.freeze\n end\n\n resource\n end\n end",
"def read_links(ltype, id)\n return {} if !v[ltype]\n return {} if !v[ltype][id]\n v[ltype][id]\n end",
"def load(objects)\n self.records = (objects || []).map { |object| new(object) }\n self.loaded = true\n self\n end",
"def preload(connection, records, association, host_table:, schema:, as:, order_by:, limit:)\n return records if records.empty?\n\n expect! records.first => Hash\n\n as = association if as.nil?\n fq_host_table = \"#{schema}.#{host_table}\"\n\n associated_table = find_associated_table(connection, association, schema: schema)\n relation = find_matching_relation(connection, fq_host_table, associated_table)\n\n if fq_host_table == relation.belonging_table\n if order_by || limit\n raise ArgumentError, \"#{association.inspect} is a singular association, w/o support for order_by: and limit:\"\n end\n\n preload_belongs_to connection, records, relation, as: as\n else\n preload_has_one_or_many connection, records, relation, as: as, order_by: order_by, limit: limit\n end\n end",
"def load_results(results_page)\n puts \"load results\"\n\n # Get all the links on the page\n links = results_page.links_with(:href => /^search_corps\\.php\\?DETAIL/)\n\n # Get the index of the last loaded link, or 0\n index = ScraperWiki.get_var(INDEX, 0)\n\n # Finish loading the rest of the links onthe page\n while index < links.length \n link = DETAIL_BASE + links[index].href\n puts \"load link \" + link\n\n # Load the current link\n begin\n ScraperWiki.sqliteexecute(\"INSERT INTO links (link) VALUES (?)\", [link])\n ScraperWiki.commit()\n rescue Exception => e\n puts \"Exception (#{e.inspect}) raised saving record #{link}\"\n end\n\n # Increment and save the index\n index = index + 1\n ScraperWiki.save_var(INDEX, index)\n end\nend",
"def load_results(results_page)\n puts \"load results\"\n\n # Get all the links on the page\n links = results_page.links_with(:href => /^search_corps\\.php\\?DETAIL/)\n\n # Get the index of the last loaded link, or 0\n index = ScraperWiki.get_var(INDEX, 0)\n\n # Finish loading the rest of the links onthe page\n while index < links.length \n link = DETAIL_BASE + links[index].href\n puts \"load link \" + link\n\n # Load the current link\n begin\n ScraperWiki.sqliteexecute(\"INSERT INTO links (link) VALUES (?)\", [link])\n ScraperWiki.commit()\n rescue Exception => e\n puts \"Exception (#{e.inspect}) raised saving record #{link}\"\n end\n\n # Increment and save the index\n index = index + 1\n ScraperWiki.save_var(INDEX, index)\n end\nend",
"def load(hashes)\n master = master()\n \n # Assign to local variables for speed increase\n rp = row_procs[master]\n rm = records_map[master]\n dm = dependency_map\n\n # This will hold the final record set that we will be replacing the object graph with.\n records = []\n\n hashes.each do |h|\n unless key = master_pk(h)\n key = hkey(master_hfor(h))\n end\n unless primary_record = rm[key]\n primary_record = rm[key] = rp.call(master_hfor(h))\n # Only add it to the list of records to return if it is a new record\n records.push(primary_record)\n end\n # Build all associations for the current object and it's dependencies\n _load(dm, primary_record, h)\n end\n \n # Remove duplicate records from all associations if this graph could possibly be a cartesian product\n # Run after_load procs if there are any\n post_process(records, dm) if @unique || !after_load_map.empty? || !limit_map.empty?\n\n records\n end",
"def load_model(mid)\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_get_model_info\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n url_get_records = url_get_records.gsub '{mid}', mid.to_s\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, {}, 'get'\n\n json = JSON.parse(response)\n unless json['status'] == 200\n raise json['message']\n end\n\n model = Dynamicloud::API::Model::RecordModel.new mid\n model.name = json['name']\n model.description = json['description']\n\n model\n end",
"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 load\n assert_keys_present!\n record_collection.load! unless loaded?\n self\n end",
"def lookup_record(url)\n begin\n Link.where(url: url).first_or_create(\n title: link_params[:title],\n code: Link::GenerateCode.run\n )\n rescue\n nil\n end\n end",
"def link!(record)\n event = event_store.read.stream(record.stream_name).forward.first\n\n event_store.link(\n event.event_id,\n stream_name: stream_name\n )\n end",
"def post_load(all_records)\n eager_graph_build_associations(all_records) if @opts[:eager_graph]\n eager_load(all_records) if @opts[:eager] && (row_proc || @opts[:eager_graph])\n super\n end",
"def all\n setup_file\n \n links_data = File.open('link_db.txt').read\n links = JSON.parse(links_data)\n return links\nend",
"def load(page_idx, record)\n # The IDListPageRecord will tell us the actual number of values stored\n # in this page.\n values = []\n unless (entries = record.page_entries) == 0\n begin\n @f.seek(page_idx * @page_size * 8)\n values = @f.read(entries * 8).unpack(\"Q#{entries}\")\n rescue IOError => e\n PEROBS.log.fatal \"Cannot read cache file #{@file_name}: #{e.message}\"\n end\n end\n\n # Create the IDListPage object with the given values.\n p = IDListPage.new(self, record, page_idx, values)\n @pages.insert(p, false)\n\n p\n end",
"def parse_link; end",
"def preload_reference_chain(**reference_attribs)\n reference_attribs.each do |t, a|\n preload_chain(a, collection: records.map { |r| r.public_send(t.to_sym) })\n end\n self\n end",
"def all\n setup_file\n \n links_data = File.open('link_db.txt').read\n links = JSON.parse(links_data)\n \n return links\nend",
"def load!\n records_by_identity = index_by { |record| record.key_values }\n\n record_set.find_each_row do |row|\n identity = row.values_at(*record_set.key_column_names)\n records_by_identity[identity].hydrate(row)\n end\n\n loaded_count = count { |record| record.loaded? }\n if loaded_count < count\n raise Cequel::Record::RecordNotFound,\n \"Expected #{count} results; got #{loaded_count}\"\n end\n\n self\n end",
"def load(attributes)\n if attributes.is_a?(Array)\n records = attributes.clone\n attributes = {}\n id = nil\n if records.length >= 1\n records.each_with_index do |rec, i|\n # The \"actual\" id is the 1st\n id = rec[\"id\"] if i == 0 && rec[\"id\"].to_i > 0\n attributes.merge!(rec)\n end\n attributes[\"id\"] = id || attributes[\"id\"]\n end\n end\n super(attributes)\n end",
"def load_record!(criteria, &block)\n record = find_or_initialize_by(criteria)\n record.status = STATUS_IMPORTED\n record.updated_at = Time.now\n yield(record)\n record.save!\n end",
"def initialize( connection, id, link, extra_data = nil )\n @id = id\n @connection = connection\n @populated = false\n @link = link\n populate_from_hash( extra_data ) if extra_data\n #populate( link )\n end",
"def load_fields(mid)\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_get_fields\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n url_get_records = url_get_records.gsub '{mid}', mid.to_s\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, {}, 'get'\n\n json = JSON.parse(response)\n unless json['status'] == 200\n raise json['message']\n end\n\n fields = []\n fs = json['fields']\n fs.each do |key, jf|\n field = Dynamicloud::API::Model::RecordField.new\n field.id = jf['id'].to_i\n field.identifier = jf['identifier']\n field.label = jf['label']\n field.comment = jf['comment']\n field.uniqueness = jf['uniqueness']\n field.required = jf['required']\n field.type = Dynamicloud::API::Model::RecordFieldType.get_field_type jf['field_type'].to_i\n field.items = Dynamicloud::API::DynamicloudHelper.build_items jf['items']\n field.mid = mid.to_i\n\n fields.push field\n end\n\n fields\n end",
"def fetch_links!\n return if content_id.blank?\n\n links = Services.publishing_api.get_links(content_id)[\"links\"]\n\n self.lead_organisation_content_ids = links[\"lead_organisations\"] || []\n self.organisation_content_ids = links[\"organisations\"] || []\n self.people_content_ids = links[\"people\"] || []\n self.working_group_content_ids = links[\"working_groups\"] || []\n end",
"def load_record(database, table, key)\n cursor = session.send(database).select_cursor(\n :table => table,\n :row_keys => [key],\n :type_cast => true\n )\n row = nil\n row = cursor.next_row if cursor.next?\n cursor.clear\n row\n end",
"def test_load\n @valid_source.save\n source_loaded = Source.find(@valid_source.uri)\n assert_kind_of(Source, source_loaded)\n assert_equal(@valid_source.primary_source, source_loaded.primary_source)\n assert_equal(@valid_source.uri, source_loaded.uri)\n end",
"def load_entity(record, name)\n set_entity(record, name)\n read\n end",
"def load_all_data\n @students = Student.all\n @employees = Employee.all\n @routes = Route.in_academic_year(academic_year_id).all(:include => :vehicle_stops)\n end",
"def parse_links_hash(link_hash_arrays)\n link_hash_arrays.each do |link_array|\n \n unless (link_array.has_key?(\"Link\"))\n next\n end\n \n # Loop thru each link pulled from XML\n (link_array[\"Link\"]).each do |link_hash|\n \n # Select or Insect Link\n puts \"Searching for link #{link_hash['title']}, entity_a: #{link_hash['entity_a']}, entity_b: #{link_hash['entity_b']}\"\n result = Link.select_or_insert(@project_id, @section_id, link_hash['entity_a'], link_hash['entity_b'], link_hash['title'])\n result.save\n puts \"Result: #{result.inspect}\"\n \n # Select or Insert LinkType\n if (link_hash.has_key?(\"type\"))\n puts \"Searching for link type #{link_hash['type']}\"\n type_result = LinkType.select_or_insert(link_hash['type'])\n type_result.save\n puts \"Result: #{type_result.inspect}\"\n \n puts \"Setting entity type for link\"\n result.link_type_id = type_result.id\n result.save\n puts \"Done.\" \n end\n \n ## Other fields???\n ## Description\n if (link_hash.has_key?(\"description\")) \n ## TODO: if / when needed \n end\n ## Title\n if (link_hash.has_key?(\"title\"))\n ## TODO: if/when needed\n end\n \n ## Logic for attributes\n if (link_hash.has_key?(\"AdditionalField\"))\n (link_hash[\"AdditionalField\"]).each do |add_field|\n field_name = add_field['name']\n field_value = add_field['value']\n puts \"[DEBUG] name: #{field_name} value: #{field_value}\"\n \n ## Insert attribute field if not exists\n link_field = PoortegoLinkField.select_or_insert(result.id, field_name)\n link_field.save\n \n ## Set attribute field\n link_field.update_attributes('value' => field_value)\n link_field.save\n end \n end\n end\n end\n end",
"def load record\n case\n when record[\"_delete\"]\n delete(record)\n else\n create_or_update(record)\n end\n end",
"def from_record(record)\n end",
"def load(id, *args, &blk); end",
"def initialize(results_record)\n\n if results_record.key? 'Record'\n @record = results_record['Record'] # single record returned by retrieve api\n else\n @record = results_record # set of records returned by search api\n end\n\n @items = @record.fetch('Items', {})\n\n @bib_entity = @record.fetch('RecordInfo', {})\n .fetch('BibRecord', {})\n .fetch('BibEntity', {})\n\n @bib_relationships = @record.fetch('RecordInfo', {})\n .fetch('BibRecord', {})\n .fetch('BibRelationships', {})\n\n @bib_part = @record.fetch('RecordInfo', {})\n .fetch('BibRecord', {})\n .fetch('BibRelationships', {})\n .fetch('IsPartOfRelationships', {})[0]\n\n @bibtex = BibTeX::Entry.new\n end",
"def read_linked_data_api(entry)\n ld_api.call(entry.url) { |response, data| return response.body, data }\n end",
"def load_marc_record\n @@sierra_api = SierraApi.new unless @@sierra_api\n\n marc_record = @@sierra_api.bibs(id: @bibnumber)\n\n relavent_tags = ['245', '500', '511', '520', '521', '546']\n\n tags = {}\n marc_record.each do |i|\n tag = i['tag']\n if relavent_tags.include?(tag)\n tags[tag] = {} unless tags.key?(tag)\n\n i['data']['subfields'].each do |j|\n code = j['code']\n if tags[tag].key?(code)\n tags[tag][code] << ' ' + j['data']\n else\n tags[tag][code] = j['data']\n end\n end\n end\n end\n #pp tags\n\n # Extract fields.\n @title = tags['245']['a'].gsub(' /', '') if defined?(tags['245']['a'])\n @summary = tags['520']['a'] if defined?(tags['520']['a'])\n @cast = tags['511']['a'] if defined?(tags['511']['a'])\n @language = tags['546']['a'] if defined?(tags['546']['a'])\n @rating = tags['521']['a'] if defined?(tags['521']['a'])\n\n if tags.key?('500')\n note = tags['500'].values.join(' ')\n if match = /\\d{4}/.match(note)\n @year = match[0] if match.length == 1\n end\n end\n\n end",
"def load_models\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_get_models\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, {}, 'get'\n\n json = JSON.parse(response)\n unless json['status'] == 200\n raise json['message']\n end\n\n models = []\n array = json['models']\n array.each do |item|\n model = Dynamicloud::API::Model::RecordModel.new item['id'].to_i\n model.name = item['name']\n model.description = item['description']\n\n models.push model\n end\n\n models\n end",
"def links(options={})\n options = {:get_dataset => false, :type => Ecore::Link, :reload => false, :preconditions => {:hidden => false}}.merge(options)\n return @links_chache if @links_chache and !options[:get_dataset] and !options[:reload]\n query = Ecore::db[options[:type].table_name].store_preconditions((@group_ids || @user_id),self.class.get_type_if_has_superclass,self,nil,(options[:preconditions] || {:hidden => false}))\n query = query.where(:orig_document_id => id)\n return query if options[:get_dataset]\n @links_chache = query.order(:name,:created_at).receive(:all)\n end",
"def ajax_catalog_link_and_source\n instance_id = params['instanceId']\n url = ENV['OKAPI_URL']\n tenant = ENV['OKAPI_TENANT']\n # Get instance HRID (e.g., bibid) for the record\n response = CUL::FOLIO::Edge.instance_record(url, tenant, folio_token, instance_id)\n link = nil\n source = nil\n if response[:code] < 300\n source = response[:instance]['source']\n # Try to identify ILL items and set source manually -- it's 'FOLIO' in the actual record.\n source = 'ill' if ill_item?(response[:instance])\n\n # Ignore Borrow Direct records for the link -- they have an HRID that looks like a legit bibid, but\n # it's something else BD-related. We can't link to those. But now, most sources are either MARC or\n # FOLIO. A FOLIO source indicates that this was a locally-created record -- e.g., for a temporary record\n # for a BD/ReShare item. Most of the others appear to be MARC-source. This is probably not entirely accurate,\n # but we can filter out the FOLIO records and probably get things right most of the time.\n link = \"https://newcatalog.library.cornell.edu/catalog/#{response[:instance]['hrid']}\" if source == 'MARC'\n end\n render json: { link: link, source: source }\n end",
"def load\n unless @id.nil?\n typed_member_ids = Strand.redis.smembers(SCOPE + ':' + @id.to_s).map { |x| x.split(':') }.group_by(&:first).map { |c, xs| [c, xs.map(&:last)] }\n typed_member_ids.each do |typed_ids|\n @members += typed_ids.first.constantize.find_by_sql(\n [\n 'SELECT x.*, l.topic_id FROM ' + typed_ids.first.tableize + ' x LEFT OUTER JOIN links l ON l.target_id = x.id AND target_type = ? WHERE x.id IN (?)',\n typed_ids.first.classify,\n typed_ids.last\n ]\n )\n end\n topic_ids = @members.map(&:topic_id).compact.uniq\n topics = Hash[Topic.find(topic_ids).collect { |t| [t.id, t] }]\n @members.each { |m| m.association(:topic).target = topics[m.topic_id] unless m.topic_id.nil? }\n topic_code = Strand.redis.hget TOPICS, @id\n unless topic_code.nil?\n @topic = Topic.find_by_code topic_code\n end\n @good = Strand.redis.hget STATUS, @id\n end\n self\n end",
"def load_records\n native_instance(true)\n native_instance.top(limit) if limit.present?\n Array(service.native_instance.execute)\n end",
"def links\n if params[:links]\n titles = params[:links][:title]\n url = params[:links][:url]\n s = titles.zip(url)\n @external_links = []\n if (params[:label] == \"Classrooms\" || params[:label] == \"Subjects\") \n if params[:label] == \"Subjects\"\n label = \"Subjects\"\n else\n label = \"Classrooms\"\n end\n s.each do |f|\n a = f.flatten\n if ( a[1] != \"\") && (a[3] != \"\")\n @external_links << @current_school.external_links.create({:classroom_id => @classroom.id, :label => label,\n :title => a[1], :url => a[3] })\n end\n end\n else\n s.each do |f|\n a = f.flatten\n if ( a[1] != \"\") && (a[3] != \"\")\n @external_links << @current_school.external_links.create({:title => a[1], :label => params[:label], :url => a[3] })\n end\n end\n end\n end\n end",
"def _load_associated_objects(opts, dynamic_opts=OPTS)\n if opts.can_have_associated_objects?(self)\n if opts.returns_array?\n _load_associated_object_array(opts, dynamic_opts)\n elsif load_with_primary_key_lookup?(opts, dynamic_opts)\n _load_associated_object_via_primary_key(opts)\n else\n _load_associated_object(opts, dynamic_opts)\n end\n elsif opts.returns_array?\n []\n end\n end",
"def load_source_records(model, pdm_object_ids)\n model.where(pdm_object_id: pdm_object_ids)\n .includes(root_tree_node: :tree, branch_tree_node: :tree, leaf_tree_node: :tree)\n .to_a\n .select(&:tree_nodes_valid?)\n .group_by(&:pdm_object_id)\n .reject { |_k, group| group.size < 2 }\n end",
"def fetch_data\n parse_data(self.organization.find_data(self.data_path, \n :include => [:url, :name, :description, :picture]))\n end",
"def ___init_record_file\n return unless @opt.mcr_log?\n # ext_file must be after ext_rsp which includes time update\n @record.ext_local.ext_file.ext_save\n @record.mklink # Make latest link\n @record.mklink(@id) # Make link to /json\n end",
"def initialize(link_options={})\n @id = link_options[\"id\"]\n @assignment_id = link_options[\"assignment_id\"] \n @link = link_options[\"link\"]\n @type = link_options[\"type\"]\n end",
"def load_data\n # @categories = Category.find(:all)\n # @infoitems = Expert.find(:all)\n end",
"def to_a\n return @records if loaded?\n\n load\n end",
"def insert_record(csv, link_name, link_path, protocol, host_url)\n url = URI.parse(\"#{protocol}://#{host_url}#{link_path}\")\n response = open(url.to_s)\n result = [] << fetch_link_name(link_name) <<\n \"#{protocol}://#{host_url}#{link_path}\" <<\n check_status(response.status.first) << response.status.first\n csv << result\n end",
"def test_load_save\n @valid_source.save\n source_loaded = Source.find(@valid_source.uri)\n source_loaded['http://loadsavetest/name'] << '4'\n source_loaded.save\n \n source_reloaded = Source.find(@valid_source.uri)\n assert_equal('4', source_reloaded['http://loadsavetest/name'][0])\n end",
"def load\n sources_data = @gateway.sources_data\n build_entity(sources_data['sources'])\n end",
"def init_on_load(persisted_rel, from_node_id, to_node_id, type)\n @rel_type = type\n @_persisted_obj = persisted_rel\n changed_attributes_clear!\n @attributes = convert_and_assign_attributes(persisted_rel.props)\n load_nodes(from_node_id, to_node_id)\n end",
"def marc_record_from_marcxml\n id = fetch(_marc_source_field)\n\n response = Faraday.get(\"#{Requests.config['bibdata_base']}/bibliographic/#{id}\")\n @can_retry = response.status == 429\n response_stream = StringIO.new(response.body)\n marc_reader = ::MARC::XMLReader.new(response_stream)\n marc_records = marc_reader.to_a\n marc_records.first\n end",
"def load_data(data_hash)\n super\n @url = data_hash['url']\n end",
"def load\n @store.transaction do\n @people_loaded = @store[:people]\n end\n end",
"def load_object(robject, data)\n robject.raw_data = data[:value]\n robject.content_type = data[:content_type]\n robject.links = data[:links]\n robject.indexes = data[:indexes]\n robject.meta = data[:meta]\n robject.etag = data[:etag]\n robject.last_modified = data[:last_modified]\n robject.vclock = data[:vclock]\n robject\n end",
"def dissect_to_record_hashes\n end",
"def load_items\n @items = []\n data_sources.each do |ds|\n items_in_ds = ds.items\n items_in_ds.each { |i| i.identifier = File.join(ds.items_root, i.identifier) }\n @items += items_in_ds\n end\n\n @items_loaded = true\n end",
"def deep_preload_reference_chain(**reference_attribs)\n reference_attribs.each do |t, a|\n deep_preload_chain(a, collection: records.map { |r| r.public_send(t.to_sym) })\n end\n self\n end",
"def load(rng = nil, attrs = {})\n\n params = {}\n params[:offset] = rng.begin unless rng.nil?\n params[:limit] =\n rng.end - rng.begin + (rng.exclude_end? ? 0 : 1) unless rng.nil?\n\n params.merge! attrs\n uri_params = Helper.to_request_params params\n req = Net::HTTP::Get.new(\"/sources?\"+uri_params)\n res = @lagoonserver.request_with_auth req\n json_sources = JSON.parse(res.body)\n @sources = json_sources.map { |src| Source.new(src, self)}\n return nil\n end",
"def process\n\n @json_set.each do |ref, json|\n \n unlinked = self.class.unlink(json)\n \n begin\n obj = Kernel.const_get(json.class.record_type.camelize).create_from_json(unlinked)\n @as_set[json.uri] = [obj.id, obj.class]\n \n # Now update the URI with the real ID\n json.uri.sub!(/\\/[0-9]+$/, \"/#{@as_set[json.uri][0].to_s}\")\n rescue Exception => e\n raise ImportException.new({:invalid_object => json, :message => e.message})\n end\n end\n \n # Update the linked record pointers in the json set\n @json_set.each do |ref, json|\n self.class.correct_links(json, @json_set)\n \n end\n \n @as_set.each do |ref, a|\n obj = a[1].get_or_die(a[0]) \n obj.update_from_json(@json_set[ref], {:lock_version => obj.lock_version}) \n @saved_uris[ref] = @json_set[ref].uri \n end\n end",
"def link\n\t\t\t@data['link']\n\t\tend",
"def load_attributes(attributes)\n @id = attributes[:id]\n @name = attributes[:name]\n @main_url = attributes[:main_url] ? attributes[:main_url].gsub(/\\/$/, '') : nil\n @created_at = attributes[:created_at]\n end",
"def load(handle, args={})\n File.open(handle) do |handle|\n db = DnaIO.new handle\n db.each do |record|\n self.add(record.sequence, record.name)\n end\n end\n end",
"def set_object_fields\n \n # source id\n ##marc_source_id = marc.get_marc_source_id\n ##self.id = marc_source_id if marc_source_id\n # FIXME how do we generate ids?\n #self.marc.set_id self.id\n \n # parent source\n parent = marc.get_parent\n # If the 773 link is removed, clear the source_id\n # But before save it so we can update the parent\n # source.\n @old_parent = source_id if !parent\n self.source_id = parent ? parent.id : nil\n \n # record type\n self.record_type = 2 if marc.is_holding?\n \n # std_title\n self.std_title, self.std_title_d = marc.get_std_title\n \n # composer\n self.composer, self.composer_d = marc.get_composer\n \n # siglum and ms_no\n # in A/1 we do not have 852 in the bibliographic data\n # instead we store in ms_no the Book RISM ID (old rism id)\n if RISM::BASE == \"a1\" and record_type == 0\n self.book_id = marc.get_book_rism_id\n else\n self.lib_siglum, self.shelf_mark = marc.get_siglum_and_shelf_mark\n end\n \n # ms_title for bibliographic records\n self.title, self.title_d = marc.get_source_title if self.record_type != 2\n \n # physical_condition and urls for holding records\n self.ms_condition, self.urls, self.image_urls = marc.get_ms_condition_and_urls if self.record_type == 2\n \n # miscallaneous\n self.language, self.date_from, self.date_to = marc.get_miscellaneous_values\n\n self.marc_source = self.marc.to_marc\n end",
"def set_link\n if params[:id]\n # raise ActionController::RoutingError.new('Not Found')\n @link = Link.find_by_admin_id(params[:id])\n elsif params[:uuid]\n @link = Link.find_by_admin_id(params[:uuid])\n elsif params[:hash_id]\n id = Hashid.decode(params[:hash_id]).first #first is required otherwise array is returned\n @link = Link.find(id)\n end\n end",
"def link\n return unless @data['link']\n link = @data['link']\n # Aozora has embed data, we just need to restructure it a bit\n @link ||= {\n kind: link['type'],\n title: link['title'],\n description: link['description'],\n url: link['url'],\n site_name: link['siteName'],\n image: link['images'].first\n }\n end",
"def load!(access_log_file_path)\n @db = get_db\n current_line = 0\n File.foreach(access_log_file_path) do |line|\n begin\n item = parse_line(line)\n rescue ArgumentError, NoMethodError => e\n error_line(\"PARSE\", current_line, [], line, e)\n current_line += 1\n next\n end\n\n\n begin\n item[:http_code] = Integer(item[:http_code])\n item[:page_number] = item[:page_number].collect do |p|\n # We don't use collect! because this array gets frozen somehow.\n if [nil, \"\"].include?(p)\n p = -1\n error_line(\"NOPAGE\", current_line, item, line, -1)\n end\n Integer(p)\n end\n\n if item[:volume_id] == \"1\"\n error_line(current_line, item, line, nil)\n end\n\n if item[:volume_id] && item[:http_code] >= 200 && item[:http_code] < 300\n insert(@db, item[:volume_id], item[:page_number], item[:access_date], item[:ip_token])\n end\n\n rescue ArgumentError, TypeError, SQLite3::ConstraintException => e\n error_line(\"INSERT\", current_line, item, line, e)\n end\n current_line += 1\n end\n return self\n end",
"def from_record(ref, record)\n obj = self.new(ref)\n\n # This smells, but we don't want to actually expose the internal record\n obj.instance_variable_set(\"@record\", record)\n obj\n end",
"def load(id)\n #find connction by identifier from .gift\n end",
"def load_file(f)\n @list_link = []\n YAML.load_file(f).each { |e|\n link = Link.new e[0], e[1]\n link.exclude = e[2] if e.size > 2\n @list_link << link\n }\n check_possibility\n @list_link_copy = Array.new @list_link\n end",
"def preload_belongs_to(connection, records, relation, as:)\n belonging_column = relation.belonging_column.to_sym\n having_column = relation.having_column.to_sym\n\n foreign_ids = H.pluck(records, belonging_column).uniq.compact\n\n scope = connection.scope(table: relation.having_table)\n scope = scope.where(having_column => foreign_ids)\n\n recs = connection.all(scope, into: Hash)\n recs_by_id = H.by_key(recs, having_column)\n\n records.each do |model|\n model[as] = recs_by_id[model.fetch(belonging_column)]\n end\n end",
"def preload(association, as: nil, order_by: nil, limit: nil)\n expect! association => Symbol\n expect! as => [nil, Symbol]\n\n # resolve oid into table and schema name.\n #\n # [TODO] is this still correct?\n schema, host_table = connection.reflection.lookup_pg_class @pg_source_oid\n\n AssociationLoader.preload connection,\n @hash_records, association,\n host_table: host_table, schema: schema, as: as,\n order_by: order_by, limit: limit\n\n @associations << association\n\n materialize\n end",
"def load_by(attrs)\n record = Persister.for(@decorated.class).find(attrs)\n\n unless record\n raise Dirt::MissingRecordError.new(\"No record matches #{attrs.collect { |pair| pair.join(' == ') }.join(', ')}.\")\n end\n\n chameleonize(record)\n\n self\n end",
"def initialize(src = nil, opt = nil)\n super\n records&.each do |rec|\n rec&.recordData&.oclcdcs&.dc_identifier&.map! { |v|\n next if v.blank? || (v = v.to_s).start_with?('http')\n v.include?(':') ? v : \"isbn:#{v}\"\n }&.compact!\n end\n end",
"def attachment_links()\n @attachment_links ||= AttachmentLink.where(\"master_id = ? AND master_type = ?\", id, class_name).limit(attachments_count)\n end",
"def links\n @mandate_import_entry_links ||= Links.new(@links)\n end",
"def records_for_populate(options = {})\n records_base(options)\n end",
"def load(records)\n records.map do |h| \n r = WeatherObservation.first_or_create({:weather_station_id => h[:weather_station_id], :date => h[:date]}, h)\n if (r.id.nil?)\n $stderr.puts(\"failed to save #{r.inspect}, #{r.errors.full_messages}\")\n end\n end\n end",
"def load(index)\n @file.pos = @record_offset + @record_size*index\n data = @file.read(@record_size)\n record = Record.new(self)\n record.instance_eval { load(index, data) }\n record\n end",
"def import fields, title_too=false\n self.title = fields.shift if title_too\n fields.each do |field|\n field.strip!\n next if field.blank?\n # Assign to either description or link, depending on whether it's parseable as a URI\n if !field.match(/\\s/)\n begin\n if URI(field)\n self.link = field\n next\n end\n rescue e # Ignore URI parsing errors\n x = 2\n end\n end\n self.description = field\n end\n self\n end",
"def read_join_relations(obj, res_row, row, join_relations)\n offset = obj.class.serializable_attributes.size\n\n for rel in join_relations\n rel_obj = rel[:target_class].og_allocate(res_row, row)\n rel_obj.og_read(res_row, row, offset)\n offset += rel_obj.class.serializable_attributes.size\n obj.instance_variable_set(\"@#{rel[:name]}\", rel_obj)\n end\n end",
"def load_with_associations\n @response = Response.with_basic_assoc.friendly.find(params[:id])\n end",
"def parse_link(link)\n return {\n title: link['given_title'],\n url: link['given_url'],\n excerpt: link['excerpt'],\n resolved_title: link['resolved_title'],\n resolved_url: link['resolved_url'],\n created_at: Time.at(link['time_added'].to_i).utc,\n updated_at: Time.at(link['time_updated'].to_i).utc,\n comment: ''\n }\n end"
] | [
"0.68154955",
"0.66979676",
"0.6455902",
"0.6243837",
"0.6213146",
"0.6065446",
"0.60491234",
"0.5975796",
"0.596967",
"0.59458137",
"0.59071857",
"0.5899719",
"0.57650113",
"0.574955",
"0.5698174",
"0.5668693",
"0.5617649",
"0.5556709",
"0.5551922",
"0.55441046",
"0.55355024",
"0.55355024",
"0.5522508",
"0.5493829",
"0.54590034",
"0.5402639",
"0.5399758",
"0.5370804",
"0.5365112",
"0.53112864",
"0.53043735",
"0.5291333",
"0.5282656",
"0.52676547",
"0.5253114",
"0.5224339",
"0.52215797",
"0.5207641",
"0.52070665",
"0.52059877",
"0.51978743",
"0.51976186",
"0.51932305",
"0.5185849",
"0.5168851",
"0.5168811",
"0.5130702",
"0.5121186",
"0.5117556",
"0.5112145",
"0.5080435",
"0.5061906",
"0.5047705",
"0.50454754",
"0.50373274",
"0.5034756",
"0.502659",
"0.5023319",
"0.5019503",
"0.5011602",
"0.50061226",
"0.4996298",
"0.49957836",
"0.49901304",
"0.4974938",
"0.49679354",
"0.49578282",
"0.4951977",
"0.494733",
"0.49413055",
"0.49410766",
"0.4939514",
"0.49378735",
"0.49268892",
"0.491826",
"0.49178964",
"0.49173427",
"0.49109113",
"0.49058074",
"0.4905771",
"0.49057359",
"0.48945898",
"0.48943484",
"0.488579",
"0.4884318",
"0.4877491",
"0.4866162",
"0.4863672",
"0.4857027",
"0.4856682",
"0.4854103",
"0.48517406",
"0.48442551",
"0.48429513",
"0.48405486",
"0.4839958",
"0.4833792",
"0.48332372",
"0.4831504",
"0.48313794"
] | 0.49777573 | 64 |
Read the links associated with given item | def read_links(ltype, id)
return {} if !v[ltype]
return {} if !v[ltype][id]
v[ltype][id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def links\n return nil unless @item and self.type == :query and @item['entry']['link']\n @item['entry']['link']\n end",
"def read_link(item)\n link = item.search(\"link:first\")\n unless link.nil?\n post_url = link.text\n post_url = link.to_s.scan(/href=['\"]?([^'\"]*)['\" ]/).to_s if (post_url.nil? or post_url.empty?)\n return post_url\n else\n return nil\n end\n end",
"def links_for_item(item)\n links = super(item)\n\n links.push({\n 'rel' => 'status',\n 'type' => api_media_type(:g5kitemjson),\n 'href' => uri_to(File.join(resource_path(item['uid']), 'status'))\n })\n links\n end",
"def item_link(record)\n doi_link = doi_generator(record)\n\n # Return DOI link, in one exists\n return doi_link if doi_link\n\n # Query OpenURL resolve service for results\n open_url_links = open_url_generator(record)\n if open_url_links.size.positive?\n # If there is only one result, return it\n return open_url_links[0] if open_url_links.size == 1\n\n # If there are multiple results, return a \"Citation Finder\" link\n return citation_generator(record)\n end\n\n # Default -- return link to the catalog detail page\n catalog_generator(record)\n end",
"def read_links()\n\t\tlinks = linkr.read_array()\n\t\t###binding.pry\n\t\t#@initial_queue = links\n\t\t###binding.pry\n\t\tlinks\n\n\tend",
"def get_item_content(course_id, item_id)\r\n relative_url = nil\t\r\n\t\r\n\t # get the item details\r\n\t response = get_item(course_id, item_id)\r\n\t return response if response.error?\r\n\r\n\t json_data = JSON.parse(response.content)\r\n\t items = json_data['items']\r\n\t \r\n\t if !items.nil? && items.length > 0\r\n\t # rel on link varies, so identify self by missing title\r\n\t links = items[0]['links']\r\n\t links.each do |link|\r\n\t\t title = link['title']\r\n\t if title.nil?\r\n\t\t relative_url = get_relative_path(link['href'])\r\n\t\t end\r\n\t\tend\r\n\t\t# Get the item\r\n\t response = get(relative_url)\r\n\t return response if response.error?\r\n\t \r\n\t # Get the item content location\r\n\t json_data = JSON.parse(response.content)\r\n\t text_multimedias = json_data['textMultimedias']\r\n\t content_url = text_multimedias[0]['contentUrl']\t\t\r\n relative_url = get_relative_path(content_url)\r\n\r\n return get(relative_url)\t\t\t\r\n\t else\r\n\t # should never get here\r\n\t raise RuntimeError, \"Unexpected condition in library: No item content path found\"\r\n\t end\r\n end",
"def item_url(item)\n item.url\n end",
"def item_url(item)\n item.url\n end",
"def search_item_link(item)\n subcategory = item[\"subcategory\"].downcase\n\n if subcategory == \"audio\"\n id = item[\"identifier\"].split(\".\").last\n path = audio_item_path(id: id)\n\n elsif subcategory == \"correspondence & papers\"\n path = correspondence_item_path(id: item[\"identifier\"])\n\n elsif subcategory == \"drill\"\n path = drill_item_path(id: item[\"identifier\"])\n\n elsif subcategory == \"features\"\n id = item[\"identifier\"].split(\".\").last\n path = feature_path(id: id)\n\n elsif subcategory == \"footage\"\n path = footage_clip_path(id: item[\"identifier\"])\n\n elsif subcategory == \"images\"\n path = image_path(id: item[\"identifier\"])\n\n elsif subcategory == \"newspaper\"\n path = newspapers_item_path(id: item[\"identifier\"])\n\n elsif subcategory == \"personal accounts\"\n id = item[\"identifier\"].split(\".\").last\n path = account_path(id: id)\n\n else\n path = item_path(id: item[\"identifier\"])\n end\n\n path\n end",
"def links\n data['links']\n end",
"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 gen_links (res, item, &block)\n\n if block # unique element\n\n [ link('via', res), link('self', res, block.call(item)) ]\n\n elsif item.respond_to?(:current_page) and item.total_pages > 1\n\n a = [\n link('via', ''),\n link('self', res, 'page' => item.current_page)\n ]\n a << link('prev', res, 'page' => item.current_page - 1) \\\n if item.current_page > 1\n a << link('next', res, 'page' => item.current_page + 1) \\\n if item.current_page < item.total_pages\n a\n\n else # collection\n\n [ link('via', ''), link('self', res) ]\n end\n end",
"def item_link(bib)\n doi_link = doi_generator(bib)\n\n # Return DOI link, in one exists\n return doi_link if doi_link\n\n # Query OpenURL resolve service for results\n open_url_links = open_url_generator(bib)\n if open_url_links.size.positive?\n # If there is only one result, return it\n return open_url_links[0] if open_url_links.size == 1\n\n # If there are multiple results, return a \"Citation Finder\" link\n return citation_generator(bib)\n end\n\n # Default -- return link to the catalog detail page\n catalog_generator(bib)\n end",
"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 doc_links(pid)\n @client.call(:get_doc_links, message: {pid: pid})\n end",
"def links\n construct_html(self.items)\n end",
"def links()\n return @links\n end",
"def links\n return @links\n end",
"def links\n return @links\n end",
"def links\n return @links\n end",
"def links; end",
"def links; end",
"def links\n @data[\"_links\"]\n end",
"def exist_links\n return [] if sumup.blank?\n\n sumup.fetch(\"public_praises\").fetch(\"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 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 link_to_item(item, options = {})\n case item\n when Collection\n collection_url(item, options)\n when Community\n community_url(item, options)\n when DataObject\n data_object_url(item.latest_published_version_in_same_language || item, options)\n when User\n user_url(item, options)\n when TaxonConcept\n taxon_url(item, options)\n when UserAddedData\n options.merge!(anchor: item.anchor)\n taxon_data_url(item.taxon_concept, options)\n when DataPointUri\n options.merge!(anchor: item.anchor)\n taxon_data_url(item.taxon_concept, options)\n when Resource\n content_partner_resource_url(options[:content_partner], item)\n else\n raise EOL::Exceptions::ObjectNotFound\n end\n end",
"def links\n self[\"link\"].map { |l| l.href }\n end",
"def links\n self[\"link\"].map { |l| l.href }\n end",
"def links\n response = Clever.request :get, url\n response[:links]\n end",
"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 links\n @links.values\n end",
"def show_links\r\n links = Document.new(self).get_links\r\n puts \"There are #{links.length} links\"\r\n index = 1\r\n links.each do |l|\r\n puts \"link: name: #{l.name}\"\r\n puts \" id: #{l.id}\"\r\n puts \" href: #{l.href}\"\r\n puts \" index: #{index}\"\r\n index += 1\r\n end\r\n end",
"def handle_item item\n separator item.link\n file_handle.write(open(item.link).read)\n file_handle.write(\"\\n\\n\")\n end",
"def html_link(item)\n tag :a, yield, :href => item.url\n end",
"def links\n\ttmp = []\n @doc.xpath('//field[@id=\"linkedWorkItems\"]/list/struct').each do |struct|\n\t linked_wid = struct.xpath('item[@id=\"workItem\"]').text\n\t role = struct.xpath('item[@id=\"role\"]').text\n\t tmp << \"#{role}:#{linked_wid}\"\n\tend\n\treturn tmp\n end",
"def link\n @link\n end",
"def links\n @links ||= []\n @links\n end",
"def link\n object[\"link\"]\n end",
"def links_feed\n end",
"def link\n\t\t\t@data['link']\n\t\tend",
"def uris_of_items_related_to(item)\n q = query.select.where([:s, :p, item.rdf_resource]).from(RDF::URI.new(get_configuration.private_graph))\n results = select(q).collect { |result| result[:s] }\n\n q = query.select.where([item.rdf_resource, :p, :o]).from(RDF::URI.new(get_configuration.private_graph))\n results |= select(q).collect { |result| result[:o] }\n\n results.select { |result| result.is_a?(RDF::URI) }.collect(&:to_s).uniq\n end",
"def links\n each_link.to_set\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 create_links(key)\n '<br>' + @items.select { |i| i[:category] == key }\n .map { |i| link_to(i[:title], i.identifier) }.join('<br>') + '<br>'*2\nend",
"def get_raw_links\n @doc.xpath(LINKS_XPATH).map { |link| link['href'] }\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 fulltext_links\n\n links = []\n\n ebscolinks = @record.fetch('FullText',{}).fetch('Links',{})\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'pdflink'\n link_label = 'PDF Full Text'\n link_icon = 'PDF Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'pdf'})\n end\n end\n end\n\n htmlfulltextcheck = @record.fetch('FullText',{}).fetch('Text',{}).fetch('Availability',{})\n if htmlfulltextcheck == '1'\n link_url = 'detail'\n link_label = 'Full Text in Browser'\n link_icon = 'Full Text in Browser Icon'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'html'})\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'ebook-pdf'\n link_label = 'PDF eBook Full Text'\n link_icon = 'PDF eBook Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'ebook-pdf'})\n end\n end\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'ebook-epub'\n link_label = 'ePub eBook Full Text'\n link_icon = 'ePub eBook Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'ebook-epub'})\n end\n end\n end\n\n items = @record.fetch('Items',{})\n if items.count > 0\n items.each do |item|\n if item['Group'] == 'Url'\n if item['Data'].include? 'linkTerm="'\n link_start = item['Data'].index('linkTerm="')+15\n link_url = item['Data'][link_start..-1]\n link_end = link_url.index('"')-1\n link_url = link_url[0..link_end]\n link_label_start = item['Data'].index('link>')+8\n link_label = item['Data'][link_label_start..-1]\n link_label = link_label.strip\n else\n link_url = item['Data']\n link_label = item['Label']\n end\n link_icon = 'Catalog Link Icon'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'cataloglink'})\n end\n end\n end\n\n if ebscolinks.count > 0\n ebscolinks.each do |ebscolink|\n if ebscolink['Type'] == 'other'\n link_label = 'Linked Full Text'\n link_icon = 'Linked Full Text Icon'\n link_url = ebscolink['Url'] || 'detail'\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'smartlinks+'})\n end\n end\n end\n\n ft_customlinks = @record.fetch('FullText',{}).fetch('CustomLinks',{})\n if ft_customlinks.count > 0\n ft_customlinks.each do |ft_customlink|\n link_url = ft_customlink['Url']\n link_label = ft_customlink['Text']\n link_icon = ft_customlink['Icon']\n links.push({url: link_url, label: link_label, icon: link_icon, type: 'customlink-fulltext'})\n end\n end\n\n links\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def all_links\n Link.all\n end",
"def links\n\t\t( 0...self.link_count ).collect do |i|\n\t\t\tself.link( i )\n\t\tend\n\tend",
"def navigation_items\n unless @io\n @io = []\n \n if can?( :index, PhoneBookEntry )\n @io << { :url => phone_book_entries_path , :title => t('phone_book_entries.index.page_title' ) }\n end\n \n # This could be a link to VoiceMails.\n #\n # if can?( :index, Object )\n # @io << { :url => \"#\" , :title => t('voice_mail') }\n # end\n \n end\n @io\n end",
"def feed_items\n feed_item\n end",
"def get_position_links\n # Get all links that have the text: \"View Details\"\n links = @page.links_with(:text => /View Details/)\n href_links = []\n # convert all links into an appropriate html link\n links.each { |link| href_links << 'https://www.jobsatosu.com' + link.href }\n href_links\n end",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_items_with_all_category page\n category_links = page.search('li a')\n category_links.each{|item|\n link = item[:href]\n text = item.text\n p text\n\n category_page = @agent.get(link)\n get_items_with_each_category(category_page, text)\n }\nend",
"def get_links(service)\n\t\treturn @transport.get_path(\"links\",service)\n\tend",
"def links\n @links ||=\n if defined? unitID\n Rentlinx.client.get_links_for_unit(self)\n else\n Rentlinx.client.get_links_for_property_id(propertyID)\n end\n end",
"def links\n links = []\n result = self.perform\n links = result.ft_links\n end",
"def links\n\n @user=current_user\n @links=Link.user_links(current_user.id)\n\n end",
"def process_item(item)\n item = Nokogiri::HTML(item.text)\n downloads_section = item.css('h2:contains(\"Download\")').first\n return unless downloads_section\n\n process_download(downloads_section.next_element.css('li').first)\n end",
"def link(attribute)\n links.find_all { |l| l.rel == attribute.to_s }\n end",
"def all\n setup_file\n \n links_data = File.open('link_db.txt').read\n links = JSON.parse(links_data)\n \n return links\nend",
"def items\n all(locator(:item)).map do |item|\n item.find(locator(:item_name)).text\n end\n end",
"def sitemap_links\n each_sitemap_link.to_a\n end",
"def all\n setup_file\n \n links_data = File.open('link_db.txt').read\n links = JSON.parse(links_data)\n return links\nend",
"def get_links\n links = @doc.search(\"//a[@class='title ']\")\n links.map! { |link| \"#{link['href']}\" } \n save_files(links)\n end",
"def url\n item_path(object)\n end",
"def get_all_items\n items = @value\n page = self\n while page.next_link != nil && !page.next_link.strip.empty? do\n page = page.get_next_page\n items.concat(page.value)\n end\n items\n end",
"def publishing_api_has_linked_items(content_id, items:)\n url = \"#{PUBLISHING_API_V2_ENDPOINT}/linked/#{content_id}\"\n stub_request(:get, %r{#{url}}).to_return(status: 200, body: items.to_json)\n end",
"def my_links\n end",
"def links\n\t\t@links.keys\n\tend",
"def read_news_item(url)\n where(:user_id => User.current_user_id, :url => url).update_all(:read => true)\n end",
"def index\n @urlitems = Urlitem.all\n end",
"def link_to_item(item)\n return t(\"common.deleted_object\") if item.blank?\n text = item.respond_to?(:name) ? item.name : item.to_s\n link_to(text, item)\n rescue\n text\n end",
"def links\n @links ||= lambda do \n raw_links.map do |link|\n hash = {}\n link.keys.each do |key|\n hash[key] = link[key]\n end\n hash\n end\n end.call\n end",
"def index\n @links = current_user.links\n end",
"def links\n @data.links ||= parsed_document.search(\"//a\") \\\n .map {|link| link.attributes[\"href\"] \\\n .to_s.strip}.uniq rescue nil\n end",
"def handle_links(links_object)\n @uri = links_object['file']\n end",
"def images_links items\n\titems.select do |item|\n\t\titem['product']['images'].length > 1\n\tend\nend",
"def fetch_all_item_details(state: ['public'], **options)\n items = fetch_all_items(**options)\n item_ids = items.select { state.include?(_1['state']) }.map { _1['id'] }\n urls = item_ids.map { \"/items/#{_1}.json\" }\n pages = concurrent_get(urls)\n pages.map { JSON.parse(_1.body) }\n end",
"def url\n item_hash.deep_find([:listing_details, :view_item_url])\n end",
"def index\n @url_links = UrlLink.all\n end",
"def items_to_attach\n array = []\n frm.table(:text=>/Items to attach/).links(:href=>/access.content.attachment/).each { |link| array << link.text }\n array\n end",
"def list_items(o)\n aux = \"\"\n o[:start] = 0 if o[:start] < 0\n items,count = o[:get].call(o[:start],o[:perpage])\n items.each{|n|\n aux << o[:render].call(n)\n }\n last_displayed = o[:start]+o[:perpage]\n if last_displayed < count\n nextpage = o[:link].sub(\"$\",\n (o[:start]+o[:perpage]).to_s)\n aux << H.a(:href => nextpage,:class=> \"more\") {\"[more]\"}\n end\n aux\n end",
"def lists\n @links = Link.all\n @short_link = ActionMailer::Base.default_url_options[:host]\n end",
"def link(link_rel)\n ls = self.links.select {|l| l[link_rel] }.map { |t| t.values }.flatten\n case ls.count\n when 1\n ls.first\n when 0\n nil\n else\n ls\n end\n end",
"def link_to(links)\n links.map { |link| \"<a href='#{link[:uri]}'>#{link[:name]}</a>\" }.join(\"<br>\")\nend",
"def return_links_array(doc)\n links = doc.css(\".search-content .teaser-item__title a\")\n recipe_links = []\n links.each do |element|\n recipe_links << \"https://www.bbcgoodfood.com\" + element.attribute('href').value\n end\n return recipe_links\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def links\n @source._links\n end",
"def get_item(course_id, item_id)\r\n relative_url = PATH_COURSES_ITEMS_ % [course_id, item_id]\r\n get(relative_url)\r\n end",
"def handle_links(json) end",
"def click_through_link\n\t\treturn '/items/' + self.items.first.slug if !self.items.first.blank?\n\t\treturn '/blog/' + self.blogs.first.slug if !self.blogs.first.blank?\n\t\treturn \"#\"\n\tend",
"def index\n @file_links = FileLink.all\n end",
"def index\n\t\t@rlinks = Rlink.all\n\tend",
"def index\n @links = Link.all\n end"
] | [
"0.72134143",
"0.7042375",
"0.6786516",
"0.6618375",
"0.64442897",
"0.6409303",
"0.6408033",
"0.6408033",
"0.64064795",
"0.6405543",
"0.6400688",
"0.6391095",
"0.6391001",
"0.6389038",
"0.6377273",
"0.635115",
"0.63477886",
"0.6341332",
"0.6341332",
"0.6341332",
"0.63182056",
"0.63182056",
"0.6313364",
"0.6275141",
"0.6257543",
"0.625075",
"0.6236408",
"0.62003773",
"0.62003773",
"0.61844724",
"0.6181724",
"0.61784846",
"0.6169977",
"0.6101786",
"0.60974425",
"0.6096085",
"0.6094263",
"0.6083654",
"0.60210735",
"0.6011719",
"0.6004687",
"0.597757",
"0.5947482",
"0.5943695",
"0.5925486",
"0.5899816",
"0.5890768",
"0.5889105",
"0.5873387",
"0.5873387",
"0.5873387",
"0.5868639",
"0.58594865",
"0.58518904",
"0.5845158",
"0.5843719",
"0.5843719",
"0.5843719",
"0.5843719",
"0.58315516",
"0.58312565",
"0.5816696",
"0.5810238",
"0.5805253",
"0.5788367",
"0.57774734",
"0.57648706",
"0.57440656",
"0.5740775",
"0.5734637",
"0.57171774",
"0.5709524",
"0.56989586",
"0.5695587",
"0.5693434",
"0.5682406",
"0.5675436",
"0.5659986",
"0.56557494",
"0.5645015",
"0.5640754",
"0.5625441",
"0.5601792",
"0.5599812",
"0.5597666",
"0.5597545",
"0.5596071",
"0.558952",
"0.5586007",
"0.5584116",
"0.5575446",
"0.5557621",
"0.5554076",
"0.55402696",
"0.5538322",
"0.5530639",
"0.55227727",
"0.5521358",
"0.551547",
"0.55147386"
] | 0.5709783 | 71 |
Main method for getting all Available TimeBlock(s) for a given date. +:base_time: DateTime used for determining the base scan date range. | def available_on(base_time)
# Stash this for future use, as we will be using it to set a
# baseline date in order to derive a bunch of different appointments
# from.
set_base_time(base_time)
# Fetch all TimeEntris related for this date query.
time_entries = time_entries_for(base)
# Transform TimeEntry(s) -> TimeSlot(s).
available_slots = generate_time_slots(time_entries)
# Combine all sequential linear slots to into a single window.
# This produces multiple windows
windows = combine_linear_slots(available_slots)
# Generate TimeBlocks from the Available Slot ranges
open_time_blocks = generate_time_blocks(windows)
# Optimize & Filter our wide collection of TimeBlocks.
optimized_blocks = optimize_time_blocks(open_time_blocks)
# Finally, present the TimeBlock(s) as Appointment records
# to the Customer.
final = transform_blocks_to_appointments(optimized_blocks)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def available_delivery_blocks(time)\n\n unless opens_today\n return []\n end\n\n # Reset date to compare with Postgres Time\n time = time.change(:month => 1, :day => 1, :year => 2000)\n\n lead_time_for_block_time_slots = 1.hour\n\n all_slots = block_slots.select { |slot| slot[:from] >= (time + lead_time_for_block_time_slots) } +\n live_slots.select { |slot| slot[:from] >= (time) }\n\n all_slots.map do |slot|\n {\n :from => slot[:from].strftime('%H:%M'),\n :to => slot[:to].strftime('%H:%M'),\n :type => slot[:type]\n }\n end\n end",
"def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end",
"def get_busy_slots(start_min, start_max, time_zone)\n result = Array.new\n @googleCalendars.each do |x|\n result.push(x[:connection].query([x[:id]],start_min, start_max, time_zone))\n end\n return result\n end",
"def index\n @time_blocks = TimeBlock.all\n end",
"def get_availabilities\n #retrieve all availability\n self.therapist_availability.collect{ |availability| availability_start_end_datetime(availability.get_occurrences, availability) }.flatten\n end",
"def bra_all_ranges_per_date(date)\n bra_all_ranges = []\n ranges(date).each do |range|\n bra_all_ranges << bra_per_range(bra_key(range,date))\n end\n bra_all_ranges\nend",
"def get_availability\n unbooked_days = []\n availability_blocks = self.availabilities.includes(:bookings)\n availability_blocks.each do |availability_block|\n booked_days = []\n availability_block.bookings.each do |booking|\n booked_days += (booking.start_date..booking.end_date).to_a\n end\n (availability_block.start_date..availability_block.end_date).each do |day|\n unbooked_days.push(day) unless booked_days.include?(day)\n end\n end\n unbooked_days\n end",
"def bra_all_ranges_per_date(date)\n bra_all_ranges = []\n ranges(date).each do |range|\n bra_all_ranges << bra_per_range(bra_key(range,date))\n end\n bra_all_ranges\n end",
"def block_slots\n slots = []\n\n unless block_delivery_end_time.blank? || block_delivery_start_time.blank?\n\n available_hours = block_delivery_end_time - block_delivery_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: block_delivery_start_time + i.hours,\n to: block_delivery_start_time + (i + 1).hours,\n type: :daytime\n }\n end\n end\n\n slots\n end",
"def get_busy_times(calendar_ids, min_date, max_date, access_token)\n form_data = {\n \"items\" => [{:id => calendar_ids}],\n \"timeMin\" => \"#{min_date.year}-#{min_date.month}-#{min_date.day}T00:00:00+00:00\",\n \"timeMax\" => \"#{max_date.year}-#{max_date.month}-#{max_date.day}T23:59:00+00:00\" \n }\n uri = URI.parse(\"https://www.googleapis.com/calendar/v3/freeBusy?access_token=#{access_token}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true \n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = form_data.to_json\n request['Content-Type'] = 'application/json'\n response = http.request(request)\n response_json = JSON.parse(response.body) \n busy_times = []\n response_json[\"calendars\"].keys.each do |calendar|\n unless response_json[\"calendars\"][calendar][\"busy\"].blank?\n response_json[\"calendars\"][calendar][\"busy\"].each do |busy|\n busy_times.push([busy[\"start\"], busy[\"end\"]])\n end\n end\n end\n busy_times\n end",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def list_blocked_rooms(start_date, end_date)\n date_valid?(start_date, end_date)\n\n blocked_rooms = []\n\n @blocks.each do |block|\n blocked_rooms += block.rooms\n end\n\n return blocked_rooms\n end",
"def get_block_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n next if line !~ /^Block times/\n values = []\n # Block times are given as a space-separated list of start,end pairs. They\n # are in units of seconds * 1e5, so convert them to seconds here for\n # consistency.\n if line =~ /^[^:]+: (.*?)\\s*$/\n values = $1.split(\" \").map{|r| r.split(\",\").map{|v| v.to_f / 1e5}}\n end\n to_return << values\n end\n to_return\nend",
"def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end",
"def find_available_rooms_in_block(blocks, group_name, start_date: Date.today, end_date: Date.today + 2)\n return Block.all_available_rooms_in_block(blocks, group_name, start_date: start_date, end_date: end_date)\n end",
"def makeBlocks(days, startTimeString, endTimeString, info)\n\tblocks = []\n\tdays.split(\"\").each do |d|\n\t\tb = SCHBlock.new(d, startTimeString, endTimeString, info)\n\t\tblocks << b\n\tend\n\t(blocks)\nend",
"def get_readings_from_remote_server_for_dates(type, start_date, end_date)\n readings = []\n start_date.upto(end_date) do |date|\n readings += get_readings_from_remote(type, date)\n end\n return readings\nend",
"def getblock(hash)\n block = @api.request 'getblock', hash\n block[\"time\"] = Time.at(block[\"time\"]).utc if block.is_a? Hash\n block\n end",
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def get_all_thermal_blocks()\n zones = find_all_commands(\"ZONE\")\n end",
"def mmc_blockinfo\n\n # number of latest block\n @blckhigh = `#{@mmc_path} getblockcount`\n\n # hash of latest block\n blckhash = `#{@mmc_path} getblockhash #{@blckhigh}`\n\n # complete json of latest block\n blckinfo = `#{@mmc_path} getblock #{blckhash}`\n\n # difficulty of latest block\n @blckdiff = `#{@mmc_path} getdifficulty`\n\n # number of 30th latest block\n rcnthigh = @blckhigh.to_i - 30\n\n # hash of 30th latest block\n rcnthash = `#{@mmc_path} getblockhash #{rcnthigh}`\n\n # complete json of 30th latest block\n rcntinfo = `#{@mmc_path} getblock #{rcnthash}`\n\n # timestamp of latest block\n blcktime = JSON.parse(blckinfo)['time'].to_i\n\n # timestamp of 30th latest block\n rcnttime = JSON.parse(rcntinfo)['time'].to_i\n\n # average blocktime of 30 last blocks in seconds\n @blocktime = (blcktime.to_f - rcnttime.to_f) / 30.0\n\n # current hashrate in hashs per minute\n @hashrate = ((2 ** 32) * @blckdiff.to_f) / (@blocktime.to_f / 60.0)\n\n # calculates current block reward and total minted coins\n i = 0\n currweek = ((@blckhigh.to_f / 1680.0) - 0.5).round\n @reward = 280.0 ### @TODO: initial reward was limited, PTS shares\n @minted = 715842.49 ### @TODO: initial reward was limited, PTS shares\n while i < currweek do\n @minted += @reward * 1680.0\n @reward *= 0.95\n i += 1\n end\n @minted += (@blckhigh.to_f - (currweek * 1680.0)) * @reward\n\nend",
"def create_block_by_date(rooms_per_block, check_in, check_out, block_id, discount_percent: 0.0)\n while self.list_vacancies(check_in, check_out).empty?\n raise StandardError(\"No more vacancies!\")\n end\n\n room_num_array = self.list_vacancies(check_in, check_out).take(rooms_per_block).to_a\n\n # take one of the rooms from the room_num_array to make a reservation\n room_num = room_num_array.first\n\n new_block = Hotel::Block.new(room_num_array, check_in, check_out, block_id, discount_percent: 0.0)\n\n new_block.make_reservation(room_num, check_in, check_out, discount_percent: 0)\n\n @blocks << new_block\n end",
"def get_all_blocks\n\n @all_blocks = Block.where(is_published: 't')\n\n end",
"def index\r\n\r\n # 基準日指定ない場合、当日を基準とする\r\n param = params[:baseDate]\r\n @baseDate = param ? Date.parse(param) : Date.today\r\n\r\n # 基準日から7日分を作成\r\n @headers = Array.new(7) do |index|\r\n I18n.l(@baseDate + index.days, format: :short_date)\r\n end\r\n\r\n @dates = Array.new(7) do |index|\r\n (@baseDate + index.days).strftime(\"%Y-%m-%d\")\r\n end\r\n\r\n # 予約データ\r\n @reservations = Reservation.where(\"start_date <= ? and ? <= end_date\", @baseDate+6, @baseDate).order(\"start_date\")\r\n @reservations.each do |res|\r\n # 上段・下段(ライセンス番号)\r\n # virtualAttributesを取得するため、whereではなくselectを使用する\r\n subSet = @reservations.select{|sub|sub.start_date <= res.start_date && res.start_date <= sub.end_date}\r\n res.top = ([0,1] - subSet.map(&:top)).min\r\n\r\n # スケジュールバー左端・幅\r\n leftDate = [res.start_date, @baseDate].max\r\n rightDate = [res.end_date, @baseDate+6].min\r\n res.left = (leftDate - @baseDate).to_i\r\n res.width = (rightDate - leftDate).to_i + 1\r\n end\r\n end",
"def get_cost\n time_range = {}\n if reserv_range.end.day - reserv_range.begin.day == 1\n time_range[reserv_range.begin.wday] = (\n ((reserv_range.begin.hour * 60 + reserv_range.begin.min) / 60.0)...24.0\n )\n\n time_range[reserv_range.end.wday] = (0.0...(reserv_range.end.hour * 60 + reserv_range.end.min) / 60.0)\n else\n time_range[reserv_range.end.wday] = (((reserv_range.begin.hour * 60 + reserv_range.begin.min) / 60.0)...(reserv_range.end.hour * 60 + reserv_range.end.min) / 60.0)\n end\n\n cost_sum = 0\n\n time_range.each do |wday, tr|\n billings = Billing\n .select(\n \"numrange(start_time, end_time) * numrange(#{tr.begin},#{tr.end}) as period, cost_cents, cost_currency\"\n )\n .where(\n 'numrange(start_time, end_time) && numrange(:start, :end) AND day_type = :day_type AND sauna_id = :sauna_id',\n start: tr.begin,\n end: tr.end,\n day_type: wday,\n sauna_id: sauna_id\n )\n\n # puts billings.to_sql\n\n billings.each do |bill|\n cost_sum += (bill.period.end - bill.period.begin) * bill.cost_cents\n end\n end\n\n cost_sum\n end",
"def ranges(date)\n ranges =[]\n bra_doc = bra_per_day(date)\n bra_doc.each do |element|\n ranges << element[\"massif\"]\n end\n ranges\nend",
"def bus_available(from_city,to_city)\n @variable = @line_id\n @buses = []\n # p \"--------Current User(#{current_user.id})---------------\"\n #freq = 7\n \n @line_id.each do |line|\n available_buses = Bus.where(route_id: line, status: true)\n # p \"--------Line Id: #{line}--Bus #{available_buses.present?}---------\"\n\n if available_buses\n\n available_buses.each do |bus|\n # p \"---------Bus#{bus.bus_timings.find_by(city: from_city.name).day_of_deperture}-City#{from_city.name}----------\"\n \n\n freq = bus.frequency\n bus_time = bus.bus_timings\n \n\n start_date = bus.start_date + (day_offset = (bus_time.find_by(city: from_city.name).day_of_deperture - 1)).day\n end_date = bus.end_date + (bus_time.find_by(city: from_city.name).day_of_deperture - 1).day\n\n # p \"-------Start #{start_date}--End #{end_date}-------\" \n\n var = start_date - freq.day\n # p \"----------var#{var}------------\"\n\n (start_date..end_date).step(freq) do |date|\n\n if (Date.today <= date) && seat_availability(bus,(date - day_offset.day))\n @buses << {\"user_id\" => current_user,\"bus_id\" => bus.id, \"date\" => date, \"start_date\" => (date - day_offset.day), \"start_time\" => bus_time.first.deperture ,\"route\" => LineColorRoute.find(line).name ,\"source\" => from_city.name.titleize, \"departure\" => bus_time.where(city: from_city.name).first.deperture,\"destination\" => to_city.name.titleize, \"arrival\" => bus_time.where(city: from_city.name).last.arrival }\n end\n \n end\n end\n end\n end\n @buses = @buses.sort_by{ |hash| hash[\"date\"]}\n end",
"def get_readings_from_remote_for_dates(type, start_date, end_date)\n\treadings = []\n\tstart_date.upto(end_date) do |date|\n\t\treadings += get_readings_from_remote(type, date)\n\tend\n\treturn readings\nend",
"def index\n if params[:date_range].blank?\n @time_slots = TimeSlot.all\n else\n input_start_time =\n input_end_time = \n @time_slots = TimeSlot.where(\"start_time > ? AND end_time < ?\", input_start_time, input_end_time)\n end\n end",
"def current_businesses\r\n ct = Localization::localizer.now()\r\n current_date = ::Date.new(ct.year, ct.month, ct.day)\r\n businesses = []\r\n unit_contracts.each do | uc |\r\n if ( (current_date >= uc.start_date) && \r\n ((uc.end_date.nil?) || (current_date < uc.end_date )) )\r\n businesses << uc.business\r\n end\r\n end\r\n \r\n return businesses\r\n end",
"def find_all_across_pages_from(time)\n find_all_across_pages(:params => { :from => time.utc.strftime(\"%Y%m%d\") })\n end",
"def timeRecordsForDate(brick, date)\n end",
"def printTimeRecords(dateBegin, dateEnd)\n tasks = []\n self.traverse_preorder() {|brick, depth|\n #print \" \" * depth, \"#{brick['brick']}:\\n\"\n brick['timeWorked'].each{ |tr|\n if(tr.inRange(dateBegin,dateEnd)) \n #print \" \" * (depth+1), tr, \"\\n\"\n #print \" \" * (depth+1), tr, \"\\n\"\n print \"\\t\", tr, \"--\", brick['brick'],\"\\n\"\n end\n tasks.push(tr)\n }\n }\n tasks\n end",
"def available_time_slot date_of_booking\n\t\tif date_of_booking.gsub(/[-]+/,\"\").to_i != Time.zone.now.strftime(\"%Y%m%d\").to_i\n\t\t\tresource_slot = self.timeslots\n\t\t\tif self.bookings.where(date_of_booking:date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day = self.bookings.where(date_of_booking: date_of_booking).where(status:1)\n\t\t\t\tbookings_of_day.each do |x|\n\t\t\t\t\tresource_slot.delete_at(x.slot)\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tresource_slot = next_time_slots\n\t\tend\n\t\tresource_slot\n\tend",
"def get_block_transactions\n Rails.logger.info(\"read_block_events block number: #{@current_block_number} - Making API call ReadBlockEvents\")\n @block_data_response = Request::OpsApi::GetBlockInfo.new.perform(public_api_request_params)\n Rails.logger.info(\"read_block_events --- block number: #{@current_block_number} --- block_fetched_response: #{@block_data_response.inspect}\")\n end",
"def ranges(date)\n ranges =[]\n bra_doc = bra_per_day(date)\n bra_doc.each do |element|\n ranges << element[\"massif\"]\n end\n p ranges\n end",
"def build_buckets(unit=:all, step=1)\n\t\thour = 60 * 60\n\t\tday = 24 * hour\n\n\t\tif step.nil?\n\t\t\tstep = 1\n\t\tend\n\n\t\tif unit.nil?\n\t\t\tunit = :all\n\t\tend\n\n\t\tbuckets = []\n\n\t\tcase unit\n\t\twhen :all\n\t\t\tbuckets << {start_date: time_frame.start_date, end_date: time_frame.end_date, objects: []}\n\n\t\twhen :year\n\t\t\tyear = time_frame.start_date.year\n\t\t\tbucket_start = Time.mktime(year, 1, 1)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.mktime(year+=step, 1, 1)\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\n\t\twhen :month\n\t\t\tmonth = time_frame.start_date.mon\n\t\t\tyear = time_frame.start_date.year\n\t\t\tbucket_start = time_frame.start_date\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_start = Time.mktime( year, (month) )\n\n\t\t\t\tmonth+=step\n\t\t\t\tif (month-12) > 0\n\t\t\t\t\tyear += 1\n\t\t\t\t month = month-12\n\t\t\t\tend\n\n\t\t\t\tbucket_end = Time.mktime(year, (month) )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\tend\n\n\t\twhen :day\n\t\t\tbucket_start = Time.mktime(time_frame.start_date.year, time_frame.start_date.mon, time_frame.start_date.day)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.at( bucket_start.to_i + step*day )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\n\t\twhen :hour\n\t\t\tbucket_start = Time.mktime(time_frame.start_date.year, time_frame.start_date.mon, time_frame.start_date.day, time_frame.start_date.hour)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.at( bucket_start.to_i + step*hour )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\t\tend\n\n\t\tbuckets.first[:start_date] = time_frame.start_date\n\t\tbuckets.last[:end_date] = time_frame.end_date\n\n\t\treturn buckets\n\tend",
"def resource_reservations(date_from, date_to, stock_plate_or_reference)\n\n BookingDataSystem::Booking.by_sql { |b| \n [select_resource_reservations(b), stock_plate_or_reference, stock_plate_or_reference,\n date_from, date_from, \n date_to, date_to,\n date_from, date_to,\n date_from, date_to ] }.all(order: :date_from) \n\n end",
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def size_time(base = self.date_from)\n\t\t\t\t\t@sizes = {} if @sizes.nil?\n\t\t\t\t\tif @sizes[base.to_s].nil?\n\t\t\t\t\t\tsize = DateTime.parse(\"2000-01-01 00:00:00 +0000\")\n\t\t\t\t\t\tself.reservations(base).each do |reservation|\n\t\t\t\t\t\t\tif reservation.above_line?\n\t\t\t\t\t\t\t\tsize += reservation.size.seconds_since_midnight.seconds\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@sizes[base.to_s] = size\n\t\t\t\t\tend\n\t\t\t\t\treturn @sizes[base.to_s]\n\t\t\t\tend",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def design_billable_time_entries\n @_design_billable_time_entries ||= billable_time_entries.select { |time_entry| time_entry.dig('task', 'name') == 'Design' }\n end",
"def time_block_params\n params[:time_block]\n end",
"def execute(&block)\n v = @v.map &block\n TimeArray.new(@start_time, v, zone: Time.zone.name)\n end",
"def index\n # @bookings = Booking.all\n @booking = Booking.new\n @room = Room.new\n @rooms = Room.all\n @selected_date = DateTime.now\n @bookings = Booking.where(:start_time => @selected_date.beginning_of_day..@selected_date.end_of_day)\n @timeNow = Time.now\n @startTime = @timeNow.beginning_of_day() + (8*60*60)\n @endTime = @timeNow.beginning_of_day() + (18*60*60)\n\n end",
"def reserved_slots(date)\n Reservation.confirmed.where(nook_id: self.id)\n .happening_within(date.beginning_of_day..date.end_of_day)\n .map do |r|\n r.start.strftime('%H%M').to_i..\n (r.end + 1.seconds).strftime('%H%M').to_i\n end\n end",
"def live_slots\n slots = []\n\n unless live_delivery_block_end_time.blank? || live_delivery_block_start_time.blank?\n available_hours = live_delivery_block_end_time - live_delivery_block_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: live_delivery_block_start_time + i.hours,\n to: live_delivery_block_start_time + (i + 1).hours,\n type: :live\n }\n end\n end\n\n slots\n end",
"def open_slots(date)\n time = date.to_time\n \n slots = []\n prev_time = time - 30.minutes\n loop do\n start_time = prev_time + 30.minutes\n \n if start_time.to_date == date\n slots << Slot.new(starts_at: start_time, cat: self)\n prev_time = start_time\n else\n break\n end\n end\n \n # Remove taken/past timeframes\n slots.reject do |slot|\n Reservation.exists?(cat: self, starts_at: slot.starts_at) || slot.starts_at.past?\n end\n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def schedule(date, channels = nil)\n\n date = DateTime.parse date.strftime('%Y-%m-%dT06:00:00Z00:00')\n\n query = {\n :after => date.strftime('%Y-%m-%dT%H:%M:%S'),\n :before => ( date + 1 ).strftime('%Y-%m-%dT05:59:59'),\n :channel => channels,\n :offset => 0,\n :limit => 100,\n :sort_by =>'time',\n :sort_order => 'ascending',\n :repeats => true,\n }\n\n results = search(query)\n\n assets = [ ]\n\n while true do\n\n assets.concat(results.assets)\n\n if results.has_more?\n next_query = results.query.merge({\n :offset => results.query[:offset] + 100\n })\n\n results = self.search(next_query)\n else\n break\n end\n end\n\n assets\n end",
"def index\n @time_banks = TimeBank.select_all.\n include_parents.\n where(params[:search]).\n order(:start, :member_id)\n @time_banks = @time_banks.where('start >= ?', Date.current-4.months) unless params[:all]\n respond_with(@time_banks)\n end",
"def get_availability(pick_up_time, return_time, reservation_id=nil)\n pick_up_time = pick_up_time.utc\n return_time = return_time.utc\n \n # Get all item reservations of this item that occur on the given time frame\n # and are not rejected.\n # If editing a reservation, that reservation is excluded with reservation_condition.\n # If no such reservations can be found, return the total item amount.\n reservation_condition = reservation_id ? \"AND c.id <> '#{reservation_id}'\" : \"\"\n time_conditions = \"((c.pick_up_time > '#{pick_up_time.to_s}' AND c.pick_up_time < '#{return_time}')\n OR (c.pick_up_time < '#{pick_up_time}' AND c.return_time > '#{return_time}')\n OR (c.return_time > '#{pick_up_time}' AND c.return_time < '#{return_time}'))\"\n reservation_query = \"\n SELECT DISTINCT ir.id, ir.amount, ir.item_id, ir.reservation_id\n FROM conversations AS c, item_reservations AS ir\n WHERE c.id = ir.reservation_id\n AND c.status <> 'Rejected'\n AND ir.item_id = '#{id.to_s}'\n AND #{time_conditions}\n #{reservation_condition}\n \"\n item_reservations = ItemReservation.find_by_sql(reservation_query)\n return amount unless item_reservations.size > 0\n \n # If overlapping reservations are found, we need to divide the given timeframe into intervals.\n # By these we mean the pick up times and return times of found reservations that occur on the\n # given timeframe. We put all these dates in an array and order it. The first item of the array\n # is the pick up time of the given time frame and the last item is the return time of the given\n # time frame.\n intervals = []\n ranges = [] \n intervals << pick_up_time << return_time\n intervals = item_reservations.inject(intervals) { \n |array, ir| array << ir.reservation.pick_up_time << ir.reservation.return_time \n }.reject { \n |t| (t < pick_up_time) || (t > return_time) \n }.uniq.sort { \n |a,b| a <=> b \n }\n \n # Get date ranges between all dates in the interval array and put them in a new array.\n for i in 0..(intervals.size - 2) do\n range = intervals[i]..intervals[i+1]\n ranges << range\n end\n \n # For each range, check if any found reservation occurs in it, and if true,\n # add the amount of that ir to the reserved item amount of that range. Finally, return the\n # amount of the range with most reserved items.\n biggest_reservation_amount = ranges.inject(0) do |amount, range|\n range_amount = 0\n item_reservations.each do |ir|\n if (range.include?(ir.reservation.pick_up_time) || range.include?(ir.reservation.return_time) || \n (range.first > ir.reservation.pick_up_time && range.last < ir.reservation.return_time))\n range_amount += ir.amount \n end \n end\n amount >= range_amount ? amount : range_amount \n end \n \n # Return total amount - amount of the range with most reserved items,\n # e.g. the amount of free items on given time frame.\n amount - biggest_reservation_amount \n end",
"def search_by_date(date)\n\t\t\treservation_by_date = []\n\n\t\t\t@reservation_blocks.each do |reservation_block|\n\t\t\t\treservation_by_date << reservation_block if reservation_block.check_date(date)\n\t\t\tend\n\n\t\t\treturn reservation_found?(reservation_by_date, \"reservations\")\n\t\tend",
"def schedule(startAt,endAt,opts={})\n ## Caching ##\n @schedules ||= {}\n if @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash]\n return @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash]\n end\n ## End Caching ##\n\n # TODO Handle events starting within the range but ending outside of it?\n\n # TODO Offload this selection to the database; okay for testing though\n # NOTE This is actually faster thanks to the query cache for small numbers of operating times, but not very scalable\n #all_regular_operating_times = OperatingTime.find(:all, :conditions => {:place_id => self.id, :override => 0}).select{|t| (t.startDate - 1) <= endAt.to_date and startAt.to_date <= (t.endDate + 1)}\n #all_special_operating_times = OperatingTime.find(:all, :conditions => {:place_id => self.id, :override => 1}).select{|t| (t.startDate - 1) <= endAt.to_date and startAt.to_date <= (t.endDate + 1)}\n # Select all relevant times (1 day buffer on each end)\n # NOTE Make sure to use generous date comparisons to allow for midnight rollovers\n all_regular_operating_times = OperatingTime.regular.by_place_id(self.id).in_range(startAt..endAt).find(:all)\n all_special_operating_times = OperatingTime.special.by_place_id(self.id).in_range(startAt..endAt).find(:all)\n\n puts \"\\nRegular OperatingTimes: #{all_regular_operating_times.inspect}\" if DEBUG\n puts \"\\nSpecial OperatingTimes: #{all_special_operating_times.inspect}\" if DEBUG\n\n regular_times = []\n special_times = []\n special_ranges = []\n\n all_special_operating_times.each do |ot|\n puts \"\\nSpecial Scheduling for: #{ot.inspect}\" if DEBUG\n\n # Special Case: Overriding with NO times (e.g. closed all day)\n if ot.start == 0 and ot.length == 0 and startAt.to_date <= ot.startDate\n # Block out the range, but don't add the \"null Times\"\n special_ranges << Range.new(ot.startDate,ot.endDate)\n next\n end\n\n # Start a day early if possible\n earlyStart = startAt-1.day < ot.startDate.midnight ? startAt.midnight : startAt - 1.day\n puts \"EarlyStart: #{earlyStart.inspect}\" if DEBUG\n\n # Calculate the next set up open/close times\n open,close = ot.next_times(earlyStart)\n next if open.nil? # No valid occurrences in the future\n\n while not open.nil? and open <= endAt do\n if DEBUG\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n puts \"Start Date: #{ot.startDate} (#{ot.startDate.class})\"\n puts \"End Date: #{ot.endDate} (#{ot.endDate.class})\"\n end\n\n if close < startAt # Skip forward to the first occurrance in our time range\n puts \"Seeking: #{close} < #{startAt}\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n special_times << [open,close]\n special_ranges << Range.new(ot.startDate,ot.endDate)\n open,close = ot.next_times(close)\n end\n\n end\n\n puts \"\\nSpecial Times: #{special_times.inspect}\" if DEBUG\n puts \"\\nSpecial Ranges: #{special_ranges.inspect}\" if DEBUG\n\n all_regular_operating_times.each do |ot|\n puts \"\\nRegular Scheduling for: #{ot.inspect}\" if DEBUG\n\n # Start a day early if possible\n earlyStart = startAt-1.day < ot.startDate.midnight ? startAt : startAt - 1.day\n puts \"EarlyStart: #{earlyStart.inspect}\" if DEBUG\n\n # Calculate the next set up open/close times\n open,close = ot.next_times(earlyStart)\n if DEBUG\n puts \"\"\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n end\n\n if open.nil? # No valid occurrences in the future\n puts \"Skipping: No valid occurrences in the future.\" if DEBUG\n next\n end\n\n while not open.nil? and open <= endAt do\n if DEBUG\n puts \"\"\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n end\n\n if close < startAt # Skip forward to the first occurrance in our time range\n puts \"Seeking: #{close} < #{startAt}\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n overridden = false\n special_ranges.each do |sr|\n overridden ||= sr.member?(open.to_date)\n end\n if overridden\n puts \"Overridden\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n # FIXME Causing an infinite loop; would be nice if this worked\n #open = startAt if open < startAt\n #close = endAt if close > endAt\n\n regular_times << [open,close]\n open,close = ot.next_times(close)\n end\n\n end\n\n puts \"\\nRegular Times: #{regular_times.inspect}\" if DEBUG\n\n # TODO Handle schedule overrides\n # TODO Handle combinations (i.e. part special, part regular)\n\n final_schedule = (regular_times+special_times).sort{|a,b|a[0] <=> b[0]}\n\n ## Truncate times larger than range ##\n if opts[:truncate]\n final_schedule.each_index do |i|\n final_schedule[i][0] = startAt.dup if final_schedule[i][0] < startAt\n final_schedule[i][1] = endAt.dup if final_schedule[i][1] > endAt\n end\n end\n ## End truncating ##\n\n ## Caching ##\n @schedules ||= {}\n @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash] = final_schedule\n ## End caching ##\n\n final_schedule\n end",
"def find_venue_for_timeslot(availability, timeslot)\n blocks_needed = availability.blocks_needed\n day_id = timeslot.day_id\n\n start_block = [0, timeslot.start_block].max\n finish_block = [blocks_per_day, timeslot.end_block].min\n\n @venues.each do |venue, venue_blocks_used|\n blocks_used_for_day = venue_blocks_used[day_id]\n\n for window_start_block in start_block...(finish_block - blocks_needed)\n window_blocks_used = blocks_used_for_day[window_start_block, blocks_needed]\n is_available = window_blocks_used.none?\n\n if is_available\n window_end_block = window_start_block + blocks_needed\n return Reservation.new(@schedule_range, availability.project, venue,\n day_id, window_start_block, window_end_block)\n end\n end\n end\n\n nil\n end",
"def get_available_requests\n start_f =start_time.to_f\n erg = []\n\n Request.all.each do |t|\n if (start_f.between?(t.start_time.to_f, t.end_time.to_f) and \n ((Geocoder::Calculations.distance_between [t.starts_at_N, t.starts_at_E], \n [starts_at_N, starts_at_E], :units => :km) <= t.start_radius) and\n ((Geocoder::Calculations.distance_between [t.ends_at_N, t.ends_at_E], \n [ends_at_N, ends_at_E], :units => :km) <= t.end_radius)) then \n erg << t\n end\n end\n return erg\n end",
"def create_reservation_within_block(start_date, end_date, block_id)\n rooms_available = check_availability_within_block(start_date, end_date, block_id)\n room_instances_for_reservation = rooms_available.map {|id| @blocks.find }\n\n\n new_block_reservation = create_reservation_basic(start_date, end_date, rooms_available)\n return new_block_reservation\n end",
"def complete_sched(curr_time)\n\t\trt_sched = []\n\n\t\t# go through each class\n\t\tself.classes.each do |class_i|\n\t\t\tif Room.is_today?(class_i, curr_time)\n\t\t\t\trt_sched.push(class_i)\n\t\t\tend\n\t\tend\n\t\tsort_class(rt_sched)\n\t\treturn rt_sched\n\tend",
"def init_availability_based_on_general_availability\n\n # Selects all the possible slots\n Time.zone = 'UTC'\n\n from = Time.zone.parse(hour_from.to_s)\n to = Time.zone.parse(hour_to.to_s)\n\n selected_slots = Slot.where(\"EXTRACT(dow FROM start) IN (#{day}) AND ((EXTRACT(hour FROM start) = #{from.hour} AND EXTRACT(minute FROM start) >= #{from.min}) OR (EXTRACT(hour FROM start) > #{from.hour} AND EXTRACT(hour FROM start) < #{to.hour}) OR (EXTRACT(hour FROM start) = #{to.hour} AND EXTRACT(minute FROM start) < #{to.min}))\")\n\n puts \"Start: #{selected_slots.first.id} - #{selected_slots.first.start}\"\n\n inserts = []\n selected_slots.each do |s|\n inserts.push \"(#{doctor_id}, #{s.id}, #{id}, now(), now())\"\n end \n\n sql = \"INSERT INTO availabilities (\\\"doctor_id\\\", \\\"slot_id\\\", \\\"availability_general_id\\\", \\\"created_at\\\", \\\"updated_at\\\") VALUES #{inserts.join(\", \")}\"\n ActiveRecord::Base.connection.execute sql\n #Time.zone = 'UTC'\n puts \"Hours from #{from.hour} to #{to.hour}\"\n end",
"def get_current_available_slots(assignments, member)\n slots = Array.new\n # puts \"getting slots for \"+member.name\n assignments.keys.each do |key|\n slot = key\n conflicts = true\n if not slot == \"manual\"\n conflicts = false\n for c in member.commitments\n d = c.day\n s = c.start_hour\n e = c.end_hour\n # TODO have these calculated somewhere else\n if d\n # puts \"taking a while on this part\"\n day = Date::DAYNAMES[d]\n # start = Chronic.parse(\"#{s} this #{day}\")\n # endt = Chronic.parse(\"#{e} this #{day}\")\n start = c.start_time\n endt = c.end_time\n if day and conflicts(start, endt, slot.start_time, slot.end_time)\n conflicts = true\n break\n end\n end\n end\n end\n if not conflicts\n if assignments[slot].length < 5000 # hard coded capacity\n slots << slot\n end\n end\n end\n return slots\n end",
"def read_blocks(start_block, block_count, nonce)\n data = @disk.read_blocks start_block + @data_start, block_count\n hmacs = (0...block_count).map do |i|\n load_data = @tree_driver.load_leaf start_block + i\n load_data[:ops] <<\n { :op => :sign, :line => load_data[:line], :session_id => @sid,\n :nonce => nonce, :data => data[i * block_size, block_size],\n :block => start_block + i }\n add_tree_data_to_ops load_data[:ops]\n response = @fpga.perform_ops load_data[:ops]\n @tree_driver.perform_ops load_data[:ops]\n response.first\n end\n { :data => data, :hmacs => hmacs }\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def daily_balances(start_date, end_date)\n LedgerAccountHelper.daily_balances(main_ledger_account, start_date, end_date)\n end",
"def availabilities_for(date)\n {\n date: date,\n slots: available_slots_for(date)\n }\n end",
"def index\n @allocated_times = AllocatedTime.all\n end",
"def make_block_reservation(number_of_rooms, cost_per_night, check_in, check_out)\n available_rooms = list_available_rooms(Hotel::DateRange.new(check_in, check_out))\n if available_rooms.length < number_of_rooms\n raise StandardError, \"There's no room in the inn\"\n end\n block_reservation = []\n number_of_rooms.times do\n room_number = available_rooms.sample[:room_number]\n reservation = Hotel::Reservation.new(room_number, cost_per_night, check_in, check_out)\n @reservations << reservation\n block_reservation << res\n end\n return block_reservation\n end",
"def grandclock(presenthour,&block)\n \n for i in (1..presenthour)\n block.call\n end\n \nend",
"def times_for_schedule_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_day + 15.hours\n task_time += 1.day if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.day\n end\n\n times\n end",
"def time\n\talltime = Array.new\n\tslices = 10\n\ti = 0\n\twhile i < slices.to_i do\n\t\talltime.push(Time.now)\n\t\ti+=1\n\tend\n\tyield\nend",
"def time_entries(start_date, end_date)\n opts = {\n params: {\n start_date: start_date.to_datetime.iso8601,\n end_date: end_date.to_datetime.iso8601\n }\n }\n\n begin\n response = toggl_resource['time_entries'].get(opts)\n rescue => e\n raise 'Error getting Toggl data: ' + e.response\n end\n data = JSON.parse response\n\n data.map do |entry|\n duration = entry['duration'].to_f\n\n # Negative duration means the task is currently running.\n # In this case, we'll set duration to how long it's been running\n if duration < 0\n duration = Time.now - Time.at(duration.abs)\n end\n\n {\n description: entry['description'],\n start: Date.parse(entry['start']),\n duration: duration\n }\n end\n end",
"def get_foot_traffic(start_date, end_date)\n total_rc = Array.new\n while start_date.next_week < end_date\n total_rc.push get_all_redemptions(start_date, start_date.next_week)\n start_date = start_date.next_week\n end\n total_rc\n end",
"def available_rooms_in_block(block_name:)\n available = reservations.find_all do |reservation|\n reservation.block_name == block_name && reservation.booking_name == nil\n end\n\n return available\n end",
"def get_all_records\r\n nodes = []\r\n time_blocks = generate_time_blocks( DEFAULT_OPTIONS[:erp_start_time].dup, Time.now )\r\n \r\n # time_blocks.each do |pair|\r\n # result = search_by_modified_date( pair.first, pair.last )\r\n # nodes.concat result unless result.empty?\r\n # end\r\n \r\n ERP::ThreadPool.new(@options[:threads], time_blocks).start do |pair|\r\n sleep(1 * rand)\r\n result = search_by_modified_date( pair.first, pair.last )\r\n nodes.concat result unless result.empty?\r\n end\r\n \r\n output_log \"#{nodes.size} records received!\"\r\n return nodes\r\n end",
"def all_suite_times; end",
"def all_suite_times; end",
"def index\n @block_types = BlockType.all\n end",
"def returnTimeHash(startTime,endTime)\r\n dataHash = {:idle=>0,:away=>0,:answered=>0,:incoming=>0,:outgoing=>0,:wrapup=>0, :avail=>0}\r\n objectsinrange = self.availabilities.find_all_by_event_date(startTime..endTime, :select=>'event_type,event_duration')\r\n for hit in objectsinrange\r\n sET = hit.event_type\r\n sED = hit.event_duration\r\n if (sET.include?(\"Click\") or sET.include?(\"OUTBOUND\")) then dataHash[:outgoing] += sED end\r\n if (sET.include?(\"Available\")) then dataHash[:idle] += sED end\r\n if (sET.include?(\"Wrap\")) then dataHash[:wrapup] += sED end\r\n if (sET.include?(\"Answered\")) \r\n dataHash[:incoming] += sED\r\n dataHash[:answered] += 1\r\n end\r\n if (sET.include?(\"Away\")) then dataHash[:away] += sED unless (sET.include?(\"Click\") or sET.include?(\"OUTBOUND\")) end \r\n end\r\n dataHash[:avail] = dataHash[:idle] + dataHash[:incoming] + dataHash[:outgoing] + dataHash[:wrapup]\r\n return dataHash\r\n end",
"def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def create_block_of_rooms(start_date, end_date, discounted_rate)\n dates = date_range(start_date, end_date)\n new_block = RoomBlock.new(start_date, end_date, room_cost: discounted_rate)\n new_block.id = assign_block_id\n\n num_of_rooms = 0\n @rooms.each do |room|\n if is_available?(room, dates) && is_not_blocked?(room, dates)\n new_block.add_room(room)\n num_of_rooms += 1\n end\n if num_of_rooms == 5\n break\n end\n end\n\n @room_blocks << new_block\n\n return new_block\n end",
"def show\n @blocks = @volunteer.blocks.order(:day, :start_time)\n # @blocks.sort_by &:day\n end",
"def is_valid_time?(timeBegin, timeEnd)\n\n\t\t#zone = Timezone.get('America/Chicago').now.zone\n\n\t\t#freebusy method only responds to a couple of months (maybe <=3)\n\t\tresponse = @client.execute(api_method: @service.freebusy.query,\n\t\t\t\t\t body: JSON.dump({\n\t\t\t timeMin: timeBegin,\n\t\t\t timeMax: timeEnd,\n\t\t\t timeZone: 'America/Chicago',\n\t\t\t items:[ id: ENV['NSCS_Calendar_ID']]\n\t\t\t }),\n\t\t\t headers: {'Content-Type' => 'application/json'})\n\t\t@client.authorization.refresh!\n\t\tevents = JSON.parse(response.body)\n\t\t\n\t\t#TODO iteratife over events.\n\t\t\n\tend",
"def valid_appointments(base_time)\n transform_blocks_to_appointments(valid_blocks(base_time))\n end",
"def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end",
"def selectTimeIntervals(dbQuery)\n\n if dbQuery.nil?\n return\n end\n\n dbQuery = setTimePeriod(dbQuery)\n\n reportTime = params['reportTime'] || \"today\"\n\n fromDate = params['fromDate'] || Date.today.to_s\n begin\n toDate = params['toDate'] || (Date.parse(fromDate, \"YYYY-MM-DD\") + 1.day).to_s\n rescue\n toDate = Date.today.to_s # Just in case someone has meddled with the query string param and sent an invalid FROM date...\n end\n\n case reportTime.downcase\n when \"past_hour\"\n @timeSlot = \"minute\"\n @numTimeSlots = 5\n fromDate = 1.hour.ago\n toDate = Time.now\n dbQuery = dbQuery.select(\"MOD(cast(date_part('minute', timestamp) as INT), #{@numTimeSlots}) as time\")\n when \"past_day\"\n @timeSlot = \"hour\"\n @numTimeSlots = 24\n fromDate = 24.hours.ago\n toDate = Time.now\n dbQuery = dbQuery.select(\"date_part('hour', timestamp) as time\")\n when \"past_week\"\n fromDate = 7.days.ago\n toDate = Time.now\n @timeSlot = \"day\"\n @numTimeSlots = 7\n dbQuery = dbQuery.select(\"EXTRACT(day from timestamp - (current_timestamp - '7 day'::interval)) as time\")\n when \"past_month\"\n fromDate = 1.month.ago\n toDate = Time.now\n @timeSlot = \"week\"\n @numTimeSlots = ((toDate - fromDate)/1.week).ceil + 1\n startingNum = ActiveRecord::Base.connection.select_value(ActiveRecord::Base.send(:sanitize_sql_array, \n [\"select date_part('week', current_timestamp - '1 month'::interval)\"]))\n\n dbQuery = dbQuery.select(\"date_part('week', timestamp) - #{startingNum} as time\")\n when \"date_range\"\n begin\n fromDate = Date.parse(params['fromDate'], 'YYYY-MM-DD').to_time\n rescue\n fromDate = Date.today #if the incoming parameter is an invalid date format, then pick TODAY as the date!\n params['fromDate'] = fromDate.to_s\n end\n begin\n toDate = Date.parse(params['toDate'], 'YYYY-MM-DD').to_time + 1.day # end date should be inclusive in the range\n rescue\n # in case of parsing error, take FROMDATE + 1 as the end date...\n params['toDate'] = (Date.parse(params['fromDate'], 'YYYY-MM-DD') + 1.day).to_s\n toDate = (Date.parse(params['fromDate'], 'YYYY-MM-DD') + 1.day).to_time\n end\n\n numDays = ((toDate - fromDate)/1.day).round\n dbQuery = dbQuery.where(\"timestamp between '#{fromDate.strftime('%F')}' and '#{toDate.strftime('%F')}'\")\n if numDays > 70 then\n @timeSlot = \"month\"\n @numTimeSlots = ((toDate - fromDate)/1.month).ceil + 1\n startingNum = ActiveRecord::Base.connection.select_value(ActiveRecord::Base.send(:sanitize_sql_array, \n [\"select date_part('month', date '#{fromDate}')\"]))\n\n dbQuery = dbQuery.select(\"date_part('month', timestamp) - #{startingNum} as time\")\n elsif numDays > 31 then\n @timeSlot = \"week\"\n @numTimeSlots = ((toDate - fromDate)/1.week).ceil + 1\n startingNum = ActiveRecord::Base.connection.select_value(ActiveRecord::Base.send(:sanitize_sql_array, \n [\"select date_part('week', date '#{fromDate}')\"]))\n\n dbQuery = dbQuery.select(\"date_part('week', timestamp) - #{startingNum} as time\")\n else\n @timeSlot = \"day\"\n @numTimeSlots = numDays\n dbQuery = dbQuery.select(\"EXTRACT(day from timestamp - date '#{fromDate}') as time\")\n end\n else #default is TODAY\n fromDate = Time.mktime(Time.now.year, Time.now.month, Time.now.day)\n toDate = fromDate + 24.hours\n @timeSlot = \"hour\"\n @numTimeSlots = 24\n\n dbQuery = dbQuery.select(\"date_part('hour', timestamp) as time\")\n end\n\n dbQuery = dbQuery.group(:time).order(:time)\n\n return dbQuery\n\n end",
"def reservation_state(base = self.date_from)\n\t\t\t\t\t@reservation_states = {} if @reservation_state.nil?\n\t\t\t\t\t@reservation_state_behaviors = {} if @reservation_state_behaviors.nil?\n\t\t\t\t\tif @reservation_states[base.to_s].nil?\n\t\t\t\t\t\t\n\t\t\t\t\t\t# Now\n\t\t\t\t\t\tnow = Time.current\n\t\t\t\t\t\t\n\t\t\t\t\t\t# States\n\t\t\t\t\t\treservation_states = config(:reservation_states)\n\n\t\t\t\t\t\t# Break times\n\t\t\t\t\t\tif config(:reservation_state_policy) == \"time_fixed\"\n\t\t\t\t\t\t\tbreak_times = []\n\t\t\t\t\t\t\treservation_states.reverse_each_with_index do |reservation_state_spec, index|\n\t\t\t\t\t\t\t\tif index != 0 # Do not consider first state\n\t\t\t\t\t\t\t\t\tstate_name = reservation_state_spec[:name]\n\t\t\t\t\t\t\t\t\ttime_fixed = self.send(\"time_fixed_#{state_name}\")\n\t\t\t\t\t\t\t\t\tif time_fixed\n\t\t\t\t\t\t\t\t\t\tbreak_times << time_fixed\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tbreak_times << break_times.last\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbreak_times = [self.datetime_from(base)]\n\t\t\t\t\t\t\treservation_states.reverse_each_with_index do |reservation_state_spec, index|\n\t\t\t\t\t\t\t\tif index != 0 && index != (reservation_states.length - 1) # Do not consider first and last state\n\t\t\t\t\t\t\t\t\tstate_name = reservation_state_spec[:name]\n\t\t\t\t\t\t\t\t\ttime_window = self.send(\"time_window_#{state_name}\")\n\t\t\t\t\t\t\t\t\tif time_window\n\t\t\t\t\t\t\t\t\t\tbreak_times << (break_times.last - time_window.days_since_new_year.days - time_window.seconds_since_midnight.seconds)\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tbreak_times << break_times.last\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\t\t# State recognititon\n\t\t\t\t\t\treservation_states.each_with_index do |reservation_state_spec, index|\n\t\t\t\t\t\t\tif index < reservation_states.length - 1\n\t\t\t\t\t\t\t\tif !break_times[reservation_states.length - 2 - index].nil? && now < break_times[reservation_states.length - 2 - index]\n\t\t\t\t\t\t\t\t\t@reservation_states[base.to_s] = reservation_state_spec[:name].to_sym\n\t\t\t\t\t\t\t\t\t@reservation_state_behaviors[base.to_s] = reservation_state_spec[:behavior].to_sym\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\telse # Last fallback state\n\t\t\t\t\t\t\t\t@reservation_states[base.to_s] = reservation_state_spec[:name].to_sym\n\t\t\t\t\t\t\t\t@reservation_state_behaviors[base.to_s] = reservation_state_spec[:behavior].to_sym\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\treturn @reservation_states[base.to_s]\n\t\t\t\tend",
"def get_blocks\n @blocks ||= Block.find :all, :conditions => { :show_in_all => '' }\n end",
"def find_booked(date)\n rooms_booked = []\n @reservations.each do |reservation|\n if reservation.reservation_date_range.start_date == date.start_date && reservation.reservation_date_range.end_date == date.end_date\n rooms_booked << reservation\n end\n end\n return rooms_booked\n end",
"def unfinished_dispatch_time_ranges\n dispatches.where(safe_return: false).map(&:active_time_window)\n end",
"def date_range\n earliest = WorkPacket.find_earliest_by_tasks( @task_ids )\n latest = WorkPacket.find_latest_by_tasks( @task_ids )\n\n # If the earliest or latest work packet value is nil, both should be\n # nil (obviously) and this means there are no work packets for the\n # tasks. In that case we just span 'all of time' so that the user\n # can see explicitly there's no booked time. Generating a report over\n # some single day range just looks odd (user thinks \"why hasn't it\n # covered all dates\"). The hide-zero-columns option can be employed\n # to clear up the report.\n\n end_of_range = latest.nil? ? Date.current : latest.date.to_date\n start_of_range = earliest.nil? ? Date.new( Timesheet.allowed_range().min, 1, 1 ) : earliest.date.to_date\n\n return ( start_of_range..end_of_range )\n end",
"def find_start_time_and_venue(availability, have_created_venue=false)\n availability.timeslots.each do |timeslot|\n reservation = find_venue_for_timeslot(availability, timeslot)\n return reservation if reservation.present?\n end\n\n # If we reach here, we failed to find an appropriate timeslot.\n if have_created_venue\n # This should be impossible, but just in case it somehow happens ...\n raise \"Unable to allocate form for #{availability.project.name}\"\n else\n create_venue\n find_start_time_and_venue(availability, have_created_venue=true)\n end\n end",
"def scan_block(client, blocknum)\n bhash = client.getblockhash(blocknum)\n block = client.getblock(bhash)\n txhashes = block['tx']\n\n # Many blocks contain > 2k transactions, so batching this\n # can cause read timeouts on slower hardware.\n # The timeout can be adjusted in btcrpcclient if needed.\n calls = txhashes.map { |txhash| ['getrawtransaction', txhash, 1] }\n txs = client.batch(calls)\n return txs.inject([]) {|findings, tx| findings += scan_tx(client, tx) }\nend",
"def get_time_entries(start_date=nil, end_date=nil)\n options = Hash.new\n options[\"start_date\"] = iso8601_date(start_date) if start_date\n options[\"end_date\"] = iso8601_date(end_date) if end_date\n get \"/time_entries\", options\n end",
"def availabilities_for(intervention)\n TimeSlot.availables(self, intervention)\n end",
"def availability_by_timeslot(ts)\n self.capacity - self.bookings_total_by_timeslot(ts)\n end",
"def health\n @blocks = @schedule.blocks(:for_registration => true).sort_by { |b| b.start }\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @schedule }\n end\n end",
"def getLeasesByDate(date)\n leases = getLeases()\n today_leases = []\n if leases.length !=0\n leases.each do |lease|\n if lease[\"status\"] == \"accepted\"\n #puts \"Gia na assssssssssssss\"\n #puts lease[\"valid_from\"].split('T')[0]\n #puts date\n #puts lease[\"valid_until\"].split('T')[0]\n if lease[\"valid_from\"].split(' ')[0] <= date && lease[\"valid_until\"].split(' ')[0]>=date\n #puts \"mpika\"\n today_leases << lease\n end\n end\n end\n end\n\n return today_leases\n end",
"def compute_timestamps(begin_time, end_time)\n @timevec = value_hash[:bartime]\n if model == DailyBar\n begin\n @time_map = TimeMap.new(begin_time, end_time, timevec, :missing_bar_error => options[:missing_bar_error])\n rescue TimeseriesException => e\n raise TimeseriesException, \"#{e.message} for #{symbol}\"\n end\n else\n timevec.each_with_index { |time, idx| @time_map[time.to_i] = idx }\n end\n end",
"def unavailable_date_ranges_from_today\n self.reservations\n .where('end_date > ?', Date.today())\n .where(status: [1, 5])\n .map {|item| [item.start_date, item.end_date]}\n end"
] | [
"0.70361656",
"0.67197216",
"0.6327685",
"0.5927963",
"0.5920603",
"0.58066165",
"0.57762384",
"0.5687271",
"0.5667841",
"0.56143665",
"0.5585009",
"0.5533882",
"0.55060583",
"0.55009145",
"0.5492323",
"0.5470167",
"0.54546696",
"0.5426355",
"0.5423387",
"0.53829724",
"0.53286076",
"0.5327365",
"0.53218263",
"0.529688",
"0.52158326",
"0.5212603",
"0.5203236",
"0.51959413",
"0.5181069",
"0.51787245",
"0.5166492",
"0.516453",
"0.51580554",
"0.5152247",
"0.51503533",
"0.51465833",
"0.5135684",
"0.51319575",
"0.51305",
"0.5128848",
"0.51266456",
"0.51190585",
"0.50806105",
"0.5073335",
"0.50659305",
"0.5058115",
"0.50502825",
"0.5048842",
"0.5042837",
"0.5035911",
"0.5032758",
"0.5028808",
"0.50064355",
"0.50000334",
"0.4994911",
"0.498973",
"0.49825817",
"0.49734485",
"0.49659115",
"0.4962966",
"0.49595028",
"0.4953895",
"0.4944923",
"0.4934541",
"0.49289307",
"0.4926376",
"0.4913306",
"0.49077708",
"0.49021703",
"0.4891465",
"0.48881745",
"0.4881693",
"0.48777986",
"0.48754528",
"0.48727778",
"0.48727778",
"0.4870888",
"0.4867887",
"0.4862747",
"0.485424",
"0.4849142",
"0.48423308",
"0.48404315",
"0.4838111",
"0.48380756",
"0.48354852",
"0.48343086",
"0.48286462",
"0.4826671",
"0.48229486",
"0.48196554",
"0.48138902",
"0.48134783",
"0.4813014",
"0.48100302",
"0.48060012",
"0.4804885",
"0.4804136",
"0.48034495",
"0.48009977"
] | 0.718394 | 0 |
Public api for returning all collisions for a given Range. The Range is transformed into a TimeBlock, and then pushed through the pipeline for natural detection of any collisions. | def collisions_for(range)
collider.detect TimeBlock.new(
start_time: range.begin,
end_time: range.end,
session: @session)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collide_hash_all(hash_rects)\n hash_rects.select { |key,value|\n value.collide_rect?+(self)\n }\n end",
"def collisions(rect)\n remain = visible_sprites(rect).to_a\n coll = remain.select { |item| item.intersect_rect? rect }\n [coll, coll - remain]\n end",
"def collisions\n [collided_bombs, collided_rubies]\n end",
"def check_collisions!\n 1000.times do\n @particles.values.map(&:tick)\n position_groups = @particles.values.group_by(&:position)\n collisions = position_groups.select { |pos, particles| particles.size > 1 }\n collisions.values.flatten.collect(&:num).map { |num| @particles.delete(num) }\n end\n @particles\n end",
"def collide_hash(hash_rects)\n hash_rects.each { |key,value|\n if value.collide_rect?+(self); return [key,value]; end\n }\n return nil\n end",
"def each_collision(game_object)\r\n start_x = (game_object.bb.left / @grid[0]).to_i\r\n stop_x = (game_object.bb.right / @grid[0]).to_i\r\n \r\n (start_x ... stop_x).each do |x|\r\n start_y = (game_object.bb.top / @grid[1]).to_i\r\n stop_y = (game_object.bb.bottom / @grid[1]).to_i\r\n \r\n (start_y ... stop_y).each do |y|\r\n yield @map[x][y] if @map[x] && @map[x][y] && @map[x][y] != game_object # Don't yield collisions with itself\r\n end\r\n end\r\n end",
"def calc_box_collision\n return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key\n collision_floor!\n collision_left!\n collision_right!\n collision_ceiling!\n end",
"def calc_box_collision\n return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key\n collision_floor\n collision_left\n collision_right\n collision_ceiling\n end",
"def collisions\n collider.detect(self)\n end",
"def dynamic_collisions(elems)\n rv = []\n elems.each do |elem|\n\n #TODO need to handle non circle types to get better bounds, at least linesegment\n cs = candidates(elem.collision_radius, elem.collision_center).flatten.select do|candidate|\n @collider.check_for_collision_by_type(elem, candidate)\n end\n rv += cs.collect {|cand| [elem, cand]}\n end\n rv\n end",
"def handle_collisions\n @collisions.map do |shape, collision_context|\n game_entity = @entity_manager.find_by_shape(shape)\n game_entity.on_collide(@entity_manager, collision_context) if game_entity\n end\n @collisions = []\n end",
"def getCollisionsToCheck\n @check_collision_list\n end",
"def get_range(range)\n r = []\n enum = range.to_enum\n begin\n while (x = enum.next) < @size\n r << get_single_key(x)\n end\n rescue StopIteration\n end\n r.empty? ? nil : r\n end",
"def each(&block)\r\n @range.each(&block)\r\n end",
"def collisions\n from = @rc\n mask = @game_board.dup\n if from\n queen = mask.element(*from)\n mask.set_at(*from,1)\n end\n rc = from\n collision_count = 0\n collision_count += mask.row(rc[0]).count {|e| e.class == Queen}\n collision_count += mask.column(rc[1]).count {|e| e.class == Queen}\n\n mask.rows.each_with_index do |row,index|\n p_row = @rc[0]+index\n m_row = @rc[0]-index\n p_col = @rc[1]+index\n m_col = @rc[1]-index\n a,b,c,d = [m_row,m_col],[m_row,p_col],[p_row,m_col],[p_row,p_col]\n valid_range = 0...mask.column_size\n collision_count+=1 if valid_range.include?(m_row) && valid_range.include?(m_col) && mask[*a].class == Queen\n collision_count+=1 if valid_range.include?(m_row) && valid_range.include?(p_col) && mask[*b].class == Queen\n collision_count+=1 if valid_range.include?(p_row) && valid_range.include?(m_col) && mask[*c].class == Queen\n collision_count+=1 if valid_range.include?(p_row) && valid_range.include?(p_col) && mask[*d].class == Queen\n end\n mask.set_at(*from,queen) if from\n collision_count\n end",
"def enemies_in_range(range)\n return case attacking_direction\n when :right\n @game_state.enemies.select do |e| \n (e.x > @x && e.x < (self.right + range)) && (e.bottom > @y || e.y < self.bottom)\n end\n when :left\n @game_state.enemies.select do |e| \n (e.right < @x && e.right > (@x - range)) && (e.bottom > @y || e.y < self.bottom)\n end\n when :up\n @game_state.enemies.select do |e| \n (e.bottom < @y && e.bottom > (@y - range)) && (e.right > @x && e.x < self.right)\n end\n when :down\n @game_state.enemies.select do |e| \n (e.y > self.bottom && e.y < (self.bottom + range)) && (e.right > @x && e.x < self.right)\n end\n end\n end",
"def collide_with_other_blocks\n @game.blocks.each do |block|\n if collide(block)\n return block\n end\n end\n nil\n end",
"def hit_objects\n game_state.game_object_map.collisions_with(self)\n #[game_state.game_object_map.from_game_object(self)]\n end",
"def collisions args\n num_balls = args.state.balls.length\n if num_balls > 1\n (0..num_balls - 1).each do |i|\n ball1 = args.state.balls[i]\n ((i + 1)..num_balls - 1).each do |j|\n ball2 = args.state.balls[j]\n dist = (((ball1[:x] - ball2[:x]) ** 2) + ((ball1[:y] - ball2[:y]) ** 2)) ** (1/2)\n if dist < args.state.ball_diameter\n args.state.collision_data = resolve_bump ball1, ball2, dist, args\n if i == 0 and args.state.first_collision_type == 3\n args.state.first_collision_type = ball2[:type]\n end\n args.state.balls_collided = true\n end\n end\n end\n end\nend",
"def range\n @cached_range ||= get_range\n end",
"def catch_collisions\n beam_collide_enemy = [:beam, :enemy]\n enemy_collide_spaceship = [:spaceship, :enemy]\n\n Constants::SPACE.add_collision_func(*beam_collide_enemy) do |beam_shape, enemy_shape|\n add_collided_shape(beam_shape, beam_collide_enemy)\n add_collided_shape(enemy_shape, beam_collide_enemy)\n end\n Constants::SPACE.add_collision_func(*enemy_collide_spaceship) do |spaceship_shape, enemy_shape|\n add_collided_shape(enemy_shape, enemy_collide_spaceship)\n add_collided_shape(spaceship_shape, enemy_collide_spaceship)\n end\n end",
"def collisions\n results = []\n\n carts.each do |cart_a|\n carts.each do |cart_b| \n if cart_a.position == cart_b.position && cart_a != cart_b\n results << [cart_a, cart_b]\n end\n end\n end\n\n results\n end",
"def check_block_availability(rooms, range)\n\t\t\tpossible_rooms = room_finder(range) # Returns available rooms in the given range.\n\t\t\tavail = []\n\n\t\t\trooms.each do |room|\n\t\t\t\tif possible_rooms.include?(room)\n\t\t\t\t\tavail << room\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn avail\n\t\tend",
"def valid_tickets\n @nearby_tickets.filter_map do |ticket|\n in_ranges = ticket.map do |val|\n merged_rules.map {|val_range| val_range.include?(val)}.include?(true)\n end\n ticket unless in_ranges.include?(false)\n end\n end",
"def front_rear_and_internal_collisions\n colliding_with.where(ended: false).where('reservations.starts_at' => range) + colliding_with.where('reservations.ends_at' => range)\n end",
"def available_rooms(range_query)\n all_rooms = @rooms.map {|room| room.number}\n\n conflicting_reservations = @reservations.find_all { |res| res.range.overlap?(range_query) == true }\n occupied_rooms = conflicting_reservations.map {|res| res.room_num}\n occupied_rooms = occupied_rooms.uniq\n\n available_rooms = all_rooms - occupied_rooms \n\n return available_rooms\n end",
"def maps_for_range(range)\n last = (range.exclude_end?) ? range.last : range.last + 1\n maps.select { |m| m.start_addr >= range.first and m.max < last }\n end",
"def time_range min, max\n spawn :@trange, [min, max].map { |e| time_to_long e }\n end",
"def check_node_overlap!\n node_to_positions = {}\n each_node do |node|\n node.proper_range.each do |position|\n if node_to_positions[position]\n already = node_to_positions[position]\n puts \"There is a proper_range overlap between #{node} and #{already}\"\n puts \"Overlapping: #{already.proper_range & node.proper_range}\"\n binding.pry\n end\n node_to_positions[position] = node\n end\n end\n end",
"def collisions(obj)\n return projectile_collisions(obj) if obj.is_a?(Projectile) && obj.keep?\n return powerup_collision(obj) if obj.is_a?(Powerup)\n return unless obj.is_a?(Ball) && obj.keep?\n player_collision(obj)\n #balls_collisions(obj)\n end",
"def range_collection\n ranges.sort_by { |_, range| range.priority }.collect { |key, range_thing| [collection_label(range_thing), key] }\n end",
"def bounds\n Enumerator.new do |yielder|\n offsets.each do |offset|\n yielder << [offset, slice_length(offset)]\n end\n end\n end",
"def grouped_by_interval( range )\n grouped = Hash.new {|h,k| h[k] = [] }\n all.each { |r| r.period_in_seconds.step( range ) { |i| grouped[i/(range)] << r } }\n grouped\n end",
"def calculate_collisions args\n args.state.bullets.each do |bullet| # perform action on every bullet and enemy in collections\n args.state.enemies.each do |enemy|\n # if bullet has not exploded yet and the bullet hits an enemy\n if !bullet.exploded && bullet.rect.intersect_rect?(enemy.rect)\n bullet.exploded = true # bullet explodes\n enemy.dead = true # enemy is killed\n end\n end\n end\n\n # All exploded bullets are rejected or removed from the bullets collection\n # and any dead enemy is rejected from the enemies collection.\n args.state.bullets = args.state.bullets.reject(&:exploded)\n args.state.enemies = args.state.enemies.reject(&:dead)\nend",
"def collide_array_all(array_rects)\n indexes = []\n for i in (0...(array_rects.length))\n if array_rects[i].collide_rect?(self)\n indexes += [i]\n end\n end\n return indexes\n end",
"def collided_rubies\n ruby_layers.map do |ruby|\n ruby if ruby.collide_with?(GameData.player_layer.rect_version)\n end.compact\n end",
"def get_squares(range)\n\tresult= []\n\ti= 1\n\twhile( i*i < range.end)\n\t\tresult << i*i\n\t\ti+= 1\n\tend\n\treturn result\nend",
"def collidesWithPlayer\n for x in @x.round..(@x + @width).round\n for y in (@y - @height).round..@y.round\n if @map.player.containsPoint?(x, y)\n @map.player.loseHealth\n end\n end\n end\n end",
"def fetch_events_time(range_begin_in_secs, range_end_in_secs)\n #\n # collect from_time beginning of day (in seconds)\n #\n frt = self.from_time.beginning_of_day.to_i\n\n case self.recurrence_type\n when \"NO_RECURRENCE\"\n self.no_recurrence_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_DAYS\"\n self.recur_every_n_days_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_WEEKS\"\n self.recur_every_n_weeks_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_MONTHS\"\n self.recur_every_n_months_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_YEARS\"\n self.recur_every_n_years_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_DAYS_OF_WEEK\"\n self.recur_every_days_of_week_dates(range_begin_in_secs, range_end_in_secs, frt)\n else\n []\n end\n end",
"def collidesWithPlayer\n for x in @x.round..(@x + @width).round\n for y in (@y - @height).round..@y.round\n if @map.player.containsPoint?(x, y)\n @map.player.loseHealth\n death\n return\n end\n end\n end\n end",
"def union(range)\n # Return self if nil (nothing new to add) or if it matches the other range (they are equivalent)\n return self.clone if range.nil?\n return self.clone if eql?(range)\n\n # Figure out which range starts earlier (to capture the most time)\n if low <= range.low\n earlier_start = self\n later_start = range\n else\n earlier_start = range\n later_start = self\n end\n \n # Figure out which ranges ends earlier (the more restrictive one)\n if high >= range.high\n earlier_end = self\n later_end = range\n else\n earlier_end = range\n later_end = self\n end\n \n result = []\n # We have continuous Ranges so we can return one Range to encapsulate both\n if earlier_start.contains?(later_start.low)\n result << Range.new(\"TS\", earlier_start.low.clone, later_end.high.clone, nil)\n else\n # The Ranges are disjoint, so we'll need to return two arrays to capture all of the potential times\n result << Range.new(\"TS\", earlier_start.low.clone, earlier_start.high.clone, nil)\n result << Range.new(\"TS\", later_start.low.clone, later_start.high.clone, nil)\n end\n end",
"def range(range, options={})\n range = (range..range) if range.is_a? Date\n data = range.map do |date|\n case type\n when :counter\n value = Prisma.redis.get(Prisma.redis_key(name, date)).to_i\n when :bitmap\n bitstring = Prisma.redis.get(Prisma.redis_key(name, date)) || ''\n string = bitstring.unpack('b*').first\n value = options[:skip_bitmap_count] ? string : string.count('1')\n end\n\n [date, value]\n end\n\n Hash[data]\n end",
"def events(range_begin = nil, range_end = nil, time_filters_in_secs = [])\n #\n # If range_begin is nil, use from_time attribute from the model.\n #\n range_begin = range_begin || self.from_time\n range_begin = Event.convert_to_datetime(range_begin).beginning_of_day.to_i\n\n #\n # If range_end is nil, use recurrence_end attribute from the model.\n # note: range_end may still be nil if no recurrence_end is specified\n # note: range_end is exclusive. substract with DAY_IN_SECONDS to\n # become inclusive (see arshaw fullcalendar docs)\n #\n range_end = Event.convert_to_datetime(range_end).end_of_day.to_i - DAY_IN_SECONDS if range_end\n range_end = [range_end, self.recurrence_end.try(:end_of_day).try(:to_i)].compact.min\n\n arr = []\n self.fetch_events_time(range_begin, range_end).each do |e|\n event_from_time_in_secs = e +\n (self.from_time.hour * HOUR_IN_SECONDS) +\n (self.from_time.min * MINUTE_IN_SECONDS)\n event_thru_time_in_secs = event_from_time_in_secs + self.duration\n\n unless time_filters_in_secs.include? event_from_time_in_secs\n arr << Event.new(self, event_from_time_in_secs, event_thru_time_in_secs)\n end\n end\n\n arr\n end",
"def missing_ranges()\n return [] if @time_map.nil?\n @time_map.missing_ranges()\n end",
"def identify_ranges(yaml_content)\n each_line_indices(yaml_content).each_with_object([]) do |(start, finish), ranges|\n if range = clean_line(yaml_content, start, finish)\n ranges << range\n end\n end\n end",
"def each_coord\n x_range, y_range = ranges\n x_range.each { |x| y_range.each { |y| yield [x, y] } }\n end",
"def resolve_horizontal_collision\n unless colliding_blocks.empty?\n x_resolutions = colliding_blocks.map do |block|\n pos = block.x2 - x1\n neg = block.x1 - x2\n\n pos < neg.abs ? pos : neg\n end\n\n z_resolutions = colliding_blocks.map do |block|\n pos = block.z2 - z1\n neg = block.z1 - z2\n\n pos < neg.abs ? pos : neg\n end\n\n pos_x, neg_x = x_resolutions.partition{|x| x > 0 }\n pos_z, neg_z = z_resolutions.partition{|z| z > 0 }\n\n dx = if pos_x.size > neg_x.size\n pos_x.min\n elsif pos_x.size < neg_x.size\n neg_x.max\n elsif pos_z.size == neg_z.size\n x_resolutions.min_by(&:abs)\n else\n 1.0/0\n end\n\n dz = if pos_z.size > neg_z.size\n pos_z.min\n elsif pos_z.size < neg_z.size\n neg_z.max\n elsif pos_x.size == neg_x.size\n z_resolutions.min_by(&:abs)\n else\n 1.0/0\n end\n\n if dx.abs < dz.abs\n @x += dx\n else\n @z += dz\n end\n end\n end",
"def collect\n [@range_low, @range_high]\n end",
"def collision_rect\r\r\n return @collisionbox\r\r\n end",
"def collided_bombs\n bomb_layers.map do |bomb|\n bomb if bomb.collide_with?(GameData.player_layer.rect_version)\n end.compact\n end",
"def walking_collisions args\n num_balls = args.state.balls.length\n if num_balls > 1\n (0..num_balls - 1).each do |i|\n if i != 0\n ball1 = args.state.balls[i]\n ((i + 1)..num_balls - 1).each do |j|\n ball2 = args.state.balls[j]\n dist = (((ball1[:x] - ball2[:x]) ** 2) + ((ball1[:y] - ball2[:y]) ** 2)) ** (1/2)\n if dist < args.state.ball_diameter\n args.state.collision_data = resolve_bump ball1, ball2, dist, args\n args.state.num_collisions += 1\n args.state.balls_collided = true\n end\n end\n end\n end\n end\nend",
"def to_collision\n #Primitives::Circle.new(@position, @radius)\n @collision_primitive\n end",
"def get_bounds\n # Go throug all blocks to find the bounds of this shape\n x_min = []\n y_min = []\n x_max = []\n y_max = []\n @blocks.each do |block| \n x_min << block.x\n y_min << block.y\n \n x_max << block.x + block.width\n y_max << block.y + block.height\n end\n\n return [x_min.min, y_min.min, x_max.max, y_max.max]\n end",
"def bsearch_range(range = 0...length, &block)\n lower = bsearch_lower_boundary(range, &block)\n upper = bsearch_upper_boundary(range, &block)\n lower...upper\n end",
"def excise(ranges)\n if ranges.class != Array\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n ranges.each do |r|\n if r.class != Range\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n end\n\n answer = Array.new\n previous_excised_stop = self.start - 1\n ranges.sort_by{|r| r.first}.each do |r|\n subslice_start = previous_excised_stop + 1\n if subslice_start <= r.first - 1\n answer.push(Slice.new(self.seq_region, subslice_start, r.first - 1))\n end\n previous_excised_stop = r.last\n if r.last > self.stop\n return answer\n end\n end\n subslice_start = previous_excised_stop + 1\n answer.push(Slice.new(self.seq_region, subslice_start, self.stop))\n return answer\n end",
"def collision_rect\r\r\n #return @custom_collision if @custom_collision.size > 0\r\r\n return super\r\r\n end",
"def time_range\n start_time..end_time\n end",
"def range( range )\n ::Vector.elements( range.to_a )\n end",
"def column_range range\n unless range.instance_of? Google::Cloud::Bigtable::ColumnRange\n raise RowFilterError, \"Range type mustbe ColumnRange\"\n end\n @grpc.column_range_filter = range.to_grpc\n self\n end",
"def reservations_by_room_and_range(room_num_query, range_query)\n return @reservations.find_all { |res| res.room_num == room_num_query && res.range.overlap?(range_query) }\n end",
"def collision(damage)\n end",
"def excise(ranges)\r\n if ranges.class != Array\r\n raise RuntimeError, \"Argument should be an array of ranges\"\r\n end\r\n ranges.each do |r|\r\n if r.class != Range\r\n raise RuntimeError, \"Argument should be an array of ranges\"\r\n end\r\n end\r\n\r\n answer = Array.new\r\n previous_excised_stop = self.start - 1\r\n ranges.sort_by{|r| r.first}.each do |r|\r\n subslice_start = previous_excised_stop + 1\r\n if subslice_start <= r.first - 1\r\n answer.push(Slice.new(self.seq_region, subslice_start, r.first - 1))\r\n end\r\n previous_excised_stop = r.last\r\n if r.last > self.stop\r\n return answer\r\n end\r\n end\r\n subslice_start = previous_excised_stop + 1\r\n answer.push(Slice.new(self.seq_region, subslice_start, self.stop))\r\n return answer\r\n end",
"def rubocop_file_ranges(file_ranges)\n output = {}\n offenses = NdrDevSupport::Rubocop::Executor.new(file_ranges.keys).offenses_by_file\n\n threads = offenses.map do |file, file_offenses|\n Thread.new do\n # Expand ranges to include entire methods, etc:\n augmenter = NdrDevSupport::Rubocop::RangeAugmenter.new(file, file_ranges[file] || [])\n # Get subset of rubocop output for those files:\n output[file] = filtered_offenses_by_line(file_offenses, augmenter.augmented_lines)\n end\n end\n threads.each(&:join)\n\n # Report on output:\n exit NdrDevSupport::Rubocop::Reporter.new(output).report\n end",
"def check_pipeline_overlap(pipeline_range)\n @active_servers = ServerNode.where(state: 'running')\n @active_servers.each do |s|\n if s.pipeline_end.to_i >= pipeline_range[0] or s.pipeline_start.to_i <= pipeline_range[1]\n else\n return false\n end\n end\n return true\n end",
"def &(range)\n return nil unless overlaps?(range) || touching?(range)\n PosRange.new [@start, range.start].max, [@end, range.end].min\n end",
"def scope_by_time(time_boundaries)\n start_time, end_time = time_boundaries\n scope_end = num_lines - 1\n # short circuit the search if possible\n if (time_at(0) > end_time) or (time_at(-1) < start_time)\n @lines = []\n return @lines\n end\n scope_begin = find_first(start_time, 0, scope_end)\n scope_end = find_last(end_time, scope_begin, scope_end)\n @lines = @lines[scope_begin..scope_end]\n end",
"def natural_rect(logical_x, logical_y, x_range, y_range)\n [\n logical_x * @tile_width,\n logical_y * @tile_width,\n x_range * @tile_width,\n y_range * @tile_width\n ]\n end",
"def search_range(array, range=nil, &block)\n lower = search_lower_boundary(array, range, &block)\n upper = search_upper_boundary(array, range, &block)\n return lower ... upper\n end",
"def intersection(range)\n int_a = (self.to_a & range.to_a) \n int_a.empty? ? nil : Range.new(int_a.min, int_a.max)\n end",
"def cells_overlapping(x, y)\n cells_at_points(corner_points_of_entity(x, y)).collect {|cx, cy| at(cx, cy) }\n end",
"def map_in_range\n clean_grid\n UNITS.each do |unit|\n position = MAP[unit.y][unit.x]\n position.occupied = true\n if unit.team == 'G'\n position.goblin_in_grid = true\n position.up.goblin_in_range = true if position.up.type == '.'\n position.right.goblin_in_range = true if position.right.type == '.'\n position.down.goblin_in_range = true if position.down.type == '.'\n position.left.goblin_in_range = true if position.left.type == '.'\n else\n position.elf_in_grid = true\n position.up.elf_in_range = true if position.up.type == '.'\n position.right.elf_in_range = true if position.right.type == '.'\n position.down.elf_in_range = true if position.down.type == '.'\n position.left.elf_in_range = true if position.left.type == '.'\n end\n end\nend",
"def getCollisionMask\n Circle.new(@x, @y, [@width, @height].max/2.0)\n end",
"def getCollisionMask\n Circle.new(@x, @y, [@width, @height].max/2.0)\n end",
"def bsearch_range (range = 0 ... self.length, &block)\r\n lower = bsearch_lower_boundary(range, &block)\r\n upper = bsearch_upper_boundary(range, &block)\r\n return lower ... upper\r\n end",
"def book(start_time, end_time)\n @bookings[start_time] += 1\n @bookings[end_time] -= 1\n temp = 0\n @bookings.keys.sort.each do |key|\n temp += @bookings[key]\n @overlap = temp if temp > @overlap\n end\n\n @overlap\n end",
"def intersecting_rectanges(rect1, rect2)\n\n intersecting_rect_width = 0\n intersecting_rect_height = 0\n intersecting_rect_left_x = 0\n intersecting_rect_bottom_y = 0\n\n if rect1[:left_x] + rect1[:width] > rect2[:left_x] && rect2[:left_x] > rect1[:left_x]\n intersecting_rect_width = rect1[:left_x] + rect1[:width] - rect2[:left_x]\n intersecting_rect_left_x = rect2[:left_x]\n elsif rect2[:left_x] + rect2[:width] > rect1[:left_x] && rect1[:left_x] > rect2[:left_x]\n intersecting_rect_width = rect2[:left_x] + rect2[:width] - rect1[:left_x]\n intersecting_rect_left_x = rect1[:left_x]\n end\n\n if rect1[:bottom_y] + rect1[:height] > rect2[:bottom_y] && rect2[:bottom_y] > rect1[:bottom_y]\n intersecting_rect_height = rect1[:bottom_y] + rect1[:height] - rect2[:bottom_y]\n intersecting_rect_bottom_y = rect1[:bottom_y]\n elsif rect2[:bottom_y] + rect2[:height] > rect1[:bottom_y] && rect1[:bottom_y] > rect2[:height]\n intersecting_rect_height = rect2[:bottom_y] + rect2[:height] - rect1[:bottom_y]\n intersecting_rect_bottom_y = rect2[:bottom_y]\n end\n \n {\n :left_x => intersecting_rect_left_x,\n :bottom_y => intersecting_rect_bottom_y,\n\n :width => intersecting_rect_width,\n :height => intersecting_rect_height\n }\nend",
"def intersection(range)\n cmp = self.begin <=> range.end\n if cmp > 0\n nil\n elsif cmp == 0\n exclude_begin? || range.exclude_end? ? nil : EqRange.new(self.begin)\n else\n cmp = range.begin <=> self.end\n if cmp > 0\n nil\n elsif cmp == 0\n range.exclude_begin? || exclude_end? ? nil : EqRange.new(range.begin)\n else\n cmp = self.begin <=> range.begin\n min = if cmp < 0\n range\n elsif cmp > 0\n self\n else\n self.exclude_begin? ? self : range\n end\n\n cmp = self.end <=> range.end\n max = if cmp > 0\n range\n elsif cmp < 0\n self\n else\n self.exclude_end? ? self : range\n end\n\n if !max.upper_bound?\n min\n elsif !min.lower_bound?\n max\n else\n MinMaxRange.new(min, max)\n end\n end\n end\n end",
"def load_time_ranges\n @time_ranges = ActiveSupport::HashWithIndifferentAccess.new\n time_ranges = @config['time']\n time_ranges.each do |t,r|\n time_range = ActiveSupport::HashWithIndifferentAccess.new\n src_ranges ||= r\n src_ranges.map { |k,v| time_range[k.to_sym] = rangify_time_boundaries(v) }\n @time_ranges[t.to_sym] = time_range\n end\n\n end",
"def setup_collisions\n self.collisions.each { |collision| collision.install_on(environment) }\n end",
"def convert_all_ranges\n if self.file_type == 'Cluster'\n required_vals = 4\n domain = {\n x_axis_min: self.x_axis_min.to_i == 0 ? nil : self.x_axis_min.to_i,\n x_axis_max: self.x_axis_max.to_i == 0 ? nil : self.x_axis_max.to_i,\n y_axis_min: self.y_axis_min.to_i == 0 ? nil : self.y_axis_min.to_i,\n y_axis_max: self.y_axis_max.to_i == 0 ? nil : self.y_axis_max.to_i\n }\n empty_domain = {\n x_axis_min: nil,\n x_axis_max: nil,\n y_axis_min: nil,\n y_axis_max: nil\n }\n if self.cluster_groups.first.is_3d?\n domain[:z_axis_min] = self.z_axis_min.to_i == 0 ? nil : self.z_axis_min.to_i\n domain[:z_axis_max] = self.z_axis_max.to_i == 0 ? nil : self.z_axis_max.to_i\n empty_domain[:z_axis_min] = nil\n empty_domain[:z_axis_max] = nil\n required_vals = 6\n end\n # need to clear out domain first to force persistence\n self.update(empty_domain)\n if required_vals == domain.values.compact.size\n self.update(domain)\n end\n end\n end",
"def unfinished_dispatch_time_ranges\n dispatches.where(safe_return: false).map(&:active_time_window)\n end",
"def bounds(x, y)\n Rule.motions.map do |k, (dx, dy)|\n rx = x + dx\n ry = y + dy\n [k, !include?(rx, ry) || blocked?(rx, ry)]\n end.to_h\n end",
"def calc_world_lookup\n\n # If the tile size isn't equal to the previous tile size,\n # the previous tile size is set to the tile size,\n # and world_lookup hash is set to empty.\n if state.tile_size != state.previous_tile_size\n state.previous_tile_size = state.tile_size\n state.world_lookup = {} # empty hash\n end\n\n # return if the world_lookup hash has keys (or, in other words, is not empty)\n # return unless the world collection has values inside of it (or is not empty)\n return if state.world_lookup.keys.length > 0\n return unless state.world.length > 0\n\n # Starts with an empty hash for world_lookup.\n # Searches through the world and finds the coordinates that exist.\n state.world_lookup = {}\n state.world.each { |x, y| state.world_lookup[[x, y]] = true }\n\n # Assigns world_collision_rects for every sprite drawn.\n state.world_collision_rects =\n state.world_lookup\n .keys\n .map do |coord_x, coord_y|\n s = state.tile_size\n # multiply by tile size so the grid coordinates; sets pixel value\n # don't forget that position is denoted by bottom left corner\n # set x = coord_x or y = coord_y and see what happens!\n x = s * coord_x\n y = s * coord_y\n {\n # The values added to x, y, and s position the world_collision_rects so they all appear\n # stacked (on top of world rects) but don't directly overlap.\n # Remove these added values and mess around with the rect placement!\n args: [coord_x, coord_y],\n left_right: [x, y + 4, s, s - 6], # hash keys and values\n top: [x + 4, y + 6, s - 8, s - 6],\n bottom: [x + 1, y - 1, s - 2, s - 8],\n }\n end\n end",
"def tt_intersects?(*args)\n tt_range.intersects?(*args)\n end",
"def clash_check(a, b)\n\tclashes = []\n a.each do |a_start, a_finish|\n range_a = a_start..a_finish\n\n # check against each of b's slots\n b.each do |b_start, b_finish|\n range_b = b_start..b_finish\n \n # detect overlap of ranges\n # if Rails: range_a.overlaps?(range_b)\n if range_a.cover?(range_b.first) || range_b.cover?(range_a.first) \n\t\t\t\tclashes << [range_a, range_b]\n end\n end\n end\n clashes.empty?\nend",
"def get_unreserved_rooms(date_range)\n unreserved_room_ids = check_reservations(date_range, reservations)\n\n blocks.each do |block|\n block_start = block[:start_date]\n block_end = block[:end_date]\n room_objs = block[:rooms]\n room_ids = room_objs.map {|room| room.room_id}\n\n if date_range[:start_date] >= block_end == true\n next\n else\n if date_range[:end_date] <= block_start == false\n room_ids.each do |id|\n unreserved_room_ids.delete(id)\n end\n end\n end\n end\n\n return unreserved_room_ids.sort.uniq\n end",
"def entities_overlapping(x, y)\n entities_at_points(corner_points_of_entity(x, y))\n end",
"def intersection(range)\n # Return self if nil (the other range has no restrictions) or if it matches the other range (they are equivalent)\n return self.clone if range.nil?\n return self.clone if eql?(range)\n\n # Figure out which range starts later (the more restrictive one)\n if low <= range.low\n earlier_start = self\n later_start = range\n else\n earlier_start = range\n later_start = self\n end\n \n # Return nil if there is no common time (the two ranges are entirely disjoint)\n return nil unless later_start.contains?(earlier_start.high)\n \n # Figure out which ranges ends earlier (the more restrictive one)\n if high >= range.high\n earlier_end = self\n later_end = range\n else\n earlier_end = range\n later_end = self\n end\n\n Range.new(\"TS\", later_start.low.clone, earlier_end.high.clone, nil)\n end",
"def busy_range\n [\n engineering_normal_salary_items,\n engineering_normal_with_tax_salary_items,\n engineering_big_table_salary_items,\n engineering_dong_fang_salary_items\n ].flat_map{|items| items.map{|item| item.salary_table.range} }.sort\n end",
"def each_match_range(range, regex); end",
"def build_spans on_range\n @spans = Array.new @size[1]\n\n @size[1].times do |y|\n spans = []\n left = (@size[1]-y-1)*@size[0]\n start = nil\n\n @size[0].times do |x|\n d = on_range.include?(@pixels[left+x])\n\n if !start && d\n start = x\n elsif start && !d\n spans << [start, x]\n start = nil\n end\n end\n\n spans << [start, @size[0]] if start\n @spans[y] = spans\n end\n end",
"def loose_bounds()\n return []\n end",
"def make_players(id_range)\n players = []\n id_range.each do |player_id|\n players << generate_player(player_id)\n end\n players\nend",
"def rank_range(range,board=@board,&block)\n range.to_a.each {|r| whole_rank(r,board,&block) }\n end",
"def generate(difficulty_range, &block)\n slots = [nil]*grid.piece_count\n context = OpenStruct.new\n\n context.slots = slots\n context.maximum_depth = 5\n context.difficulty_range = difficulty_range\n\n symmetries = (difficulty_range.last - difficulty_range.first)\n equal = (difficulty_range.last - difficulty_range.first)/6\n generate_backtrack(context, symmetries, &block)\n context\n end",
"def clamp(start_range, end_range)\n Proc.new { |target|\n next start_range if target < start_range\n next end_range if target > end_range\n\n target\n }\n end",
"def range_by_lines(range)\n begin_of_first_line = range.begin_pos - range.column\n\n last_line = range.source_buffer.source_line(range.last_line)\n last_line_offset = last_line.length - range.last_column\n end_of_last_line = range.end_pos + last_line_offset\n\n Parser::Source::Range.new(range.source_buffer,\n begin_of_first_line,\n end_of_last_line)\n end",
"def load_commits(range)\n commits = load_ref_commits(range.last)\n if range.first == ''\n base_commits = []\n else\n base_commits = load_ref_commits(range.first).map! do |commit|\n commit.id\n end\n end\n commits.reject { |commit| base_commits.include? commit.id }\n end",
"def overlaps?(range)\n !(completely_left_of?(range) || completely_right_of?(range))\n end",
"def bounds\n return [] unless @grpc.bounding_box\n @bounds ||= Array(@grpc.bounding_box.vertices).map do |v|\n Vertex.from_grpc v\n end\n end"
] | [
"0.6032244",
"0.5861564",
"0.5708567",
"0.56075084",
"0.5579013",
"0.5519869",
"0.54588366",
"0.5458093",
"0.5350583",
"0.52792895",
"0.5246726",
"0.5141044",
"0.50969744",
"0.5044568",
"0.5018214",
"0.49943906",
"0.49637446",
"0.49148008",
"0.49016166",
"0.48722035",
"0.4865291",
"0.4829549",
"0.4798508",
"0.47725752",
"0.47642615",
"0.47552037",
"0.47483826",
"0.47363093",
"0.47064456",
"0.46928605",
"0.46917763",
"0.46739706",
"0.46722507",
"0.46673197",
"0.46615762",
"0.4660851",
"0.46559265",
"0.46541107",
"0.4638195",
"0.46365774",
"0.46318018",
"0.4621035",
"0.4620386",
"0.46189448",
"0.4603148",
"0.46008068",
"0.4597872",
"0.45956233",
"0.45943108",
"0.45910257",
"0.45869398",
"0.45823833",
"0.45687115",
"0.45565486",
"0.45541418",
"0.45512578",
"0.4543457",
"0.45288217",
"0.4522801",
"0.45212388",
"0.45197526",
"0.4505927",
"0.44941682",
"0.44867954",
"0.44766405",
"0.4473208",
"0.44696164",
"0.4462469",
"0.44540915",
"0.44537675",
"0.44526953",
"0.4442816",
"0.4442816",
"0.44411242",
"0.4437883",
"0.4435976",
"0.44334695",
"0.44281104",
"0.44275814",
"0.44262794",
"0.44229844",
"0.4417364",
"0.44166362",
"0.4411255",
"0.44047773",
"0.440189",
"0.4385973",
"0.4385677",
"0.4381064",
"0.43802467",
"0.43705598",
"0.43681276",
"0.43671253",
"0.43658668",
"0.4363533",
"0.4362881",
"0.43623477",
"0.43595627",
"0.43581587",
"0.43508184"
] | 0.78286237 | 0 |
Generate TimeSlots over a given range using the minimum service duration | def time_slots_for(time_entry)
count = (duration_for(time_entry.range) / block_size).floor.to_i
time = time_entry.start_time
slots = count.times.map do |i|
# Instantiate a new TimeSlot out of thin air (no backing store)
slot = TimeSlot.new time, time + block_size.minutes, time_entry
# Stash the current session onto the slot as well, so it may handle
# some of it's own session based logic.
slot.session = session
# finally increment the time for the next iteration
time = time + block_size.minutes
slot
end
# Detect deadspace at the TimeSlot layer.
# If found, we add a final TimeSlot to make up the difference.
if time < time_entry.end_time
slots << TimeSlot.new(time, time_entry.end_time, time_entry)
end
# Return the aggregated slot collection
slots
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_time_slots\n return unless params[:start_time]\n\n start_time = Time.from_picker(params.delete(:start_time))\n end_time = Time.from_picker(params.delete(:end_time))\n\n return if end_time < start_time # Prevent infinite loop\n\n shift_length = params.delete(:shift_length).to_i\n shift_overlap = params.delete(:shift_overlap).to_i\n people_per_shift = params.delete(:people_per_shift)\n\n num_shifts = ((end_time - start_time) / shift_length).ceil\n return if num_shifts > 100 # Arbitrary threshold to prevent flooding database\n\n cur_time = start_time\n TimeSlot.transaction do\n while cur_time < end_time\n end_shift_time = cur_time + shift_length + shift_overlap\n TimeSlot.create! job: @job,\n start_time: cur_time,\n end_time: [end_shift_time, end_time].min,\n slots: people_per_shift\n cur_time += shift_length\n end\n end\n end",
"def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def block_slots\n slots = []\n\n unless block_delivery_end_time.blank? || block_delivery_start_time.blank?\n\n available_hours = block_delivery_end_time - block_delivery_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: block_delivery_start_time + i.hours,\n to: block_delivery_start_time + (i + 1).hours,\n type: :daytime\n }\n end\n end\n\n slots\n end",
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n {gained_weight: 0, duration: @slots_size})\n @slots << verterx\n\n current_time += @slots_size\n break if current_time >= finish_time\n end\n\n current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight\n end\n end",
"def slots\n slot_start = start_time\n slot_end = slot_start + slot_length\n while slot_end <= end_time\n slot = ::V2::TimeSlot.new(start_time: slot_start, end_time: slot_end, event_id: @event_id)\n @slots << slot if slot.valid? && slot.save\n slot_start = slot_end + buffer\n slot_end = slot_start + slot_length\n end\n\n @slots\n end",
"def mask_for_time_slots\n offset = (ends_at.next_day.beginning_of_day - ends_at) / APPOINTMENT_INTERVAL\n slots_number = (ends_at - starts_at) / APPOINTMENT_INTERVAL\n ('1' * slots_number).to_i(2) << offset\n end",
"def get_time_slot_array\n time_slot_array = [\"07:00\", \"07:30\", \"08:00\", \"08:30\", \"09:00\", \"09:30\", \"10:00\", \"10:30\",\n \"11:00\", \"11:30\", \"12:00\", \"12:30\", \"13:00\", \"13:30\", \"14:00\", \"14:30\",\n \"15:00\", \"15:30\", \"16:00\", \"16:30\", \"17:00\", \"17:30\", \"18:00\", \"18:30\",\n \"19:00\", \"19:30\", \"20:00\", \"20:30\", \"21:00\"]\n end",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def time_range min, max\n spawn :@trange, [min, max].map { |e| time_to_long e }\n end",
"def vacant_slots(from, to)\n\n end",
"def time_range\n range_time = []\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 am\"\n range_time << \"#{time}:30 am\"\n end\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 pm\"\n range_time << \"#{time}:30 pm\"\n end\n range_time\n end",
"def live_slots\n slots = []\n\n unless live_delivery_block_end_time.blank? || live_delivery_block_start_time.blank?\n available_hours = live_delivery_block_end_time - live_delivery_block_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: live_delivery_block_start_time + i.hours,\n to: live_delivery_block_start_time + (i + 1).hours,\n type: :live\n }\n end\n end\n\n slots\n end",
"def random_range_start\n base.to_datetime + (rand(1..30) * 30).minutes\n end",
"def timeslots\n\t\tif (self != nil)\n\t\t\tcompany = self.company\n\t\t\tstart_time = company.start_time\n\t\t\tend_time = company.end_time\n\t\t\tcompany_duration = (( end_time - start_time )/60).round(2)\n\t\t\tno_of_slots = ( company_duration / (self.time_slot.hour*60 + self.time_slot.min) ).to_i\n\t\t\ttime_slot_array =Array.new\n\t\t\tremember_hour = start_time.hour.round\n\t\t\tremember_min = start_time.min\n\t\t\tno_of_slots.times do | index |\n\t\t\t\ta = remember_hour == 0 ? \"00\" : remember_hour\n\t\t\t\tb = remember_min == 0 ? \"00\" : remember_min\n\t\t\t\tc = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour == 0 ? \"00\" :((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\td = (remember_min + self.time_slot.min) % 60 == 0 ? \"00\" : (remember_min + self.time_slot.min) % 60\n\t\t\t\ttime_slot_array << [\"#{a}:#{b}-#{c}:#{d}\", index]\n\t\t\t\tremember_hour = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\tremember_min = (remember_min + self.time_slot.min) % 60\n\t\t\tend\n\t\t\ttime_slot_array\n\t\tend\n\tend",
"def time_range\n start_time..end_time\n end",
"def open_slots(date)\n time = date.to_time\n \n slots = []\n prev_time = time - 30.minutes\n loop do\n start_time = prev_time + 30.minutes\n \n if start_time.to_date == date\n slots << Slot.new(starts_at: start_time, cat: self)\n prev_time = start_time\n else\n break\n end\n end\n \n # Remove taken/past timeframes\n slots.reject do |slot|\n Reservation.exists?(cat: self, starts_at: slot.starts_at) || slot.starts_at.past?\n end\n end",
"def times_for_schedule_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_day + 15.hours\n task_time += 1.day if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.day\n end\n\n times\n end",
"def time_range\n return 0 if start_hour.blank? || start_minute.blank?\n\n return 0 if end_hour.blank? || end_minute.blank?\n\n hours_between_times\n end",
"def build_ends_at(entity, begins_at)\n reservation_periods = entity.reservation_periods.includes(:period_unit)\n if reservation_periods.empty?\n # The entity does not have any reserve periods: insert a temporary fake reserve period of a half hour to use for building the length\n reservation_periods = [build(:reservation_period, period_unit: TimeUnit.find_by!(key: 'half_hour'))]\n end\n\n # Determine minimum and maximum length we want to allow\n min_length = entity.min_reservation_length_seconds || 0\n if entity.max_reservation_length_seconds.present?\n max_length = entity.max_reservation_length_seconds # Use the defined maximum length\n else\n # The max length is 50 times the largest reserve period with a maximum of one year (for performance reasons)\n max_length = [reservation_periods.sort_by(&:length).last.length * 50, 1.year].min\n end\n\n desired_length = min_length + rand(max_length - min_length) # The desired length of the reservation we want to at least achieve. This is a random function that centers between the min and max length.\n\n # Build a length which is a combination of random reserve periods and is at least the desired length (and at most the maximum length)\n length = 0\n while length < desired_length do\n max_remaining_length = max_length - length # Determine the remaining length we can use\n reservation_period = reservation_periods.select { |rp| rp.length < max_remaining_length }.sample # Pick a random reserve period that does not exceed this length\n if reservation_period.present?\n length += reservation_period.length # Apply the reserve period\n else\n break # Stop building length if we cannot find a suitable reservation_period anymore\n end\n end\n\n begins_at + length\nend",
"def manage_time_slots\n @time_slot = TimeSlot.new\n\n end",
"def reserved_slots(date)\n Reservation.confirmed.where(nook_id: self.id)\n .happening_within(date.beginning_of_day..date.end_of_day)\n .map do |r|\n r.start.strftime('%H%M').to_i..\n (r.end + 1.seconds).strftime('%H%M').to_i\n end\n end",
"def time_slot_range_label(time_slot)\n start_time = time_slot.start_time.to_s(:time_slot_short)\n end_time = time_slot.end_time.to_s(:time_slot_long)\n \"#{start_time} - #{end_time}\"\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def make_players(id_range)\n players = []\n id_range.each do |player_id|\n players << generate_player(player_id)\n end\n players\nend",
"def time_intervals(program,insert_repeat_interval = true)\n intervals = map{|d|d.time_intervals}.flatten.uniq.find_all{|i|program.interval === i.tstart}\n if program.repeat_first_interval and insert_repeat_interval\n firstinterval = intervals.min.copy\n firstinterval.shift!(-program.resolution*60)\n intervals << firstinterval\n end\n intervals\n end",
"def get_busy_slots(start_min, start_max, time_zone)\n result = Array.new\n @googleCalendars.each do |x|\n result.push(x[:connection].query([x[:id]],start_min, start_max, time_zone))\n end\n return result\n end",
"def car_slots_ordered(start_time, num_slots)\n self.car_slots.where(\"start_time >= ? AND end_time <= ?\", start_time, start_time.advance(:days => +num_slots)).order(:start_time)\n # TODO: handle case where num slots returned != num slots requested (probably means we forgot to create enough car slots)\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def reserve_time_slot(id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :participant_id,\n :cancel_existing,\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/calendar_events/{id}/reservations\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end",
"def random_range_end(start)\n start + (rand(1..5) * 30).minutes\n end",
"def set_time_frame time, time_slot = 30.minutes\n Time.at(((time.to_i / time_slot).round * time_slot) + time_slot).to_i\n end",
"def date_calc(start,day_start,day_duration,round)\n time=start;schedule=[]\n round.size.times do |r|\n#print day_start+day_duration;print \"\\n\"\n if time >= day_start + day_duration\n#print time;print \"\\n\"\n time=day_start+1.day\n day_start = time\n end\n schedule[r] = time\n time+=HEAT_INTERVAL\n end\n\n return schedule\n end",
"def slice( start, stop )\n \n start_point = create_period( calculate_bucket( TimeSeries.Normalise_Time( start ) ) )\n stop_point = create_period( calculate_bucket( TimeSeries.Normalise_Time( stop ) ) )\n\n # Create a new TimeSeries object with the same resolution as\n # self, and clones of each bucket from start to stop.\n \n new_slice = TimeSeries.new( @resolution_unit )\n\n ( start_point .. stop_point ).each do |period|\n if not @buckets[period].empty? then\n new_slice[period] = @buckets[period].clone\n end\n end\n \n new_slice\n end",
"def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end",
"def merge_ranges(schedule)\n merged_schedule = []\n\n schedule.each do |meeting|\n overlapping_time_slots = check_times(meeting, merged_schedule)\n merged_schedule -= overlapping_time_slots if merged_schedule.include?(overlapping_time_slots)\n merged_schedule << slot_merger(overlapping_time_slots)\n end\n\n merged_schedule\nend",
"def remove_time_slot\n\n end",
"def initialize(free_slot_input)\n @free_slots = JSON.parse(free_slot_input.to_json)\n\n # convert String datetime to an integer format for easy comparisons\n for elem in @free_slots \n elem['start'] = (DateTime.parse elem['start']).strftime('%s').to_i\n elem['end'] = (DateTime.parse elem['end']).strftime('%s').to_i\n end\n end",
"def block_delivery_start_time\n unless delivery_slots_from.blank?\n delivery_slots_from.round_up(60.minutes)\n end\n end",
"def times_for_send_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_hour + 30.minutes\n task_time += 1.hour if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.hour\n end\n\n times\n end",
"def time_slot_interval\n return @time_slot_interval\n end",
"def from_meeting_rooms!(meeting_rooms)\n @time_slots = []\n meeting_rooms.each do |meeting_room|\n meeting_room.time_slots.each do |time_slot|\n if time_slot.is_a? TimeSlot\n @time_slots << time_slot.duration_in_minutes\n end\n end\n end\n self\n end",
"def to_range(from, to, step)\n to_time(from).to(to_time(to), step.minutes).collect { |t| t.to_s(:hrs_and_mins)} if step > 0\n end",
"def time_slot_params\n params.require(:time_slot).permit(:name, :begins_at, :ends_at)\n end",
"def timeslot_params\n params.require(:timeslot).permit(:user_id, :start_at, :end_at)\n end",
"def range(start, finish)\n {\n 'duration' => ((finish - start) * 1000).to_i,\n 'start' => [start.to_i, start.usec/1000].join(''),\n #'end' => [finish.to_i, finish.usec/1000].join('')\n }\n end",
"def range(start, finish)\n {\n 'duration' => ((finish - start) * 1000).to_i,\n 'start' => [start.to_i, start.usec/1000].join(''),\n 'end' => [finish.to_i, finish.usec/1000].join('')\n }\n end",
"def slot_params\n params.require(:slot).permit(:start_time, :end_time)\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def start_end_time\n errors[:start_time] << _('errors.invalid_shift_time') if start_time.to_i > end_time.to_i\n end",
"def time_slot_interval=(value)\n @time_slot_interval = value\n end",
"def generate_schedule(courses)\n num_days = 5\n num_time_slots = 111 # num of 5 minute intervals from 8:00am - 5:15pm\n schedule = Array.new(num_time_slots) { Array.new(num_days, 0)} # important !!!!!\n \n courses.each do |course|\n if course.meetingtime_start.nil? or course.meetingtime_end.nil? or \n course.meeting_days.nil?\n next\n end\n \n start_time = parse_time(course.meetingtime_start)\n end_time = parse_time(course.meetingtime_end)\n days = parse_day(course.meeting_days)\n schedule = insert_course(schedule, days, start_time, end_time)\n end\n \n # print_schedule(schedule)\n \n return schedule\n end",
"def timeslot_params\n params.require(:timeslot).permit(:start_time, :duration, :availability, :customer_count)\n end",
"def time_sums(n)\n times = []\n hr = 0\n until hr == 24\n min = 0\n until min == 60\n min_sum = min.to_s.split('').map(&:to_i).reduce(&:+)\n hr_sum = hr.to_s.split('').map(&:to_i).reduce(&:+)\n sum = min_sum + hr_sum\n\n minString = min.to_s.split('')\n hrString = hr.to_s.split('')\n\n minString.unshift('0') until minString.length == 2\n hrString.unshift('0') until hrString.length == 2\n\n times << hrString.join('') + \":\" + minString.join('') if sum == n\n\n min += 1\n end\n hr += 1\n end\n times\nend",
"def range_start=( value ); @range_start = value; rationalise_dates(); end",
"def generate_schedule\n \tschedule = Array.new\n \tqueue = Array.new\n \tcurrent_job = nil\n \tcurrent_job_execution_time = 0\n\n \tfor time in 0...hyper_period\n \t\t# add released tasks to queue\n \t\tqueue += get_released_jobs time\n\n \t\t# give the current job credit for execution in last step\n \t\tcurrent_job_execution_time += 1 unless current_job.nil?\n\n \t\t#check if current task is finished\n \t\tif !!current_job and current_job[:task].worst_case_execution_time == current_job_execution_time\n \t\t\t#task is finished\n \t\t\tcurrent_job = nil\n \t\t\tcurrent_job_execution_time = 0\n \t\tend\n\n \t\t#find a task to execute\n \t\tif current_job.nil?\n \t\t\tcurrent_job = get_highest_priorty_task(queue)\n \t\t\tqueue.delete(current_job)\n \t\tend\n\n \t\t# if we are missing a deadline task set is not schedulable\n \t\tif !!current_job and time >= current_job[:deadline]\n \t\t\treturn nil\n \t\tend\n\n \t\t# add current job to schedule\n \t\tschedule.push(current_job.nil? ? 0 : current_job[:task].id)\n\n \t\t#log whats executing in this slot\n \t\t#puts \"Slot #{time + 1} \" + (current_job.nil? ? \"Idle\" : current_job[:task].name)\n \tend\n\n \t# if queue isn't empty, then return nil\n \treturn nil unless queue.empty?\n\n \t#return schedule\n \tschedule\n end",
"def time_slots_list_params\n params.require(:time_slots_list).permit(:start_date, :end_date, :duration, :event_name, :group, :priority)\n end",
"def time_slot_duration(time_slot)\n diff = time_slot.ends_at - time_slot.starts_at\n diff += 2400 if diff < 0\n hour, minute = diff.divmod 100\n result = \"#{hour}hr\"\n result << \" #{minute}min\" unless minute == 0\n result\n end",
"def index\n if params[:date_range].blank?\n @time_slots = TimeSlot.all\n else\n input_start_time =\n input_end_time = \n @time_slots = TimeSlot.where(\"start_time > ? AND end_time < ?\", input_start_time, input_end_time)\n end\n end",
"def retirement_range\n #large simulation\n (1..30)\n end",
"def inc_time_slot\n # ex. with 4 bits -> we want range 1..15, \n @lock.synchronize{@current_slot = (@current_slot % @max_slot) + 1}\n end",
"def base_for_time_range_components\n Time.current.beginning_of_day\n end",
"def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend",
"def month_range start_time, end_time\n start_date = start_time.month_start.to_date\n end_date = end_time.month_start.to_date\n current_date = start_date\n result = []\n while current_date <= end_date\n result << current_date.to_time\n current_date = current_date.next_month\n end\n result\nend",
"def get_periods(first_start, first_end) \n\t\tperiods = []\n\n\t\tnot_ends = \n\t\t\t(@until.is_a? Fixnum) ?\n\t\t\tlambda {|i,d| i < @until} :\n\t\t\tlambda {|i,d| d < @until}\n\n\t\tduration = first_end - first_start\n\t\tcurrent_start = first_start\n\n\t\ti = 0\n\t\twhile not_ends.call(i, current_start)\n\t\t\tperiods << [current_start, current_start + duration]\n\n\t\t\tcurrent_start += @period_duration\n\t\t\ti +=1\n\t\tend\n\n\t\tperiods\n\tend",
"def dayrange(start, finish)\n if start > finish\n s = start\n start = finish\n finish = s\n end\n days = [start]\n day = start + 1.day\n while day <= finish\n days << day\n day += 1.day\n end\n days\n end",
"def range_start; range.first; end",
"def random_time_range\n i = Array((3..20)).sample\n [(Date.current - i.months).iso8601, (Date.current + i.months).iso8601]\n end",
"def generate_schedule\r\n match_list = make_match_list\r\n schedule = make_empty_schedule\r\n # pp match_list\r\n # pp match_list.size\r\n\r\n scheduled_matches = []\r\n referee_count = 0\r\n move_to_next_slot = false\r\n\r\n schedule.each do |day|\r\n # puts \"#{day[:day]}\"\r\n day[:slots].each do |slots|\r\n # puts \" #{slots[:time]}\"\r\n\r\n match_count = -1\r\n move_to_next_slot = false\r\n match_to_validate = {}\r\n\r\n slots[:matches].each do |match|\r\n # puts \" scheduled (#{scheduled_matches.size})\"; pp scheduled_matches\r\n # puts \"match list (#{match_list.size})\"; pp match_list\r\n # puts \" to_val: \"; pp scheduled_matches\r\n while(!validate_rest_time(match_to_validate, scheduled_matches))\r\n match_count += 1 #next match on match_list\r\n # puts \" CLASH: mc=#{match_count} \"\r\n match_to_validate = {:teams=>match_list[match_count],:day => day[:day], :time => slots[:time]}\r\n\r\n if(match_list.size == match_count)\r\n # puts \"----> Move to next slot\"\r\n move_to_next_slot=true\r\n break\r\n end\r\n end\r\n\r\n # puts \"move_to_next_slot: #{move_to_next_slot}\"\r\n \r\n unless(move_to_next_slot)\r\n scheduled_matches << match_to_validate\r\n match[:referees] = REFEREES[referee_count%REFEREES.size]\r\n match[:score] = [0,0]\r\n match[:teams] = match_list.delete_at(match_count)\r\n # print \"Adding match: \"; pp match\r\n # puts \"-\"*34\r\n referee_count += 1\r\n match_count = 0\r\n match_to_validate = {:teams=>match_list[match_count], :day => match[:day], :time => match[:time]}\r\n else\r\n break\r\n end\r\n\r\n end\r\n\r\n end\r\n end\r\n\r\n schedule\r\n end",
"def schedule(startAt,endAt,opts={})\n ## Caching ##\n @schedules ||= {}\n if @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash]\n return @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash]\n end\n ## End Caching ##\n\n # TODO Handle events starting within the range but ending outside of it?\n\n # TODO Offload this selection to the database; okay for testing though\n # NOTE This is actually faster thanks to the query cache for small numbers of operating times, but not very scalable\n #all_regular_operating_times = OperatingTime.find(:all, :conditions => {:place_id => self.id, :override => 0}).select{|t| (t.startDate - 1) <= endAt.to_date and startAt.to_date <= (t.endDate + 1)}\n #all_special_operating_times = OperatingTime.find(:all, :conditions => {:place_id => self.id, :override => 1}).select{|t| (t.startDate - 1) <= endAt.to_date and startAt.to_date <= (t.endDate + 1)}\n # Select all relevant times (1 day buffer on each end)\n # NOTE Make sure to use generous date comparisons to allow for midnight rollovers\n all_regular_operating_times = OperatingTime.regular.by_place_id(self.id).in_range(startAt..endAt).find(:all)\n all_special_operating_times = OperatingTime.special.by_place_id(self.id).in_range(startAt..endAt).find(:all)\n\n puts \"\\nRegular OperatingTimes: #{all_regular_operating_times.inspect}\" if DEBUG\n puts \"\\nSpecial OperatingTimes: #{all_special_operating_times.inspect}\" if DEBUG\n\n regular_times = []\n special_times = []\n special_ranges = []\n\n all_special_operating_times.each do |ot|\n puts \"\\nSpecial Scheduling for: #{ot.inspect}\" if DEBUG\n\n # Special Case: Overriding with NO times (e.g. closed all day)\n if ot.start == 0 and ot.length == 0 and startAt.to_date <= ot.startDate\n # Block out the range, but don't add the \"null Times\"\n special_ranges << Range.new(ot.startDate,ot.endDate)\n next\n end\n\n # Start a day early if possible\n earlyStart = startAt-1.day < ot.startDate.midnight ? startAt.midnight : startAt - 1.day\n puts \"EarlyStart: #{earlyStart.inspect}\" if DEBUG\n\n # Calculate the next set up open/close times\n open,close = ot.next_times(earlyStart)\n next if open.nil? # No valid occurrences in the future\n\n while not open.nil? and open <= endAt do\n if DEBUG\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n puts \"Start Date: #{ot.startDate} (#{ot.startDate.class})\"\n puts \"End Date: #{ot.endDate} (#{ot.endDate.class})\"\n end\n\n if close < startAt # Skip forward to the first occurrance in our time range\n puts \"Seeking: #{close} < #{startAt}\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n special_times << [open,close]\n special_ranges << Range.new(ot.startDate,ot.endDate)\n open,close = ot.next_times(close)\n end\n\n end\n\n puts \"\\nSpecial Times: #{special_times.inspect}\" if DEBUG\n puts \"\\nSpecial Ranges: #{special_ranges.inspect}\" if DEBUG\n\n all_regular_operating_times.each do |ot|\n puts \"\\nRegular Scheduling for: #{ot.inspect}\" if DEBUG\n\n # Start a day early if possible\n earlyStart = startAt-1.day < ot.startDate.midnight ? startAt : startAt - 1.day\n puts \"EarlyStart: #{earlyStart.inspect}\" if DEBUG\n\n # Calculate the next set up open/close times\n open,close = ot.next_times(earlyStart)\n if DEBUG\n puts \"\"\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n end\n\n if open.nil? # No valid occurrences in the future\n puts \"Skipping: No valid occurrences in the future.\" if DEBUG\n next\n end\n\n while not open.nil? and open <= endAt do\n if DEBUG\n puts \"\"\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n end\n\n if close < startAt # Skip forward to the first occurrance in our time range\n puts \"Seeking: #{close} < #{startAt}\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n overridden = false\n special_ranges.each do |sr|\n overridden ||= sr.member?(open.to_date)\n end\n if overridden\n puts \"Overridden\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n # FIXME Causing an infinite loop; would be nice if this worked\n #open = startAt if open < startAt\n #close = endAt if close > endAt\n\n regular_times << [open,close]\n open,close = ot.next_times(close)\n end\n\n end\n\n puts \"\\nRegular Times: #{regular_times.inspect}\" if DEBUG\n\n # TODO Handle schedule overrides\n # TODO Handle combinations (i.e. part special, part regular)\n\n final_schedule = (regular_times+special_times).sort{|a,b|a[0] <=> b[0]}\n\n ## Truncate times larger than range ##\n if opts[:truncate]\n final_schedule.each_index do |i|\n final_schedule[i][0] = startAt.dup if final_schedule[i][0] < startAt\n final_schedule[i][1] = endAt.dup if final_schedule[i][1] > endAt\n end\n end\n ## End truncating ##\n\n ## Caching ##\n @schedules ||= {}\n @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash] = final_schedule\n ## End caching ##\n\n final_schedule\n end",
"def range(start, finish, step)\n return [] if start >= finish\n\n Enumerator.new do |y|\n y << start\n while (start += step) < finish\n y << start\n end\n end\n end",
"def create\n @event = Event.find(params[:timeslot][:event_id])\n redirect_to event_path(@event) unless current_user.user_role.can_create\n\n # Used as increment\n count = params[:timeslot][:count].to_i\n\n # Formats time parameters for use in Time object\n start_time_hour = params[:timeslot]['start_time(4i)'].to_i\n end_time_hour = params[:timeslot]['end_time(4i)'].to_i\n start_time_minute = params[:timeslot]['start_time(5i)'].to_i\n end_time_minute = params[:timeslot]['end_time(5i)'].to_i\n\n # Formats start time\n minutes = start_time_minute\n hours = start_time_hour\n string_time = \"#{hours}:#{minutes}\"\n\n # Creates Time objects for start and end time\n end_time = Time.find_zone('UTC').parse(\"#{end_time_hour}:#{end_time_minute}\")\n time = Time.find_zone('UTC').parse(string_time)\n\n # Redirects to new form if count is not provided and if start time is larger than end time\n # Creates Timeslot objects otherwise\n if time > end_time || count < 10\n redirect_to new_timeslot_path(event_id: params[:timeslot][:event_id])\n else\n # Creates timeslots by starting at start time and skip counting\n # (using 'count' variable) to end time\n while time <= end_time\n\n timeslot = Timeslot.new\n timeslot.time = time\n timeslot.duration = count\n timeslot.event_id = params[:timeslot][:event_id]\n\n timeslot.save\n\n time += (count * 60)\n end\n\n # Redirects to the event page for the timslots' event\n @eventid = params[:timeslot][:event_id]\n @event_exit = Event.find(@eventid)\n redirect_to @event_exit\n end\n end",
"def generate_range(min, max, step)\n array = []\n\n while min <= max\n\n array << min\n min += step\n end\n puts array\nend",
"def active_period\n [[@starting, @from].max, [@to - 1, @ending].min] # -1 sec: include only last unit day\n end",
"def minimum_participants(min=2)\n select { |timeslot, participants|\n participants.count >= min\n }\n end",
"def create\n @plan = SemesterPlan.new(plan_params)\n if @plan.save\n [\"Montag\", \"Dienstag\", \"Mittwoch\", \"Donnerstag\", \"Freitag\"].each do |day|\n start_time = 8\n 4.times do\n timeslot = @plan.time_slots.create!(start: start_time, end: start_time + 2, day: day)\n start_time += 2\n end\n end\n flash[:success] = \"Erstellen erfolgreich\"\n redirect_to semester_plan_path @plan\n else\n flash[:danger] = \"Erstellen fehlgeschlagen\"\n redirect_to new_semester_plan_path\n end\n\n end",
"def every(step)\n return [@start] unless @finish > @start\n\n [].tap do |range|\n while @start <= @finish do\n range << @start.to_date.to_s\n @start = @start.advance(step)\n end\n end\n end",
"def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend",
"def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end",
"def slot_time\n 0\n end",
"def time_slot_fiber\n # The combinatinos of day groupings\n # HACK: When both days are the same the class meets once per week.\n day_groups = [ [:monday, :thursday],\n [:monday, :monday],\n [:tuesday, :friday],\n [:tuesday, :tuesday],\n [:monday, :wednesday],\n [:wednesday, :wednesday],\n [:thursday, :thursday],\n [:friday, :friday] ]\n\n # The set of times that classes meet on any day.\n times_avaliable = [ ['1000', '1120'],\n ['1230', '1350'],\n ['1400', '1520'],\n ['1700', '1820'] ]\n\n # Map day symbols to integer values.\n day_nums = { monday: 1, tuesday: 2,\n wednesday: 3, thursday: 4 , friday: 5 }\n\n # Returns the next set of meeting times\n return Fiber.new do\n # Pick a random day and time combination.\n\n while true # The fiber must flow!\n days = day_groups[rand(day_groups.length)]\n starttime, endtime = times_avaliable[rand(times_avaliable.length)]\n Fiber.yield(days.map do |day|\n Meeting.new({ day: day_nums[day], starttime: starttime, endtime: endtime })\n end)\n end\n end\n end",
"def find_in_range(time_from:, time_to:, time_windows: time_span_windows)\n #puts \"find_in_range, Recieve: diff: #{(time_to - time_from)}, time_from: #{time_from}, time_to: #{time_to}, time_window_left: #{time_windows.size}\"\n return [] if (time_to - time_from) < shorter_time_window_span\n\n while bucket = time_windows.shift\n next unless found_windows = find_fitting_windows(time_from, time_to, bucket)\n return found_windows +\n find_in_range(time_from: time_from, time_to: found_windows.first.fetch(:window_starts), time_windows: time_windows.clone) +\n find_in_range(time_from: found_windows.last.fetch(:window_finishes), time_to: time_to, time_windows: time_windows.clone)\n end\n end",
"def from_ranges\n self[:date_time_slot] = RangeSupport.range_to_string(self[:date_time_slot])\n end",
"def merged_meetings_2(meeting_time_ranges)\n # merged_meetings where we cannot assume how many time blocks\n meeting_time_ranges = meeting_time_ranges.sort\n\n merged_meeting_times = []\n\n last_start_time = nil\n last_end_time = nil\n meeting_time_ranges.each do |meeting_time_range|\n start_time = meeting_time_range[0]\n end_time = meeting_time_range[1]\n\n if last_start_time.nil? # no values have been stored yet\n last_start_time = start_time\n last_end_time = end_time\n next\n end\n\n if start_time <= last_end_time # current start_time is before the last end_time\n if start_time < last_start_time\n # current start_time earlier than last_start_time - assign as last_start_time\n last_start_time = start_time\n end\n\n if end_time > last_end_time\n # current end_time later than last_end_time - assign it end_time as last_end_time\n last_end_time = end_time\n end\n next\n end\n\n if start_time > last_end_time\n # we have reached the start of a new range - store the last range\n merged_meeting_times << [last_start_time, last_end_time]\n\n # reset the last_end_time and last_start_time to the current values\n last_start_time = start_time\n last_end_time = end_time\n next\n end\n end\n\n # be sure to append the remaining last meeting time range\n merged_meeting_times << [last_start_time, last_end_time]\n\n merged_meeting_times\nend",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def time_slot_params\n params.require(:time_slot).permit(:start_time, :end_time, :capacity, :closed, :chartertype, :comments, :price)\n end",
"def merged_meetings(meeting_time_ranges)\n # assuming meetings can fall at most 12 30-minute blocks past 9am\n start_times = Array.new(13, nil) # array of start times at their index\n end_times = Array.new(13, nil) # array of end times - their index is their start time\n meeting_time_ranges.each do |meeting_time_range|\n start_time = meeting_time_range[0]\n end_time = meeting_time_range[1]\n\n # add start_time to start_times\n start_times[start_time] = start_time\n\n # add end_time to end_times at its start_time index, unless there is already a later end_time at that index\n end_times[start_time] = end_time unless !end_time[start_time].nil? && end_time[start_time] > end_time\n end\n\n merged_meeting_times = []\n\n # start_times look something like [0, nil, nil, 3, 4, nil, nil, nil, nil, 9, 10, nil]\n # end_times look something like [1, nil, nil, 5, 8, nil, nil, nil, nil, 10, 12, nil]\n last_start_time = nil\n last_end_time = nil\n start_times.each do |start_time|\n next if start_time.nil?\n\n if last_start_time.nil? # no values have been stored yet\n last_start_time = start_time\n last_end_time = end_times[start_time]\n next\n end\n\n if start_time <= last_end_time # current start_time is before the last end_time\n if start_time < last_start_time\n # current start_time earlier than last_start_time - assign as last_start_time\n last_start_time = start_time\n end\n\n if end_times[start_time] > last_end_time\n # current end_time later than last_end_time - assign it end_time as last_end_time\n last_end_time = end_times[start_time]\n end\n next\n end\n\n if start_time > last_end_time\n # we have reached the start of a new range - store the last range\n merged_meeting_times << [last_start_time, last_end_time]\n\n # reset the last_end_time and last_start_time to the current values\n last_start_time = start_time\n last_end_time = end_times[start_time]\n next\n end\n end\n\n # be sure to append the remaining last meeting time range\n merged_meeting_times << [last_start_time, last_end_time]\n\n merged_meeting_times\nend",
"def repeat min = nil, max = nil\n ParsletRepetition.new self.to_parseable, min, max\n end",
"def schedule_slots(params = {})\n scope 'user_schedule'\n post('/schedule/slots/', params)\n end",
"def start=(time); end",
"def create_range_partition_of(parent_table_name, options)\n if (options[:range_start].nil? || options[:range_end].nil?) && options[:default].blank?\n raise ArgumentError, 'range_start and range_end or default must be defined'\n end\n\n Tablature.database.create_range_partition_of(parent_table_name, options)\n end",
"def create_shifts(contiguous_timings)\n contiguous_timings.each{|timing| create_shift(timing)}\n end",
"def schedule(start = 0, stop = 100)\n\n # Sort intervals by end point asc\n # iterate from left to right\n # at each endpoint find the max weight from the start to that endpoint\n # Make a comparison if the start of the interval is after the end of the previous \"checkpoint\"\n # add the weight adn that is the new checkpoint\n # if it overlaps then select the larger of the two endpoints\n # This is almost right but not quite\n # we want to break up at previously weighed sectionif we need to\n # we shodul get keep the list of all endpoints weights\n\n # x---x\n # x----x\n # x-------x\n\n # 1,4,3\n # 5,9,4\n # 7,12,5\n\n # Keep the checkpoints here\n # [4:3, 9:7]\n # then see 7,12,5\n # choose 5 or 7 we'd say 7 and may want to do say 7 is max from 0<=>12\n # but if we split it up\n # [4:3, 9:7, 12:8]\n # we could get max 8 if we exclude the middle one\n\n endpoints = []\n interval_list = sort(@interval_list)\n\n interval_list.each do |interval|\n max_weight = interval.weight\n steps = []\n\n # endpoint list is sorted so ya konw we could just do binary search here\n # woudl bring the whoel thing down to nlgn\n endpoints.reverse.each do |endpoint|\n if interval.start > endpoint.stop\n max_weight += endpoint.best_weight\n steps = endpoint.steps.clone\n break\n end\n end\n\n # If we do better by ignoring this interval than record that\n if endpoints.last && endpoints.last.best_weight > max_weight\n max_weight = endpoints.last.best_weight\n steps = endpoints.last.steps\n else\n steps << interval\n end\n\n endpoints << EndpointWeight.new(interval.stop, max_weight, steps)\n end\n\n # endpoints is non-decrasing with each entry. Last must be max\n puts endpoints.last\n endpoints.last.best_weight\n end",
"def rand_step_func max_footprint, min_steps, max_steps, floor = 0.0\n steps = []\n step_ranges = interval_sample(0, max_footprint, rand_int(min_steps - 1, max_steps - 1)).sort + [max_footprint]\n probs = interval_sample(floor, 1, step_ranges.length, 6).sort.reverse\n step_ranges.each_with_index do |footprint, i|\n steps << {'cum_footprint' => footprint, 'p' => probs[i]}\n end\n DecreasingStepFunction.new steps\n end",
"def build_begins_at(entity)\n last_reservation = entity.reservations.where('ends_at >= ?', Time.zone.now).reorder(ends_at: :desc).first\n if last_reservation.present?\n last_reservation.ends_at + rand(72).hours\n else\n (Time.zone.now + 1.hour).beginning_of_hour\n end\nend",
"def expand_service_range\n self.service_start_date ||= (service_except_dates + service_added_dates).min\n self.service_end_date ||= (service_except_dates + service_added_dates).max\n true\n end",
"def timeslot_params\n params.require(:timeslot).permit(:start, :end, :faculty_id)\n end",
"def build_buckets(unit=:all, step=1)\n\t\thour = 60 * 60\n\t\tday = 24 * hour\n\n\t\tif step.nil?\n\t\t\tstep = 1\n\t\tend\n\n\t\tif unit.nil?\n\t\t\tunit = :all\n\t\tend\n\n\t\tbuckets = []\n\n\t\tcase unit\n\t\twhen :all\n\t\t\tbuckets << {start_date: time_frame.start_date, end_date: time_frame.end_date, objects: []}\n\n\t\twhen :year\n\t\t\tyear = time_frame.start_date.year\n\t\t\tbucket_start = Time.mktime(year, 1, 1)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.mktime(year+=step, 1, 1)\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\n\t\twhen :month\n\t\t\tmonth = time_frame.start_date.mon\n\t\t\tyear = time_frame.start_date.year\n\t\t\tbucket_start = time_frame.start_date\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_start = Time.mktime( year, (month) )\n\n\t\t\t\tmonth+=step\n\t\t\t\tif (month-12) > 0\n\t\t\t\t\tyear += 1\n\t\t\t\t month = month-12\n\t\t\t\tend\n\n\t\t\t\tbucket_end = Time.mktime(year, (month) )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\tend\n\n\t\twhen :day\n\t\t\tbucket_start = Time.mktime(time_frame.start_date.year, time_frame.start_date.mon, time_frame.start_date.day)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.at( bucket_start.to_i + step*day )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\n\t\twhen :hour\n\t\t\tbucket_start = Time.mktime(time_frame.start_date.year, time_frame.start_date.mon, time_frame.start_date.day, time_frame.start_date.hour)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.at( bucket_start.to_i + step*hour )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\t\tend\n\n\t\tbuckets.first[:start_date] = time_frame.start_date\n\t\tbuckets.last[:end_date] = time_frame.end_date\n\n\t\treturn buckets\n\tend"
] | [
"0.7170792",
"0.6663513",
"0.6558084",
"0.6462332",
"0.64136404",
"0.6384976",
"0.6365225",
"0.63063604",
"0.6271311",
"0.6268339",
"0.61531085",
"0.6131482",
"0.6111703",
"0.597443",
"0.59514713",
"0.59509254",
"0.5946872",
"0.58817",
"0.5870683",
"0.58646303",
"0.5817582",
"0.57943964",
"0.5789449",
"0.5682598",
"0.56554264",
"0.56107026",
"0.55570567",
"0.5514249",
"0.5509991",
"0.55089676",
"0.5495149",
"0.5486934",
"0.5480513",
"0.54789954",
"0.5467167",
"0.5463121",
"0.546145",
"0.5454576",
"0.5452416",
"0.54454654",
"0.54324335",
"0.53865886",
"0.5363141",
"0.53549224",
"0.53544384",
"0.5350751",
"0.5338917",
"0.53383994",
"0.5334712",
"0.53344786",
"0.53295743",
"0.53164834",
"0.5315258",
"0.5313246",
"0.5312264",
"0.5311177",
"0.5311017",
"0.5308366",
"0.53004867",
"0.52939665",
"0.5289544",
"0.5284744",
"0.5283805",
"0.5283018",
"0.52816796",
"0.5273563",
"0.52673143",
"0.52273947",
"0.5221244",
"0.52200145",
"0.52189964",
"0.52189606",
"0.52162147",
"0.51985586",
"0.5193404",
"0.51896065",
"0.51882184",
"0.51866984",
"0.5182801",
"0.51824045",
"0.51704055",
"0.5165247",
"0.5164316",
"0.51555544",
"0.51478755",
"0.514441",
"0.5140865",
"0.5139226",
"0.5123747",
"0.5110748",
"0.5107945",
"0.51071185",
"0.5098921",
"0.5096446",
"0.50923854",
"0.50912833",
"0.508828",
"0.5087642",
"0.5083547",
"0.507786"
] | 0.63567793 | 7 |
Return all valid TimeBlock(s) for a given base time. | def valid_blocks(base_time)
set_base_time(base_time)
time_entries = time_entries_for(base)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def available_delivery_blocks(time)\n\n unless opens_today\n return []\n end\n\n # Reset date to compare with Postgres Time\n time = time.change(:month => 1, :day => 1, :year => 2000)\n\n lead_time_for_block_time_slots = 1.hour\n\n all_slots = block_slots.select { |slot| slot[:from] >= (time + lead_time_for_block_time_slots) } +\n live_slots.select { |slot| slot[:from] >= (time) }\n\n all_slots.map do |slot|\n {\n :from => slot[:from].strftime('%H:%M'),\n :to => slot[:to].strftime('%H:%M'),\n :type => slot[:type]\n }\n end\n end",
"def get_block_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n next if line !~ /^Block times/\n values = []\n # Block times are given as a space-separated list of start,end pairs. They\n # are in units of seconds * 1e5, so convert them to seconds here for\n # consistency.\n if line =~ /^[^:]+: (.*?)\\s*$/\n values = $1.split(\" \").map{|r| r.split(\",\").map{|v| v.to_f / 1e5}}\n end\n to_return << values\n end\n to_return\nend",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.minutes, time_entry\n\n # Stash the current session onto the slot as well, so it may handle\n # some of it's own session based logic.\n slot.session = session\n\n # finally increment the time for the next iteration\n time = time + block_size.minutes\n\n slot\n end\n\n # Detect deadspace at the TimeSlot layer.\n # If found, we add a final TimeSlot to make up the difference.\n if time < time_entry.end_time\n slots << TimeSlot.new(time, time_entry.end_time, time_entry)\n end\n\n # Return the aggregated slot collection\n slots\n end",
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def valid_appointments(base_time)\n transform_blocks_to_appointments(valid_blocks(base_time))\n end",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def block_slots\n slots = []\n\n unless block_delivery_end_time.blank? || block_delivery_start_time.blank?\n\n available_hours = block_delivery_end_time - block_delivery_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: block_delivery_start_time + i.hours,\n to: block_delivery_start_time + (i + 1).hours,\n type: :daytime\n }\n end\n end\n\n slots\n end",
"def index\n @time_blocks = TimeBlock.all\n end",
"def time_to_block(time)\n Rational(time / time_divisor).floor * time_divisor\n end",
"def makeBlocks(days, startTimeString, endTimeString, info)\n\tblocks = []\n\tdays.split(\"\").each do |d|\n\t\tb = SCHBlock.new(d, startTimeString, endTimeString, info)\n\t\tblocks << b\n\tend\n\t(blocks)\nend",
"def time_fragments\n []\n end",
"def available_on(base_time)\n # Stash this for future use, as we will be using it to set a\n # baseline date in order to derive a bunch of different appointments\n # from.\n set_base_time(base_time)\n\n # Fetch all TimeEntris related for this date query.\n time_entries = time_entries_for(base)\n\n # Transform TimeEntry(s) -> TimeSlot(s).\n available_slots = generate_time_slots(time_entries)\n\n # Combine all sequential linear slots to into a single window.\n # This produces multiple windows\n windows = combine_linear_slots(available_slots)\n\n # Generate TimeBlocks from the Available Slot ranges\n open_time_blocks = generate_time_blocks(windows)\n\n # Optimize & Filter our wide collection of TimeBlocks.\n optimized_blocks = optimize_time_blocks(open_time_blocks)\n\n # Finally, present the TimeBlock(s) as Appointment records\n # to the Customer.\n final = transform_blocks_to_appointments(optimized_blocks)\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def get_busy_slots(start_min, start_max, time_zone)\n result = Array.new\n @googleCalendars.each do |x|\n result.push(x[:connection].query([x[:id]],start_min, start_max, time_zone))\n end\n return result\n end",
"def time_block_params\n params[:time_block]\n end",
"def get_all_thermal_blocks()\n zones = find_all_commands(\"ZONE\")\n end",
"def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end",
"def slots\n slot_start = start_time\n slot_end = slot_start + slot_length\n while slot_end <= end_time\n slot = ::V2::TimeSlot.new(start_time: slot_start, end_time: slot_end, event_id: @event_id)\n @slots << slot if slot.valid? && slot.save\n slot_start = slot_end + buffer\n slot_end = slot_start + slot_length\n end\n\n @slots\n end",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def get_all_blocks\n\n @all_blocks = Block.where(is_published: 't')\n\n end",
"def valid_schedule?(time_blocks)\n time_blocks = quicksort_timeblocks(time_blocks)\n return !exists_overlap?(time_blocks)\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def get_time_slot_array\n time_slot_array = [\"07:00\", \"07:30\", \"08:00\", \"08:30\", \"09:00\", \"09:30\", \"10:00\", \"10:30\",\n \"11:00\", \"11:30\", \"12:00\", \"12:30\", \"13:00\", \"13:30\", \"14:00\", \"14:30\",\n \"15:00\", \"15:30\", \"16:00\", \"16:30\", \"17:00\", \"17:30\", \"18:00\", \"18:30\",\n \"19:00\", \"19:30\", \"20:00\", \"20:30\", \"21:00\"]\n end",
"def timeslots\n\t\tif (self != nil)\n\t\t\tcompany = self.company\n\t\t\tstart_time = company.start_time\n\t\t\tend_time = company.end_time\n\t\t\tcompany_duration = (( end_time - start_time )/60).round(2)\n\t\t\tno_of_slots = ( company_duration / (self.time_slot.hour*60 + self.time_slot.min) ).to_i\n\t\t\ttime_slot_array =Array.new\n\t\t\tremember_hour = start_time.hour.round\n\t\t\tremember_min = start_time.min\n\t\t\tno_of_slots.times do | index |\n\t\t\t\ta = remember_hour == 0 ? \"00\" : remember_hour\n\t\t\t\tb = remember_min == 0 ? \"00\" : remember_min\n\t\t\t\tc = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour == 0 ? \"00\" :((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\td = (remember_min + self.time_slot.min) % 60 == 0 ? \"00\" : (remember_min + self.time_slot.min) % 60\n\t\t\t\ttime_slot_array << [\"#{a}:#{b}-#{c}:#{d}\", index]\n\t\t\t\tremember_hour = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\tremember_min = (remember_min + self.time_slot.min) % 60\n\t\t\tend\n\t\t\ttime_slot_array\n\t\tend\n\tend",
"def all_timeslots\n unless @all_timeslots.present?\n @all_timeslots = (1..5).map do |day_id|\n Timeslot.new(self, day_id, @day_start_minute, @day_end_minute)\n end\n end\n\n @all_timeslots\n end",
"def unfinished_dispatch_time_ranges\n dispatches.where(safe_return: false).map(&:active_time_window)\n end",
"def live_slots\n slots = []\n\n unless live_delivery_block_end_time.blank? || live_delivery_block_start_time.blank?\n available_hours = live_delivery_block_end_time - live_delivery_block_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: live_delivery_block_start_time + i.hours,\n to: live_delivery_block_start_time + (i + 1).hours,\n type: :live\n }\n end\n end\n\n slots\n end",
"def valid_times_sorted()\n self.valid_times.sort{|a,b|a.from_time <=> b.from_time}\n end",
"def missing_ranges()\n return [] if @time_map.nil?\n @time_map.missing_ranges()\n end",
"def load_time_ranges\n @time_ranges = ActiveSupport::HashWithIndifferentAccess.new\n time_ranges = @config['time']\n time_ranges.each do |t,r|\n time_range = ActiveSupport::HashWithIndifferentAccess.new\n src_ranges ||= r\n src_ranges.map { |k,v| time_range[k.to_sym] = rangify_time_boundaries(v) }\n @time_ranges[t.to_sym] = time_range\n end\n\n end",
"def getblock(hash)\n block = @api.request 'getblock', hash\n block[\"time\"] = Time.at(block[\"time\"]).utc if block.is_a? Hash\n block\n end",
"def blocks_time\n @measurements[PATH_MEASURES].time if @measurements[PATH_MEASURES]\n end",
"def add_blocks_to_schedule(time_blocks, schedule, recurring)\n time_blocks.each do |block|\n day_of_week = block.split(\"_\")[0]\n time = block.split(\"_\")[1]\n start_time = Time.utc(\"2011\", nil, nil, time.split(\" - \")[0])\n end_time = Time.utc(\"2011\", nil, nil, time.split(\" - \")[1])\n \n if Day.exists?(day_of_week, schedule.id)\n day = Day.where(:name => day_of_week, :schedule_id => schedule.id).first\n else\n day = Day.new(:name => day_of_week, :schedule_id => schedule.id)\n day.save\n end\n \n if !TimeBlock.exists?(start_time, end_time, day.id, recurring)\n time_block = TimeBlock.new(:start_time => start_time, :end_time => end_time, :day_id => day.id, :recurring => recurring)\n time_block.save\n end\n end\n end",
"def time\n\talltime = Array.new\n\tslices = 10\n\ti = 0\n\twhile i < slices.to_i do\n\t\talltime.push(Time.now)\n\t\ti+=1\n\tend\n\tyield\nend",
"def each_with_time(&block)\n arr = @v.map.with_index{|v, i| TimeAndValue.new(@start_time+i.hours, v)}\n arr.each(&block)\n end",
"def timecodes\n return [] if start_time.nil?\n start_hour = start_time.strftime(\"%H\")\n start_min = start_time.strftime(\"%M\").to_i < 30 ? \"00\" : \"30\"\n curr_time = Time.parse(\"#{start_hour}:#{start_min}\")\n timecode_array = []\n while curr_time < Time.parse(\"#{end_time.strftime(\"%H\")}:#{end_time.strftime(\"%M\")}\") - 1.second\n timecode_array << \"#{curr_time.strftime(\"%H\").to_i}:#{curr_time.strftime(\"%M\")}\"\n curr_time = curr_time + 30.minutes\n end\n timecode_array_with_days = []\n %w(monday tuesday wednesday thursday friday saturday sunday).each do |day|\n timecode_array_with_days << timecode_array.collect{|t| \"#{t}_#{day}\"}.flatten if read_attribute(day)\n end\n timecode_array_with_days.flatten\n end",
"def blocks\n unless defined?(@blocks)\n bs = block_sizes\n qst = query.starts\n tst = target.starts\n qseqs = query.seqs\n tseqs = target.seqs\n @blocks = (0...block_count).collect do |i|\n SegmentPair.new(query.size, strand, bs[i],\n qst[i], tst[i], qseqs[i], tseqs[i])\n end\n end\n @blocks\n end",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end",
"def next_clean_time(addr) \n #Figure out side of the street\n side = self.get_side(addr) \n \n #Find all blocks that match Street Address \n all_blocks = self.blocks\n blocks = all_blocks.where(\"side = ? AND bottom <= ? AND top >= ?\", side, addr, addr)\n if blocks == []\n return nil\n else \n #Compute the next cleaning times for the block and pick the smallest(i.e. the soonest) time\n cts = Array.new\n blocks.each{|x|cts << x.ct.next_time}\n best = cts.min\n return best, blocks[0].id\n end\n end",
"def validate_block(block)\n # check block ready conditions\n # 1. parent block must already be accepted.\n parent_block = get_block(block.parent_hash)\n raise BlockNotReadyError.new(\"can't find parent block by hash #{block.parent_hash.to_hex}\") unless parent_block\n # TODO 2. pow_chain_ref block must already be accepted.\n # 3. local time must greater or equal than minimum timestamp.\n unless (local_timestamp = Time.now.to_i) >= (minimum_timestamp = genesis_time + block.slot_number * SLOT_DURATION)\n raise BlockNotReadyError.new(\"local_timestamp(#{local_timestamp}) must greater than or equal with minimum_timestamp(#{minimum_timestamp})\")\n end\n end",
"def grandclock(presenthour,&block)\n \n for i in (1..presenthour)\n block.call\n end\n \nend",
"def blocks\n @blocks ||= []\n end",
"def contains_block?(block_of_time)\n if(self.start_time <= block_of_time.start_time &&\n self.end_time >= block_of_time.end_time)\n true\n else\n false\n end\n end",
"def time_bounds\n bounds = envelope.tx.time_bounds\n\n raise Mobius::Client::Error::Unauthorized unless signed_correctly?\n raise Mobius::Client::Error::MalformedTransaction if bounds.nil?\n\n bounds\n end",
"def get_blocks\n @blocks ||= Block.find :all, :conditions => { :show_in_all => '' }\n end",
"def blocks\n @blocks ||= []\n end",
"def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end",
"def init_timevec\n value_hash[:bartime] ||= model.time_vector(symbol, begin_time, end_time)\n compute_timestamps(begin_time, end_time)\n end",
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n {gained_weight: 0, duration: @slots_size})\n @slots << verterx\n\n current_time += @slots_size\n break if current_time >= finish_time\n end\n\n current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight\n end\n end",
"def number_of_compatible_time_blocks_with(schedule)\n compatibilities = 0\n \n # does user have a schedule and does <tt>schedule</tt> exist\n if self.schedule != nil and schedule != nil\n self_days = self.schedule.days\n schedule_days = schedule.days\n \n # are there days in each schedule\n if self_days != nil and schedule_days != nil\n self_days.each do |self_day|\n schedule_days.each do |schedule_day|\n if self_day.name == schedule_day.name\n # are there time blocks in each day\n if self_day.time_blocks != nil and schedule_day.time_blocks != nil\n self_day.time_blocks.each do |self_block|\n schedule_day.time_blocks.each do |schedule_block|\n if self_block.chunk_of_time == schedule_block.chunk_of_time\n compatibilities += 1\n end\n end\n end\n end\n end\n end\n end\n end\n end\n \n compatibilities\n end",
"def is_valid_time?(timeBegin, timeEnd)\n\n\t\t#zone = Timezone.get('America/Chicago').now.zone\n\n\t\t#freebusy method only responds to a couple of months (maybe <=3)\n\t\tresponse = @client.execute(api_method: @service.freebusy.query,\n\t\t\t\t\t body: JSON.dump({\n\t\t\t timeMin: timeBegin,\n\t\t\t timeMax: timeEnd,\n\t\t\t timeZone: 'America/Chicago',\n\t\t\t items:[ id: ENV['NSCS_Calendar_ID']]\n\t\t\t }),\n\t\t\t headers: {'Content-Type' => 'application/json'})\n\t\t@client.authorization.refresh!\n\t\tevents = JSON.parse(response.body)\n\t\t\n\t\t#TODO iteratife over events.\n\t\t\n\tend",
"def blocks_for_block_size\n # We're already done with the last block behavior, if we wanted a small\n # last block, or if we only generated a single block\n return block_list if block_list.size <= 1 || last_block == :small_last\n\n case last_block\n when :truncate_all\n # Implemented in add_for_block_size\n nil\n when :small_last\n # Implemented just above\n nil\n when :truncate_last\n block_list.pop\n else # default to :big_last behavior\n last = block_list.pop\n block_list.last.words.concat(last.words)\n end\n\n block_list\n end",
"def blocks_for_num_blocks\n # Don't create blocks if we have no words\n return [] if @single_block.empty?\n\n # Split the single block into the right size and return\n @single_block.in_groups(@num_blocks, false).each_with_object([]) do |b, ret|\n ret << Block.new(b, I18n.t('lib.frequency.block_count_dataset',\n num: ret.size + 1, total: @num_blocks))\n end\n end",
"def get_blocks\n if (branches = @cur_state.branches[@tape.val])\n branches.map { |branch| branch.block } \n else\n [@cur_state.default]\n end\n end",
"def get_blocks(options = {block_range: (0..0)}, &block)\n get_block_objects(options.merge(object: :block), block)\n end",
"def list_blocked_rooms(start_date, end_date)\n date_valid?(start_date, end_date)\n\n blocked_rooms = []\n\n @blocks.each do |block|\n blocked_rooms += block.rooms\n end\n\n return blocked_rooms\n end",
"def get_start_times\n times = []\n self.start_time.split('%').each do |t|\n times.push(DateTime.strptime(t, '%m-%d-%Y %H:%M'))\n end\n times\n end",
"def optimize_time_blocks(time_blocks)\n Optimizer.new.optimize(time_blocks)\n end",
"def find_show_start_time(start_of_show)\n empty_block_count = 0\n check_if_show_within_hour(start_of_show)\n while @current_time_check <= start_of_show\n if empty_block_count == 4\n @shows_with_blanks << Event.new(start_date_time: @current_time_check - 1.hour, end_date_time: @current_time_check)\n check_if_show_within_hour(start_of_show)\n empty_block_count = 0\n else\n @current_time_check += 15.minutes\n empty_block_count += 1\n end\n end\n return @shows_with_blanks\n end",
"def execute(&block)\n v = @v.map &block\n TimeArray.new(@start_time, v, zone: Time.zone.name)\n end",
"def time_range\n range_time = []\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 am\"\n range_time << \"#{time}:30 am\"\n end\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 pm\"\n range_time << \"#{time}:30 pm\"\n end\n range_time\n end",
"def quicksort_timeblocks(time_blocks)\n if (time_blocks.size <= 1)\n return time_blocks\n end\n\n pivot = time_blocks[0]\n left = []\n right = []\n\n time_blocks[1..time_blocks.size-1].each do |tb|\n if (tb.term.to_i < pivot.term.to_i)\n left.push(tb)\n elsif (pivot.term.to_i < tb.term.to_i)\n right.push(tb)\n elsif (before_in_week(tb.day, pivot.day))\n left.push(tb)\n elsif (before_in_week(pivot.day, tb.day))\n right.push(tb)\n elsif (tb.start_time < pivot.start_time)\n left.push(tb)\n else\n right.push(tb)\n end\n end\n\n sorted_left = quicksort_timeblocks(left)\n sorted_right = quicksort_timeblocks(right)\n time_blocks = sorted_left.push(pivot) + sorted_right\n return time_blocks\n end",
"def restaurant_time_select\n\t\ttimes = (0..23).map { |hour| [formatted_time(hour), hour] }\n\tend",
"def calculate_missed_runs(last_run_time, as_time)\n missed_times = []\n last_time = last_run_time\n while (next_run = next_run_time(last_time, as_time))\n missed_times << next_run\n last_time = next_run\n end\n\n generate_to_enqueue_list(missed_times)\n end",
"def calculate_missed_runs(last_run_time, as_time)\n missed_times = []\n last_time = last_run_time\n while (next_run = next_run_time(last_time, as_time))\n missed_times << next_run\n last_time = next_run\n end\n\n generate_to_enqueue_list(missed_times)\n end",
"def make_block_reservation(number_of_rooms, cost_per_night, check_in, check_out)\n available_rooms = list_available_rooms(Hotel::DateRange.new(check_in, check_out))\n if available_rooms.length < number_of_rooms\n raise StandardError, \"There's no room in the inn\"\n end\n block_reservation = []\n number_of_rooms.times do\n room_number = available_rooms.sample[:room_number]\n reservation = Hotel::Reservation.new(room_number, cost_per_night, check_in, check_out)\n @reservations << reservation\n block_reservation << res\n end\n return block_reservation\n end",
"def validate\n\t\tif not isEmpty(self.time)\n\t\t\terrors.add(:time, \"is already occupied.\")\n\t\tend\n\t\tif not Schedule.isValidTimeSlot(self.schedule, self.time)\n\t\t\terrors.add(:time, \"is not a valid timeslot.\")\n\t\tend\n\tend",
"def test_bad_block\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd19\")\r\n\t\t\r\n\t\tassert_equal 0, tb.validate_block\r\n\tend",
"def test_time_stamp_correct\r\n hash_calc = Minitest::Mock.new('test_hash_calculator')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n def block_checker.parse(block, char); ['3456','2349']; end\r\n block_checker.expect(:validate_time, 3456, [\"3456\", hash_calc])\r\n block_checker.expect(:validate_time, 2349, [\"2349\", hash_calc])\r\n time_arr = [3456, 2330]\r\n assert_equal [3456, 2349], @g.time_stamp( '3456.2349', time_arr, hash_calc, block_checker, 0)\r\n end",
"def empty_times\n r = {times: 'should not be empty'}\n return not_found r\n end",
"def times_for_send_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_hour + 30.minutes\n task_time += 1.hour if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.hour\n end\n\n times\n end",
"def create_blocks prev_hash, n, opts = {}\n interval = opts[:interval] || 600\n time = opts[:time] || Time.now.to_i\n bits = opts[:bits] || 553713663\n block = @store.get_block(prev_hash)\n n.times do |i|\n block = create_block block.hash, true, [], @key, 50e8, {\n time: time += interval, bits: bits }\n # block = @store.get_block(block.hash)\n # puts \"#{i} #{block.hash[0..8]} #{block.prev_block.reverse_hth[0..8]} #{Time.at(block.time).strftime('%Y-%m-%d %H:%M:%S')} c: #{block.chain} b: #{block.bits} n: #{block.nonce} w: #{block.work}\"\n end\n block\nend",
"def size_time(base = self.date_from)\n\t\t\t\t\t@sizes = {} if @sizes.nil?\n\t\t\t\t\tif @sizes[base.to_s].nil?\n\t\t\t\t\t\tsize = DateTime.parse(\"2000-01-01 00:00:00 +0000\")\n\t\t\t\t\t\tself.reservations(base).each do |reservation|\n\t\t\t\t\t\t\tif reservation.above_line?\n\t\t\t\t\t\t\t\tsize += reservation.size.seconds_since_midnight.seconds\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@sizes[base.to_s] = size\n\t\t\t\t\tend\n\t\t\t\t\treturn @sizes[base.to_s]\n\t\t\t\tend",
"def get_record_blocks\n\n blocks = []\n current_block = nil\n\n File.readlines(@file).each do |l|\n\n # start of a new aragorn result\n if l =~ /^Location \\[(\\d+),(\\d+)\\]$/\n\n if current_block\n blocks << parse_block(current_block)\n current_block = []\n else \n current_block = Array.new\n end\n end\n\n if current_block\n current_block << l\n end \n\n end\n unless current_block.nil?\n blocks << parse_block(current_block)\n end\n\n return blocks\n end",
"def find_available_rooms_in_block(blocks, group_name, start_date: Date.today, end_date: Date.today + 2)\n return Block.all_available_rooms_in_block(blocks, group_name, start_date: start_date, end_date: end_date)\n end",
"def read_control_block # :nodoc:\n\t control_time = read_time\n\t control_block_type = rio.read(1).unpack('C').first\n\t control_value = read_time\n\t if control_block_type == CONTROL_SET_TIMEBASE\n\t\t@time_base << [control_time, control_value]\n\t elsif control_block_type == CONTROL_SET_TIMEOFFSET\n\t\t@time_offset << [control_time, Float(control_value.tv_sec) + control_value.tv_usec / 1.0e6]\n\t else \n\t\traise \"unknown control block type #{control_block_type}\"\n\t end\n\tend",
"def create\n @time_block = TimeBlock.new(time_block_params)\n\n respond_to do |format|\n if @time_block.save\n format.html { redirect_to @time_block, notice: 'Time block was successfully created.' }\n format.json { render :show, status: :created, location: @time_block }\n else\n format.html { render :new }\n format.json { render json: @time_block.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_outside_time_range\n # outside of time-range, hidden\n blob = <<ICS\nBEGIN:VCALENDAR\nBEGIN:VEVENT\nUID:foobar6\nDTSTART:20110101T090000Z\nDTEND:20110101T100000Z\nEND:VEVENT\nEND:VCALENDAR\nICS\n\n assert_free_busy_report(\n '',\n blob\n )\n end",
"def diff_from(time: nil, version: nil)\n all.map { |record| record.diff_from(time: time, version: version) }\n end",
"def get_busy_times(calendar_ids, min_date, max_date, access_token)\n form_data = {\n \"items\" => [{:id => calendar_ids}],\n \"timeMin\" => \"#{min_date.year}-#{min_date.month}-#{min_date.day}T00:00:00+00:00\",\n \"timeMax\" => \"#{max_date.year}-#{max_date.month}-#{max_date.day}T23:59:00+00:00\" \n }\n uri = URI.parse(\"https://www.googleapis.com/calendar/v3/freeBusy?access_token=#{access_token}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true \n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = form_data.to_json\n request['Content-Type'] = 'application/json'\n response = http.request(request)\n response_json = JSON.parse(response.body) \n busy_times = []\n response_json[\"calendars\"].keys.each do |calendar|\n unless response_json[\"calendars\"][calendar][\"busy\"].blank?\n response_json[\"calendars\"][calendar][\"busy\"].each do |busy|\n busy_times.push([busy[\"start\"], busy[\"end\"]])\n end\n end\n end\n busy_times\n end",
"def no_overlap\n self.class.where(user_id: user.id, time_type: time_type).each do |other_time|\n errors.add(:start_time, \"i'm a sad error\") if overlaps?(other_time)\n end\n end",
"def test_outside_time_range2\n # outside of time-range, hidden\n blob = <<ICS\nBEGIN:VCALENDAR\nBEGIN:VEVENT\nUID:foobar7\nDTSTART:20110104T090000Z\nDTEND:20110104T100000Z\nEND:VEVENT\nEND:VCALENDAR\nICS\n\n assert_free_busy_report(\n '',\n blob\n )\n end",
"def test_good_block\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd18\")\r\n\t\t\r\n\t\tassert_equal 1, tb.validate_block\r\n\tend",
"def time_base\n\t if @time_base.empty?\n\t\tTime.at(0)\n\t else\n\t\t@time_base.last[1] \n\t end\n\tend",
"def get_blocks\n @blocks\n end",
"def all_game_times\n @rules.collect(&:game_times).flatten.uniq\n end",
"def check_times\n if start_end_times.count > 0 && !start_end_times.nil?\n start_end_times.each do |t|\n return true if t.check_time_ranges\n end\n\n false\n else\n true\n end\n end",
"def get_block_cells block\n\t\tblock_cells = []\n\t\t(block / 3 * 3...block / 3 * 3 + 3).each do |r|\n\t\t\t(block % 3 * 3...block % 3 * 3 + 3).each do |c|\n\t\t\t\tblock_cells << r * 9 + c\n\t\t\tend\n\t\tend\n\treturn block_cells\n\n\tend",
"def design_billable_time_entries\n @_design_billable_time_entries ||= billable_time_entries.select { |time_entry| time_entry.dig('task', 'name') == 'Design' }\n end",
"def time_range\n return 0 if start_hour.blank? || start_minute.blank?\n\n return 0 if end_hour.blank? || end_minute.blank?\n\n hours_between_times\n end",
"def time\n\t\t\t\tDateTime.strptime(block_nTime.to_s, \"%s\").to_s\n\t\t\tend",
"def verify_start_time time\n\n # Check that there are currently\n # records on the day to iterate through\n dsym = self.class.date_symbol time\n return true if not self.class.days_index[dsym]\n\n self.class.days_index[dsym].each do |record|\n\n next if record.end_time == :running\n next if record == self\n if time < record.end_time\n raise ArgumentError, \"Time conflict with existing record\" if time_in_record? time, record\n end\n end\n true\n end",
"def set_time_block\n @time_block = TimeBlock.find(params[:id])\n end",
"def basic_blocks\n @basic_block_collection ||= BasicBlockCollection.new(self)\n end",
"def parse_times( times )\n case times\n when /^\\s*any\\b/i\n Hour.new(\"12 AM\")..Hour.new(\"11 PM\")\n when /^\\s*before (\\d+ [AP]M)\\b/i\n Hour.new(\"12 AM\")..Hour.new($1)\n when /^\\s*after (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new(\"11 PM\")\n when /^\\s*(\\d+ [AP]M) to (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new($2)\n when /^\\s*not available\\b/i\n nil\n else\n raise \"Unexpected availability format.\"\n end\n end"
] | [
"0.6995972",
"0.666866",
"0.61515516",
"0.60989684",
"0.6043392",
"0.6019025",
"0.57999414",
"0.5793993",
"0.5751547",
"0.56786937",
"0.5677315",
"0.5637624",
"0.5597517",
"0.55707026",
"0.55529094",
"0.5491499",
"0.5484656",
"0.5475232",
"0.54654413",
"0.5422617",
"0.5392022",
"0.5366929",
"0.5350359",
"0.52865314",
"0.5268814",
"0.52152836",
"0.5203646",
"0.5186633",
"0.51743",
"0.5164157",
"0.5160499",
"0.51538295",
"0.5134557",
"0.51138586",
"0.51016647",
"0.50832516",
"0.50826645",
"0.50763005",
"0.506101",
"0.5060319",
"0.5036269",
"0.5021218",
"0.50131416",
"0.49999943",
"0.4989145",
"0.49842092",
"0.49838936",
"0.49728608",
"0.49584112",
"0.49403456",
"0.49291503",
"0.4897992",
"0.48494017",
"0.48473892",
"0.4835672",
"0.48056647",
"0.47992283",
"0.4799023",
"0.4793719",
"0.47830826",
"0.4780397",
"0.4777683",
"0.4768383",
"0.47656927",
"0.47633487",
"0.47599566",
"0.47590467",
"0.47582972",
"0.47506645",
"0.47506645",
"0.47466275",
"0.4745714",
"0.47344175",
"0.47211584",
"0.4717401",
"0.47112513",
"0.47007877",
"0.46880198",
"0.46847954",
"0.46804023",
"0.4673371",
"0.46649557",
"0.46649554",
"0.46481207",
"0.46478146",
"0.46469733",
"0.46455207",
"0.4640529",
"0.46397918",
"0.4624417",
"0.4624313",
"0.46185264",
"0.46139",
"0.46128458",
"0.4610986",
"0.4600887",
"0.45972288",
"0.45948604",
"0.45922753",
"0.4582082"
] | 0.8538772 | 0 |
Returns all valid Appointments for a given base time. | def valid_appointments(base_time)
transform_blocks_to_appointments(valid_blocks(base_time))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_appointments\n # Appointment\n return unless current_user\n @appointments = current_user.appointments\n\n clean_open_appointments = sanatize_open_appointments(current_user.open_appointments)\n @pending_requests = clean_open_appointments.group_by do |d|\n start_date = set_in_timezone(d.start_date, current_user.id)\n start_date.strftime('%A %B %d')\n end\n\n @in_progress_appointments = current_user\n .in_progress_appointments.group_by do |d|\n start_date = set_in_timezone(d.start_date, current_user.id)\n start_date.strftime('%A %B %d')\n end\n @scheduled_appointments = current_user.scheduled_appointments\n .group_by do |d|\n start_date = set_in_timezone(d.start_date, current_user.id)\n start_date.strftime('%A %B %d')\n end\n\n @past_appointments = past_appointments.group_by do |d|\n start_date = set_in_timezone(d.start_date, current_user.id)\n start_date.strftime('%A %B %d')\n end\n\n @appointments = current_user.appointments\n\n # Appointment Packs\n @appointment_packs = active_appointment_packs\n @past_appointment_packs = past_appointment_packs\n end",
"def available_on(base_time)\n # Stash this for future use, as we will be using it to set a\n # baseline date in order to derive a bunch of different appointments\n # from.\n set_base_time(base_time)\n\n # Fetch all TimeEntris related for this date query.\n time_entries = time_entries_for(base)\n\n # Transform TimeEntry(s) -> TimeSlot(s).\n available_slots = generate_time_slots(time_entries)\n\n # Combine all sequential linear slots to into a single window.\n # This produces multiple windows\n windows = combine_linear_slots(available_slots)\n\n # Generate TimeBlocks from the Available Slot ranges\n open_time_blocks = generate_time_blocks(windows)\n\n # Optimize & Filter our wide collection of TimeBlocks.\n optimized_blocks = optimize_time_blocks(open_time_blocks)\n\n # Finally, present the TimeBlock(s) as Appointment records\n # to the Customer.\n final = transform_blocks_to_appointments(optimized_blocks)\n end",
"def appointments(params = {})\n scope 'user_schedule'\n get('schedule/appointments/', params)\n end",
"def index\n if !time_slot_params[:start].present? && !time_slot_params[:end].present?\n @appointments = Appointment.all\n else\n #time_slot_params[:start], time_slot_params[:end]\n @appointments = Appointment.in_time_slot_only(time_slot_params).all\n end\n render :json => @appointments, :status => :ok\n end",
"def appointments\n Appointment.all(contact: to_s)\n end",
"def missed_appointments\n appointments = Observation.joins(:encounter)\n .merge(appointment_encounters)\n .where.not(person_id: referral_patients.select(:person_id))\n .where(concept: ConceptName.where(name: 'Appointment date').select(:concept_id))\n .where('value_datetime BETWEEN ? AND ? AND encounter.program_id = ?',\n @start_date.strftime('%Y-%m-%d 00:00:00'),\n @end_date.strftime('%Y-%m-%d 23:59:59'), 1)\n .group(:person_id)\n\n appointments.each_with_object([]) do |appointment, patients|\n patient = missed_appointment?(appointment)\n\n patients << patient unless patient.blank?\n end\n end",
"def appointments(officer_id)\n client.get(\"officers/#{officer_id}/appointments/\")\n end",
"def index\n appointment_can_cancel_and_reschedule\n\n # If patient already had a dose, keep it in the same UBS.\n # This is an optimized query, hence a little odd using +pick+s.\n ubs_id = Appointment.where(id: current_patient.doses.pick(:appointment_id)).pick(:ubs_id)\n\n # Otherwise limit to where they can schedule\n ubs_id = allowed_ubs_ids if ubs_id.blank?\n\n @days = parse_days\n @appointments = scheduler.open_times_per_ubs(from: @days.days.from_now.beginning_of_day,\n to: @days.days.from_now.end_of_day,\n filter_ubs_id: ubs_id)\n rescue AppointmentScheduler::NoFreeSlotsAhead\n redirect_to home_community_appointments_path, flash: { alert: 'Não há vagas disponíveis para reagendamento.' }\n end",
"def appointments\n Appointment.all.filter { |appointment| appointment.provider_id == self.id || appointment.user_id == self.id}\n end",
"def get_appts\n @user = current_user\n @appointments = @user.appointments.actual.includes(:status, :address, :assignments, {:subscription => :subscriptionable}, :employees, :team)\n # filter by the datetime object via params from fullcalendar\n filter_show = ActiveSupport::JSON.decode(params[:filter_show])\n appointments_in_range = @appointments.where(\"appointments.start_time >= :start_time AND appointments.start_time <= :end_time\", {:start_time => Time.at(params['start'].to_i), :end_time => Time.at(params['end'].to_i)} )\n events = []\n appointments_in_range.each do |appointment|\n if appointment_is_allowed?(appointment, filter_show)\n customer = appointment.subscription.subscriptionable\n eventHash = {:id => appointment.id, :title => calendar_title(appointment, customer), :start => \"#{appointment.start_time.iso8601}\", :end => \"#{appointment.end_time.iso8601}\", :allDay => false, :recurring => appointment.subscription.repeat }\n\n eventHash[:backgroundColor] = event_background_color(appointment, params[:event_color])\n eventHash[:borderColor] = eventHash[:backgroundColor]\n\n events << eventHash\n # optional day view\n #events << {:id => event.id, :title => @customer_name, :url => \"/appointments/\"+event.id.to_s+\"/edit\", :description => \"Description here\", :start => \"#{event.start_time.iso8601}\", :end => \"#{event.end_time.iso8601}\", :allDay => true}\n end\n end\n render :json => events\n end",
"def set_appointments\n @appointments = []\n latest_message = Message.order('created_at').last\n lines = latest_message.message_lines.where(order: params[:Body].split(' ').map(&:to_i))\n lines.each do |line|\n @appointments << line.appointment\n end\n end",
"def fetch_appointments(obj, t_d)\n (z = obj.state.appointments_for_dates[t_d]) ? z : {}\n # x = (z = obj.state.appointment_availabilities[t_d]) ? z : {}\n # begining = Moment.new(t_d).set(hour: 9).format()\n # ending = Moment.new(t_d).set(hour: 19).format()\n # x.each do |k, v|\n # v.each do |av|\n # break if av.map.is_a? Array\n # p_av = JSON.parse(av.map).each_slice(2).to_a.sort {|x, y| x[1] <=> y[1]} unless av.map.length == 1\n # p_av.unshift([begining, begining])\n # p_av.push([ending, ending])\n # _map = []\n # i = 0\n # while i < (p_av.length - 1)\n # first = Moment.new p_av[i][1]\n # second = Moment.new p_av[i + 1][0]\n # d = second.diff(first, \"minutes\")\n # if d > 20\n # _map << [first, second]\n # end\n # i += 1\n # end\n # av.map = _map\n # end\n # end \n # x\n end",
"def validate_time(start_time, end_time)\n\t\t\t\ttime_now = Time.now.strftime(\"%m/%d/%Y %H:%M\")\n\t\t\t\tappointments = Appointment.all\n\t\t\t\ttoday = start_time.split[0]\n\t\t\t\ttoday_appts = appointments.where(start_time: today)\n\t\t\t\tresult = false\n\n\t\t\t\tif start_time > time_now\n\t\t\t\t\tif today_appts.length == 0\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\t\ttoday_appts.each do |appt|\n\t\t\t\t\t\tif start_time <= appt.end_time && appt.start_time <= end_time\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tresult = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend#end of each loop\n\t\t\t\tend#end of if start_time\n\t\t\t\tresult\n\t\t\tend",
"def index\n @appointment = current_patient.appointments.not_checked_in.current\n if @appointment && !@appointment.can_cancel_and_reschedule?\n return redirect_to(\n home_community_appointments_path,\n flash: { alert: t('alerts.cannot_cancel_or_reschedule', days: Rails.configuration.x.schedule_up_to_days) }\n )\n end\n\n @days = parse_days\n @appointments = scheduler.open_times_per_ubs(from: @days.days.from_now.beginning_of_day,\n to: @days.days.from_now.end_of_day)\n rescue AppointmentScheduler::NoFreeSlotsAhead\n redirect_to home_community_appointments_path, flash: { alert: 'Não há vagas disponíveis para reagendamento.' }\n end",
"def appointments\n # 1. access the Appt's @@all variable\n # 2. from there, select only the appoints whose doctor is self\n Appointment.all.select{|appointment| appointment.doctor == self}\n end",
"def appointments\n Appointment.all.select { |x| x.patient == self }\n end",
"def appointments\r\n Appointment.all.collect do\r\n\t\t\t|appt| appt if appt.doctor == self\r\n\t\tend\r\n\tend",
"def appointments\n Appointment.all.collect do\n\t\t\t|appt| appt if appt.doctor == self\n\t\tend\n\tend",
"def my_appointments(user)\n Appointment.where(user_id: user.id)\n end",
"def appointments_on(date)\n appointments.starts_on(date).to_a\n end",
"def check_overlap\n appointments = Appointment.all\n current_start = DateTime.strptime(self.start_time,\"%m/%d/%y %H:%M\").to_time\n current_end = DateTime.strptime(self.end_time,\"%m/%d/%y %H:%M\").to_time\n\n appointments.each do |appt|\n appt_start = DateTime.strptime(appt.start_time,\"%m/%d/%y %H:%M\").to_time\n appt_end = DateTime.strptime(appt.end_time,\"%m/%d/%y %H:%M\").to_time\n\n ## if the appointment being checked is a new appointment ##\n if @new_appt\n if current_start >= appt_start && current_start <= appt_end\n @valid = false\n elsif current_end >= appt_start && current_end <= appt_end\n @valid = false\n end\n\n ## if the appointment being checked is an old appointment being updated ##\n else\n if current_start > appt_start && current_start < appt_end\n @valid = false\n elsif current_end > appt_start && current_end < appt_end\n @valid = false\n end\n end\n\n end\n @valid\n p @valid\n end",
"def appointment_unique_with_doctor_in_clinic\n times_taken = []\n begin\n self.doctor.appointments.confirmed.each do |appt|\n unless appt.id == self.id\n times_taken << appt.appointment_time\n end\n end\n rescue NoMethodError\n errors.add(:doctor_id, 'No doctor specified')\n end\n errors.add(:appointment_time, \"Time not available\") if times_taken.include?(appointment_time)\n end",
"def appointments\n Appointment.all.select {|appt| appt.patient == self}\n end",
"def remaining_appointments_today\n Appointment.today.with_doctor(doctor_id).\n where(appointment_time: appointment_time+1.minute...DateTime.tomorrow)\n end",
"def approval\n @appointments = Appointment.in_clinic(@admin).requests.\n order_by_time.includes(:doctor, :patient).not_past\n end",
"def populate_with_appointments(\n appointments_start_dates\n )\n appointments_start_dates.each do |start_date|\n expert = Expert.find(expert_id)\n if expert.available_for_datetime(start_date)\n appointment = appointments.new(\n user_id: user_id,\n service_id: service_id,\n expert_id: expert_id,\n description: description,\n start_date: start_date,\n duration_in_min: service.duration_in_min,\n type: 'OpenAppointment'\n )\n\n if appointment.save\n appointments << appointment\n true\n else\n puts \"---- 🔸 FAILURE | while saving appointment \\\n error:#{appointment.errors.messages}🔸\\\n in populate_with_appointments\"\n false\n end\n else\n puts \"---- 🔸 FAILURE | Expert(#{expert.id}) not available for \\\n start_date #{start_date}🔸in populate_with_appointments\"\n return false\n end\n end\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def time_collision_validation\n\t\tappointments = Appointment.all\n\n\t\t#if duration is equals to 0, it means it is fixed pay. \n\t\t#Here, duration is set to 0 so it will not be validated \n\t\t#This will execute if is_pay_per hour is set to 0\n\t\tif @start_date.present? && @start_time.present? && duration == 0.to_s\n\t\t\tstart_at = Time.parse(\"#{@start_date} #{@start_time}\") + (1.hours)\n\t\t\t\n\t\t\tappointments.each do |a|\n\t\t\t\t# will ensure that the appointment to compare will not be compared to itself in the database if it exists\n\t\t\t\tif a.id.to_s != @appointment_id.to_s\n\t\t\t\t\t# compare fixed-pay input to pay per hour appointment\n\t\t\t\t\tif a.task.is_pay_per_hour && start_at < a.end_at && start_at >= a.start_at \n\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\terrors.add(:start_date, \"An appointment is already \n\t\t\t\t\t\t\tset at #{a.start_at.strftime(\"%I:%M%p\")}, #{a.start_at.strftime(\"%d/%m/%Y\")} \n\t\t\t\t\t\t\tto #{a.end_at.strftime(\"%I:%M%p\")} on #{a.end_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\tbreak\n\n\n\t\t\t\t\t\t#compare fixed-pay input to fixed pay appointment\n\t\t\t\t\telsif !a.task.is_pay_per_hour && start_at == a.start_at \n\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\terrors.add(:start_date, \"A fixed pay appointment is aleady set at #{a.start_at.strftime(\"%I:%M%p\")}\n\t\t\t\t\t\t\t, #{a.start_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend \t\n\t\t\t\tend \t\n\t\t\tend\n\n\n\t\t\t\t#Here, duration should be present and will be always validated\n\t\t\t\t#This will execute if is_pay_per hour is set to 1\n\t\t\telsif @start_date.present? && @start_time.present? && duration.present?\n\t\t\t\tstart_at = Time.parse(\"#{@start_date} #{@start_time}\") + (1.hours)\n\t\t\t\tend_at = Time.parse(\"#{@start_date} #{@start_time}\") + (@duration.to_f.hours+ (1.hours))\n\n\t\t\t\tappointments.each do |a|\n\t\t\t\t\t# will ensure that the appointment to compare will not be compared to itself in the database if it exists\n\t\t\t\t\tif a.id.to_s != @appointment_id.to_s\n\t\t\t\t\t\t# compare pay per hour input to pay per hour appointment\n\t\t\t\t\t\tif a.task.is_pay_per_hour && start_at < a.end_at && a.start_at < end_at \n\n\t\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\t\terrors.add(:start_date, \"An appointment already \n\t\t\t\t\t\t\t\texists at #{a.start_at.strftime(\"%I:%M%p\")}, #{a.start_at.strftime(\"%d/%m/%Y\")} \n\t\t\t\t\t\t\t\tto #{a.end_at.strftime(\"%I:%M%p\")} on #{a.end_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t#compare pay per hour input to fixed pay appointment\n\t\t\t\t\t\telsif !a.task.is_pay_per_hour && a.start_at <= end_at && a.start_at >= start_at\n\n\t\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\t\terrors.add(:start_date, \"A fixed pay appointment is aleady set at #{a.start_at.strftime(\"%I:%M%p\")}\n\t\t\t\t\t\t\t\t, #{a.start_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\t\tbreak\t\t\t\t\n\t\t\t\t\t\tend\t\t\t\n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\tend \n\t\tend",
"def index\n @request = current_user.requests.last\n @appointments = current_user.appointments\n @appointments_uncomplete = current_user.appointments.completed_false\n @appointment = Appointment.new\n end",
"def appointment(params = {})\n @appointment_id = params.delete :appointment_id\n scope 'user_schedule'\n\n get_one('schedule/appointmenttypes/', @appointment_id, params)\n end",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def provider_schedules_appointments_ajax\n time_start = Time.at((params[:time_start].to_f)/1000).change({ hour: 0, min: 0, sec: 0 })\n time_end = Time.at((params[:time_end].to_f)/1000).change({ hour: 23, min: 59, sec: 59 })\n \n schedules = ProviderSchedule.where(\"provider_id = ? and time >= ? and time <= ?\", params[:provider_id], time_start, time_end)\n \n appointments = Appointment.where(\"provider_id = ? and time_start >= ? and time_end <= ?\", params[:provider_id], time_start, time_end)\n \n if !is_admin? and !(signed_in? and current_provider.id == Integer(params[:provider_id]))\n appointments.each_with_index do |appointment, index|\n appointments[index] = appointment.safe\n end\n end\n \n container = { \"status\" => \"success\", \"appointments\" => appointments, \"schedules\" => schedules }\n render :json => container.to_json\n end",
"def index\n start_time = params[:start_time]\n end_time = params[:end_time]\n first_name = params[:first_name]\n last_name = params[:last_name]\n\n if start_time && end_time\n @appointments = Appointment.where(start_time: start_time, end_time: end_time)\n elsif start_time\n @appointments = Appointment.where(start_time: start_time)\n elsif end_time\n @appointments = Appointment.where(end_time: end_time)\n elsif first_name & last_name\n @appointments = Appointment.where(first_name: first_name, last_name: last_name)\n elsif first_name\n @appointments = Appointment.where(first_name: first_name)\n else last_name\n @appointments = Appointment.where(last_name: last_name)\n end\n\n render json: @appointments, status: 200\n end",
"def open_appointment_slots(params = {})\n scope 'user_schedule'\n get('schedule/appointments', params)\n end",
"def appointments\n Appointment.all.select do |appointment| appointment.patient == self end\n end",
"def appointments\n Appointment.all.select{|appointment| appointment.doctor == self}\n end",
"def appointments\n Appointment.all.select {|appointments| appointments.patient == self}\n end",
"def all_actual_meetings\n # Exceptions are positive (Tue/Thu class meeting on Wed)\n # or negative (Tue/Thu class doesn't meet on Tue)\n positive_exceptions = exceptions_as_dates - all_potential_meetings\n all_potential_meetings - exceptions_as_dates + positive_exceptions\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.all\n end",
"def index\n @type_appointments = TypeAppointment.all\n end",
"def index\n @app_appointments = AppAppointment.all\n end",
"def get_busy_slots(start_min, start_max, time_zone)\n result = Array.new\n @googleCalendars.each do |x|\n result.push(x[:connection].query([x[:id]],start_min, start_max, time_zone))\n end\n return result\n end",
"def appointments\n Appointment.all.select do |appointment|\n appointment.patient == self\n end\n end",
"def appointments\n Appointment.all.select do |appointment|\n appointment.patient == self\n end\n end",
"def index\n @appointments = current_user.fetch_appointments\n end",
"def client_appointments\n self.clients.map(&:appointments)\n end",
"def job_appointments\n warn \"DEPRECATED: LDAP no longer contains job appointment data - you now need to go through HCM. This method will always return an empty Array\"\n []\n end",
"def booked_appointments\n booked_appointment = []\n self.carts.each do |cart|\n booked_appointment.push(cart.potential_appointments.where(booked_status?: true ))\n end\n return booked_appointment.flatten\n end",
"def open_appointments\n date = Date.parse(params[:date])\n clinic = Clinic.find(params[:clinic_id])\n doctor = Doctor.find(params[:doctor_id])\n # @times = doctor.open_appointment_times(date)\n @times = clinic.open_appointment_times(date, doctor)\n if @times.is_a?(Hash)\n render json: {status: 1, error: @times[:error]}\n else\n render json: { status: 0, times: @times }\n end\n #@appointment = Appointment.new\n #render json: {open_times: @open_times}\n # render json: {times: [\n # {time: '8:00 AM', enabled: true, selected: false, index: 0},\n # {time: '8:30 AM', enabled: false, selected: false, index: 1},\n # {time: '9:00 AM', enabled: true, selected: false, index: 2},\n # {time: '9:30 AM', enabled: true, selected: false, index: 3},\n # {time: '10:00 AM', enabled: false, selected: false, index: 4},\n # {time: '10:30 AM', enabled: false, selected: false, index: 5},\n # {time: '11:00 AM', enabled: false, selected: false, index: 6},\n # {time: '11:30 AM', enabled: true, selected: false, index: 7},\n # {time: '12:00 PM', enabled: true, selected: false, index: 8},\n # {time: '12:30 PM', enabled: true, selected: false, index: 9},\n # {time: '1:00 PM', enabled: false, selected: false, index: 10},\n # {time: '1:30 PM', enabled: true, selected: false, index: 11},\n # {time: '2:00 PM', enabled: false, selected: false, index: 12},\n # {time: '2:30 PM', enabled: false, selected: false, index: 13},\n # {time: '3:00 PM', enabled: true, selected: false, index: 14},\n # {time: '3:30 PM', enabled: true, selected: false, index: 15},\n # {time: '4:00 PM', enabled: true, selected: false, index: 16},\n # {time: '4:30 PM', enabled: false, selected: false, index: 17},\n # {time: '5:00 PM', enabled: true, selected: false, index: 18},\n # {time: '5:30 PM', enabled: true, selected: false, index: 19}]}\n\n end",
"def appointments\n Appointment.all.select{|appointments| appointments.doctor == self}\n end",
"def dashboard\n if signed_in?\n \t @provider = current_provider\n else\n redirect_to root_url\n end\n \n @pending_appointments = @provider.appointments.where(\"accepted = 0\").where(['time_start >= ?', DateTime.now]).order(\"time_start asc\")\n @confirmed_appointments = @provider.appointments.where(\"accepted = 1\").where(['time_start >= ?', DateTime.now]).order(\"time_start asc\")\n @past_appointments = @provider.appointments.where(['time_start < ?', DateTime.now]).order(\"time_start desc\")\n @denied_appointments = @provider.appointments.where(\"accepted = 2\").where(['time_start >= ?', DateTime.now]).order(\"time_start desc\")\n \n require 'date'\n end",
"def created_appointments\n Appointment.all(created_by: to_s)\n end",
"def get_busy_times(calendar_ids, min_date, max_date, access_token)\n form_data = {\n \"items\" => [{:id => calendar_ids}],\n \"timeMin\" => \"#{min_date.year}-#{min_date.month}-#{min_date.day}T00:00:00+00:00\",\n \"timeMax\" => \"#{max_date.year}-#{max_date.month}-#{max_date.day}T23:59:00+00:00\" \n }\n uri = URI.parse(\"https://www.googleapis.com/calendar/v3/freeBusy?access_token=#{access_token}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true \n request = Net::HTTP::Post.new(uri.request_uri)\n request.body = form_data.to_json\n request['Content-Type'] = 'application/json'\n response = http.request(request)\n response_json = JSON.parse(response.body) \n busy_times = []\n response_json[\"calendars\"].keys.each do |calendar|\n unless response_json[\"calendars\"][calendar][\"busy\"].blank?\n response_json[\"calendars\"][calendar][\"busy\"].each do |busy|\n busy_times.push([busy[\"start\"], busy[\"end\"]])\n end\n end\n end\n busy_times\n end",
"def no_appts_avail?\n appointments.empty?\n end",
"def all\n @lighthouse_appointments = get_lighthouse_appointments.resource&.entry\n @locations = get_locations\n\n return default_response if lighthouse_appointments.blank?\n\n concurrent_pgd_requests\n @facilities = get_facilities\n\n return default_response if patient.blank? || questionnaires.blank?\n\n compose\n end",
"def appointments\n @appointments\n end",
"def appointments\n @appointments\n end",
"def appointments\n Appointment.all.select {|appointment| appointment.patient == self}\n # Appointment.all.select {|appointment| appointment.doctor == self}\n end",
"def index\n @appointment = Appointment.new\n @appointments = Appointment.all\n end",
"def index\n @appointments = Appointment.where('time >= ?', Time.now).order(time: :asc)\n if @appointments.length == 0\n flash[:alert] = \"You have no appointments. Create one now to get started.\"\n end\n end",
"def parse(appointments)\n appointments_list = appointments.dig(:booked_appointment_collections, 0, :booked_cc_appointments) || []\n\n appointments_list.map do |appointment_hash|\n location = location(\n appointment_hash[:provider_practice], appointment_hash[:address], appointment_hash[:provider_phone]\n )\n\n adapted_hash = generate_hash(appointment_hash, location)\n\n Mobile::V0::Appointment.new(adapted_hash)\n end\n end",
"def patients\n appointments.collect { |appt| appt.patient }\n end",
"def doctor_double_booked #We check this against all of the doctors appointments \n this_start = self.start_time #Instance methods that are called on a particular doctor's appointment \n this_end = self.end_time \n conflict = doctor.appointments.any? do |appointment| \n #Look through all of the doctors appointments and checks if there are any overlapping appointments (start_time, end_time). \n #any? returns true or false. \n \n other_start = appointment.start_time \n other_end = appointment.end_time\n other_start < this_end && this_end < other_end || other_start < this_start && this_start < other_end\n # other_start < this_end && this_end < other_end \n #This means that this appointment ends in the middle of an existing appointment.\n \n # other_start < this_start && this_start < other_end \n #This means that this appointment starts in the middle of an existing appointment. \n end\n if conflict #true or false \n errors.add(:doctor, 'has a conflicting appointment') \n # Adds an error message to the appointment with an error message about the doctor. The doctor is the key, the message is the value. \n end\n end",
"def is_appointments_not_empty\n\t\tAppointment.all.present? \n\tend",
"def index\n @appointments = Appointment.all.order(:section, :time_slot)\n end",
"def get_appts_grid\n @user = current_user\n @appointments = @user.appointments.actual.includes(:status, :address, :assignments, {:subscription => :subscriptionable}, :employees, :team)\n filter_show = ActiveSupport::JSON.decode(params[:filter_show])\n\n appointments_in_range = @appointments.where(\"appointments.start_time >= :start_time AND appointments.start_time <= :end_time\", {:start_time => Time.at(params['start'].to_i), :end_time => Time.at(params['end'].to_i)} )\n\n # Initialize events by employee hash\n events = {}\n\n if params['source'] == 'employees'\n current_user.employees.active.each do |employee|\n if filter_show[\"employees\"][employee.full_name]\n events[employee.id] = []\n end\n end\n elsif params['source'] == 'team'\n current_user.teams.each do |team|\n if filter_show[\"team\"][team.name]\n events[team.id] = []\n end\n end\n end\n\n events[0] = []\n\n appointments_in_range.each do |appointment|\n if filter_show[\"status\"][appointment.status.name]\n customer = appointment.subscription.subscriptionable\n eventHash = {:id => appointment.id, :title => calendar_title(appointment, customer), :start => \"#{appointment.start_time.iso8601}\", :end => \"#{appointment.end_time.iso8601}\", :allDay => false, :recurring => appointment.subscription.repeat }\n\n if params['source'] == 'employees'\n\n if appointment.assignments.size == 0\n eventHash[:backgroundColor] = @user.unassigned_color\n eventHash[:borderColor] = eventHash[:backgroundColor]\n events[0] << eventHash\n else\n appointment.employees.each do |employee|\n if events.has_key?(employee.id)\n eventCopy = eventHash.clone\n eventCopy[:backgroundColor] = employee.calendar_color\n eventCopy[:borderColor] = eventHash[:backgroundColor]\n events[employee.id] << eventCopy\n end\n end\n end\n\n elsif params['source'] == 'team'\n\n if appointment.team.blank?\n eventHash[:backgroundColor] = @user.no_team_color\n events[0] << eventHash\n else\n if events.has_key?(appointment.team.id)\n eventHash[:backgroundColor] = appointment.team.calendar_color\n events[appointment.team.id] << eventHash\n end\n end\n\n end\n end\n end\n\n render :text => events.to_json\n end",
"def patients\r\n appointments.map { |s|s.patient }\r\n end",
"def appointments\n Appointment.all.select do |appointment_instance|\n appointment_instance.doctor == self \n end\n end",
"def initialize(name)\n @name = name\n @appointments = []\n end",
"def initialize(name)\n @name = name\n @appointments = []\n end",
"def initialize(name)\n @name = name\n @appointments = []\n end",
"def initialize(name)\n @name = name\n @appointments = []\n end",
"def initialize(name)\n @name = name\n @appointments = []\n end",
"def has_appointment?(date, time)\n datetime = Temporal.generate_datetime(date, time)\n\n !is_available?(datetime, 20) #the time is broken up into 20 minute blocks\n end",
"def appointments\n Appointment.all.select do |a|\n a.doctor == self\n end\n end",
"def patients\n self.appointments.map do |appointment|\n appointment.patient\n # binding.pry\n end\n # Appointments.all.select {|doc| }\n end",
"def get_appointments\n begin\n @appointments = Appointment.all.order('created_at asc').map { |appointment| { doctor_name: appointment.doctor.name, patient_name: appointment.patient.name, disease: appointment.disease } }\n @msg = { status: STATUS_SUCCESS, appointments: @appointments, message: SUCCESS_MESSAGE, token: request.headers[:Authorization].split(\"Token token=\").last, user: current_user.email }\n rescue Exception => e\n @msg = { status: STATUS_ERROR, message: CREDENTIAL_ERROR_MSG, token: request.headers[:Authorization].split(\"Token token=\").last, user: current_user.email }\n end\n render json: @msg\n end",
"def index\n @appointments = Appointment.all\nend",
"def find_owner_appointments\n owner_appointments = Appointment.all.select { |appointment| appointment.owners.include?(self) || appointment.owner_id == id } \n if !owner_appointments.empty?\n owner_appointments\n else\n nil\n end\n end",
"def new\n\n\t\t\n\t\t\t@appointments = Appointment.all\n\t\t\t@taken_slots = []\n\n\t\t\t@appointments.each do |appt|\n\t\t\t\t\t#@taken_slots << [appt.time.strftime(\"%I:%M %p\")]\n\t\t\tend\n\n\t\t\t# @appointments.each do |appt|\n\t\t\t# \tif is_taken?(appt)\n\t\t\t# \t\t@taken_times << appt.time.strftime(\"%I:%M %p\")\n\t\t\t# \tend\n\t\t\t# end\n\t\t\t\n\t\t\t@appointment = Appointment.new\n\t\t\t\n\t\tif current_user.present?\n\t\t\t@appointment.user_id = current_user.id\n\t\t\t@appointment.save\n\n\t\tend\n\n\tend",
"def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end",
"def get_lighthouse_appointments\n @get_lighthouse_appointments ||=\n lighthouse_appointment_service.search(\n patient: user.icn,\n date: [date_ge_one_month_ago, date_le_two_weeks_from_now],\n _count: '100'\n )\n end",
"def index\n ##@events = Event.where(start: params[:start]..params[:end])\n ##@appointments = Appointment.all\n @appointments = Appointment.where(nil)\n @appointments = @appointments.para_o_calendar(current_user.calendar_id).para_o_dia(dia_selected)\n\n if params[:start_date].present?\n mes_para_consulta = params[:start_date].to_date\n else\n mes_para_consulta = Date.current\n end\n\n #if params[:start].present?\n # puts params[:start]\n #end\n\n beginning_of_month = mes_para_consulta.beginning_of_month\n end_of_month = beginning_of_month.end_of_month\n\n @appointments_todos = Appointment.where(schedule_on: beginning_of_month..end_of_month)\n @appointments_todos = @appointments_todos.para_o_calendar(current_user.calendar_id)\n\n\n#start=2019-02-19T00%3A00%3A00&end=2019-02-20T00%3A00%3A00\n if params[:start].present?\n \n mes = params[:start].to_date\n else\n mes = Date.current\n end\n\n inicio_do_mes = mes.beginning_of_month\n fim_do_mes = inicio_do_mes.end_of_month\n\n puts inicio_do_mes\n puts fim_do_mes\n\n @appointments_mes = Appointment.where(schedule_on: inicio_do_mes..fim_do_mes)\n @appointments_mes = @appointments_mes.para_o_calendar(current_user.calendar_id)\n\n @appointments_all = Appointment.where(nil)\n ##@appointments_all = Appointment.find(:all, :order => \"id desc\", :limit => 5)\n @appointments_all = @appointments_all.para_o_calendar(current_user.calendar_id)\n\n end",
"def appointments\n\n Appointment.all.select {|appointment| appointment.doctor == self}\n # binding.pry\n # [1,2,3,4,5].select { |num| num.even? }\n end",
"def patients\n self.appointments.collect do |a|\n a.patient\n end\n end",
"def index\r\n @appointments = current_member.appointment\r\n end",
"def index\n @next_appointments = NextAppointment.all\n end",
"def show_vendor_availability\n start_time = params[:start_time]\n end_time = params[:end_time]\n meetings = VendorCalendarUnavailability.where(vendor_id: @current_user.id).where(\"((end_time > ?) OR (end_time < ?)) AND ((start_time > ?) OR (start_time < ?))\", start_time, end_time, start_time, end_time)\n render json: { unavailable_times: meetings }, status: 200\n end",
"def patients\n @appointments.collect do |appt|\n appt.patient\n end\n end",
"def all_timeslots\n unless @all_timeslots.present?\n @all_timeslots = (1..5).map do |day_id|\n Timeslot.new(self, day_id, @day_start_minute, @day_end_minute)\n end\n end\n\n @all_timeslots\n end",
"def overview\n @my_appointments = current_user.appointments \n @my_user_hours = current_user.user_hours \n @recipient_appointment = RecipientAppointment.new \n end",
"def all_potential_meetings\n meetings = []\n day_meetings.each do |day|\n @timeline_week_count.times do |wk|\n meetings << (@beginning_of_first_week + wk.weeks).date_of_upcoming(day)\n end\n end\n meetings.sort\n end",
"def to_a\n appointments.each_with_object([]) do |appt, accumulator|\n key = context_key(appt)\n next unless hashed_questionnaires.key?(key)\n\n accumulator << { appointment: appt.to_h, questionnaire: questions_with_qr(key) }\n end\n end",
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end"
] | [
"0.7045828",
"0.6885598",
"0.6717285",
"0.6605498",
"0.6413851",
"0.63946986",
"0.63369745",
"0.6309198",
"0.6276353",
"0.6226337",
"0.61962336",
"0.61922294",
"0.6171634",
"0.6166286",
"0.6164967",
"0.616016",
"0.60806805",
"0.60776097",
"0.6060947",
"0.60355353",
"0.60132176",
"0.59426355",
"0.59293175",
"0.5899311",
"0.58493906",
"0.58325523",
"0.5817051",
"0.58087194",
"0.58079076",
"0.57700557",
"0.5749178",
"0.5723308",
"0.5687908",
"0.56875503",
"0.5685969",
"0.56820005",
"0.5674151",
"0.5670622",
"0.5670185",
"0.5670185",
"0.5670185",
"0.5670185",
"0.5670185",
"0.5670185",
"0.5670185",
"0.5663127",
"0.56623745",
"0.563986",
"0.5629763",
"0.5629763",
"0.562688",
"0.56222665",
"0.5618887",
"0.5612987",
"0.56019425",
"0.5584223",
"0.5582964",
"0.55821836",
"0.5558686",
"0.5558317",
"0.55506045",
"0.55443114",
"0.55443114",
"0.55366457",
"0.5525987",
"0.5520612",
"0.55031186",
"0.5477239",
"0.54651034",
"0.5462928",
"0.54602665",
"0.5447416",
"0.543846",
"0.54327255",
"0.54187167",
"0.54187167",
"0.54187167",
"0.54187167",
"0.54187167",
"0.539415",
"0.5389186",
"0.53761774",
"0.53661805",
"0.536429",
"0.53637624",
"0.5355901",
"0.5345571",
"0.53406453",
"0.53237617",
"0.5311056",
"0.5307295",
"0.52898055",
"0.528464",
"0.5279452",
"0.5258486",
"0.5245077",
"0.52406",
"0.52277935",
"0.5225453",
"0.5224672"
] | 0.8377896 | 0 |
Returns the amount of minutes that occur between a DateTime range | def duration_for(range)
raise "Range cannot be nil" if range.nil?
raise "Durations can only be calculated for ranges" unless range.kind_of? Range
((range.end - range.begin) * 24 * 60).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_work_minutes\n @date_range.inject(0) do |minutes, date|\n # Do not count days off\n minutes += get_minutes_in_day(date) unless day_off?(date)\n minutes\n end\n end",
"def get_minutes\n de = self.string_to_datetime(@from)\n a = self.string_to_datetime(@to)\n \n total = ((a.hour - de.hour) * 60) + (a.min - de.min)\n end",
"def get_duration_integer_minutes\n\t\t((end_time - start_time) / 60).to_i\n\tend",
"def time_count(start_time, end_time)\n h1 = get_hour(start_time)\n h2 = get_hour(end_time)\n m1 = get_minute(start_time)\n m2 = get_minute(end_time)\n\n return 0 if ( h1 > h2 ) || ( h1 == h2 && m1 >= m2 )\n \n 1\n end",
"def calc_mins_till\n (@difference.round(2) / 60.00).round(2)\n end",
"def time_range\n return 0 if start_hour.blank? || start_minute.blank?\n\n return 0 if end_hour.blank? || end_minute.blank?\n\n hours_between_times\n end",
"def diff(start, finish)\n utc_start = to_utc(start)\n utc_finish = to_utc(finish)\n utc_start, utc_finish = utc_finish, utc_start if utc_finish < utc_start\n minutes = 0\n\n while utc_start != utc_finish\n week = find_weekpattern(utc_start)\n r_minutes, utc_start = week.diff(utc_start, utc_finish)\n minutes += r_minutes\n end\n minutes\n end",
"def time_length\n (end_time.hour - start_time.hour) + (end_time.min - start_time.min) / 60.0\n end",
"def time_range\n start_time..end_time\n end",
"def period_in_seconds\n (start_time.to_i..end_time.to_i)\n end",
"def time_diff\n diff = (@start_at and @end_at) ? @end_at.to_time - @start_at.to_time : 0\n diff.round.to_i\n end",
"def duration; ((endtime()- starttime()) / 60).to_i; end",
"def elapsed_minutes(start_time, end_time)\n raise \"End time must be after start time\" unless start_time < end_time\n working_start_time = time(start_time)\n working_end_time = time_or_end_of_day(end_time)\n\n if year_day(working_start_time) == year_day(working_end_time) # both times are on the same day\n return to_work_time(working_end_time) - to_work_time(working_start_time)\n end\n\n # elapsed time spans more than one day\n\n minutes = minutes_to_end_of_day(working_start_time)\n while year_day(working_start_time) < year_day(working_end_time)\n working_start_time = next_working_day(working_start_time)\n if year_day(working_start_time) < year_day(working_end_time)\n minutes += total_working_minutes(working_start_time)\n else\n minutes += minutes_worked_today_until(working_end_time)\n end\n end\n minutes\n end",
"def in_minutes\n Duration::new(seconds: @seconds).to_minutes\n end",
"def nights\n count = (@end_date - @start_date)/(60*60*24)\n return count\n end",
"def counting_minutes(str)\n time1, time2 = str.split('-')\n mins1, mins2 = time_to_minutes(time1), time_to_minutes(time2)\n difference = mins2 - mins1\n if difference.negative?\n difference += 1440\n end\n difference\nend",
"def count_time(relevant_line)\n t0 = 0\n time_between = []\n relevant_line.each do |n|\n t1 = Time.parse(n)\n d = t1 - t0\n t0 = t1\n time_between << d\n end\n time_between\nend",
"def CountingMinutesI(str)\n\n from = str.split(\"-\")[0]\n to = str.split(\"-\")[1]\n fromMinute = from.gsub(\"am\", \"\").gsub(\"pm\", \"\")\n fromMinute = fromMinute.split(\":\")[0].to_i * 60 + fromMinute.split(\":\")[1].to_i\n toMinute = to.gsub(\"am\", \"\").gsub(\"pm\", \"\")\n toMinute = toMinute.split(\":\")[0].to_i * 60 + toMinute.split(\":\")[1].to_i\n \n result = 0\n multiple = 12\n if(fromMinute > toMinute)\n if (from.include?(\"am\") && to.include?(\"am\")) || (from.include?(\"pm\") && to.include?(\"pm\")) \n multiple = 24\n end\n result = multiple * 60 - (fromMinute - toMinute)\n elsif\n if (from.include?(\"am\") && to.include?(\"am\")) || (from.include?(\"pm\") && to.include?(\"pm\")) \n result = toMinute - fromMinute\n elsif\n result = multiple * 60 - (fromMinute - toMinute)\n end\n end\n return result\n \nend",
"def length\n difference = (self.end_time.to_datetime - self.begin_time.to_datetime).to_f\n if difference.approx( HALF_DAY, 0.01)\n 0.5\n elsif difference.approx( WHOLE_DAY, 0.01)\n 1.0\n else\n included_dates.reject {|d| black_out?(d)}.length.to_f\n end\n end",
"def CountingMinutesI(str)\n parts = str.scan(/(\\d+):(\\d\\d)(..)-(\\d+):(\\d\\d)(..)/).flatten\n\n first_min = (parts[0].to_i * 60) + (parts[1].to_i) + (parts[2] == \"pm\" ? 720 : 0)\n second_min = (parts[3].to_i * 60) + (parts[4].to_i) + (parts[5] == \"pm\" ? 720 : 0)\n\n second_min += 1440 if first_min > second_min\n\n second_min - first_min\nend",
"def duration\n @range.last - @range.first\n end",
"def metrics_time_range(start_time, end_time)\n resource.metrics.for_time_range(start_time, end_time)\n end",
"def interval\n @to.to_i - @from.to_i\n end",
"def time_between(start_point, end_point)\n return 0 unless start_point.time && end_point.time\n end_point.time - start_point.time\n end",
"def running_time_in_minutes\n return 0 if self.started_at.nil? and self.stopped_at.nil?\n\n if self.stopped_at.nil?\n # Raid has not yet been stopped, use the current time\n ((Time.now - self.started_at)/60.0).floor\n else\n ((self.stopped_at - self.started_at)/60.0).floor\n end\n end",
"def total_working_minutes(date_time)\n return 0 unless working_day?(date_time)\n work_day = get_work_day(date_time)\n work_day.total_minutes\n end",
"def minutes\n (seconds % 3600) / 60\n end",
"def minutes_remaining\n time_elapsed = (Time.new - @start_time) / 60\n (@total_paid * 60 - time_elapsed).floor\n end",
"def seconds_in_minutes(num_min)\n\tnum_min * 60\nend",
"def nights\n return (@end_date - @start_date).to_i\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n # Your code goes here!\n return 0 if list_of_integers.length == 0 || upper_bound < lower_bound\n\n numbers_between = 0\n\n list_of_integers.each { |this_integer| \n if this_integer >= lower_bound && this_integer <= upper_bound\n numbers_between += 1\n end\n }\n\n return numbers_between\nend",
"def minutes\n _nudge[1]\n end",
"def count_between(list_of_integers,lower_bound,upper_bound)\nr = Range.new(lower_bound,upper_bound)\nnew_array=[]\nlist_of_integers.each do |x|\n if r.include?(x)\n new_array.push(x)\n end\n\nend\n\nreturn new_array.length\nend",
"def nights\n (end_date - start_date).to_i\n end",
"def month_range start_time, end_time\n start_date = start_time.month_start.to_date\n end_date = end_time.month_start.to_date\n current_date = start_date\n result = []\n while current_date <= end_date\n result << current_date.to_time\n current_date = current_date.next_month\n end\n result\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\nnew_array=Array.new\nlist_of_integers.each {|x|\n if x >= lower_bound.to_i && x <= upper_bound.to_i\n new_array << x\n end}\n return new_array.length\nend",
"def get_owghat_range\n @now = (Time.now.hour-1) *60 + Time.now.min \n if @now <420 and @now>300\n return 1\n elsif @now>720 and @now<1140\n return 2\n elsif @now>1200 and @now<1440 \n return 4\n else \n return -1\n end\n end",
"def workdays_in_range\n end_time ? (start_time.to_date..end_time.to_date).select { |d| (1..5).cover?(d.wday) }.size - offset : 1\n end",
"def minutes\n (@seconds.abs / 60) % 60 * (@seconds < 0 ? -1 : 1)\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\n new_array = []\n \n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n new_array.push(num)\n end\n end\n new_array.length\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\n #find numbers less than or equal to upper bound\n #find numbers greater than or equal to lower bound\n # how many there are\n counter = []\n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n counter.push(num)\n else\n end\n end\n return counter.length\nend",
"def getMinutes\r\n\t\t\t\t\treturn @minutes\r\n\t\t\t\tend",
"def duration\n if start_time && end_time\n end_time.to_i - start_time.to_i\n else\n 0.0\n end\n end",
"def minutes_till(other, options = {})\n options[:overflow] = true if options[:overflow].nil?\n\n if options[:overflow]\n if self > other\n (self.minutes_till(TimeOfDay.new(\"24:00\"))) + other.to_i\n else\n other.to_i - self.to_i\n end\n else\n raise TimeOfDayOutOfRange if self > other\n other.to_i - self.to_i\n end\n end",
"def total_minutes\n hours * 60 + minutes\n end",
"def mins\n @msecs / MIN_TO_MS_F\n end",
"def difference_in_minutes time_one, time_two\n time_one_with_resetted_date = reset_date_for_time time_one\n time_two_with_resetted_date = reset_date_for_time time_two\n (time_one_with_resetted_date - time_two_with_resetted_date) / 60\n end",
"def to_minutes; Rational === @val ? @val/60 : @val/60.0 end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n count = 0\n list_of_integers.each do |int|\n if (lower_bound..upper_bound).include? int\n count = count + 1\n end\n end\n return count\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers.nil?\n return 0\n end\n list_of_integers.count do |integer|\n (lower_bound..upper_bound).include?(integer)\n end\nend",
"def ends_at\n starts_at + minutes.minutes\n end",
"def days_between(start_time, end_time)\n days_between = (Date.parse(end_time) - Date.parse(start_time)).to_i\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\nelsif upper_bound < lower_bound\n return 0\nend\n# sum = 0\n# sum = list_of_integers[lower_bound..upper_bound].each\n# for integer in lower_bound..upper_bound\n# p integer\n# if list_of_integers.each >= lower_bound && list_of_integers.each <= upper_bound\nnew_array = []\nlist_of_integers.each do |number| if number >= lower_bound && number <= upper_bound\nnew_array.push(number)\nend\nend\nsum = new_array.length\nsum\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\n\n list_of_integers.each do |n|\n answer = 0\n if n >= lower_bound && n <= upper_bound\n answer = answer + 1\n else\n end\n\n end\nend",
"def minutes_worked_today_until(date_time)\n return 0 unless working_day?(date_time)\n work_day = get_work_day(date_time)\n t = to_work_time(date_time)\n return 0 if t < work_day.start_time\n return total_working_minutes(date_time) if t > work_day.end_time\n end_time = to_work_time(date_time)\n end_time - work_day.start_time\n end",
"def CountingMinutesI(str)\n times = str.split('-')\n times.map! do |time|\n hours, minutes = time.split(':').map(&:to_i)\n hours += 12 if time[-2..-1] == 'pm' && hours < 12\n hours -= 12 if time[-2..-1] == 'am' && hours >= 12\n hours * 60 + minutes\n end\n times.reverse.inject(:-) % 1440\nend",
"def num_of_nights\n num_of_nights = (end_date - start_date).to_i\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\n end\n new_array = list_of_integers.select { |x| x >= lower_bound && x <= upper_bound }\n new_array.length\nend",
"def time_diff(start_time, end_time)\n #calculate time elapsed\n elapsed_seconds = ((self.end_time - self.start_time)).to_i\n mins, secs = elapsed_seconds.divmod(60)\n hours, mins = mins.divmod(60)\n days, hours = hours.divmod(24)\n return days, hours, mins, secs\nend",
"def minutes() 60 * seconds end",
"def elapsed_time\n seconds = (self.end_at.to_i - self.start_at.to_i)\n (seconds / 60)\n end",
"def getDurationMinutes\r\n\t\t\t\t\treturn @durationMinutes\r\n\t\t\t\tend",
"def number_of_hours(datetime, exclude_shift = nil)\n week_start = datetime.beginning_of_week\n week_end = datetime.end_of_week\n\n base = exclude_shift ? shifts.where(\"id != ?\", exclude_shift.id) : shifts\n\n base.where(\"start <= ? AND finish >= ?\", week_end, week_start).sum do |shift|\n # Intersect the shift with the week boundaries\n in_week_start = [week_start, shift.start].max\n in_week_finish = [week_end, shift.finish].min\n\n (in_week_finish - in_week_start)/3600\n end.round(2)\n end",
"def duration\n @duration ||=\n self.starts_at && self.ends_at &&\n ((self.ends_at - self.starts_at) / 60.0 / 60.0)\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\ncount = 0\nrange_array = *(lower_bound..upper_bound)\nlist_of_integers.each do |i|\nif range_array.include?(i) == true\ncount += 1\nend\nend\nreturn count\nend",
"def minutes ; Duration[self * 60] ; end",
"def get_worked_hours start_time, end_time\n start_time = DateTime.new(start_time.year, start_time.month, start_time.day, start_time.hour, start_time.min, start_time.sec)\n end_time = DateTime.new(end_time.year, end_time.month, end_time.day, end_time.hour, end_time.min, end_time.sec)\n hours_diff = ((end_time.to_time - start_time.to_time) / 1.hours ).round(2)\n hours_diff *= -1 if hours_diff < 0\n return hours_diff\n end",
"def worked(start_date = DateTime.now, end_date = start_date)\n self.timeslips(start_date, end_date).collect do |timeslip|\n timeslip.hours\n end.inject(0) { |sum, i| sum += i }\n end",
"def after_midnight(time)\n hrs, mins = time.split(':')\n mins_in_hrs = hrs.to_i * 60\n total = mins_in_hrs + mins.to_i\n return 0 if total == 1440\n total\nend",
"def minutes\n self * SECONDS_IN_MINUTES\n end",
"def duration\n @duration ||= (range[1] - range[0]) / 1000.0\n end",
"def calculate_length(minutes, seconds)\n (minutes * 60) + seconds\nend",
"def duration\n return -1.0 if @start_time.nil? || @end_time.nil?\n (@end_time - @start_time) / 60.0\n end",
"def pm_ratio_value\n return 1 if end_date.nil?\n num_days = (end_date - start_date).to_i + 1\n num_days == 3 ? 0 : num_days\n end",
"def timegap(start_time, end_time)\n time_gap = Time.parse(end_time) - Time.parse(start_time) \n (time_gap / 3600).ceil\nend",
"def time_range min, max\n spawn :@trange, [min, max].map { |e| time_to_long e }\n end",
"def time_duration(mytime, start_time, end_time)\n # implement this\n return 9999999\n end",
"def calc_hours_till\n (calc_mins_till / 60.00).round(2)\n end",
"def duration\n 1 + (@end_date - @start_date).to_i\n end",
"def elapsed_time\n if end_time && start_time\n return ((end_time - start_time)/60).round\n else\n return 0\n end\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n\treturn list_of_integers.count {|x| x >= lower_bound && x <= upper_bound}\nend",
"def days_diff\n if self.end_at.nil? || self.start_at.nil?\n return 0\n end\n n = Integer(self.end_at - self.start_at) + 1\n return n\n end",
"def before_midnight(time)\n total_minutes = after_midnight(time)\n total_minutes == 0 ? 0 : 1440 - total_minutes\nend",
"def total(from = nil, to = nil)\n intervals(from, to).inject(0){|m, (start, stop)| m + (stop - start)}.to_i\n end",
"def total_minutes_towards_goal(array)\n total = 0 \n array.each do |each_one|\n total += each_one.time_unit_minutes\n end\n total\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\n end\n\n counter = 0\n list_of_integers.each { |x|\n if (x >= lower_bound) && (x <= upper_bound)\n counter += 1\n elsif\n counter += 0\n end\n }\n p counter\nend",
"def minutes ; self * 60 ; end",
"def total_time\n entries.reduce(0) do |acc, entry|\n acc + entry.total_minutes\n end\n end",
"def set_time_range\n begin_date = Date.strptime(params[:begin_date], '%Y-%m-%d') rescue User.minimum(:created_at) rescue Date.new(2015)\n end_date = Date.strptime(params[:end_date], '%Y-%m-%d') rescue Time.zone.today\n @stats_time_range = (begin_date.beginning_of_day)..(end_date.end_of_day)\n end",
"def minutes\n\t\treturn self * 60\n\tend",
"def minutes\n\t\treturn self * 60\n\tend",
"def duration(quest)\n created = quest.created_at\n updated = quest.updated_at\n minutes = (updated - created) / 1.minutes\n return minutes.round\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\n list_of_integers.count {|x| x>= lower_bound && x <= upper_bound}\nend",
"def calc_interval(number_events)\n\tprng = 60.00/number_events # temporal solution, IMPROVE\n\n\treturn (interval)\nend",
"def recalculate_stats_interval\n 30 # minutes\n end",
"def extract_range(options)\n (options[:range] || (options[:since]..options[:until]))\n .to_time_range.round(options[:granularity]).utc\n end",
"def count_between(list_of_integers, lower_bound, upper_bound)\nin_bounds = []\n\n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n in_bounds << num\n else\n \"out of bounds\"\n end\n end\n\n p in_bounds.length\n\nend",
"def minutes\n value_parts[1]\n end",
"def minutes\n value_parts[1]\n end"
] | [
"0.711077",
"0.68749887",
"0.67467177",
"0.6497978",
"0.6446701",
"0.64376456",
"0.6242228",
"0.61701834",
"0.600537",
"0.5982471",
"0.59077907",
"0.58859533",
"0.5776286",
"0.5773847",
"0.5755307",
"0.57261384",
"0.5721615",
"0.5717158",
"0.57100457",
"0.57046914",
"0.5669144",
"0.56521565",
"0.5643499",
"0.5609185",
"0.5596371",
"0.55836356",
"0.55832314",
"0.55782115",
"0.5563652",
"0.55457956",
"0.554458",
"0.55432725",
"0.5543181",
"0.55165297",
"0.5507257",
"0.5490086",
"0.5483103",
"0.5474859",
"0.5473715",
"0.547052",
"0.5454892",
"0.5441329",
"0.5438207",
"0.5435601",
"0.5432719",
"0.54288256",
"0.5395315",
"0.53896445",
"0.5355212",
"0.5341967",
"0.5339096",
"0.53313786",
"0.53289354",
"0.5325536",
"0.5325244",
"0.5304846",
"0.52967244",
"0.5290491",
"0.5281552",
"0.5280531",
"0.5275868",
"0.5275074",
"0.52676845",
"0.5255919",
"0.52537555",
"0.52518404",
"0.5248944",
"0.5247701",
"0.5241108",
"0.523981",
"0.5238575",
"0.5238482",
"0.5238428",
"0.5234121",
"0.52234864",
"0.52181536",
"0.5216742",
"0.52135634",
"0.5212188",
"0.52119726",
"0.5210619",
"0.5210451",
"0.52101433",
"0.5205266",
"0.51961064",
"0.5194938",
"0.5194258",
"0.51934624",
"0.51913756",
"0.5190387",
"0.51858467",
"0.51858467",
"0.5183611",
"0.51775473",
"0.5169194",
"0.5165226",
"0.5152315",
"0.51405334",
"0.5140353",
"0.5140353"
] | 0.60406035 | 8 |
Get all TimeEntry(s) that match the current session properties. +:target_date+ A DateTime to base the TimeEntry collection query from. | def time_entries_for(target_date)
target_day = Skej::NLP.parse(session, target_date.to_s)
.strftime('%A')
.downcase
.to_sym
TimeEntry.where(build_query_params).with_day(target_day).map do |entry|
entry.session = session and entry
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_entries\n get_ticket_property_list(\"time_entries\" , Unfuddled::TimeEntry)\n end",
"def get_time_entries(start_date=nil, end_date=nil)\n options = Hash.new\n options[\"start_date\"] = iso8601_date(start_date) if start_date\n options[\"end_date\"] = iso8601_date(end_date) if end_date\n get \"/time_entries\", options\n end",
"def entries\n settings.time_entries.present? ? settings.time_entries : []\n end",
"def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end",
"def time_entries(start_date, end_date)\n opts = {\n params: {\n start_date: start_date.to_datetime.iso8601,\n end_date: end_date.to_datetime.iso8601\n }\n }\n\n begin\n response = toggl_resource['time_entries'].get(opts)\n rescue => e\n raise 'Error getting Toggl data: ' + e.response\n end\n data = JSON.parse response\n\n data.map do |entry|\n duration = entry['duration'].to_f\n\n # Negative duration means the task is currently running.\n # In this case, we'll set duration to how long it's been running\n if duration < 0\n duration = Time.now - Time.at(duration.abs)\n end\n\n {\n description: entry['description'],\n start: Date.parse(entry['start']),\n duration: duration\n }\n end\n end",
"def time_log_entries(user_id, started_at, stopped_at, project_id)\n result = TimeLogEntry::Flex.by_user(user_id)\n if started_at.present? && stopped_at.present?\n result = result.after_stopped_at(started_at.sub(' ', 'T'))\n result = result.before_started_at(stopped_at.sub(' ', 'T'))\n end\n result = result.by_project(project_id) if project_id.present?\n result.map{ |found_element| found_element['_source'] }\n end",
"def all_matchday_times\n all_matches = fetch_matches\n matchtimes = Hash[(1..38).collect { |md| [md, []] }]\n all_matches.each do |m|\n matchtimes[m['matchday']].push(m['utcDate'])\n end\n matchtimes\n end",
"def index\n @session_times = SessionTime.all\n end",
"def index\n @records = current_user.records.order(target_date: :desc)\n end",
"def extract_target_entries\n extract_host_entries\n extract_event_entries\n extract_service_entries\n extract_note_entries\n extract_vuln_entries\n extract_web_entries\n end",
"def time_entry_scope(options={})\n @query.results_scope(options)\n end",
"def time_entry_scope(options={})\n @query.results_scope(options)\n end",
"def entries\n if @group_by\n most_recent_matching_entry_in_group\n elsif @most_recent_only\n Array(most_recent_matching_entry)\n elsif @created_within\n get_created_within\n else\n matching_entries\n end\n end",
"def find\n return nil unless entry_paths.any?\n past_entries = entry_paths.map do |path|\n match = path.match(DATE_PATH_MATCHER)\n Date.parse(match.to_s)\n end.select { |date| date < today }\n\n past_entries.last\n end",
"def get_entries(date = nil)\r\n if date.nil?\r\n list = []\r\n for i in @log\r\n list.push(i)\r\n end\r\n elsif @log[date].nil?\r\n list = nil\r\n else\r\n list = @log[date]\r\n end\r\n list\r\n end",
"def filtered_by_target(target)\n filtered_by_association(\"target\", target)\n end",
"def retrieve_tasks\n Query.get_data(@values[:id], @values[:start_time], @values[:end_time])\n end",
"def retrieve_tasks\n Query.get_data(@values[:id], @values[:start_time], @values[:end_time])\n end",
"def retrieve_tasks\n Query.get_data(@values[:id], @values[:start_time], @values[:end_time])\n end",
"def hits_for_day(timestamp)\n properties = Advert.where(user_id: self.id).pluck(:property_id)\n beg_time = Time.zone.at(timestamp).beginning_of_day\n end_time = Time.zone.at(timestamp).end_of_day\n Hit.where(\"property_id IN (?)\", properties).where(created_at: beg_time..end_time).all\n end",
"def list_targets\n # Date is the current date per RFC 2616, section 3.3.1,\n # rfc1123-date format, e.g.: Sun, 22 Apr #2012 08:49:37 GMT.\n date_timestamp = Time.now.httpdate # ruby provides this date format with httpdate method\n signature = build_signature(\"/targets\", nil, \"GET\", date_timestamp)\n raise ArgumentError.new(\"Signature returned nil. Aborting...\") if signature.nil?\n\n authorization_header = \"VWS \" + @accesskey + \":\" + signature\n begin\n RestClient.get(TARGETS_URL, Date: date_timestamp, Authorization: authorization_header)\n rescue => e\n e.response\n end\n end",
"def matchdays_times_for(matchdays)\n all_matches = fetch_matches_scheduled\n matchtimes = Hash[matchdays.collect { |md| [md, []] }]\n all_matches.each do |m|\n next unless matchdays.include?(m['matchday'])\n\n matchtimes[m['matchday']].push(m['utcDate'])\n end\n matchtimes\n end",
"def list(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time: :unset, start_time_before: :unset, start_time_after: :unset, end_time: :unset, end_time_before: :unset, end_time_after: :unset, limit: nil, page_size: nil)\n self.stream(\n to: to,\n from: from,\n parent_call_sid: parent_call_sid,\n status: status,\n start_time: start_time,\n start_time_before: start_time_before,\n start_time_after: start_time_after,\n end_time: end_time,\n end_time_before: end_time_before,\n end_time_after: end_time_after,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def show\n @event = Event.find(params[:id])\n @times_allowed = @event.times_allowed.map(&:to_datetime)\n @participants = @event.participants\n end",
"def time_entry(id:)\n ::TimeEntry.find_by(id: id)\n end",
"def all_people_scheduled\n Entry.users_for_client(self.id)\n end",
"def fetch_events_time(range_begin_in_secs, range_end_in_secs)\n #\n # collect from_time beginning of day (in seconds)\n #\n frt = self.from_time.beginning_of_day.to_i\n\n case self.recurrence_type\n when \"NO_RECURRENCE\"\n self.no_recurrence_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_DAYS\"\n self.recur_every_n_days_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_WEEKS\"\n self.recur_every_n_weeks_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_MONTHS\"\n self.recur_every_n_months_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_YEARS\"\n self.recur_every_n_years_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_DAYS_OF_WEEK\"\n self.recur_every_days_of_week_dates(range_begin_in_secs, range_end_in_secs, frt)\n else\n []\n end\n end",
"def history_timestamps\n self.class.history.timestamps do |query|\n query.where(:id => self)\n end\n end",
"def show\n\t\tif current_user.caregiver\n\t\t\t@target\t= current_user.caregiver\n\t\t\tif params[:related_id]\n\t\t\t\t@related_user = Requester.find(params[:related_id])\n\t\t\telse\t\n\t\t\t\t@related_user = Requester.find(params[:id])\n\t\t\tend\n\t\t\t@schedules = @target.schedules.where(:requester => @related_user).where([\"scheduled_date >=?\",@@target_date - 2.days]).where([\"scheduled_date <?\",@@target_date + 2.days]).order(\"scheduled_date Asc\")\n\t\telse\n\t\t\t@target\t= current_user.requester\n\t\t\tif params[:related_id]\n\t\t\t\t@related_user = Caregiver.find(params[:related_id])\n\t\t\telse\n\t\t\t\t@related_user = Caregiver.find(params[:id])\n\t\t\tend\t\n\t\t\t@schedules = @target.schedules.where(:caregiver => @related_user).where([\"scheduled_date >=?\", @@target_date - 2.days]).where([\"scheduled_date <?\",@@target_date + 2.days]).order(\"scheduled_date Asc\")\n\t\tend\n\t\t@schedule_dates = @schedules.pluck(:scheduled_date).uniq\n\t\t@schedule_ids = @schedules.pluck(:id).uniq\n\t\t@timezones = TimeZone.find(@schedules.includes(:events).pluck(:time_zone_id).uniq)\n\t\t# no use:\n\t\t# @schedules = @requester.caregivers.where(:user => current_user).uniq.first.schedules\n\t\t# @schedules = Schedule.includes(:events).where(:requester_id => @requester_id)\n\t\t# @schedules = Schedule.where([\"scheduled_date>?\", Time.now]).where([\"scheduled_date<?\",Time.now + 7.days]).find_by_id(@requester.events.includes(:schedule).pluck(:schedule_id))\n\tend",
"def index\n @logs ||= Log.where(device_id: selected_device).order(created_at: :desc)\n unless params[:start_time].blank?\n start_date = DateTime.parse(\"#{params[:start_time]} 00:00:00\")\n @logs = @logs.where(\"created_at >= :start_time\", {start_time: start_date})\n end\n\n unless params[:end_time].blank?\n end_date = DateTime.parse(\"#{params[:end_time]} 23:59:59\")\n @logs = @logs.where(\"created_at <= :end_time\", {end_time: end_date})\n end\n end",
"def show_team_entries\n @meeting_events_list = @meeting.meeting_events\n .joins(:event_type, :stroke_type)\n .includes(:event_type, :stroke_type)\n .order('meeting_events.event_order')\n\n # Get a timestamp for the cache key:\n @max_entry_updated_at = get_timestamp_from_relation_chain(:meeting_entries)\n end",
"def all_sessions\n @the_sessions = []\n teachers = Teacher.where(school_id: current_teacher.school_id)\n teachers.each do |the_teacher|\n some_sessions = Session.where( session_teacher: the_teacher)\n @the_sessions << some_sessions \n end\n return @the_sessions\n end",
"def get_all_user_sessions(user_uid,start_date,user_request_id)\n # PostgresLacticSessions.get_by_uid(user_uid,start_date,user_request_id)\n get_pg_by_uid(user_uid,start_date,user_request_id)\n end",
"def pull_time_entries_harvest(user_id)\n harvest_uri = URI(\"https://api.harvestapp.com/v2/time_entries?user_id=#{user_id}&updated_since=#{last_updated_time}\")\n\n Net::HTTP.start(harvest_uri.host, harvest_uri.port, use_ssl: true) do |http|\n harvest_request = Net::HTTP::Get.new harvest_uri\n\n harvest_request[\"Authorization\"] = \"Bearer #{harvest_access_token}\"\n harvest_request[\"Harvest-Account-ID\"] = harvest_account_id\n harvest_request[\"User-Agent\"] = harvest_user_agent\n \n harvest_response = http.request harvest_request\n json_response = JSON.parse(harvest_response.body)\n return json_response[\"time_entries\"]\n end\n end",
"def starting(time_since:, time_until:)\n table.where(\"start >= ? AND start <= ?\", time_since, time_until).entries\n end",
"def index\n set_user\n @time_offs = TimeOff.all\n end",
"def get_current_calendar\n session[:cal_time] ||= Time.now\n Entry.find(:all,\n :conditions => [ 'created_at > ? and created_at < ?',\n\t\t session[:cal_time].at_beginning_of_month,\n\t\t session[:cal_time].next_month.at_beginning_of_month ]\n\t ).collect { |e|\n e.created_at.day\n }.uniq\n end",
"def get_times\n @start_time = case params[:start]\n when Hash\n DateTime.civil(params[:start][:year].to_i, params[:start][:month].to_i, params[:start][:day].to_i, params[:start][:hour].to_i, params[:start][:minute].to_i, 0)\n when String\n DateTime.strptime(params[:start], \"%Y:%m:%d %h:%m:%s\")\n else nil\n end\n @end_time = case params[:end]\n when Hash\n DateTime.civil(params[:end][:year].to_i, params[:end][:month].to_i, params[:end][:day].to_i, params[:end][:hour].to_i, params[:end][:minute].to_i, 0)\n when String\n DateTime.strptime(params[:end], \"%Y:%m:%d %h:%m:%s\")\n else DateTime.now\n end\n logger.debug \"#{@start_time} to #{@end_time}\"\n end",
"def list\n key = KEY_FORMAT % @visualization.id\n users_expiry = $tables_metadata.hgetall(key)\n now = current_timestamp\n users_expiry.select { |_, expiry| expiry.to_i > now }.keys\n end",
"def index\n if dates_ok?\n @entries = Entry.where(\"user_id = ?\", current_user.id).where(\"\\\"time\\\"(date) BETWEEN ? AND ?\", params[:timeFrom], params[:timeTo]).where(\"CAST(date AS DATE) >= ? and CAST(date AS DATE) <= ?\", Date.parse(params[:dateFrom]), Date.parse(params[:dateTo]))\n else\n @entries = Entry.where(\"user_id = ?\", current_user)\n end\n\n end",
"def get_runtime_timestamps\n all_events = events.to_a\n start_time = DateTime.parse(all_events.first['timestamp'])\n completion_time = DateTime.parse(all_events.last['timestamp'])\n [start_time, completion_time]\n end",
"def days_scheduled(start_date, end_date)\n all_entries = Entry.user_entries_by_date(self.id, start_date, end_date)\n all_entries.select { |_,v| v.any? }.keys\n end",
"def get_trends_times(selection)\n # this is get_latest_trends_timing but for a selection of times -- it will allow the user to search for cohorts of trends over scalable time as opposed to a single snapshot. It may replace get_latest_trends_timing as it will return however many time-objects specified by the parameter.\n return_array = LocalTrendingEvent.where(country_id: self.id).order(\"time_of_trend desc\")\n times_array = []\n return_array.each do |lte|\n times_array.push(lte.time_of_trend)\n end\n times_array.uniq!\n return times_array[0..selection.to_i]\n end",
"def current_deals\n if params[:start_time] && params[:end_time]\n @deals = Deals.find(:all, :conditions => {:dateTime.now => start_date..end_date})\n end\n end",
"def list(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, limit: nil, page_size: nil)\n self.stream(\n to: to,\n from: from,\n parent_call_sid: parent_call_sid,\n status: status,\n start_time_before: start_time_before,\n start_time: start_time,\n start_time_after: start_time_after,\n end_time_before: end_time_before,\n end_time: end_time,\n end_time_after: end_time_after,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def get_current_events\n events = get_events\n current_events = []\n \n events.each do |event| \n if event.date > DateTime.now and event.date < DateTime.now + 2.months\n current_events << event\n end\n end\n \n return current_events\n end",
"def all(options={})\n results = []\n current_time = Time.now\n key = \"#{current_time.year}/#{current_time.month}/#{current_time.day}/#{current_time.hour}\"\n case options[:order]\n when \"application\"\n column_family = :logs_by_application\n when \"machine\"\n column_family = :logs_by_machine\n else\n return current_epoch(options)\n end\n options.delete(:order)\n @@data_store.get(column_family, key, options).each do |log_entry|\n uuid = log_entry[1].keys.first.to_guid\n attributes = @@data_store.get(:logs, key, uuid)\n attributes[\"uuid\"] = uuid\n results << new(attributes)\n end\n results\n end",
"def time_entry(id)\n object_from_response(:get, \"time_entries/#{id}\", \"time-entry\")\n end",
"def all_history_as_of(last_update)\n history(history: { since: last_update })\n end",
"def list(m, target)\n target.gsub!(/^\\s+/,\"\") #remove leading whitespace\n results = []\n read(:tasks).each do |record|\n unless target.empty?\n target_regex = /#{target}/\n if record[\"tag\"] =~ target_regex || record[\"creator\"] =~ target_regex\n results << record\n end\n end\n end\n m.reply \"==== found #{results.length} results. ====\"\n # sort by last bumped\n sorted = results.sort do |x,y| \n xd = DateTime.iso8601(x[\"bumped\"]) \n yd = DateTime.iso8601(y[\"bumped\"]) \n yd <=> xd\n end\n sorted.each_with_index do |r, ind|\n m.reply \"!#{r[\"id\"]} ##{r[\"tag\"]} '#{r[\"text\"]}'; created by #{r[\"creator\"]}\"\n end\n m.reply \"==== **** ====\"\n end",
"def get_entries_from_db(query, target_column)\n\t\tresults = [] \n\t\t# gid_history = Set.new\n\t\t\n\t\t# 1. Get the base dictionary.\n\t\t# Notice:\n\t\t# Assume that the names of base dictionaries are unique.\n\t\t#\n\t\tdic = @db::Dictionary.select(:id).where(:title => @dic_name).first\n\t\tif dic.nil?\n\t\t\treturn results\n\t\tend\n\n\t\t# 2. Get the list of removed entries from the associated user dictionary.\n\t\t# Notice:\n\t\t#\n\t\tuser_dics = @db::UserDictionary.select(:id).where(:dictionary_id => dic[:id]).where(:user_id => @user_id)\n\t\tif user_dics.blank?\n\t\t\tremoved_entry_idlist = []\n\t\telse\n\t\t\t# Assume that the user dictionary to a specific base dictionary is unique (only one)\n\t\t\ttarget_user_dic = user_dics.first\n\n\t\t\t# Convert a key-value hash to an array of values by using .all.values\n\t\t\tremoved_entry_idlist = @db::RemovedEntry.select(:entry_id).where(:user_dictionary_id => target_user_dic[:id]).all.map do | item |\n\t\t\t\titem[:entry_id]\n\t\t\tend\n\t\tend\n\t\t\n\t\t# 3. Retrieve the entries for a given query except those are marked as removed\n removed_entry_idlist = [0] if removed_entry_idlist.blank?\n\t\tds = @db::Entry.where(:dictionary_id => dic[:id]).where(target_column => query).where('id NOT IN (?)', removed_entry_idlist)\n\t\tds.all.each do |row|\n\t\t\tresults << { label: row[:label], uri: row[:uri], title: row[:view_title] }\n\t\t\t# Use if the same gene id has not been found yet\n\t\t\t# if not gid_history.include?( row[:uri] )\n\t\t\t# \tresults << { label: row[:label], uri: row[:uri], title: row[:title] }\n\t\t\t# \tgid_history.add( row[:uri] )\n\t\t\t# end\n\t\tend\n\n\t\t# 4. Add newly added entries by a user\n\t\tif user_dics.present?\n\t\t\tds = @db::NewEntry.where(:user_dictionary_id => target_user_dic[:id]).where(target_column => query)\n\t\t\tds.all.each do |row|\n\t\t\t\tresults << { label: row[:label], uri: row[:uri], title: row[:view_title] }\n\n\t\t\t# \tif not gid_history.include?( row[:uri] )\n\t\t\t# \t\tresults << { label: row[:label], uri: row[:uri], title: row[:title] }\n\t\t\t# \t\tgid_history.add( row[:uri] )\n\t\t\t# \tend\n\t\t\tend\n\t\tend\n\n\t\treturn results\n\tend",
"def from\n @from ||= begin\n results = relation.search_with_conditions(public_access, rows: 1, sort: MODIFIED_DATE_FIELD + ' asc')\n if results.present?\n results.first.fetch(MODIFIED_DATE_FIELD)\n else\n BEGINNING_OF_TIME\n end\n end\n end",
"def assets_under_lease\n ActiveFedora::Base.where(\"#{Hydra.config.permissions.lease.expiration_date}:[* TO *]\")\n end",
"def where(options={})\n results = []\n current_time = Time.now\n key = \"#{current_time.year}/#{current_time.month}/#{current_time.day}/#{current_time.hour}\"\n\n # Multiple compares\n if options[:machine].is_a?(String) && options[:application].is_a?(String)\n key = key + \"_\" + options[:machine]\n @@data_store.get(:logs_by_machine_and_application, key, options[:application]).each do |attribute_value|\n attribute_value[1].keys.each do |uuid|\n guid = uuid.to_guid\n attributes = @@data_store.get(:logs, key, guid)\n attributes[\"uuid\"] = guid\n results << new(attributes)\n end\n end\n # Compare\n elsif options[:machine].is_a?(String)\n @@data_store.get(:logs_by_machine, key, options[:machine]).each { |log_entry| results << parse_log_entry(log_entry) }\n elsif options[:application].is_a?(String)\n @@data_store.get(:logs_by_application, key, options[:application]).each { |log_entry| results << parse_log_entry(log_entry) }\n # Range\n elsif options[:machine].is_a?(Array)\n results = range(:logs_by_machine, key, :start => options[:machine].first, :end => options[:machine].second)\n elsif options[:application].is_a?(Array)\n results = range(:logs_by_application, key, :start => options[:application].first, :end => options[:application].second)\n elsif options[:date].is_a?(Array)\n results = range(:logs, key, :start => options[:date].first, :end => options[:date].second)\n end\n results\n end",
"def get_tracked_time_by_user(user_id, options = {})\n options.merge!({user_id: user_id })\n if options[:start]\n options[:start] = options[:start].strftime('%Y-%m-%d %H:%M:%S')\n end\n if options[:end]\n options[:end] = options[:end].strftime('%Y-%m-%d %H:%M:%S')\n end\n result = Paymo::API.get :entries, :get_tracked_time_by_user, options\n { time: result['time']['_content'] }\n end",
"def fetch_target_entries(conditions = {})\n if self.content_type\n self.content_type.ordered_entries(where: conditions)\n else\n []\n end\n end",
"def find_target_items\n last_job_at = Time.parse(get_config(\"TIME_LAST_INDEX_JOB\") || Time.now.yesterday.to_s)\n debug \"last_job_at = #{last_job_at}\"\n Item.valid.all(:conditions=>[\"indexed_at is null or (updated_at > ? and updated_at > indexed_at)\",last_job_at])\n end",
"def entries\n AllEntries.new(Page.new(latest_events_path, @mingle_access))\n end",
"def all_people_tracked\n Timing.users_for_client(self.id)\n end",
"def otm_all_target_tables\n [self.otm_table_namer.table_name,self.otm_table_namer.temp,self.otm_table_namer.yesterday]\n end",
"def days_without_time_tracked(look_back = 1.week)\n raise ArgumentError, 'look_back must be at least 1 day' if look_back < 1.day\n return [] if archived?\n results = []\n dates = (look_back.ago.to_date..Date.today - 1).map(&:to_date).reject{ |d| d.saturday? || d.sunday? }\n dates.each do |date|\n results << date if timings.submitted_timings.where(started_at: date.beginning_of_day...date.end_of_day).blank?\n end\n results\n end",
"def location_times\n LocationTime.where_match(\"movie_id\", id, \"==\")\n end",
"def location_times\n LocationTime.where_match(\"movie_id\", id, \"==\")\n end",
"def query_start_time\n start_time - 1.hour\n end",
"def get_time_entries(xero_tenant_id, project_id, opts = {})\n data, _status_code, _headers = get_time_entries_with_http_info(xero_tenant_id, project_id, opts)\n data\n end",
"def events(query)\n ret = Array.new\n \n feed = Feedjira::Feed.parse jira_query(query)\n \n feed.entries.each do |feed_evt|\n event = event_from_feed(feed_evt)\n event.person = query.person\n \n if (event.time < query.to && event.time > query.from)\n ret << event\n end\n end\n \n ret\n end",
"def search_time_sheet_activities(options={})\n cur_date = options[:start]\n method = 'search.messages'\n entries = []\n cnt = 0\n max_cnt = 15\n\n loop do\n fdate = cur_date.strftime('%Y-%m-%d')\n printf \"\\n>>> gathering activities for #{fdate}\"\n \n query = \"in:engineering from:me on:#{fdate}\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n\n break unless(cnt > max_cnt or cur_date < options[:stop])\n \n cur_date += (60*60*24)\n cnt += 1\n end\n\n entries = entries.sort_by { |h| h[:ts] }\n end",
"def entries(limit=nil)\n limit ||= -1\n LiveJournal::Request::GetEvents.new(@user, :recent => limit, :strict => false).run\n end",
"def get_keys(start_date, end_date = nil)\n keys = []\n keys << get_key_for(start_date)\n unless end_date.nil?\n while start_date <= end_date\n start_date += 60*60\n keys << get_key_for(start_date) unless start_date > end_date\n end\n keys << get_key_for(end_date)\n end\n keys.uniq\n end",
"def session_events(opts)\n ::ApplicationRecord.connection_pool.with_connection {\n # If we have the ID, there is no point in creating a complex query.\n if opts[:id] && !opts[:id].to_s.empty?\n return Array.wrap(Mdm::SessionEvent.find(opts[:id]))\n end\n\n # Passing workspace keys to the search will cause exceptions, so remove them if they were accidentally included.\n opts.delete(:workspace)\n\n order = opts.delete(:order)\n order = order.nil? ? DEFAULT_ORDER : order.to_sym\n\n limit = opts.delete(:limit) || DEFAULT_LIMIT\n offset = opts.delete(:offset) || DEFAULT_OFFSET\n\n search_term = opts.delete(:search_term)\n results = Mdm::SessionEvent.where(opts).order(created_at: order).offset(offset).limit(limit)\n\n if search_term && !search_term.empty?\n re_search_term = /#{search_term}/mi\n results = results.select { |event|\n event.attribute_names.any? { |a| event[a.intern].to_s.match(re_search_term) }\n }\n end\n results\n }\n end",
"def index\n @class_times = ClassTime.all\n end",
"def search_time_sheet_events(options={})\n days = {}\n method = 'search.messages'\n max_cnt = 15\n cnt = 0\n cur_date = options[:start]\n total_hours = 0.0\n\n loop do\n entries = []\n fdate = cur_date.strftime('%Y-%m-%d')\n printf \"\\n>>> processing #{fdate}\"\n \n query = \"in:engineering from:me on:#{fdate} biab\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {state: :off, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n\n query = \"in:engineering from:me on:#{fdate} brb\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {state: :off, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n \n query = \"in:engineering from:me on:#{fdate} back\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {state: :on, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n \n query = \"in:engineering from:me on:#{fdate} good\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n state = (x['text'] =~ /evening|night/) ? :off : :on\n {state: state, ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n\n entries = entries.sort_by { |h| h[:ts] }\n days[fdate] = {entries: entries}\n\n start_entry = nil\n last_entry = nil\n seconds = 60*15\n total_time_for_day = 0.0\n start = nil\n entries.each do |entry|\n begin\n printf \".\"\n entry[:diff] = 0\n\n if(entry[:state] == :off)\n stop = Time.at((entry[:ts].to_f / seconds).round * seconds)\n start = nil\n entry[:ts] = stop\n next unless start_entry\n\n diff = entry[:ts] - start_entry[:ts]\n start_entry[:diff] = (diff/(60*60))\n\n total_time_for_day += start_entry[:diff]\n start_entry = nil\n else\n time = Time.at((entry[:ts].to_f / seconds).round * seconds)\n entry[:ts] = time\n\n start_entry = entry if start_entry.nil?\n end\n rescue Exception => e\n puts \"Problem with entry: #{entry.inspect}\nstart_entry: #{start_entry.inspect}\n\"\n raise e\n end\n last_entry = entry\n end\n\n if(start_entry)\n today = Time.now.strftime(\"%Y%m%d\")\n process_day = start_entry[:ts].strftime(\"%Y%m%d\")\n\n if(today == process_day)\n time = Time.at((Time.now.to_f / seconds).round * seconds)\n\n diff_work = time - start_entry[:ts]\n start_entry[:diff] = diff_work/(60*60)\n total_time_for_day += start_entry[:diff]\n \n entries << {state: :pending, ts: time, text: \"still working\"}\n\n else\n entries << {state: :off, ts: last_entry[:ts], text: \"good day/evening (you never checked out?)\"}\n end\n end\n\n if entries.length > 0\n entries[entries.length-1][:diff] = 0.0 \n days[fdate][:hours] = total_time_for_day\n total_hours += days[fdate][:hours]\n printf \"=> #{days[fdate][:hours]} for day; #{total_hours} for range\"\n end\n\n break unless(cnt > max_cnt or cur_date < options[:stop])\n\n # go to next day\n cur_date += (60*60*24)\n cnt += 1\n end\n\n days[:hours] = total_hours\n report = {report: days}\n puts \"\\n>>> DONE!\"\n report\n end",
"def daily\n if dates_ok?\n @entries = Entry.where('user_id = ?\n AND \"time\"(date) BETWEEN ? AND ?\n AND CAST(date AS DATE) >= ? and CAST(date AS DATE) <= ?', current_user.id, params[:timeFrom], params[:timeTo], Date.parse(params[:dateFrom]), Date.parse(params[:dateTo])).\n select('CAST(date AS DATE), sum(calories) as calories').group('CAST(date AS DATE)')\n else\n @entries = Entry.where('user_id = ?', current_user.id).\n select('CAST(date AS DATE), sum(calories) as calories').group('CAST(date AS DATE)')\n end\n end",
"def times_for_schedule_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_day + 15.hours\n task_time += 1.day if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.day\n end\n\n times\n end",
"def by_target\n targets.\n map { |t| [t.object, @matches[t].map { |m| m.candidate.object }] }.\n to_h.\n freeze\n end",
"def events_in_time_range(start_date_string, end_date_string)\n return self.events if self.events.nil?\n\n if(start_date_string.is_a?(String))\n # I was told there would be no timezones :/\n start_time = DateTime.parse(start_date_string).to_time.utc\n end_time = DateTime.parse(end_date_string).to_time.utc\n else\n start_time = start_date_string\n end_time = end_date_string\n end\n\n self.events.select do |e| \n created_at_time = DateTime.parse(e.created_at).to_time.utc\n created_at_time >= start_time && created_at_time < end_time\n end\n end",
"def since_launch\n t_start = Time.parse(\"November 1, 2008\")\n t_current = t_start\n t_end = Time.today\n stats = []\n while (t_current < t_end) do\n puts \"Getting stats for #{t_current.to_s(:date_only)}\"\n stats << \"#{t_current.strftime('%m/%d/%Y')}, #{User.count(:conditions => ['activated_at >= ? and activated_at < ?', t_current, t_current + 1.day])}\"\n t_current += 1.day\n end\n puts stats\n end",
"def index\n time_range=Time.now.midnight..Time.now.end_of_day\n\n @users=User.joins(:user_times).where(:user_times=>{:login_time=>time_range,:logout_time=>nil})\n\n #@user_times=UserTime.where(\"date(login_time)=?\", DateTime.now.to_date).where(:logout_time=>nil) # implement and unique \n #@l=@user_times.where\n #@a=@user_times.map{|e| e.user_id}\n #@users=User.find(@a)\n\n # @user_times = UserTime.all\n \n #@users=@user_time.user.all\n # @at=@user_times.map{|e| e.login_time}\n end",
"def time_entry_scope(options={})\n scope = @query.results_scope(options)\n if @issue\n scope = scope.on_issue(@issue)\n end\n scope\n end",
"def time_filter(selection)\n\t\t\tif self.method_defined? :gc_created_at\n\t\t\t\ttime_column = 'gc_created_at'\n\t\t\telsif self.method_defined? :source_created_at\n\t\t\t\ttime_column = 'source_created_at'\n\t\t\telse\n\t\t\t\ttime_column = 'created_at'\n\t\t\tend\n\t\t\t\n\t\t\tif selection.is_a?(Hash)\n\t\t\t\tif selection[:filter] == 'between'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.parse(selection[:from]))\n\t\t\t\t\t\t.where(name_of_class + '.' + time_column + '<= ?', Time.parse(selection[:to]))\n\t\t\t\telse\n\t\t\t\t\tself.all\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tcase selection\n\t\t\t\twhen 'any'\n\t\t\t\t\tself.all\n\t\t\t\twhen 'today'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today)\n\t\t\t\twhen 'yesterday'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today - 1)\n\t\t\t\twhen 'this_week'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.now.beginning_of_week)\n\t\t\t\twhen 'this_month'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.now.beginning_of_month)\n\t\t\t\twhen 'last_month'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.now.last_month.beginning_of_month)\n\t\t\t\t\t\t.where(name_of_class + '.' + time_column + '<= ?', Time.now.last_month.end_of_month)\n\t\t\t\twhen 'last_7_days'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today - 7)\n\t\t\t\twhen 'last_30_days'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today - 30)\n\t\t\t\telse\n\t\t\t\t\tself.all\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def all_sessions\n self.test_sessions\n end",
"def get_all_attended_events\n events_id = Attendance.where(:user_id => self).map{ |attendence| attendence.event.id}\n Event.where(:id => events_id).where_first_meeting_starts_in_past\n end",
"def retrieve_worktime\n Query.get_time_worktime(@values[:id], @values[:start_time],\n @values[:end_time])\n end",
"def index\n @timetable_entries = TimetableEntry.all\n end",
"def all_game_times\n @rules.collect(&:game_times).flatten.uniq\n end",
"def entries(query = {})\n resp =\n _instrument 'entries', type: 'Entry', query: query do\n get('entries', query)\n end\n resp.assert_ok!\n end",
"def index\n return unless restrict_to_hosts\n\n @sessions = Session.where(event_id: @event.id)\n end",
"def get_targets(name=:target)\n ActivityTarget.where(:name => name, :activity_id => id).map{ |at| at.target }\n end",
"def stop_times\n StopTimeVersion.where(:stop_identifier => identifier)\n end",
"def index\n @allocated_times = AllocatedTime.all\n end",
"def get_device_times(id, from, to)\n node = find_start(id, from)\n list = Array.new\n while node && node.value < to_epoch(to) do\n list.push(node.value)\n break unless node.next\n node = node.next\n end\n return list\nend",
"def find_all_transitions_by_target_id(target_id)\n _arcs = arcs.select {|arc| arc.target_id == target_id}\n _transitions = _arcs.map do |arc|\n transitions.find {|transition| transition.id == arc.source_id}\n end.compact.uniq\n\n if block_given?\n _transitions.each {|transition| yield transition}\n else\n return _transitions\n end\n end",
"def find_all_across_pages_from(time)\n find_all_across_pages(:params => { :from => time.utc.strftime(\"%Y%m%d\") })\n end",
"def starts_today\n all.select {|event| event.starts == (@date_for_test || Date.today)}\n end",
"def events_for target, event_types\n url = GITHUB_EVENT_API_END_POINT % target\n etag = @etag_hash[target]\n last_event = @last_event_hash[target]\n\n events_to_send = []\n page = 1\n while page <= 10\n result = @clnt.get(url, {client_id: @client_id, client_secret: @client_secret}, {\"If-None-Match\" => etag})\n break unless result.status_code == 200\n events = JSON.load result.body\n if page == 1 # etag and last event should be set when querying the very first page\n @etag_hash[target] = result.header[\"etag\"]\n @last_event_hash[target] = events[0]\n end\n\n events.each do |event|\n return events_to_send if last_event == event # no need to proceed\n events_to_send << event if event_types.accept? event\n end\n\n page += 1\n end\n\n events_to_send\n end",
"def events_in_period\n t0 = start.midnight\n tf = finish.end_of_day\n\n events = []\n while t0 < tf\n t1 = [t0.advance(days: 21), tf].min\n events.concat(dog.stream(t0, t1, tags: @job_tags)[1]['events'])\n t0 = t1\n end\n events\n end",
"def fetch_active_session\n Rails.logger.debug \"SessionService::fetch_active_session::BEGIN\" \n current_time = Time.now\n active_session = @company.active_sessions.where(:company_id => @company.id).where(\" ? > start_time and ? < end_time\", current_time, current_time).first\n end"
] | [
"0.5922868",
"0.5683903",
"0.5566405",
"0.53385276",
"0.5298395",
"0.52521545",
"0.5115447",
"0.50400954",
"0.48718688",
"0.48286006",
"0.48045316",
"0.48045316",
"0.4798784",
"0.47657496",
"0.47596595",
"0.4755274",
"0.4742012",
"0.4742012",
"0.4742012",
"0.47243476",
"0.47109145",
"0.47024012",
"0.46744612",
"0.4661811",
"0.4648173",
"0.46476164",
"0.46442735",
"0.46428186",
"0.46378818",
"0.4636532",
"0.46332696",
"0.46243638",
"0.46144757",
"0.4612346",
"0.46023402",
"0.46004394",
"0.4594065",
"0.4583161",
"0.4577458",
"0.45709467",
"0.4568939",
"0.45646042",
"0.45595837",
"0.4551964",
"0.45484504",
"0.4542701",
"0.4540818",
"0.45277786",
"0.45229673",
"0.45206782",
"0.45184073",
"0.4516717",
"0.45005313",
"0.44955903",
"0.44949105",
"0.44884107",
"0.44820553",
"0.44772115",
"0.44664207",
"0.4461505",
"0.44503126",
"0.4449045",
"0.4447188",
"0.44407034",
"0.44407034",
"0.4431967",
"0.44251645",
"0.44233978",
"0.4418803",
"0.44161358",
"0.44042203",
"0.44012243",
"0.43968996",
"0.43960425",
"0.43843096",
"0.43805954",
"0.43782118",
"0.43766713",
"0.4374094",
"0.43725696",
"0.43723997",
"0.43720302",
"0.43692696",
"0.43635374",
"0.43597117",
"0.43595055",
"0.43566668",
"0.43471923",
"0.43377167",
"0.43286583",
"0.43177313",
"0.42986",
"0.42941242",
"0.42939374",
"0.42859805",
"0.4285401",
"0.42805913",
"0.42794734",
"0.42695832",
"0.42651498"
] | 0.8224443 | 0 |
Produces TimeSlot(s) from a collection of TimeEntries | def generate_time_slots(time_entries)
time_entries.map { |entry| extract_available_slots(entry) }.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.minutes, time_entry\n\n # Stash the current session onto the slot as well, so it may handle\n # some of it's own session based logic.\n slot.session = session\n\n # finally increment the time for the next iteration\n time = time + block_size.minutes\n\n slot\n end\n\n # Detect deadspace at the TimeSlot layer.\n # If found, we add a final TimeSlot to make up the difference.\n if time < time_entry.end_time\n slots << TimeSlot.new(time, time_entry.end_time, time_entry)\n end\n\n # Return the aggregated slot collection\n slots\n end",
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end",
"def get_time_slot_array\n time_slot_array = [\"07:00\", \"07:30\", \"08:00\", \"08:30\", \"09:00\", \"09:30\", \"10:00\", \"10:30\",\n \"11:00\", \"11:30\", \"12:00\", \"12:30\", \"13:00\", \"13:30\", \"14:00\", \"14:30\",\n \"15:00\", \"15:30\", \"16:00\", \"16:30\", \"17:00\", \"17:30\", \"18:00\", \"18:30\",\n \"19:00\", \"19:30\", \"20:00\", \"20:30\", \"21:00\"]\n end",
"def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end",
"def slots\n slot_start = start_time\n slot_end = slot_start + slot_length\n while slot_end <= end_time\n slot = ::V2::TimeSlot.new(start_time: slot_start, end_time: slot_end, event_id: @event_id)\n @slots << slot if slot.valid? && slot.save\n slot_start = slot_end + buffer\n slot_end = slot_start + slot_length\n end\n\n @slots\n end",
"def all_timeslots\n unless @all_timeslots.present?\n @all_timeslots = (1..5).map do |day_id|\n Timeslot.new(self, day_id, @day_start_minute, @day_end_minute)\n end\n end\n\n @all_timeslots\n end",
"def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end",
"def time_entries\n get_ticket_property_list(\"time_entries\" , Unfuddled::TimeEntry)\n end",
"def timeslots\n\t\tif (self != nil)\n\t\t\tcompany = self.company\n\t\t\tstart_time = company.start_time\n\t\t\tend_time = company.end_time\n\t\t\tcompany_duration = (( end_time - start_time )/60).round(2)\n\t\t\tno_of_slots = ( company_duration / (self.time_slot.hour*60 + self.time_slot.min) ).to_i\n\t\t\ttime_slot_array =Array.new\n\t\t\tremember_hour = start_time.hour.round\n\t\t\tremember_min = start_time.min\n\t\t\tno_of_slots.times do | index |\n\t\t\t\ta = remember_hour == 0 ? \"00\" : remember_hour\n\t\t\t\tb = remember_min == 0 ? \"00\" : remember_min\n\t\t\t\tc = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour == 0 ? \"00\" :((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\td = (remember_min + self.time_slot.min) % 60 == 0 ? \"00\" : (remember_min + self.time_slot.min) % 60\n\t\t\t\ttime_slot_array << [\"#{a}:#{b}-#{c}:#{d}\", index]\n\t\t\t\tremember_hour = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\tremember_min = (remember_min + self.time_slot.min) % 60\n\t\t\tend\n\t\t\ttime_slot_array\n\t\tend\n\tend",
"def time_entries(start_date, end_date)\n opts = {\n params: {\n start_date: start_date.to_datetime.iso8601,\n end_date: end_date.to_datetime.iso8601\n }\n }\n\n begin\n response = toggl_resource['time_entries'].get(opts)\n rescue => e\n raise 'Error getting Toggl data: ' + e.response\n end\n data = JSON.parse response\n\n data.map do |entry|\n duration = entry['duration'].to_f\n\n # Negative duration means the task is currently running.\n # In this case, we'll set duration to how long it's been running\n if duration < 0\n duration = Time.now - Time.at(duration.abs)\n end\n\n {\n description: entry['description'],\n start: Date.parse(entry['start']),\n duration: duration\n }\n end\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def from_meeting_rooms!(meeting_rooms)\n @time_slots = []\n meeting_rooms.each do |meeting_room|\n meeting_room.time_slots.each do |time_slot|\n if time_slot.is_a? TimeSlot\n @time_slots << time_slot.duration_in_minutes\n end\n end\n end\n self\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def timetable_from_items(items)\n h = {}\n items.select { |i| i.identifier =~ %r{^/schedule/day/.+} }.sort_by { |d| d[:conference_day] }.map do |day|\n h[day[:slug]] = timetable_from_items_for_day(items, day)\n end\n h\n end",
"def to_a(resolution: :hour)\n return [] if @start.nil? && @finish.nil?\n\n if finish < start\n to_time_array(start, TimeOfDay.new(23), resolution) +\n to_time_array(TimeOfDay.new(0), finish, resolution)\n else\n to_time_array(start, finish, resolution)\n end\n end",
"def block_slots\n slots = []\n\n unless block_delivery_end_time.blank? || block_delivery_start_time.blank?\n\n available_hours = block_delivery_end_time - block_delivery_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: block_delivery_start_time + i.hours,\n to: block_delivery_start_time + (i + 1).hours,\n type: :daytime\n }\n end\n end\n\n slots\n end",
"def time_fragments\n []\n end",
"def get_timeslots_12hrs\n #create the new array\n timeslots_12hrs = Array.new\n\n for i in 0...@timeslots.length\n temp_holder = @timeslots[i].split(':')\n temp_holder[0] = temp_holder[0].to_i\n\n if temp_holder[0] > 12\n temp_holder[0] = temp_holder[0] - 12\n timeslots_12hrs.push(temp_holder[0].to_s + \":\" + temp_holder[1] + \"pm\")\n elsif temp_holder[0] == 12\n timeslots_12hrs.push(temp_holder[0].to_s + \":\" + temp_holder[1] + \"pm\")\n else\n timeslots_12hrs.push(@timeslots[i] + \"am\")\n end\n end\n\n return timeslots_12hrs\n end",
"def get_timeslots_12hrs\n \t#create the new array\n \t@timeslots_12hrs = Array.new\n\n for i in 0...@timeslots.length\n @temp_holder = @timeslots[i].split(':')\n @temp_holder[0] = @temp_holder[0].to_i\n if @temp_holder[0] > 12\n @temp_holder[0] = @temp_holder[0] - 12\n @timeslots_12hrs.push(@temp_holder[0].to_s + \":\" + @temp_holder[1] + \"pm\")\n elsif @temp_holder[0] == 12\n @timeslots_12hrs.push(@temp_holder[0].to_s + \":\" + @temp_holder[1] + \"pm\")\n else\n @timeslots_12hrs.push(@timeslots[i] + \"am\")\n end\n end\n\n return @timeslots_12hrs\n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def get_start_times\n times = []\n self.start_time.split('%').each do |t|\n times.push(DateTime.strptime(t, '%m-%d-%Y %H:%M'))\n end\n times\n end",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end",
"def get_times(hash)\n\ttimes = hash.map { |name, time| time }\nend",
"def restaurant_time_select\n\t\ttimes = (0..23).map { |hour| [formatted_time(hour), hour] }\n\tend",
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n {gained_weight: 0, duration: @slots_size})\n @slots << verterx\n\n current_time += @slots_size\n break if current_time >= finish_time\n end\n\n current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight\n end\n end",
"def manage_time_slots\n @time_slot = TimeSlot.new\n\n end",
"def create_time_slots\n return unless params[:start_time]\n\n start_time = Time.from_picker(params.delete(:start_time))\n end_time = Time.from_picker(params.delete(:end_time))\n\n return if end_time < start_time # Prevent infinite loop\n\n shift_length = params.delete(:shift_length).to_i\n shift_overlap = params.delete(:shift_overlap).to_i\n people_per_shift = params.delete(:people_per_shift)\n\n num_shifts = ((end_time - start_time) / shift_length).ceil\n return if num_shifts > 100 # Arbitrary threshold to prevent flooding database\n\n cur_time = start_time\n TimeSlot.transaction do\n while cur_time < end_time\n end_shift_time = cur_time + shift_length + shift_overlap\n TimeSlot.create! job: @job,\n start_time: cur_time,\n end_time: [end_shift_time, end_time].min,\n slots: people_per_shift\n cur_time += shift_length\n end\n end\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def groupped_slots\n @groupped_slots ||= publication_history.group_by do |published_at|\n time_of_day = date_to_local_duration(published_at)\n duration_to_slot(time_of_day)\n end\n end",
"def speeches\n self.time_slots\n end",
"def timespan\n [Time.parse(items.last['created_at']).utc, Time.parse(items.first['created_at']).utc] rescue nil\n end",
"def timespan\n [Time.parse(items.last['created_at']).utc, Time.parse(items.first['created_at']).utc] rescue nil\n end",
"def for_each_time_range(t)\n RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts|\n yield(ts)\n end\n end",
"def get_time_entries(start_date=nil, end_date=nil)\n options = Hash.new\n options[\"start_date\"] = iso8601_date(start_date) if start_date\n options[\"end_date\"] = iso8601_date(end_date) if end_date\n get \"/time_entries\", options\n end",
"def create_shifts(contiguous_timings)\n contiguous_timings.each{|timing| create_shift(timing)}\n end",
"def split(range = nil)\n if self.record_category and self.activity?\n entry_end = self.end_timestamp || Time.now\n time = range ? [self.timestamp, range.begin.midnight.in_time_zone].max : self.timestamp\n end_time = range ? [entry_end, range.end.midnight.in_time_zone].min : entry_end\n list = Array.new\n while time < end_time\n new_end = [entry_end, (time + 1.day).midnight.in_time_zone].min\n list << [time, new_end, self]\n time = new_end\n end\n else\n return [self.timestamp, nil, self]\n end\n list\n end",
"def timecodes\n return [] if start_time.nil?\n start_hour = start_time.strftime(\"%H\")\n start_min = start_time.strftime(\"%M\").to_i < 30 ? \"00\" : \"30\"\n curr_time = Time.parse(\"#{start_hour}:#{start_min}\")\n timecode_array = []\n while curr_time < Time.parse(\"#{end_time.strftime(\"%H\")}:#{end_time.strftime(\"%M\")}\") - 1.second\n timecode_array << \"#{curr_time.strftime(\"%H\").to_i}:#{curr_time.strftime(\"%M\")}\"\n curr_time = curr_time + 30.minutes\n end\n timecode_array_with_days = []\n %w(monday tuesday wednesday thursday friday saturday sunday).each do |day|\n timecode_array_with_days << timecode_array.collect{|t| \"#{t}_#{day}\"}.flatten if read_attribute(day)\n end\n timecode_array_with_days.flatten\n end",
"def for_each_time_range(t)\n RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts|\n yield(ts)\n end\n end",
"def index\n @day_timeslots = DayTimeslot.all\n end",
"def parse_times_and_items\n @item_counts.sort.each do |item_count|\n items = item_count[1] # returns hash\n time = item_count[0].strftime(\"%I:%M\")\n @times.push(time)\n\n str = \"\"\n items.sort.each do |sub_arr|\n item = sub_arr[0]\n quantity = sub_arr[1]\n item = item.pluralize if quantity > 1\n str.concat(\"#{quantity} #{item}, \")\n end\n @items.push(str.slice(0...-2))\n\n end\n end",
"def total(entries)\n seconds = entries.inject(0) { |sum, entry| sum + (entry[:end] - entry[:start]) }\n hours = seconds / 3600\nend",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def parse_srt_times(times)\n times =~ /^([0-9:,]+) --> ([0-9:,]+)/ # May have trailing data.\n [$1, $2].map {|t| parse_srt_time(t) }\n end",
"def time_rows\n rows = []\n (0..NUM_HALF_HOURS-1).each do |half_hour|\n cols = []\n row = content_tag :tr do\n cols << hour_cell(half_hour)\n cols << minute_cell(half_hour)\n (0..(num_days-1)).each do |day|\n cols << event_cells(half_hour,day)\n end\n cols.join.html_safe\n end\n rows << row\n end\n rows.join.html_safe\n end",
"def live_slots\n slots = []\n\n unless live_delivery_block_end_time.blank? || live_delivery_block_start_time.blank?\n available_hours = live_delivery_block_end_time - live_delivery_block_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: live_delivery_block_start_time + i.hours,\n to: live_delivery_block_start_time + (i + 1).hours,\n type: :live\n }\n end\n end\n\n slots\n end",
"def times_for_schedule_update_requests(start_time, end_time)\n times = []\n\n task_time = start_time.beginning_of_day + 15.hours\n task_time += 1.day if task_time < start_time\n\n while task_time < end_time\n times << task_time\n task_time += 1.day\n end\n\n times\n end",
"def entries\n settings.time_entries.present? ? settings.time_entries : []\n end",
"def time_range\n range_time = []\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 am\"\n range_time << \"#{time}:30 am\"\n end\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 pm\"\n range_time << \"#{time}:30 pm\"\n end\n range_time\n end",
"def index\n @time_slots_lists = TimeSlotsList.all\n @time_slots_list = TimeSlotsList.new\n end",
"def scheduled_meetings\n return [] if schedule.start_with?('TBA') # sometimes there's trailing whitespace\n\n abbreviations, start_time, end_time = schedule.match(MEETING_SCHEDULE_REGEX).captures\n # For each abbreviation, create a ScheduledMeeting for that day\n abbreviations.scan(/[A-Z][a-z]?/) # MTuWThFSaSu\n .map { |day_abbreviation| ScheduledMeeting.new day_abbreviation, start_time, end_time, self }\n end",
"def initialize(time_window)\n @timeframes = [] \n \n for group in time_window.split(\";\")\n days, times = Array.new(7, false), []\n\n for item in group.split(\" \")\n # Range of values?\n if item.include?(\"-\")\n # Yes, Figure out if range is days or times\n range = item.split(\"-\")\n \n if Days.include?(range[0]) \n set_day_range(days, range[0], range[1])\n else\n times << TimeRange.new(range[0], range[1])\n end\n else\n days[Days.index(item)] = true if Days.include?(item)\n end\n end\n \n @timeframes << TimeFrame.new(days, times)\n end\n end",
"def start_times\n relevant_events_scope.\n interval_starts.\n unscope(:order).\n order(:video_time).\n pluck(:video_time)\n end",
"def make_event_times_array(dates_array, hour, min)\n\t\tevent_times = Array.new\n\n\t\tdates_array.each_index do |index|\n\t\t\n\t\t\tevent_times[index] = create_event_time(dates_array[index],hour, min)\n\t\tend\n\n\t\treturn event_times\n\tend",
"def aggregate_time_entries(entries)\n result = {}\n entries.each do |entry|\n if entry.values != nil\n p6activity = entry.task.p6_activity\n if !p6activity.nil?\n if !result.has_key?(p6activity)\n result[p6activity] = 0.0\n end\n entry.values.each do |value|\n result[p6activity] += value.hours.to_f\n end\n end\n end\n end\n result\n end",
"def mask_for_time_slots\n offset = (ends_at.next_day.beginning_of_day - ends_at) / APPOINTMENT_INTERVAL\n slots_number = (ends_at - starts_at) / APPOINTMENT_INTERVAL\n ('1' * slots_number).to_i(2) << offset\n end",
"def add_timeslot_location(start_time, end_time, location_flex_rating, location_id_array)\n rt = ResponseTimeslot.new :start_time => start_time, :end_time => end_time, :location_flexibility_rating => location_flex_rating\n location_id_array.each do | location_id |\n # TODO - revisit preference logic here\n rt.response_timeslot_locations << (ResponseTimeslotLocation.new :event_location_id => location_id)\n end\n self.response_timeslots << (rt)\n self.save\n \n end",
"def generate_tabling_slots(assignments)\n\tp 'destroying all tabling slots'\n\tTablingSlot.destroy_all\n\tp 'creating new tabling slots'\n\tassignments.keys.each do |time|\n\t\tts = TablingSlot.new\n\t\tts.time = time\n\t\tts.member_ids = assignments[time].map {|x| x.id}\n\t\tp ts.time\n\t\tp ts.member_ids\n\t\tts.save\n\tend\n\n\tp 'there are now ' + TablingSlot.all.length.to_s + ' slots'\nend",
"def normalize_time_entries_harvest(time_entries)\n time_entries.each do |time_entry|\n project_original_id = time_entry[\"payload\"][\"project\"][\"id\"]\n task_original_id = time_entry[\"payload\"][\"task\"][\"id\"]\n project = Project.find_by(original_id: project_original_id, workspace_id: harvest_workspace.id)\n task = Task.find_by(original_id: task_original_id, project_id: project.id)\n \n original_id = time_entry[\"payload\"][\"id\"]\n \n found_time_entry = TimeEntry.find_by(task_id: task.id, original_id: original_id)\n duration_seconds = (time_entry[\"payload\"][\"hours\"] * 60 * 60).to_i\n started_at = time_entry[\"payload\"][\"spent_date\"].to_datetime\n if found_time_entry\n found_time_entry.duration_seconds = duration_seconds\n found_time_entry.started_at = started_at\n else\n found_time_entry = TimeEntry.create!(task_id: task.id, started_at: started_at, duration_seconds: duration_seconds, original_id: original_id)\n end\n end\n end",
"def index\n @timeslots = Timeslot.all\n end",
"def index\n @timeslots = Timeslot.all\n end",
"def tasks_for_timeline\n tasks_f_time ||= []\n milestones.each do |mile|\n mile.tasks.each do |task|\n task.update(start_date: start_date) if task.start_date.nil?\n task.update(end_date: task.start_date + task.pm_duration_estimation.days) if task.end_date.nil?\n tasks_f_time << [task.name + ' | ' + mile.name + ' | ' + task.advance_percentage.to_s + \"% \", task.start_date, task.end_date]\n end\n end\n tasks_f_time\n end",
"def recalc_times(starting_at=0, list=@events)\n t = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n list[starting_at .. -1].each do |e|\n t += e.delta_time\n e.time_from_start = t\n end\n end",
"def get_datetimes(row)\n mm, dd, yyyy = get_date(row, \"Date\")\n start_hh, start_mm = get_time(row, \"Start Time\")\n end_hh, end_mm = get_time(row, \"End Time\")\n [Time.local(yyyy, mm, dd, start_hh, start_mm), Time.local(yyyy, mm, dd, end_hh, end_mm)]\nend",
"def time_slot_fiber\n # The combinatinos of day groupings\n # HACK: When both days are the same the class meets once per week.\n day_groups = [ [:monday, :thursday],\n [:monday, :monday],\n [:tuesday, :friday],\n [:tuesday, :tuesday],\n [:monday, :wednesday],\n [:wednesday, :wednesday],\n [:thursday, :thursday],\n [:friday, :friday] ]\n\n # The set of times that classes meet on any day.\n times_avaliable = [ ['1000', '1120'],\n ['1230', '1350'],\n ['1400', '1520'],\n ['1700', '1820'] ]\n\n # Map day symbols to integer values.\n day_nums = { monday: 1, tuesday: 2,\n wednesday: 3, thursday: 4 , friday: 5 }\n\n # Returns the next set of meeting times\n return Fiber.new do\n # Pick a random day and time combination.\n\n while true # The fiber must flow!\n days = day_groups[rand(day_groups.length)]\n starttime, endtime = times_avaliable[rand(times_avaliable.length)]\n Fiber.yield(days.map do |day|\n Meeting.new({ day: day_nums[day], starttime: starttime, endtime: endtime })\n end)\n end\n end\n end",
"def recalc_times(starting_at=0, list=@events)\n\tt = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n\tlist[starting_at .. -1].each { | e |\n\t t += e.delta_time\n\t e.time_from_start = t\n\t}\n end",
"def each\n @timevec.each_with_index { |time,i | v = values_at(i, *enum_attrs); yield v }\n end",
"def partition_schedules_per_day(schedules, datetime_span)\n date = datetime_span.first.to_date\n end_date = datetime_span.last.to_date\n result = []\n while date <= end_date do \n day_sch = schedules.select do |sch| sch.start_datetime.to_date == date end\n# day_sch = [] if day_sch.nil?\n day_sch.nil? and day_sch = []\n result << [date, day_sch]\n schedules = schedules[day_sch.length..-1]\n date += 1.day\n end\n result\n end",
"def each_with_time(&block)\n arr = @v.map.with_index{|v, i| TimeAndValue.new(@start_time+i.hours, v)}\n arr.each(&block)\n end",
"def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end",
"def trips_by_weekday()\n TripCollection.new( @trips.select {|k, t| t.start_time.wday.between?(1,5) } )\n end",
"def compute_timestamps(begin_time, end_time)\n @timevec = value_hash[:bartime]\n if model == DailyBar\n begin\n @time_map = TimeMap.new(begin_time, end_time, timevec, :missing_bar_error => options[:missing_bar_error])\n rescue TimeseriesException => e\n raise TimeseriesException, \"#{e.message} for #{symbol}\"\n end\n else\n timevec.each_with_index { |time, idx| @time_map[time.to_i] = idx }\n end\n end",
"def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end",
"def index\n if params[:date_range].blank?\n @time_slots = TimeSlot.all\n else\n input_start_time =\n input_end_time = \n @time_slots = TimeSlot.where(\"start_time > ? AND end_time < ?\", input_start_time, input_end_time)\n end\n end",
"def get_runtime_timestamps\n all_events = events.to_a\n start_time = DateTime.parse(all_events.first['timestamp'])\n completion_time = DateTime.parse(all_events.last['timestamp'])\n [start_time, completion_time]\n end",
"def datetimes\n intervals.map do |interval|\n datetimes = []\n datetime = interval.first_datetime\n while datetime <= interval.last_datetime\n datetimes << datetime\n datetime = datetime + frequency.duration\n end\n datetimes\n end\n end",
"def get_unique_permutations annotation_time_slot\r\n\t\treturn annotation_time_slot.uniq.permutation.to_a\r\n\tend",
"def map_events\n mapped_timeline = Timeline.new\n self.each do |time,events|\n mapped_timeline[time] = events.map{|event| yield event }\n end\n mapped_timeline\n end",
"def all_matchday_times\n all_matches = fetch_matches\n matchtimes = Hash[(1..38).collect { |md| [md, []] }]\n all_matches.each do |m|\n matchtimes[m['matchday']].push(m['utcDate'])\n end\n matchtimes\n end",
"def generate_tabling_assignments(times, members)\n\t\t\"\"\"\n\t\tcreate assignment hash of timeslot (hour) to member list\n\t\t\"\"\"\n\t\tunassigned = Set.new(members)\n\t\tassignments = Hash.new\n\t\twhile unassigned.length() > 0\n\t\t\tmcv = get_MCV(unassigned, times)\n\t\t\tlcv = get_LCV(assignments, mcv, times)\n\t\t\tif not assignments.has_key?(lcv)\n\t\t\t\tassignments[lcv] = Array.new\n\t\t\tend\n\t\t\tassignments[lcv] << mcv\n\t\t\tunassigned.delete(mcv)\n\t\tend\n\t\treturn assignments\n\tend",
"def init_timevec\n value_hash[:bartime] ||= model.time_vector(symbol, begin_time, end_time)\n compute_timestamps(begin_time, end_time)\n end",
"def merge_ranges(schedule)\n merged_schedule = []\n\n schedule.each do |meeting|\n overlapping_time_slots = check_times(meeting, merged_schedule)\n merged_schedule -= overlapping_time_slots if merged_schedule.include?(overlapping_time_slots)\n merged_schedule << slot_merger(overlapping_time_slots)\n end\n\n merged_schedule\nend",
"def get_time_list(from,to)\n time_list = Array.new\n time_list.push(from)\n temp_from = from.split(\" \")[0]\n temp_to = to.split(\" \")[0]\n date_from = Date.parse temp_from\n date_to = Date.parse temp_to\n if date_to < date_from\n puts \"from is starttime,to is endtime\"\n return nil\n end\n time = Array.new\n date_from.upto( date_to){ |i| time.push(i.to_s); time_list.push(\"#{i} 24:00:00\")}\n time_list[time_list.size-1] = to\n return time,time_list\n end",
"def time_series(template_series)\n ts = []\n header = true\n File.foreach(template_series) do |line|\n line = line.split(' ',6)\n ts << line[0..4] unless header || line.size < 4\n header = false if line.first==\"*\"\n end\n t0 = parse_time_stamp(ts[0].first)\n t1 = parse_time_stamp(ts[1].first)\n [ts, (t1 - t0).to_f]\n end",
"def daytime_intervals(s, e, day_start = 8, day_end = 21)\n def hours(x)\n x / 24.0\n end\n\n result = []\n\n # Temporary start and end variables. These are shifted around inplace.\n ts = s\n te = e\n\n while ts < e\n # Move ts forward in time as necessary until it is inside the time range\n unless (day_start...day_end).cover?(ts.hour)\n # Advance ts to next break\n if ts.hour < day_start\n ts += hours(day_start - ts.hour)\n else\n ts += hours(24 + day_start - ts.hour)\n end\n end\n\n # ts is in range now, check te\n if (day_start..day_end).cover?(te.hour) && te.to_date == ts.to_date\n # both ts and te are in range, so add the interval and reset both\n # variables\n result << [ts, te].map(&:to_s)\n ts = te\n te = e\n else\n # Modify te to be in range, the interval will be picked up on the next\n # loop assuming all variables are still valid.\n te = ts\n te += hours(day_end - ts.hour)\n end\n end\n\n result\nend",
"def time_intervals(program,insert_repeat_interval = true)\n intervals = map{|d|d.time_intervals}.flatten.uniq.find_all{|i|program.interval === i.tstart}\n if program.repeat_first_interval and insert_repeat_interval\n firstinterval = intervals.min.copy\n firstinterval.shift!(-program.resolution*60)\n intervals << firstinterval\n end\n intervals\n end",
"def index\n @sessions = Session.enabled\n @time_slots = TimeSlot.select { |ts| ts.enabled }.sort { |x,y| x.start_time <=> y.start_time }.to_a\n @meeting_spaces = MeetingSpace.all.order :name\n\n if params[:time_slot_id]\n @current_time_slot = @time_slots.select {|ts|ts.id == params[:time_slot_id].to_i}.first\n else\n sorted_time_slots = @time_slots.sort {|x,y| x.start_time <=> y.start_time}\n @current_time_slot = sorted_time_slots.select {|ts| ts.end_time >= Time.now}.first\n @current_time_slot = sorted_time_slots.first unless @current_time_slot\n end\n\n @prev_time_slots = {}\n @next_time_slots = {}\n for i in 0..@time_slots.length-1\n @prev_time_slots[@time_slots[i].id] = (@time_slots[i-1].id if i > 0)\n @next_time_slots[@time_slots[i].id] = (@time_slots[i+1].id if i < (@time_slots.length - 1))\n end\n end",
"def to_a(resolution: :hour)\n resolution_multiplier = resolution == :hour ? 60 * 60 : 60\n time_units = ((start - finish) / resolution_multiplier).abs.to_i\n\n Array.new(time_units) do |time_unit|\n start + (time_unit * resolution_multiplier)\n end\n end",
"def setup_timetable\n # Create a hash of free times for output rendering\n @free_times = [{}, {}, {}, {}, {}, {}, {}]\n @person.free_times.each do |ft|\n ft.start_time.step(ft.end_time + (ft.end_time % Timetable::INTERVAL), Timetable::INTERVAL) do |time|\n css_class = ft.css_class.present? ? ft.css_class : 'good'\n @free_times[ft.day_of_week][time] = css_class\n end\n end\n # raise @free_times.inspect\n end",
"def for\n timeslot = Time.parse(params[:timeslot])\n timeslot = (timeslot + timeslot.gmtoff).utc # Holy hell this is nasty. Why doesn't Time.utc work like Time.parse?\n render :partial => 'aggregate', \n :locals => { \n :conference_sessions => ConferenceSession.all( :conditions => { :start_time => timeslot } ) \n }\n end",
"def initialize(free_slot_input)\n @free_slots = JSON.parse(free_slot_input.to_json)\n\n # convert String datetime to an integer format for easy comparisons\n for elem in @free_slots \n elem['start'] = (DateTime.parse elem['start']).strftime('%s').to_i\n elem['end'] = (DateTime.parse elem['end']).strftime('%s').to_i\n end\n end",
"def add_timeset(*args, &block)\n if block_given?\n timesets(*args, &block)\n else\n timesets(args.first) {}\n end\n end",
"def timings\n\t\treturn [] unless self.timing_line?\n\t\ta,b = @value.split(' --> ')\n\t\treturn [SubtitleTiming.new(a), SubtitleTiming.new(b)]\n\tend",
"def segments_for_timestamps(start_timestamp, end_timestamp, granularity)\n start_ts = time_segment_for_timestamp(start_timestamp, granularity)\n end_ts = time_segment_for_timestamp(end_timestamp, granularity)\n\n segments = [start_ts]\n ts = start_ts\n while ts < end_ts\n ts += granularity\n segments << ts\n end\n\n segments\n end",
"def fetch_events_time(range_begin_in_secs, range_end_in_secs)\n #\n # collect from_time beginning of day (in seconds)\n #\n frt = self.from_time.beginning_of_day.to_i\n\n case self.recurrence_type\n when \"NO_RECURRENCE\"\n self.no_recurrence_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_DAYS\"\n self.recur_every_n_days_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_WEEKS\"\n self.recur_every_n_weeks_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_MONTHS\"\n self.recur_every_n_months_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_N_YEARS\"\n self.recur_every_n_years_dates(range_begin_in_secs, range_end_in_secs, frt)\n when \"EVERY_DAYS_OF_WEEK\"\n self.recur_every_days_of_week_dates(range_begin_in_secs, range_end_in_secs, frt)\n else\n []\n end\n end",
"def watch_frequency\n starts, ends = start_times, end_times\n start_index, end_index = 0, 0\n frequencies = []\n active_intervals = 0\n return [] if end_times.empty?\n (0..end_times.last).each do |video_time|\n start_advance = elements_till(starts, start_index) { |time| time <= video_time }\n end_advance = elements_till(ends, end_index) { |time| time < video_time }\n\n active_intervals += start_advance - end_advance\n start_index += start_advance\n end_index += end_advance\n\n frequencies << active_intervals\n end\n frequencies\n end",
"def validate(entries)\n first = last = nil\n errors = []\n entries.each do |entry|\n if entry[:end] < entry[:start]\n errors << \"#{entry[:raw]} has its end before its start.\"\n end\n first = entry[:start] if first.nil? || first > entry[:start]\n last = entry[:end] if last.nil? || last < entry[:end]\n end\n if last && first && last - first > 14*24*60*60 # 14 days\n errors << \"Time entries span more than two weeks! from #{first} to #{last}\"\n end\n errors\nend",
"def hours_per_day(entries)\n hours_per_day = Hash.new(0.0)\n entries.each do |entry|\n hours_per_day[entry[:start].to_date] += (entry[:end] - entry[:start]) / 3600.0\n end\n hours_per_day\nend"
] | [
"0.73997855",
"0.7293364",
"0.6935869",
"0.6710855",
"0.65502787",
"0.6529408",
"0.62408537",
"0.6206863",
"0.60246116",
"0.60169065",
"0.6007946",
"0.6006138",
"0.59570074",
"0.59515446",
"0.5933802",
"0.5849529",
"0.5832255",
"0.57931644",
"0.57828283",
"0.57533526",
"0.5735045",
"0.57214767",
"0.5697638",
"0.56853676",
"0.5670124",
"0.5657035",
"0.5643781",
"0.5603836",
"0.5598085",
"0.55702645",
"0.55530256",
"0.5544124",
"0.55338997",
"0.55211824",
"0.55211824",
"0.5509735",
"0.5481575",
"0.5474972",
"0.54702973",
"0.54693836",
"0.5463786",
"0.5437151",
"0.54366",
"0.5435687",
"0.543266",
"0.5430805",
"0.54226905",
"0.5420284",
"0.54053515",
"0.53962004",
"0.53655595",
"0.53623694",
"0.5331733",
"0.53299874",
"0.53163487",
"0.5311771",
"0.52934414",
"0.5267521",
"0.52644837",
"0.5249605",
"0.5236888",
"0.52309424",
"0.52309424",
"0.52286553",
"0.52218026",
"0.52182454",
"0.5207582",
"0.51985323",
"0.51940393",
"0.51656973",
"0.5142602",
"0.5139483",
"0.51341593",
"0.51321673",
"0.5119859",
"0.51061755",
"0.5102068",
"0.50979066",
"0.50961405",
"0.50876045",
"0.508254",
"0.5070575",
"0.5067847",
"0.5062475",
"0.5059959",
"0.5059196",
"0.50550365",
"0.5039446",
"0.50328964",
"0.503101",
"0.503002",
"0.5027785",
"0.50078857",
"0.49988848",
"0.49986413",
"0.49946308",
"0.4984244",
"0.4982428",
"0.49722433",
"0.49720424"
] | 0.7823904 | 0 |
Produces TimeSlot(s) from a collection of TimeSlotWindows | def generate_time_blocks(windows)
results = windows.map do |window|
# Create a date based n todays date, but with the time changed to
# that of the entry start/end.
entry_start = base.change(
hour: window.start_time.hour,
min: window.start_time.minute)
# By rounding off with #floor, we go the easy route (no partial time blocks)
# Note: iterator is zero based.
blocks = (window.duration / block_size).floor.times.map { |i|
start_time = Skej::Warp.zone(
entry_start + (i * block_size).minutes,
session.chosen_office.time_zone)
end_time = Skej::Warp.zone(
start_time + block_size.minutes,
session.chosen_office.time_zone)
target_day = Skej::NLP.parse(session, window.day)
.strftime('%A')
.downcase
.to_sym
TimeBlock.new(
session: session,
time_entry_id: window.time_entry.id,
business_id: session.business_id,
time_sheet_id: window.time_sheet_id,
office_id: window.office_id,
day: target_day,
start_time: start_time,
end_time: end_time)
}
end.flatten # results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.minutes, time_entry\n\n # Stash the current session onto the slot as well, so it may handle\n # some of it's own session based logic.\n slot.session = session\n\n # finally increment the time for the next iteration\n time = time + block_size.minutes\n\n slot\n end\n\n # Detect deadspace at the TimeSlot layer.\n # If found, we add a final TimeSlot to make up the difference.\n if time < time_entry.end_time\n slots << TimeSlot.new(time, time_entry.end_time, time_entry)\n end\n\n # Return the aggregated slot collection\n slots\n end",
"def get_time_slot_array\n time_slot_array = [\"07:00\", \"07:30\", \"08:00\", \"08:30\", \"09:00\", \"09:30\", \"10:00\", \"10:30\",\n \"11:00\", \"11:30\", \"12:00\", \"12:30\", \"13:00\", \"13:30\", \"14:00\", \"14:30\",\n \"15:00\", \"15:30\", \"16:00\", \"16:30\", \"17:00\", \"17:30\", \"18:00\", \"18:30\",\n \"19:00\", \"19:30\", \"20:00\", \"20:30\", \"21:00\"]\n end",
"def slots\n slot_start = start_time\n slot_end = slot_start + slot_length\n while slot_end <= end_time\n slot = ::V2::TimeSlot.new(start_time: slot_start, end_time: slot_end, event_id: @event_id)\n @slots << slot if slot.valid? && slot.save\n slot_start = slot_end + buffer\n slot_end = slot_start + slot_length\n end\n\n @slots\n end",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def all_timeslots\n unless @all_timeslots.present?\n @all_timeslots = (1..5).map do |day_id|\n Timeslot.new(self, day_id, @day_start_minute, @day_end_minute)\n end\n end\n\n @all_timeslots\n end",
"def timeslots\n\t\tif (self != nil)\n\t\t\tcompany = self.company\n\t\t\tstart_time = company.start_time\n\t\t\tend_time = company.end_time\n\t\t\tcompany_duration = (( end_time - start_time )/60).round(2)\n\t\t\tno_of_slots = ( company_duration / (self.time_slot.hour*60 + self.time_slot.min) ).to_i\n\t\t\ttime_slot_array =Array.new\n\t\t\tremember_hour = start_time.hour.round\n\t\t\tremember_min = start_time.min\n\t\t\tno_of_slots.times do | index |\n\t\t\t\ta = remember_hour == 0 ? \"00\" : remember_hour\n\t\t\t\tb = remember_min == 0 ? \"00\" : remember_min\n\t\t\t\tc = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour == 0 ? \"00\" :((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\td = (remember_min + self.time_slot.min) % 60 == 0 ? \"00\" : (remember_min + self.time_slot.min) % 60\n\t\t\t\ttime_slot_array << [\"#{a}:#{b}-#{c}:#{d}\", index]\n\t\t\t\tremember_hour = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\tremember_min = (remember_min + self.time_slot.min) % 60\n\t\t\tend\n\t\t\ttime_slot_array\n\t\tend\n\tend",
"def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def manage_time_slots\n @time_slot = TimeSlot.new\n\n end",
"def from_meeting_rooms!(meeting_rooms)\n @time_slots = []\n meeting_rooms.each do |meeting_room|\n meeting_room.time_slots.each do |time_slot|\n if time_slot.is_a? TimeSlot\n @time_slots << time_slot.duration_in_minutes\n end\n end\n end\n self\n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def speeches\n self.time_slots\n end",
"def initialize(time_window)\n @timeframes = [] \n \n for group in time_window.split(\";\")\n days, times = Array.new(7, false), []\n\n for item in group.split(\" \")\n # Range of values?\n if item.include?(\"-\")\n # Yes, Figure out if range is days or times\n range = item.split(\"-\")\n \n if Days.include?(range[0]) \n set_day_range(days, range[0], range[1])\n else\n times << TimeRange.new(range[0], range[1])\n end\n else\n days[Days.index(item)] = true if Days.include?(item)\n end\n end\n \n @timeframes << TimeFrame.new(days, times)\n end\n end",
"def unfinished_dispatch_time_ranges\n dispatches.where(safe_return: false).map(&:active_time_window)\n end",
"def block_slots\n slots = []\n\n unless block_delivery_end_time.blank? || block_delivery_start_time.blank?\n\n available_hours = block_delivery_end_time - block_delivery_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: block_delivery_start_time + i.hours,\n to: block_delivery_start_time + (i + 1).hours,\n type: :daytime\n }\n end\n end\n\n slots\n end",
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n {gained_weight: 0, duration: @slots_size})\n @slots << verterx\n\n current_time += @slots_size\n break if current_time >= finish_time\n end\n\n current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight\n end\n end",
"def create_shifts(contiguous_timings)\n contiguous_timings.each{|timing| create_shift(timing)}\n end",
"def live_slots\n slots = []\n\n unless live_delivery_block_end_time.blank? || live_delivery_block_start_time.blank?\n available_hours = live_delivery_block_end_time - live_delivery_block_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: live_delivery_block_start_time + i.hours,\n to: live_delivery_block_start_time + (i + 1).hours,\n type: :live\n }\n end\n end\n\n slots\n end",
"def groupped_slots\n @groupped_slots ||= publication_history.group_by do |published_at|\n time_of_day = date_to_local_duration(published_at)\n duration_to_slot(time_of_day)\n end\n end",
"def create_time_slots\n return unless params[:start_time]\n\n start_time = Time.from_picker(params.delete(:start_time))\n end_time = Time.from_picker(params.delete(:end_time))\n\n return if end_time < start_time # Prevent infinite loop\n\n shift_length = params.delete(:shift_length).to_i\n shift_overlap = params.delete(:shift_overlap).to_i\n people_per_shift = params.delete(:people_per_shift)\n\n num_shifts = ((end_time - start_time) / shift_length).ceil\n return if num_shifts > 100 # Arbitrary threshold to prevent flooding database\n\n cur_time = start_time\n TimeSlot.transaction do\n while cur_time < end_time\n end_shift_time = cur_time + shift_length + shift_overlap\n TimeSlot.create! job: @job,\n start_time: cur_time,\n end_time: [end_shift_time, end_time].min,\n slots: people_per_shift\n cur_time += shift_length\n end\n end\n end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def slots\n @slots = Candlestick.slots\n end",
"def start_times\n relevant_events_scope.\n interval_starts.\n unscope(:order).\n order(:video_time).\n pluck(:video_time)\n end",
"def find_in_range(time_from:, time_to:, time_windows: time_span_windows)\n #puts \"find_in_range, Recieve: diff: #{(time_to - time_from)}, time_from: #{time_from}, time_to: #{time_to}, time_window_left: #{time_windows.size}\"\n return [] if (time_to - time_from) < shorter_time_window_span\n\n while bucket = time_windows.shift\n next unless found_windows = find_fitting_windows(time_from, time_to, bucket)\n return found_windows +\n find_in_range(time_from: time_from, time_to: found_windows.first.fetch(:window_starts), time_windows: time_windows.clone) +\n find_in_range(time_from: found_windows.last.fetch(:window_finishes), time_to: time_to, time_windows: time_windows.clone)\n end\n end",
"def index\n @timeslots = Timeslot.all\n end",
"def index\n @timeslots = Timeslot.all\n end",
"def index\n @time_slots_lists = TimeSlotsList.all\n @time_slots_list = TimeSlotsList.new\n end",
"def time_range\n range_time = []\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 am\"\n range_time << \"#{time}:30 am\"\n end\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 pm\"\n range_time << \"#{time}:30 pm\"\n end\n range_time\n end",
"def restaurant_time_select\n\t\ttimes = (0..23).map { |hour| [formatted_time(hour), hour] }\n\tend",
"def open_slots(date)\n time = date.to_time\n \n slots = []\n prev_time = time - 30.minutes\n loop do\n start_time = prev_time + 30.minutes\n \n if start_time.to_date == date\n slots << Slot.new(starts_at: start_time, cat: self)\n prev_time = start_time\n else\n break\n end\n end\n \n # Remove taken/past timeframes\n slots.reject do |slot|\n Reservation.exists?(cat: self, starts_at: slot.starts_at) || slot.starts_at.past?\n end\n end",
"def get_busy_slots(start_min, start_max, time_zone)\n result = Array.new\n @googleCalendars.each do |x|\n result.push(x[:connection].query([x[:id]],start_min, start_max, time_zone))\n end\n return result\n end",
"def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end",
"def combine_linear_slots(slots)\n last_slot = false\n end_time = false\n start_time = false\n flushed = false # Tracks the current continuity chain\n count = 0\n aggregate = []\n debug = []\n\n slots.sort_by(&:start_time).each_with_index do |slot, i|\n # Very close to each other, mark it as a continuation\n # to the end_time.\n\n start_time = slot.start_time unless last_slot\n end_time = slot.end_time unless last_slot\n\n if slot.start_time < (end_time + 30.seconds)\n debug << \"slot:#{slot.start_time} - neighbor detected\"\n end_time = slot.end_time\n\n elsif last_slot\n debug << \"slot:#{slot.start_time} - gap detected\"\n aggregate << TimeSlot.new(start_time, end_time, slot.time_entry)\n\n start_time = slot.start_time\n end_time = slot.end_time\n\n end\n\n last_slot = slot\n end\n\n aggregate << TimeSlot.new(start_time, end_time, last_slot.time_entry) if last_slot\n aggregate.uniq\n end",
"def time_fragments\n []\n end",
"def timetable_from_items(items)\n h = {}\n items.select { |i| i.identifier =~ %r{^/schedule/day/.+} }.sort_by { |d| d[:conference_day] }.map do |day|\n h[day[:slug]] = timetable_from_items_for_day(items, day)\n end\n h\n end",
"def mask_for_time_slots\n offset = (ends_at.next_day.beginning_of_day - ends_at) / APPOINTMENT_INTERVAL\n slots_number = (ends_at - starts_at) / APPOINTMENT_INTERVAL\n ('1' * slots_number).to_i(2) << offset\n end",
"def index\n @day_timeslots = DayTimeslot.all\n end",
"def index\n if params[:date_range].blank?\n @time_slots = TimeSlot.all\n else\n input_start_time =\n input_end_time = \n @time_slots = TimeSlot.where(\"start_time > ? AND end_time < ?\", input_start_time, input_end_time)\n end\n end",
"def index\n @sessions = Session.enabled\n @time_slots = TimeSlot.select { |ts| ts.enabled }.sort { |x,y| x.start_time <=> y.start_time }.to_a\n @meeting_spaces = MeetingSpace.all.order :name\n\n if params[:time_slot_id]\n @current_time_slot = @time_slots.select {|ts|ts.id == params[:time_slot_id].to_i}.first\n else\n sorted_time_slots = @time_slots.sort {|x,y| x.start_time <=> y.start_time}\n @current_time_slot = sorted_time_slots.select {|ts| ts.end_time >= Time.now}.first\n @current_time_slot = sorted_time_slots.first unless @current_time_slot\n end\n\n @prev_time_slots = {}\n @next_time_slots = {}\n for i in 0..@time_slots.length-1\n @prev_time_slots[@time_slots[i].id] = (@time_slots[i-1].id if i > 0)\n @next_time_slots[@time_slots[i].id] = (@time_slots[i+1].id if i < (@time_slots.length - 1))\n end\n end",
"def generate_codebook_time_series_list(items)\n html = '<ul class=\"list-unstyled\">'\n\n items.each do |item|\n\n if item.class == TimeSeriesGroup\n # add group\n html << generate_codebook_time_series_group_item(item)\n\n elsif item.class == TimeSeriesQuestion\n # add question\n html << generate_codebook_time_series_question_item(item)\n end\n\n end\n\n html << '</ul>'\n\n return html.html_safe\n end",
"def create_shifts\n\tself.shifts=[]\n\tif self.locations.size==0\n\t self.locations=self.area.locations\n\tend\n\tst=self.shifttimes \n \tst.each do |t|\n\t\tself.locations.each do |l|\n\t\t\n\t\t\tshift=Shift.new\n\t\t\tshift.location=l\n\t\t\tshift.start=t\n\t\t\tself.shifts << shift\n\t\tend\n \tend\n end",
"def get_timeslots_12hrs\n #create the new array\n timeslots_12hrs = Array.new\n\n for i in 0...@timeslots.length\n temp_holder = @timeslots[i].split(':')\n temp_holder[0] = temp_holder[0].to_i\n\n if temp_holder[0] > 12\n temp_holder[0] = temp_holder[0] - 12\n timeslots_12hrs.push(temp_holder[0].to_s + \":\" + temp_holder[1] + \"pm\")\n elsif temp_holder[0] == 12\n timeslots_12hrs.push(temp_holder[0].to_s + \":\" + temp_holder[1] + \"pm\")\n else\n timeslots_12hrs.push(@timeslots[i] + \"am\")\n end\n end\n\n return timeslots_12hrs\n end",
"def get_timeslots_12hrs\n \t#create the new array\n \t@timeslots_12hrs = Array.new\n\n for i in 0...@timeslots.length\n @temp_holder = @timeslots[i].split(':')\n @temp_holder[0] = @temp_holder[0].to_i\n if @temp_holder[0] > 12\n @temp_holder[0] = @temp_holder[0] - 12\n @timeslots_12hrs.push(@temp_holder[0].to_s + \":\" + @temp_holder[1] + \"pm\")\n elsif @temp_holder[0] == 12\n @timeslots_12hrs.push(@temp_holder[0].to_s + \":\" + @temp_holder[1] + \"pm\")\n else\n @timeslots_12hrs.push(@timeslots[i] + \"am\")\n end\n end\n\n return @timeslots_12hrs\n end",
"def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end",
"def watch_frequency\n starts, ends = start_times, end_times\n start_index, end_index = 0, 0\n frequencies = []\n active_intervals = 0\n return [] if end_times.empty?\n (0..end_times.last).each do |video_time|\n start_advance = elements_till(starts, start_index) { |time| time <= video_time }\n end_advance = elements_till(ends, end_index) { |time| time < video_time }\n\n active_intervals += start_advance - end_advance\n start_index += start_advance\n end_index += end_advance\n\n frequencies << active_intervals\n end\n frequencies\n end",
"def split(range = nil)\n if self.record_category and self.activity?\n entry_end = self.end_timestamp || Time.now\n time = range ? [self.timestamp, range.begin.midnight.in_time_zone].max : self.timestamp\n end_time = range ? [entry_end, range.end.midnight.in_time_zone].min : entry_end\n list = Array.new\n while time < end_time\n new_end = [entry_end, (time + 1.day).midnight.in_time_zone].min\n list << [time, new_end, self]\n time = new_end\n end\n else\n return [self.timestamp, nil, self]\n end\n list\n end",
"def timespan\n [Time.parse(items.last['created_at']).utc, Time.parse(items.first['created_at']).utc] rescue nil\n end",
"def timespan\n [Time.parse(items.last['created_at']).utc, Time.parse(items.first['created_at']).utc] rescue nil\n end",
"def split_showers(showers)\n showers.\n each_slice(2).\n flat_map{|before, after|\n next unless after\n [ [:shower, before], [:pause, hours_between(before, after)] ].\n push([ :shower, showers.last ]).\n unshift([ :pause, hours_between(Time.now, showers.first) ])\n }\nend",
"def set_time_slots_list\n last_slot = TimeSlotsList.last\n while last_slot\n TimeSlotsList.last.destroy\n last_slot = TimeSlotsList.last\n end\n @time_slots_list = TimeSlotsList.new\n @time_slots_list.group = params[:group]\n @group = params[:group]\n @time_slots_list.save!\n end",
"def trips_by_weekday()\n TripCollection.new( @trips.select {|k, t| t.start_time.wday.between?(1,5) } )\n end",
"def index\n date_range = unix_date(params[:date])\n @timeslots = Timeslot.where('start_time >= ? and start_time <= ?', date_range[:beginning_of_day], date_range[:end_of_day])\n # render :json => @timeslots.as_json(only: [])\n end",
"def time_rows\n rows = []\n (0..NUM_HALF_HOURS-1).each do |half_hour|\n cols = []\n row = content_tag :tr do\n cols << hour_cell(half_hour)\n cols << minute_cell(half_hour)\n (0..(num_days-1)).each do |day|\n cols << event_cells(half_hour,day)\n end\n cols.join.html_safe\n end\n rows << row\n end\n rows.join.html_safe\n end",
"def windows(opts = {})\n WindowCollection.new self, opts\n end",
"def merge_ranges(schedule)\n merged_schedule = []\n\n schedule.each do |meeting|\n overlapping_time_slots = check_times(meeting, merged_schedule)\n merged_schedule -= overlapping_time_slots if merged_schedule.include?(overlapping_time_slots)\n merged_schedule << slot_merger(overlapping_time_slots)\n end\n\n merged_schedule\nend",
"def windows(window = nil)\n @windows ||= []\n if window\n @windows << window\n @windows.uniq!\n end\n @windows\n end",
"def item_list_windows\n instance_variables.map{ |v|instance_variable_get v}.select{|w|w.is_a?(Window_ShopItems) }\n end",
"def generate_tabling_slots(assignments)\n\tp 'destroying all tabling slots'\n\tTablingSlot.destroy_all\n\tp 'creating new tabling slots'\n\tassignments.keys.each do |time|\n\t\tts = TablingSlot.new\n\t\tts.time = time\n\t\tts.member_ids = assignments[time].map {|x| x.id}\n\t\tp ts.time\n\t\tp ts.member_ids\n\t\tts.save\n\tend\n\n\tp 'there are now ' + TablingSlot.all.length.to_s + ' slots'\nend",
"def index\n @slots = @calendar.slots\n end",
"def time_slot_fiber\n # The combinatinos of day groupings\n # HACK: When both days are the same the class meets once per week.\n day_groups = [ [:monday, :thursday],\n [:monday, :monday],\n [:tuesday, :friday],\n [:tuesday, :tuesday],\n [:monday, :wednesday],\n [:wednesday, :wednesday],\n [:thursday, :thursday],\n [:friday, :friday] ]\n\n # The set of times that classes meet on any day.\n times_avaliable = [ ['1000', '1120'],\n ['1230', '1350'],\n ['1400', '1520'],\n ['1700', '1820'] ]\n\n # Map day symbols to integer values.\n day_nums = { monday: 1, tuesday: 2,\n wednesday: 3, thursday: 4 , friday: 5 }\n\n # Returns the next set of meeting times\n return Fiber.new do\n # Pick a random day and time combination.\n\n while true # The fiber must flow!\n days = day_groups[rand(day_groups.length)]\n starttime, endtime = times_avaliable[rand(times_avaliable.length)]\n Fiber.yield(days.map do |day|\n Meeting.new({ day: day_nums[day], starttime: starttime, endtime: endtime })\n end)\n end\n end\n end",
"def get_start_times\n times = []\n self.start_time.split('%').each do |t|\n times.push(DateTime.strptime(t, '%m-%d-%Y %H:%M'))\n end\n times\n end",
"def set_windows(uniq)\n INTERVAL_TYPES.each do |interval|\n set_window_interval(interval, true) if uniq\n set_window_interval(interval)\n end\n end",
"def recalc_times(starting_at=0, list=@events)\n\tt = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n\tlist[starting_at .. -1].each { | e |\n\t t += e.delta_time\n\t e.time_from_start = t\n\t}\n end",
"def shift_time_array\n time_shift = Time.now.in_time_zone(self.time_zone).utc_offset\n time_shift = (time_shift/3600).round\n\n if self.week_preferred != \"allday\"\n self.week_array.map! { |hour| (hour != 0 ? (hour + (time_shift)) % 24 : 0 )}\n self.week_array.sort!\n end\n\n if self.weekend_preferred != \"allday\"\n self.weekend_array.map! { |hour| (hour != 0 ? (hour + (time_shift)) % 24 : 0 )}\n self.weekend_array.sort!\n end\n end",
"def recalc_times(starting_at=0, list=@events)\n t = (starting_at == 0) ? 0 : list[starting_at - 1].time_from_start\n list[starting_at .. -1].each do |e|\n t += e.delta_time\n e.time_from_start = t\n end\n end",
"def get_runtime_timestamps\n all_events = events.to_a\n start_time = DateTime.parse(all_events.first['timestamp'])\n completion_time = DateTime.parse(all_events.last['timestamp'])\n [start_time, completion_time]\n end",
"def get_times(hash)\n\ttimes = hash.map { |name, time| time }\nend",
"def time_intervals(program,insert_repeat_interval = true)\n intervals = map{|d|d.time_intervals}.flatten.uniq.find_all{|i|program.interval === i.tstart}\n if program.repeat_first_interval and insert_repeat_interval\n firstinterval = intervals.min.copy\n firstinterval.shift!(-program.resolution*60)\n intervals << firstinterval\n end\n intervals\n end",
"def timeslot_output(timeslot)\n\t {:id=>timeslot.id,:start_time=>timeslot.start_time,:duration=>timeslot.duration,:boats=>timeslot.assets.map{|asset| asset.id},:availability=>timeslot.availability,:customer_count=>timeslot.customer_count}\n\tend",
"def day_times\n @day_times ||= available_times.map(&:day_time)\n @day_times\n end",
"def time_entries(options = {})\n entries = []\n time_invested(options).groups.each { |g| entries << g[\"time_entries\"] }\n\n process_list_response( entries.flatten , Unfuddled::TimeEntry )\n end",
"def add_timeslot_location(start_time, end_time, location_flex_rating, location_id_array)\n rt = ResponseTimeslot.new :start_time => start_time, :end_time => end_time, :location_flexibility_rating => location_flex_rating\n location_id_array.each do | location_id |\n # TODO - revisit preference logic here\n rt.response_timeslot_locations << (ResponseTimeslotLocation.new :event_location_id => location_id)\n end\n self.response_timeslots << (rt)\n self.save\n \n end",
"def make_event_times_array(dates_array, hour, min)\n\t\tevent_times = Array.new\n\n\t\tdates_array.each_index do |index|\n\t\t\n\t\t\tevent_times[index] = create_event_time(dates_array[index],hour, min)\n\t\tend\n\n\t\treturn event_times\n\tend",
"def sorted_dates\n self.time_slots.sort_by(&:scheduled)\n end",
"def from_ranges\n self[:date_time_slot] = RangeSupport.range_to_string(self[:date_time_slot])\n end",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def get_unique_permutations annotation_time_slot\r\n\t\treturn annotation_time_slot.uniq.permutation.to_a\r\n\tend",
"def timecodes\n return [] if start_time.nil?\n start_hour = start_time.strftime(\"%H\")\n start_min = start_time.strftime(\"%M\").to_i < 30 ? \"00\" : \"30\"\n curr_time = Time.parse(\"#{start_hour}:#{start_min}\")\n timecode_array = []\n while curr_time < Time.parse(\"#{end_time.strftime(\"%H\")}:#{end_time.strftime(\"%M\")}\") - 1.second\n timecode_array << \"#{curr_time.strftime(\"%H\").to_i}:#{curr_time.strftime(\"%M\")}\"\n curr_time = curr_time + 30.minutes\n end\n timecode_array_with_days = []\n %w(monday tuesday wednesday thursday friday saturday sunday).each do |day|\n timecode_array_with_days << timecode_array.collect{|t| \"#{t}_#{day}\"}.flatten if read_attribute(day)\n end\n timecode_array_with_days.flatten\n end",
"def each_with_time(&block)\n arr = @v.map.with_index{|v, i| TimeAndValue.new(@start_time+i.hours, v)}\n arr.each(&block)\n end",
"def next_times(count)\n\n next_time ? [ next_time ] : []\n end",
"def remove_time_slot\n\n end",
"def for_each_time_range(t)\n RedisAnalytics.redis_key_timestamps.map{|x, y| t.strftime(x)}.each do |ts|\n yield(ts)\n end\n end",
"def split_into_weeks(time_span)\n week = time_span.begin..time_span.begin.end_of_week\n time_periods = [week]\n while week.begin.next_week.end_of_week < time_span.end\n week = week.begin.next_week..week.begin.next_week.end_of_week\n time_periods << week\n end\n time_periods << (week.begin.next_week..(time_span.end - 1))\nend",
"def windows\n IITWindowCollection.new(@ole.Windows)\n end",
"def copytermweeksedit\n @slotwpofirst = Slot.where.not(wpo: nil).order(:timeslot).first\n @slotwpolast = Slot.where.not(wpo: nil).order(:timeslot).last\nend",
"def vacant_slots(from, to)\n\n end",
"def pick_movies(range, filters, timeleft)\n movies = filter(filters)\n picked = []\n halls = schedule.detect { |p| p.range_time == range }.hall\n start = range.first\n # Отбросываем фильмы, которые точно не поместятся\n # Выбираем из оставшихся рандомные, снижаем допустимое время\n # Создаем объект ScheduleLine, который занимается печатью строки расписания\n while timeleft > 0\n movie = movies.reject { |m| m.duration > timeleft }.sample\n return picked if movie.nil?\n picked << ImdbPlayfield::ScheduleLine.new(start: start, movie: movie, halls: halls)\n start += movie.duration * 60\n timeleft -= movie.duration\n end\n end",
"def add_timeset(*args, &block)\n if block_given?\n timesets(*args, &block)\n else\n timesets(args.first) {}\n end\n end",
"def time_slot_range_label(time_slot)\n start_time = time_slot.start_time.to_s(:time_slot_short)\n end_time = time_slot.end_time.to_s(:time_slot_long)\n \"#{start_time} - #{end_time}\"\n end",
"def slots_per_campaign(campaign_id)\n ::TimeSlot.where(campaign_id: campaign_id).map do |record|\n if block_given?\n yield record\n else\n record\n end\n end\n end",
"def show\n @event = Event.find(params[:id])\n @timeslots = @event.timeslots\n @timeslots = Timeslot.where(event_id: params[:id]).order('time')\n end",
"def all\n court_slots\n end",
"def get_datetimes(row)\n mm, dd, yyyy = get_date(row, \"Date\")\n start_hh, start_mm = get_time(row, \"Start Time\")\n end_hh, end_mm = get_time(row, \"End Time\")\n [Time.local(yyyy, mm, dd, start_hh, start_mm), Time.local(yyyy, mm, dd, end_hh, end_mm)]\nend",
"def slot(parsed)\n html = String.new\n idArray = Array.new\n i = 0\n parsed['value'].each do |array|\n butVal = array['data']['start']\n butVal = butVal.to_s\n butVal.insert(-3,':')\n idArray.push(i)\n html << '<tr>\n <td colspan=\"8\">\n <div> <button value=' + butVal + ' class=\"timeSlot\" data-day=' + array['day'] + ' data-length='+ array['length'].to_s + ' id=' + idArray[i].to_s + '>' + array['show'] + ' </button>\n </div>\n </td>\n </tr>'\n i = i + 1\n end\n return html.html_safe\n end",
"def month_range start_time, end_time\n start_date = start_time.month_start.to_date\n end_date = end_time.month_start.to_date\n current_date = start_date\n result = []\n while current_date <= end_date\n result << current_date.to_time\n current_date = current_date.next_month\n end\n result\nend",
"def widgets(win_name)\n @driver.getQuickWidgetList(win_name).map do |java_widget|\n case java_widget.getType\n when QuickWidget::WIDGET_ENUM_MAP[:button]\n QuickButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:checkbox]\n QuickCheckbox.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:dialogtab]\n QuickDialogTab.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:dropdown]\n QuickDropdown.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:editfield]\n QuickEditField.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:label]\n QuickLabel.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:radiobutton]\n QuickRadioButton.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:treeview]\n QuickTreeView.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:treeitem]\n QuickTreeItem.new(self,java_widget)\n when QuickWidget::WIDGET_ENUM_MAP[:thumbnail]\n QuickTreeItem.new(self,java_widget)\n else\n QuickWidget.new(self,java_widget)\n end\n end.to_a\n end"
] | [
"0.69684774",
"0.66403735",
"0.6522786",
"0.64842707",
"0.64607245",
"0.6315037",
"0.6260561",
"0.61152977",
"0.5953129",
"0.5904408",
"0.5851289",
"0.57530767",
"0.5634359",
"0.5601106",
"0.5556569",
"0.55542845",
"0.5491609",
"0.5475066",
"0.54636014",
"0.5437108",
"0.54204386",
"0.53106517",
"0.52992886",
"0.5254288",
"0.522802",
"0.5215389",
"0.5214111",
"0.51994836",
"0.51983404",
"0.51983404",
"0.5180015",
"0.5155409",
"0.514697",
"0.51468307",
"0.51428837",
"0.5094713",
"0.5050067",
"0.50358874",
"0.499237",
"0.4984712",
"0.49842545",
"0.49816108",
"0.49760437",
"0.4974319",
"0.49661422",
"0.49632964",
"0.49615845",
"0.49478042",
"0.49450386",
"0.4923358",
"0.49231875",
"0.49231875",
"0.49112538",
"0.4904453",
"0.4901258",
"0.49005166",
"0.48995808",
"0.48985937",
"0.48758295",
"0.48733804",
"0.4866204",
"0.48644918",
"0.4831945",
"0.4826845",
"0.48200068",
"0.4800475",
"0.47965923",
"0.47894168",
"0.47858107",
"0.47837436",
"0.477968",
"0.4777116",
"0.47648853",
"0.47641712",
"0.47362244",
"0.47355258",
"0.47315428",
"0.47312003",
"0.47111022",
"0.4710694",
"0.47029364",
"0.46989265",
"0.468683",
"0.4667782",
"0.4667484",
"0.4652406",
"0.4652399",
"0.4646708",
"0.46422243",
"0.46420944",
"0.46322832",
"0.4628296",
"0.46266076",
"0.46263963",
"0.462199",
"0.4619923",
"0.46174794",
"0.46169648",
"0.46051857",
"0.46022606"
] | 0.64953905 | 3 |
Responsible combining a collection of slots into common groups, defined by touching boundaries. +:slots: Array / Collection of TimeSlot(s) | def combine_linear_slots(slots)
last_slot = false
end_time = false
start_time = false
flushed = false # Tracks the current continuity chain
count = 0
aggregate = []
debug = []
slots.sort_by(&:start_time).each_with_index do |slot, i|
# Very close to each other, mark it as a continuation
# to the end_time.
start_time = slot.start_time unless last_slot
end_time = slot.end_time unless last_slot
if slot.start_time < (end_time + 30.seconds)
debug << "slot:#{slot.start_time} - neighbor detected"
end_time = slot.end_time
elsif last_slot
debug << "slot:#{slot.start_time} - gap detected"
aggregate << TimeSlot.new(start_time, end_time, slot.time_entry)
start_time = slot.start_time
end_time = slot.end_time
end
last_slot = slot
end
aggregate << TimeSlot.new(start_time, end_time, last_slot.time_entry) if last_slot
aggregate.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_ranges(schedule)\n merged_schedule = []\n\n schedule.each do |meeting|\n overlapping_time_slots = check_times(meeting, merged_schedule)\n merged_schedule -= overlapping_time_slots if merged_schedule.include?(overlapping_time_slots)\n merged_schedule << slot_merger(overlapping_time_slots)\n end\n\n merged_schedule\nend",
"def groupped_slots\n @groupped_slots ||= publication_history.group_by do |published_at|\n time_of_day = date_to_local_duration(published_at)\n duration_to_slot(time_of_day)\n end\n end",
"def slots\n slot_start = start_time\n slot_end = slot_start + slot_length\n while slot_end <= end_time\n slot = ::V2::TimeSlot.new(start_time: slot_start, end_time: slot_end, event_id: @event_id)\n @slots << slot if slot.valid? && slot.save\n slot_start = slot_end + buffer\n slot_end = slot_start + slot_length\n end\n\n @slots\n end",
"def time_slots\n collection=[]\n start_time=Time.now.beginning_of_hour\n end_time=Time.now.tomorrow.midnight-1.hour\n time=start_time\n\n while time < end_time\n collection<<[time.beginning_of_hour.hour, time.beginning_of_hour]\n time=time+1.hour\n end\n\n collection\n end",
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.minutes, time_entry\n\n # Stash the current session onto the slot as well, so it may handle\n # some of it's own session based logic.\n slot.session = session\n\n # finally increment the time for the next iteration\n time = time + block_size.minutes\n\n slot\n end\n\n # Detect deadspace at the TimeSlot layer.\n # If found, we add a final TimeSlot to make up the difference.\n if time < time_entry.end_time\n slots << TimeSlot.new(time, time_entry.end_time, time_entry)\n end\n\n # Return the aggregated slot collection\n slots\n end",
"def timeslots\n\t\tif (self != nil)\n\t\t\tcompany = self.company\n\t\t\tstart_time = company.start_time\n\t\t\tend_time = company.end_time\n\t\t\tcompany_duration = (( end_time - start_time )/60).round(2)\n\t\t\tno_of_slots = ( company_duration / (self.time_slot.hour*60 + self.time_slot.min) ).to_i\n\t\t\ttime_slot_array =Array.new\n\t\t\tremember_hour = start_time.hour.round\n\t\t\tremember_min = start_time.min\n\t\t\tno_of_slots.times do | index |\n\t\t\t\ta = remember_hour == 0 ? \"00\" : remember_hour\n\t\t\t\tb = remember_min == 0 ? \"00\" : remember_min\n\t\t\t\tc = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour == 0 ? \"00\" :((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\td = (remember_min + self.time_slot.min) % 60 == 0 ? \"00\" : (remember_min + self.time_slot.min) % 60\n\t\t\t\ttime_slot_array << [\"#{a}:#{b}-#{c}:#{d}\", index]\n\t\t\t\tremember_hour = ((remember_min + self.time_slot.min)/60 )+remember_hour+self.time_slot.hour\n\t\t\t\tremember_min = (remember_min + self.time_slot.min) % 60\n\t\t\tend\n\t\t\ttime_slot_array\n\t\tend\n\tend",
"def mask_for_time_slots\n offset = (ends_at.next_day.beginning_of_day - ends_at) / APPOINTMENT_INTERVAL\n slots_number = (ends_at - starts_at) / APPOINTMENT_INTERVAL\n ('1' * slots_number).to_i(2) << offset\n end",
"def timeslots\n data['timeslots'].map { |ts|\n Timeslot.new(\n Time.at(ts['start_date']),\n Time.at(ts['end_date'] || ts['start_date']),\n data['timezone']\n )\n }.reject(&:finished?).sort_by(&:start_date)\n end",
"def time_slots\n\n # you can book by the hour, and you can stay for an hour\n reservation_interval = 1.hour\n\n # Determine the earliest time we will allow reservation\n # It can't be in the past, we'll start 10 minutes from now\n start_time = Time.zone.now + 10.minutes\n # Then we have to round to the next hour block\n start_time = Time.zone.at( (start_time.to_f / reservation_interval).ceil * reservation_interval )\n # Then, if we are still earlier than opening hour, just use the opening hour\n # We can use the 'max' Array method\n start_time = [start_time, start_time.change(hour: opening_hour)].max\n\n # Determine the furthest in the future we will allow reservations\n end_time = (start_time + 3.days).change(hour: closing_hour)\n\n # Now, we want to make a list of every hour between our start_time and our end_time\n # For this we can use a begin... end while condition loop.\n # We'll start with an empty array that will hold all the hours,\n # and a variable to hold each hour, which we will keep increasing by 1 hour, and then add to our array\n # Our loop condition will have us stop looping once we've reached the end time\n\n all_times = []\n a_time = start_time\n\n begin\n\n # add this time to our list of times\n all_times << a_time\n\n # increment the time\n a_time += reservation_interval\n\n # Once we get to closing time, we have to skip ahead to the next day's opening\n # That way you can't make a reservation at 2am\n if (a_time + reservation_interval) > a_time.change(hour: closing_hour)\n a_time = (a_time + 1.day).change(hour:opening_hour)\n end\n\n end while a_time < end_time\n\n all_times\n end",
"def block_slots\n slots = []\n\n unless block_delivery_end_time.blank? || block_delivery_start_time.blank?\n\n available_hours = block_delivery_end_time - block_delivery_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: block_delivery_start_time + i.hours,\n to: block_delivery_start_time + (i + 1).hours,\n type: :daytime\n }\n end\n end\n\n slots\n end",
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n {gained_weight: 0, duration: @slots_size})\n @slots << verterx\n\n current_time += @slots_size\n break if current_time >= finish_time\n end\n\n current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight\n end\n end",
"def get_time_slot_array\n time_slot_array = [\"07:00\", \"07:30\", \"08:00\", \"08:30\", \"09:00\", \"09:30\", \"10:00\", \"10:30\",\n \"11:00\", \"11:30\", \"12:00\", \"12:30\", \"13:00\", \"13:30\", \"14:00\", \"14:30\",\n \"15:00\", \"15:30\", \"16:00\", \"16:30\", \"17:00\", \"17:30\", \"18:00\", \"18:30\",\n \"19:00\", \"19:30\", \"20:00\", \"20:30\", \"21:00\"]\n end",
"def create_time_slots\n return unless params[:start_time]\n\n start_time = Time.from_picker(params.delete(:start_time))\n end_time = Time.from_picker(params.delete(:end_time))\n\n return if end_time < start_time # Prevent infinite loop\n\n shift_length = params.delete(:shift_length).to_i\n shift_overlap = params.delete(:shift_overlap).to_i\n people_per_shift = params.delete(:people_per_shift)\n\n num_shifts = ((end_time - start_time) / shift_length).ceil\n return if num_shifts > 100 # Arbitrary threshold to prevent flooding database\n\n cur_time = start_time\n TimeSlot.transaction do\n while cur_time < end_time\n end_shift_time = cur_time + shift_length + shift_overlap\n TimeSlot.create! job: @job,\n start_time: cur_time,\n end_time: [end_shift_time, end_time].min,\n slots: people_per_shift\n cur_time += shift_length\n end\n end\n end",
"def merged_meetings(meeting_time_ranges)\n # assuming meetings can fall at most 12 30-minute blocks past 9am\n start_times = Array.new(13, nil) # array of start times at their index\n end_times = Array.new(13, nil) # array of end times - their index is their start time\n meeting_time_ranges.each do |meeting_time_range|\n start_time = meeting_time_range[0]\n end_time = meeting_time_range[1]\n\n # add start_time to start_times\n start_times[start_time] = start_time\n\n # add end_time to end_times at its start_time index, unless there is already a later end_time at that index\n end_times[start_time] = end_time unless !end_time[start_time].nil? && end_time[start_time] > end_time\n end\n\n merged_meeting_times = []\n\n # start_times look something like [0, nil, nil, 3, 4, nil, nil, nil, nil, 9, 10, nil]\n # end_times look something like [1, nil, nil, 5, 8, nil, nil, nil, nil, 10, 12, nil]\n last_start_time = nil\n last_end_time = nil\n start_times.each do |start_time|\n next if start_time.nil?\n\n if last_start_time.nil? # no values have been stored yet\n last_start_time = start_time\n last_end_time = end_times[start_time]\n next\n end\n\n if start_time <= last_end_time # current start_time is before the last end_time\n if start_time < last_start_time\n # current start_time earlier than last_start_time - assign as last_start_time\n last_start_time = start_time\n end\n\n if end_times[start_time] > last_end_time\n # current end_time later than last_end_time - assign it end_time as last_end_time\n last_end_time = end_times[start_time]\n end\n next\n end\n\n if start_time > last_end_time\n # we have reached the start of a new range - store the last range\n merged_meeting_times << [last_start_time, last_end_time]\n\n # reset the last_end_time and last_start_time to the current values\n last_start_time = start_time\n last_end_time = end_times[start_time]\n next\n end\n end\n\n # be sure to append the remaining last meeting time range\n merged_meeting_times << [last_start_time, last_end_time]\n\n merged_meeting_times\nend",
"def all_timeslots\n unless @all_timeslots.present?\n @all_timeslots = (1..5).map do |day_id|\n Timeslot.new(self, day_id, @day_start_minute, @day_end_minute)\n end\n end\n\n @all_timeslots\n end",
"def merged_meetings_2(meeting_time_ranges)\n # merged_meetings where we cannot assume how many time blocks\n meeting_time_ranges = meeting_time_ranges.sort\n\n merged_meeting_times = []\n\n last_start_time = nil\n last_end_time = nil\n meeting_time_ranges.each do |meeting_time_range|\n start_time = meeting_time_range[0]\n end_time = meeting_time_range[1]\n\n if last_start_time.nil? # no values have been stored yet\n last_start_time = start_time\n last_end_time = end_time\n next\n end\n\n if start_time <= last_end_time # current start_time is before the last end_time\n if start_time < last_start_time\n # current start_time earlier than last_start_time - assign as last_start_time\n last_start_time = start_time\n end\n\n if end_time > last_end_time\n # current end_time later than last_end_time - assign it end_time as last_end_time\n last_end_time = end_time\n end\n next\n end\n\n if start_time > last_end_time\n # we have reached the start of a new range - store the last range\n merged_meeting_times << [last_start_time, last_end_time]\n\n # reset the last_end_time and last_start_time to the current values\n last_start_time = start_time\n last_end_time = end_time\n next\n end\n end\n\n # be sure to append the remaining last meeting time range\n merged_meeting_times << [last_start_time, last_end_time]\n\n merged_meeting_times\nend",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def vacant_slots(from, to)\n\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def consolidate(schedules)\n schedules\n .group_by(&:first)\n .transform_values { _1.map(&:last).consolidate_ranges(:time) }\n end",
"def from_meeting_rooms!(meeting_rooms)\n @time_slots = []\n meeting_rooms.each do |meeting_room|\n meeting_room.time_slots.each do |time_slot|\n if time_slot.is_a? TimeSlot\n @time_slots << time_slot.duration_in_minutes\n end\n end\n end\n self\n end",
"def set_time_slots_list\n last_slot = TimeSlotsList.last\n while last_slot\n TimeSlotsList.last.destroy\n last_slot = TimeSlotsList.last\n end\n @time_slots_list = TimeSlotsList.new\n @time_slots_list.group = params[:group]\n @group = params[:group]\n @time_slots_list.save!\n end",
"def car_slots_ordered(start_time, num_slots)\n self.car_slots.where(\"start_time >= ? AND end_time <= ?\", start_time, start_time.advance(:days => +num_slots)).order(:start_time)\n # TODO: handle case where num slots returned != num slots requested (probably means we forgot to create enough car slots)\n end",
"def generate_schedule\r\n match_list = make_match_list\r\n schedule = make_empty_schedule\r\n # pp match_list\r\n # pp match_list.size\r\n\r\n scheduled_matches = []\r\n referee_count = 0\r\n move_to_next_slot = false\r\n\r\n schedule.each do |day|\r\n # puts \"#{day[:day]}\"\r\n day[:slots].each do |slots|\r\n # puts \" #{slots[:time]}\"\r\n\r\n match_count = -1\r\n move_to_next_slot = false\r\n match_to_validate = {}\r\n\r\n slots[:matches].each do |match|\r\n # puts \" scheduled (#{scheduled_matches.size})\"; pp scheduled_matches\r\n # puts \"match list (#{match_list.size})\"; pp match_list\r\n # puts \" to_val: \"; pp scheduled_matches\r\n while(!validate_rest_time(match_to_validate, scheduled_matches))\r\n match_count += 1 #next match on match_list\r\n # puts \" CLASH: mc=#{match_count} \"\r\n match_to_validate = {:teams=>match_list[match_count],:day => day[:day], :time => slots[:time]}\r\n\r\n if(match_list.size == match_count)\r\n # puts \"----> Move to next slot\"\r\n move_to_next_slot=true\r\n break\r\n end\r\n end\r\n\r\n # puts \"move_to_next_slot: #{move_to_next_slot}\"\r\n \r\n unless(move_to_next_slot)\r\n scheduled_matches << match_to_validate\r\n match[:referees] = REFEREES[referee_count%REFEREES.size]\r\n match[:score] = [0,0]\r\n match[:teams] = match_list.delete_at(match_count)\r\n # print \"Adding match: \"; pp match\r\n # puts \"-\"*34\r\n referee_count += 1\r\n match_count = 0\r\n match_to_validate = {:teams=>match_list[match_count], :day => match[:day], :time => match[:time]}\r\n else\r\n break\r\n end\r\n\r\n end\r\n\r\n end\r\n end\r\n\r\n schedule\r\n end",
"def live_slots\n slots = []\n\n unless live_delivery_block_end_time.blank? || live_delivery_block_start_time.blank?\n available_hours = live_delivery_block_end_time - live_delivery_block_start_time\n\n number_of_slots = available_hours / 60.minutes\n\n number_of_slots.to_i.times do |i|\n slots << {\n from: live_delivery_block_start_time + i.hours,\n to: live_delivery_block_start_time + (i + 1).hours,\n type: :live\n }\n end\n end\n\n slots\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def default_time_slots\n start_time = Time.parse(\"9:00\")\n end_time = Time.parse(\"20:30\")\n slots = []\n t = start_time\n while t <= end_time\n slots << t.strftime(\"%H:%M\")\n t += 30.minutes;\n end\n\n slots\n end",
"def manage_time_slots\n @time_slot = TimeSlot.new\n\n end",
"def time_slot_range_label(time_slot)\n start_time = time_slot.start_time.to_s(:time_slot_short)\n end_time = time_slot.end_time.to_s(:time_slot_long)\n \"#{start_time} - #{end_time}\"\n end",
"def find_venue_for_timeslot(availability, timeslot)\n blocks_needed = availability.blocks_needed\n day_id = timeslot.day_id\n\n start_block = [0, timeslot.start_block].max\n finish_block = [blocks_per_day, timeslot.end_block].min\n\n @venues.each do |venue, venue_blocks_used|\n blocks_used_for_day = venue_blocks_used[day_id]\n\n for window_start_block in start_block...(finish_block - blocks_needed)\n window_blocks_used = blocks_used_for_day[window_start_block, blocks_needed]\n is_available = window_blocks_used.none?\n\n if is_available\n window_end_block = window_start_block + blocks_needed\n return Reservation.new(@schedule_range, availability.project, venue,\n day_id, window_start_block, window_end_block)\n end\n end\n end\n\n nil\n end",
"def split(range = nil)\n if self.record_category and self.activity?\n entry_end = self.end_timestamp || Time.now\n time = range ? [self.timestamp, range.begin.midnight.in_time_zone].max : self.timestamp\n end_time = range ? [entry_end, range.end.midnight.in_time_zone].min : entry_end\n list = Array.new\n while time < end_time\n new_end = [entry_end, (time + 1.day).midnight.in_time_zone].min\n list << [time, new_end, self]\n time = new_end\n end\n else\n return [self.timestamp, nil, self]\n end\n list\n end",
"def add_timeslot_location(start_time, end_time, location_flex_rating, location_id_array)\n rt = ResponseTimeslot.new :start_time => start_time, :end_time => end_time, :location_flexibility_rating => location_flex_rating\n location_id_array.each do | location_id |\n # TODO - revisit preference logic here\n rt.response_timeslot_locations << (ResponseTimeslotLocation.new :event_location_id => location_id)\n end\n self.response_timeslots << (rt)\n self.save\n \n end",
"def populate_groups_for_round i=@round\r\n temp_groups = []\r\n (1..@number_of_groups).each_entry do |x|\r\n temp_group = Group.new(:position => i, :day => x, :schedule_dataset => self)\r\n temp_groups.push(temp_group)\r\n end\r\n\r\n # Add seminarians who need to be assigned to a single day\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups)\r\n sem.add_to_group(possible_grps.first) if possible_grps.count == 1 && !possible_grps.first.full?\r\n end\r\n\r\n # Add seminarians with too many duplicates to a group with least number of seminarians\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).sort_by{|g| g.seminarians.count}\r\n sem.add_to_group(possible_grps.first) if sem.duplicate_days >= @duplicate_days_allowed && !possible_grps.first.full?\r\n end\r\n\r\n # Add at least one seminarian to each group\r\n seminarians_left = seminarians_for_round(i)\r\n seminarians_left.shuffle.each do |sem|\r\n possible_grps = sem.possible_groups(temp_groups).shuffle\r\n sem.add_to_group(possible_grps.first) if possible_grps.count < @number_of_groups && possible_grps.first.seminarians.count == 0\r\n end\r\n\r\n seminarians_left = seminarians_for_round(i)\r\n \r\n while seminarians_left.any? do\r\n\r\n #Find the smallest groups\r\n smallest_number = temp_groups.sort_by{|g| g.seminarians.count}.first.seminarians.count\r\n small_groups = temp_groups.select{|tg| tg.seminarians.count == smallest_number}\r\n\r\n best_match = nil\r\n best_score = 9000\r\n\r\n small_groups.shuffle.each do |group|\r\n seminarians_left.shuffle.each do |sem|\r\n \r\n #Find the best match of seminarians and small groups\r\n if sem.score_for_group(group) < best_score\r\n best_match = [sem, group]\r\n best_score = sem.score_for_group(group)\r\n end\r\n end\r\n end\r\n \r\n best_match.first.add_to_group(best_match.second) if best_match\r\n seminarians_left = seminarians_for_round(i)\r\n end\r\n \r\n temp_groups.each{|g| @groups.push(g)}\r\n end",
"def get_busy_slots(start_min, start_max, time_zone)\n result = Array.new\n @googleCalendars.each do |x|\n result.push(x[:connection].query([x[:id]],start_min, start_max, time_zone))\n end\n return result\n end",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def overlap(existing_reservations)\n booked_rooms = []\n existing_reservations.each do |reservation|\n if @check_out >= reservation.check_in && @check_out < reservation.check_out ||\n @check_in >= reservation.check_in && @check_in < reservation.check_out ||\n @check_in > reservation.check_in && @check_out < reservation.check_out\n if reservation.class == BookingSystem::Block\n reservation.avail_block_rooms.map { |block_room_num| booked_rooms << block_room_num }\n else\n booked_rooms << reservation.room_num\n end\n end\n end\n return booked_rooms\n end",
"def open_slots(date)\n time = date.to_time\n \n slots = []\n prev_time = time - 30.minutes\n loop do\n start_time = prev_time + 30.minutes\n \n if start_time.to_date == date\n slots << Slot.new(starts_at: start_time, cat: self)\n prev_time = start_time\n else\n break\n end\n end\n \n # Remove taken/past timeframes\n slots.reject do |slot|\n Reservation.exists?(cat: self, starts_at: slot.starts_at) || slot.starts_at.past?\n end\n end",
"def time_slot_fiber\n # The combinatinos of day groupings\n # HACK: When both days are the same the class meets once per week.\n day_groups = [ [:monday, :thursday],\n [:monday, :monday],\n [:tuesday, :friday],\n [:tuesday, :tuesday],\n [:monday, :wednesday],\n [:wednesday, :wednesday],\n [:thursday, :thursday],\n [:friday, :friday] ]\n\n # The set of times that classes meet on any day.\n times_avaliable = [ ['1000', '1120'],\n ['1230', '1350'],\n ['1400', '1520'],\n ['1700', '1820'] ]\n\n # Map day symbols to integer values.\n day_nums = { monday: 1, tuesday: 2,\n wednesday: 3, thursday: 4 , friday: 5 }\n\n # Returns the next set of meeting times\n return Fiber.new do\n # Pick a random day and time combination.\n\n while true # The fiber must flow!\n days = day_groups[rand(day_groups.length)]\n starttime, endtime = times_avaliable[rand(times_avaliable.length)]\n Fiber.yield(days.map do |day|\n Meeting.new({ day: day_nums[day], starttime: starttime, endtime: endtime })\n end)\n end\n end\n end",
"def generate_schedule(courses)\n num_days = 5\n num_time_slots = 111 # num of 5 minute intervals from 8:00am - 5:15pm\n schedule = Array.new(num_time_slots) { Array.new(num_days, 0)} # important !!!!!\n \n courses.each do |course|\n if course.meetingtime_start.nil? or course.meetingtime_end.nil? or \n course.meeting_days.nil?\n next\n end\n \n start_time = parse_time(course.meetingtime_start)\n end_time = parse_time(course.meetingtime_end)\n days = parse_day(course.meeting_days)\n schedule = insert_course(schedule, days, start_time, end_time)\n end\n \n # print_schedule(schedule)\n \n return schedule\n end",
"def init_availability_based_on_general_availability\n\n # Selects all the possible slots\n Time.zone = 'UTC'\n\n from = Time.zone.parse(hour_from.to_s)\n to = Time.zone.parse(hour_to.to_s)\n\n selected_slots = Slot.where(\"EXTRACT(dow FROM start) IN (#{day}) AND ((EXTRACT(hour FROM start) = #{from.hour} AND EXTRACT(minute FROM start) >= #{from.min}) OR (EXTRACT(hour FROM start) > #{from.hour} AND EXTRACT(hour FROM start) < #{to.hour}) OR (EXTRACT(hour FROM start) = #{to.hour} AND EXTRACT(minute FROM start) < #{to.min}))\")\n\n puts \"Start: #{selected_slots.first.id} - #{selected_slots.first.start}\"\n\n inserts = []\n selected_slots.each do |s|\n inserts.push \"(#{doctor_id}, #{s.id}, #{id}, now(), now())\"\n end \n\n sql = \"INSERT INTO availabilities (\\\"doctor_id\\\", \\\"slot_id\\\", \\\"availability_general_id\\\", \\\"created_at\\\", \\\"updated_at\\\") VALUES #{inserts.join(\", \")}\"\n ActiveRecord::Base.connection.execute sql\n #Time.zone = 'UTC'\n puts \"Hours from #{from.hour} to #{to.hour}\"\n end",
"def reserved_slots(date)\n Reservation.confirmed.where(nook_id: self.id)\n .happening_within(date.beginning_of_day..date.end_of_day)\n .map do |r|\n r.start.strftime('%H%M').to_i..\n (r.end + 1.seconds).strftime('%H%M').to_i\n end\n end",
"def find_possible_combination(talks_to_schedule, morning)\n #talks_to_schedule = talks_to_schedule.sort_by(&:time_length)\n min_time_limit = 180\n max_time_limit = morning ? 180 : 240\n talks_combinations = []\n talks_to_schedule.each do |talk|\n new_combinations = []\n new_combinations << [talk] if talk.time_length <= max_time_limit\n talks_combinations.each do |previous_combination|\n current_list = previous_combination + [ talk ]\n sum = current_list.inject(0){|accumulator, talk|accumulator+ talk.time_length}\n if sum <= max_time_limit\n new_combinations << current_list\n return current_list if sum >= min_time_limit && sum <= max_time_limit\n end\n end\n talks_combinations = talks_combinations + new_combinations\n end\n talks_combinations\n end",
"def gametime_collapsed_segments\n segments.reduce([]) do |segs, seg|\n if segs.last.try(:gametime_duration_ms) == 0\n skipped_seg = segs.last\n segs + [Segment.new(\n segs.pop.attributes.merge(\n name: \"#{skipped_seg.name} + #{seg.name}\",\n realtime_start_ms: skipped_seg.realtime_start_ms,\n realtime_end_ms: seg.realtime_end_ms,\n realtime_duration_ms: seg.realtime_duration_ms,\n gametime_start_ms: skipped_seg.gametime_start_ms,\n gametime_end_ms: skipped_seg.gametime_end_ms,\n gametime_duration_ms: seg.gametime_duration_ms,\n gametime_reduced: true\n )\n )]\n else\n segs + [seg]\n end\n end\n end",
"def available_slots\n # Doit regarder le board et renvoyer un array avec les slots restants\n slots = []\n @board.each do |k,v|\n v.each_with_index { |num,i| slots << k + (i+1).to_s if num.zero?}\n end\n slots\n end",
"def get_current_available_slots(assignments, member)\n slots = Array.new\n # puts \"getting slots for \"+member.name\n assignments.keys.each do |key|\n slot = key\n conflicts = true\n if not slot == \"manual\"\n conflicts = false\n for c in member.commitments\n d = c.day\n s = c.start_hour\n e = c.end_hour\n # TODO have these calculated somewhere else\n if d\n # puts \"taking a while on this part\"\n day = Date::DAYNAMES[d]\n # start = Chronic.parse(\"#{s} this #{day}\")\n # endt = Chronic.parse(\"#{e} this #{day}\")\n start = c.start_time\n endt = c.end_time\n if day and conflicts(start, endt, slot.start_time, slot.end_time)\n conflicts = true\n break\n end\n end\n end\n end\n if not conflicts\n if assignments[slot].length < 5000 # hard coded capacity\n slots << slot\n end\n end\n end\n return slots\n end",
"def create_shifts(contiguous_timings)\n contiguous_timings.each{|timing| create_shift(timing)}\n end",
"def not_overlapping\n @meetingsRD = Meeting.where(\"day = ? and room = ?\", day, room)\n overlap = false\n @meetingsRD.each do |mtng|\n if (id != mtng.id)\n if ((finish <= mtng.start) || (start >= mtng.finish))\n overlap = false\n else\n overlap = true\n errors.add(:finish, 'Sorry! It overlaps ' + (mtng.subject).upcase + ' meeting')\n errors.add(:start, 'Sorry! It overlaps ' + (mtng.subject).upcase + ' meeting')\n break #if overlap, finish the loop\n end\n end\n end\n end",
"def schedule_sections(sections, schedules)\n if (sections.empty?)\n return schedules\n end\n\n new_schedules = []\n sections.each do |sec|\n # try adding sec to each possible schedule\n schedules.each do |sched|\n # build the time blocks associated with this section\n # onto an existing schedule\n schedule = sched + TimeBlock.where(section: sec)\n\n # add constructed schedule to the list of new schedules\n new_schedules.push(schedule)\n end\n\n return new_schedules\n end\n\n return new_schedules\n end",
"def extend_boundaries(min_odds, max_odds)\n [min_odds - extend_min_interval(min_odds, max_odds),\n max_odds + extend_max_interval(min_odds, max_odds)]\n end",
"def all_slot\n type = params[:type] || 'all_slots'\n @user = User.find(params[:data])\n\n @scoring_scale = @user.departments.first.cds_template.scoring_scale\n \n @competencies = Competency.all\n\n case type\n when 'all_slots'\n @slot_assesses = @user.slot_assesses.order(\"id\")\n when 'passed_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Passed\").order(\"id\")\n when 'not_passed_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Not Passed\").order(\"id\")\n when 'not_assessed_yet_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Not Assessed Yet\").order(\"id\")\n when 'not_added_slots'\n @slot_assesses = @user.slot_assesses.where(status: \"Not Added Yet\").order(\"id\")\n end\n render :layout => false\n end",
"def overlaps\n siblings.overlaps date, date_ended\n end",
"def combined_share\n based_on_slot.conversion + balanced_with_slot.conversion\n end",
"def schedule(startAt,endAt,opts={})\n ## Caching ##\n @schedules ||= {}\n if @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash]\n return @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash]\n end\n ## End Caching ##\n\n # TODO Handle events starting within the range but ending outside of it?\n\n # TODO Offload this selection to the database; okay for testing though\n # NOTE This is actually faster thanks to the query cache for small numbers of operating times, but not very scalable\n #all_regular_operating_times = OperatingTime.find(:all, :conditions => {:place_id => self.id, :override => 0}).select{|t| (t.startDate - 1) <= endAt.to_date and startAt.to_date <= (t.endDate + 1)}\n #all_special_operating_times = OperatingTime.find(:all, :conditions => {:place_id => self.id, :override => 1}).select{|t| (t.startDate - 1) <= endAt.to_date and startAt.to_date <= (t.endDate + 1)}\n # Select all relevant times (1 day buffer on each end)\n # NOTE Make sure to use generous date comparisons to allow for midnight rollovers\n all_regular_operating_times = OperatingTime.regular.by_place_id(self.id).in_range(startAt..endAt).find(:all)\n all_special_operating_times = OperatingTime.special.by_place_id(self.id).in_range(startAt..endAt).find(:all)\n\n puts \"\\nRegular OperatingTimes: #{all_regular_operating_times.inspect}\" if DEBUG\n puts \"\\nSpecial OperatingTimes: #{all_special_operating_times.inspect}\" if DEBUG\n\n regular_times = []\n special_times = []\n special_ranges = []\n\n all_special_operating_times.each do |ot|\n puts \"\\nSpecial Scheduling for: #{ot.inspect}\" if DEBUG\n\n # Special Case: Overriding with NO times (e.g. closed all day)\n if ot.start == 0 and ot.length == 0 and startAt.to_date <= ot.startDate\n # Block out the range, but don't add the \"null Times\"\n special_ranges << Range.new(ot.startDate,ot.endDate)\n next\n end\n\n # Start a day early if possible\n earlyStart = startAt-1.day < ot.startDate.midnight ? startAt.midnight : startAt - 1.day\n puts \"EarlyStart: #{earlyStart.inspect}\" if DEBUG\n\n # Calculate the next set up open/close times\n open,close = ot.next_times(earlyStart)\n next if open.nil? # No valid occurrences in the future\n\n while not open.nil? and open <= endAt do\n if DEBUG\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n puts \"Start Date: #{ot.startDate} (#{ot.startDate.class})\"\n puts \"End Date: #{ot.endDate} (#{ot.endDate.class})\"\n end\n\n if close < startAt # Skip forward to the first occurrance in our time range\n puts \"Seeking: #{close} < #{startAt}\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n special_times << [open,close]\n special_ranges << Range.new(ot.startDate,ot.endDate)\n open,close = ot.next_times(close)\n end\n\n end\n\n puts \"\\nSpecial Times: #{special_times.inspect}\" if DEBUG\n puts \"\\nSpecial Ranges: #{special_ranges.inspect}\" if DEBUG\n\n all_regular_operating_times.each do |ot|\n puts \"\\nRegular Scheduling for: #{ot.inspect}\" if DEBUG\n\n # Start a day early if possible\n earlyStart = startAt-1.day < ot.startDate.midnight ? startAt : startAt - 1.day\n puts \"EarlyStart: #{earlyStart.inspect}\" if DEBUG\n\n # Calculate the next set up open/close times\n open,close = ot.next_times(earlyStart)\n if DEBUG\n puts \"\"\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n end\n\n if open.nil? # No valid occurrences in the future\n puts \"Skipping: No valid occurrences in the future.\" if DEBUG\n next\n end\n\n while not open.nil? and open <= endAt do\n if DEBUG\n puts \"\"\n puts \"Open: #{open}\"\n puts \"Close: #{close}\"\n end\n\n if close < startAt # Skip forward to the first occurrance in our time range\n puts \"Seeking: #{close} < #{startAt}\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n overridden = false\n special_ranges.each do |sr|\n overridden ||= sr.member?(open.to_date)\n end\n if overridden\n puts \"Overridden\" if DEBUG\n open,close = ot.next_times(close)\n next\n end\n\n # FIXME Causing an infinite loop; would be nice if this worked\n #open = startAt if open < startAt\n #close = endAt if close > endAt\n\n regular_times << [open,close]\n open,close = ot.next_times(close)\n end\n\n end\n\n puts \"\\nRegular Times: #{regular_times.inspect}\" if DEBUG\n\n # TODO Handle schedule overrides\n # TODO Handle combinations (i.e. part special, part regular)\n\n final_schedule = (regular_times+special_times).sort{|a,b|a[0] <=> b[0]}\n\n ## Truncate times larger than range ##\n if opts[:truncate]\n final_schedule.each_index do |i|\n final_schedule[i][0] = startAt.dup if final_schedule[i][0] < startAt\n final_schedule[i][1] = endAt.dup if final_schedule[i][1] > endAt\n end\n end\n ## End truncating ##\n\n ## Caching ##\n @schedules ||= {}\n @schedules[(startAt.xmlschema+endAt.xmlschema+opts.to_s).hash] = final_schedule\n ## End caching ##\n\n final_schedule\n end",
"def attended_slots\n self.tabling_slot_members.where(status_id: Status.where(name: :attended).first).map do |tsm|\n tsm.tabling_slot\n end\n end",
"def add_to_list(interval)\n # edge case \n if (interval.begin_t < @list[0].begin_t)\n @list.insert(0, IntervalCounter.new(interval.begin_t, @list[0].begin_t, interval.items))\n end\n # other cases\n i = 0\n while @list[i]\n if (interval.begin_t < @list[i].begin_t && interval.end_t > @list[i].end_t)\n @list[i].items = increment_new_list(interval.items, @list[i].items, true)\n \n elsif (interval.end_t > @list[i].begin_t && interval.end_t < @list[i].end_t)\n items_list = increment_new_list(interval.items, @list[i].items, false)\n time_slot = IntervalCounter.new(@list[i].begin_t, interval.end_t, items_list)\n @list[i].begin_t = interval.end_t\n @list.insert(i, time_slot)\n \n elsif (interval.begin_t > @list[i].begin_t && interval.begin_t < @list[i].end_t)\n items_list = increment_new_list(interval.items, @list[i].items, false)\n time_slot = IntervalCounter.new(interval.begin_t, @list[i].end_t, items_list)\n @list[i].end_t = interval.begin_t\n @list.insert(i + 1, time_slot)\n \n elsif (interval.begin_t > @list[i].begin_t && interval.end_t < @list[i].end_t)\n time_slot = IntervalCounter.new(interval.end_t, @list[i].end_t, list[i].items)\n @list[i].end_t = interval.begin_t\n items_list = increment_new_list(interval.items, @list[i].items, false)\n @list.insert(i + 1, IntervalCounter.new(interval.begin_t, interval.end_t, items_list))\n @list.insert(i + 1, time_slot)\n end\n if (interval.end_t > @list[@list.length-1].end_t) \n @list.insert(@list.length, IntervalCounter.new(@list[@list.length-1].end_t, interval.end_t, interval.items))\n end\n i += 1\n end\n @list\n end",
"def empty_slots\n # INITIALIZE an array of empty slots\n empty_slots_indices = []\n # FOR EACH empty slot access its index\n @slots.each_with_index do |slot_num, index|\n # IF slot_num is 0\n if slot_num == 0\n # ADD its index in the collection of empty slots\n empty_slots_indices << index\n end\n end\n empty_slots_indices\n end",
"def overlaps?(other)\n a, b = [self, other].map(&:range)\n #\n # Although a Shift which passes through midnight is stored\n # internally as lasting more than TimeOfDay::NUM_SECONDS_IN_DAY\n # seconds from midnight, that's not how it is meant to be\n # handled. Rather, it consists of two chunks:\n #\n # range.first => Midnight\n # Midnight => range.last\n #\n # The second one is *before* the first. None of it is more than\n # TimeOfDay::NUM_SECONDS_IN_DAY after midnight. We thus need to shift\n # each of our ranges to cover all overlapping possibilities.\n #\n one_day = TimeOfDay::NUM_SECONDS_IN_DAY\n ashifted =\n Range.new(a.first + one_day, a.last + one_day, a.exclude_end?)\n bshifted =\n Range.new(b.first + one_day, b.last + one_day, b.exclude_end?)\n #\n # For exclusive ranges we need:\n #\n # a.ending > b.beginning && b.ending > a.beginning\n #\n # and for inclusive we need:\n #\n # a.ending >= b.beginning && b.ending >= a.beginning\n #\n aop = a.exclude_end? ? :> : :>=\n bop = b.exclude_end? ? :> : :>=\n #\n (a.last.send(aop, b.first) && b.last.send(bop, a.first)) ||\n (ashifted.last.send(aop, b.first) && b.last.send(bop, ashifted.first)) ||\n (a.last.send(aop, bshifted.first) && bshifted.last.send(bop, a.first))\n end",
"def create_shifts\n\tself.shifts=[]\n\tif self.locations.size==0\n\t self.locations=self.area.locations\n\tend\n\tst=self.shifttimes \n \tst.each do |t|\n\t\tself.locations.each do |l|\n\t\t\n\t\t\tshift=Shift.new\n\t\t\tshift.location=l\n\t\t\tshift.start=t\n\t\t\tself.shifts << shift\n\t\tend\n \tend\n end",
"def grouped_by_interval( range )\n grouped = Hash.new {|h,k| h[k] = [] }\n all.each { |r| r.period_in_seconds.step( range ) { |i| grouped[i/(range)] << r } }\n grouped\n end",
"def create_groups\n Group.create(name: \"MWF Morning\", days: [\"Monday\", \"Wednesday\", \"Friday\"], \n start_time: Time.local(2014, 8, 25, 8, 30, 0),\n end_time: Time.local(2014, 8, 25, 11, 30, 0)\n )\n Group.create(name: \"TTH Morning\", days: [\"Tuesday\", \"Thursday\"], \n start_time: Time.local(2014, 8, 25, 8, 30, 0),\n end_time: Time.local(2014, 8, 25, 11, 30, 0)\n )\n Group.create(name: \"Afternoon\", days: [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\"], \n start_time: Time.local(2014, 8, 25, 12, 30, 0),\n end_time: Time.local(2014, 8, 25, 15, 30, 0)\n )\nend",
"def exists_overlap?(time_blocks)\n (0..time_blocks.size - 2).each do |i|\n if (time_blocks[i].term == time_blocks[i+1].term &&\n time_blocks[i].day == time_blocks[i+1].day &&\n time_blocks[i].end_time > time_blocks[i+1].start_time)\n return true\n end\n end\n return false\n end",
"def all\n court_slots\n end",
"def build_buckets(unit=:all, step=1)\n\t\thour = 60 * 60\n\t\tday = 24 * hour\n\n\t\tif step.nil?\n\t\t\tstep = 1\n\t\tend\n\n\t\tif unit.nil?\n\t\t\tunit = :all\n\t\tend\n\n\t\tbuckets = []\n\n\t\tcase unit\n\t\twhen :all\n\t\t\tbuckets << {start_date: time_frame.start_date, end_date: time_frame.end_date, objects: []}\n\n\t\twhen :year\n\t\t\tyear = time_frame.start_date.year\n\t\t\tbucket_start = Time.mktime(year, 1, 1)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.mktime(year+=step, 1, 1)\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\n\t\twhen :month\n\t\t\tmonth = time_frame.start_date.mon\n\t\t\tyear = time_frame.start_date.year\n\t\t\tbucket_start = time_frame.start_date\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_start = Time.mktime( year, (month) )\n\n\t\t\t\tmonth+=step\n\t\t\t\tif (month-12) > 0\n\t\t\t\t\tyear += 1\n\t\t\t\t month = month-12\n\t\t\t\tend\n\n\t\t\t\tbucket_end = Time.mktime(year, (month) )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\tend\n\n\t\twhen :day\n\t\t\tbucket_start = Time.mktime(time_frame.start_date.year, time_frame.start_date.mon, time_frame.start_date.day)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.at( bucket_start.to_i + step*day )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\n\t\twhen :hour\n\t\t\tbucket_start = Time.mktime(time_frame.start_date.year, time_frame.start_date.mon, time_frame.start_date.day, time_frame.start_date.hour)\n\t\t\twhile bucket_start < time_frame.end_date\n\t\t\t\tbucket_end = Time.at( bucket_start.to_i + step*hour )\n\t\t\t\tbuckets << {start_date: bucket_start, end_date: bucket_end, objects: []}\n\t\t\t\tbucket_start = bucket_end\n\t\t\tend\n\t\tend\n\n\t\tbuckets.first[:start_date] = time_frame.start_date\n\t\tbuckets.last[:end_date] = time_frame.end_date\n\n\t\treturn buckets\n\tend",
"def slot_empty?(slot, event)\n return ((slot.id + @slots_size).to_datetime <= event.start.to_datetime or\n slot.id >= event.finish.to_datetime)\n end",
"def combine_ranges(code, ranges); end",
"def get_times_array(padding = true)\n @times = (padding) ? [@start_dt - 1.hour] : [@start_dt]\n \n # and including every 1/2 hour until one hour after the selected end time\n while true do\n tmp = @times.last + 30.minutes\n (padding) ? (tmp == (@end_dt + 1.hour)) ? break : '' : (tmp == @end_dt) ? break : ''\n @times.push(tmp)\n end\n end",
"def overlaps_with(other_groups, options = {})\n return [] if other_groups.nil?\n matching_groups = []\n for other in other_groups\n match = false\n matching_groups << other if other == self && options[:include_self]\n next if other == self\n next if other.day_of_week != day_of_week\n next if other.depart_time.nil? || other.return_time.nil?\n self_range = (depart_time.to_time.to_i..return_time.to_time.to_i) \n other_range = (other.depart_time.to_time.to_i..other.return_time.to_time.to_i) \n match = self_range.intersection(other_range)\n matching_groups << other if match\n end\n matching_groups\n end",
"def overlaps?\n self.class.all.any? do |other|\n (start_hour > other.start_hour && start_hour < other.end_hour) ||\n (end_hour > other.start_hour && end_hour < other.end_hour)\n end\n end",
"def front_rear_and_internal_collisions\n colliding_with.where(ended: false).where('reservations.starts_at' => range) + colliding_with.where('reservations.ends_at' => range)\n end",
"def game_data\r\n [\r\n {start_at: '20.11.2022 17:00', place: 'Al-Chaur', team1_name: 'Katar', team2_name: 'Ecuador', group: GROUP_A, round: GROUP},\r\n\r\n {start_at: '21.11.2022 14:00', place: 'Ar-Rayyan', team1_name: 'England', team2_name: 'Iran', group: GROUP_B, round: GROUP},\r\n {start_at: '21.11.2022 17:00', place: 'Doha', team1_name: 'Senegal', team2_name: 'Niederlande', group: GROUP_A, round: GROUP},\r\n {start_at: '21.11.2022 20:00', place: 'Ar-Rayyan', team1_name: 'USA', team2_name: 'Wales', group: GROUP_B, round: GROUP},\r\n\r\n {start_at: '22.11.2022 11:00', place: 'Lusail', team1_name: 'Argentinien', team2_name: 'Saudi-Arabien', group: GROUP_C, round: GROUP},\r\n {start_at: '22.11.2022 14:00', place: 'Doha', team1_name: 'Dänemark', team2_name: 'Tunesien', group: GROUP_D, round: GROUP},\r\n {start_at: '22.11.2022 17:00', place: 'Doha', team1_name: 'Mexiko', team2_name: 'Polen', group: GROUP_C, round: GROUP},\r\n {start_at: '22.11.2022 20:00', place: 'Al Wakrah', team1_name: 'Frankreich', team2_name: 'Australien', group: GROUP_D, round: GROUP},\r\n\r\n {start_at: '23.11.2022 11:00', place: 'Al-Chaur', team1_name: 'Marokko', team2_name: 'Kroatien', group: GROUP_F, round: GROUP},\r\n {start_at: '23.11.2022 14:00', place: 'Ar-Rayyan', team1_name: 'Deutschland', team2_name: 'Japan', group: GROUP_E, round: GROUP},\r\n {start_at: '23.11.2022 17:00', place: 'Doha', team1_name: 'Spanien', team2_name: 'Costa Rica', group: GROUP_E, round: GROUP},\r\n {start_at: '23.11.2022 20:00', place: 'Ar-Rayyan', team1_name: 'Belgien', team2_name: 'Kanada', group: GROUP_F, round: GROUP},\r\n\r\n {start_at: '24.11.2022 11:00', place: 'Al Wakrah', team1_name: 'Schweiz', team2_name: 'Kamerun', group: GROUP_G, round: GROUP},\r\n {start_at: '24.11.2022 14:00', place: 'Doha', team1_name: 'Uruguay', team2_name: 'Südkorea', group: GROUP_H, round: GROUP},\r\n {start_at: '24.11.2022 17:00', place: 'Doha', team1_name: 'Portugal', team2_name: 'Ghana', group: GROUP_H, round: GROUP},\r\n {start_at: '24.11.2022 20:00', place: 'Lusail', team1_name: 'Brasilien', team2_name: 'Serbien', group: GROUP_G, round: GROUP},\r\n\r\n {start_at: '25.11.2022 11:00', place: 'Ar-Rayyan', team1_name: 'Wales', team2_name: 'Iran', group: GROUP_B, round: GROUP},\r\n {start_at: '25.11.2022 14:00', place: 'Doha', team1_name: 'Katar', team2_name: 'Senegal', group: GROUP_A, round: GROUP},\r\n {start_at: '25.11.2022 17:00', place: 'Ar-Rayyan', team1_name: 'Niederlande', team2_name: 'Ecuador', group: GROUP_A, round: GROUP},\r\n {start_at: '25.11.2022 20:00', place: 'Al-Chaur', team1_name: 'England', team2_name: 'USA', group: GROUP_B, round: GROUP},\r\n\r\n {start_at: '26.11.2022 11:00', place: 'Al Wakrah', team1_name: 'Tunesien', team2_name: 'Australien', group: GROUP_D, round: GROUP},\r\n {start_at: '26.11.2022 14:00', place: 'Doha', team1_name: 'Polen', team2_name: 'Saudi-Arabien', group: GROUP_C, round: GROUP},\r\n {start_at: '26.11.2022 17:00', place: 'Doha', team1_name: 'Frankreich', team2_name: 'Dänemark', group: GROUP_D, round: GROUP},\r\n {start_at: '26.11.2022 20:00', place: 'Lusail', team1_name: 'Argentinien', team2_name: 'Mexiko', group: GROUP_C, round: GROUP},\r\n\r\n {start_at: '27.11.2022 11:00', place: 'Ar-Rayyan', team1_name: 'Japan', team2_name: 'Costa Rica', group: GROUP_E, round: GROUP},\r\n {start_at: '27.11.2022 14:00', place: 'Doha', team1_name: 'Belgien', team2_name: 'Marokko', group: GROUP_F, round: GROUP},\r\n {start_at: '27.11.2022 17:00', place: 'Ar-Rayyan', team1_name: 'Kroatien', team2_name: 'Kanada', group: GROUP_F, round: GROUP},\r\n {start_at: '27.11.2022 20:00', place: 'Al-Chaur', team1_name: 'Spanien', team2_name: 'Deutschland', group: GROUP_E, round: GROUP},\r\n\r\n {start_at: '28.11.2022 11:00', place: 'Al Wakrah', team1_name: 'Kamerun', team2_name: 'Serbien', group: GROUP_G, round: GROUP},\r\n {start_at: '28.11.2022 14:00', place: 'Doha', team1_name: 'Südkorea', team2_name: 'Ghana', group: GROUP_H, round: GROUP},\r\n {start_at: '28.11.2022 17:00', place: 'Doha', team1_name: 'Brasilien', team2_name: 'Schweiz', group: GROUP_G, round: GROUP},\r\n {start_at: '28.11.2022 20:00', place: 'Lusail', team1_name: 'Portugal', team2_name: 'Uruguay', group: GROUP_H, round: GROUP},\r\n\r\n {start_at: '29.11.2022 16:00', place: 'Al-Chaur', team1_name: 'Niederlande', team2_name: 'Katar', group: GROUP_A, round: GROUP},\r\n {start_at: '29.11.2022 16:00', place: 'Ar-Rayyan', team1_name: 'Ecuador', team2_name: 'Senegal', group: GROUP_A, round: GROUP},\r\n {start_at: '29.11.2022 20:00', place: 'Ar-Rayyan', team1_name: 'Wales', team2_name: 'England', group: GROUP_B, round: GROUP},\r\n {start_at: '29.11.2022 20:00', place: 'Doha', team1_name: 'Iran', team2_name: 'USA', group: GROUP_B, round: GROUP},\r\n\r\n {start_at: '30.11.2022 16:00', place: 'Al Wakrah', team1_name: 'Australien', team2_name: 'Dänemark', group: GROUP_D, round: GROUP},\r\n {start_at: '30.11.2022 16:00', place: 'Doha', team1_name: 'Tunesien', team2_name: 'Frankreich', group: GROUP_D, round: GROUP},\r\n {start_at: '30.11.2022 20:00', place: 'Doha', team1_name: 'Polen', team2_name: 'Argentinien', group: GROUP_C, round: GROUP},\r\n {start_at: '30.11.2022 20:00', place: 'Lusail', team1_name: 'Saudi-Arabien', team2_name: 'Mexiko', group: GROUP_C, round: GROUP},\r\n\r\n {start_at: '01.12.2022 16:00', place: 'Ar-Rayyan', team1_name: 'Kroatien', team2_name: 'Belgien', group: GROUP_F, round: GROUP},\r\n {start_at: '01.12.2022 16:00', place: 'Doha', team1_name: 'Kanada', team2_name: 'Marokko', group: GROUP_F, round: GROUP},\r\n {start_at: '01.12.2022 20:00', place: 'Ar-Rayyan', team1_name: 'Japan', team2_name: 'Spanien', group: GROUP_E, round: GROUP},\r\n {start_at: '01.12.2022 20:00', place: 'Al-Chaur', team1_name: 'Costa Rica', team2_name: 'Deutschland', group: GROUP_E, round: GROUP},\r\n\r\n {start_at: '02.12.2022 16:00', place: 'Al Wakrah', team1_name: 'Ghana', team2_name: 'Uruguay', group: GROUP_H, round: GROUP},\r\n {start_at: '02.12.2022 16:00', place: 'Doha', team1_name: 'Südkorea', team2_name: 'Portugal', group: GROUP_H, round: GROUP},\r\n {start_at: '02.12.2022 20:00', place: 'Doha', team1_name: 'Serbien', team2_name: 'Schweiz', group: GROUP_G, round: GROUP},\r\n {start_at: '02.12.2022 20:00', place: 'Lusail', team1_name: 'Kamerun', team2_name: 'Brasilien', group: GROUP_G, round: GROUP},\r\n\r\n # Achtelfinale\r\n {start_at: '03.12.2022 16:00', place: 'Ar-Rayyan', team1_placeholder_name: '1. Gruppe A', team2_placeholder_name: '2. Gruppe B', group: nil, round: ROUND_OF_16},\r\n {start_at: '03.12.2022 20:00', place: 'Ar-Rayyan', team1_placeholder_name: '1. Gruppe C', team2_placeholder_name: '2. Gruppe D', group: nil, round: ROUND_OF_16},\r\n\r\n {start_at: '04.12.2022 16:00', place: 'Doha', team1_placeholder_name: '1. Gruppe D', team2_placeholder_name: '2. Gruppe C', group: nil, round: ROUND_OF_16},\r\n {start_at: '04.12.2022 20:00', place: 'Al-Chaur', team1_placeholder_name: '1. Gruppe B', team2_placeholder_name: '2. Gruppe A', group: nil, round: ROUND_OF_16},\r\n\r\n {start_at: '05.12.2022 16:00', place: 'Al Wakrah', team1_placeholder_name: '1. Gruppe E', team2_placeholder_name: '2. Gruppe F', group: nil, round: ROUND_OF_16},\r\n {start_at: '05.12.2022 20:00', place: 'Doha', team1_placeholder_name: '1. Gruppe G', team2_placeholder_name: '2. Gruppe H', group: nil, round: ROUND_OF_16},\r\n\r\n {start_at: '06.12.2022 16:00', place: 'Doha', team1_placeholder_name: '1. Gruppe F', team2_placeholder_name: '2. Gruppe E', group: nil, round: ROUND_OF_16},\r\n {start_at: '06.12.2022 20:00', place: 'Lusail', team1_placeholder_name: '1. Gruppe H', team2_placeholder_name: '2. Gruppe G', group: nil, round: ROUND_OF_16},\r\n\r\n # Viertelfinale\r\n {start_at: '09.12.2022 16:00', place: 'Doha', team1_placeholder_name: 'Sieger AF 5', team2_placeholder_name: 'Sieger AF 6', group: nil, round: QUARTERFINAL},\r\n {start_at: '09.12.2022 20:00', place: 'Lusail', team1_placeholder_name: 'Sieger AF 1', team2_placeholder_name: 'Sieger AF 2', group: nil, round: QUARTERFINAL},\r\n {start_at: '10.12.2022 16:00', place: 'Doha', team1_placeholder_name: 'Sieger AF 7', team2_placeholder_name: 'Sieger AF 8', group: nil, round: QUARTERFINAL},\r\n {start_at: '10.12.2022 20:00', place: 'Al-Chaur', team1_placeholder_name: 'Sieger AF 3', team2_placeholder_name: 'Sieger AF 4', group: nil, round: QUARTERFINAL},\r\n\r\n # Halbfinale\r\n {start_at: '13.12.2022 20:00', place: 'Lusail', team1_placeholder_name: 'Sieger VF 1', team2_placeholder_name: 'Sieger VF 2', group: nil, round: SEMIFINAL},\r\n {start_at: '14.12.2022 20:00', place: 'Al-Chaur', team1_placeholder_name: 'Sieger VF 3', team2_placeholder_name: 'Sieger VF 4', group: nil, round: SEMIFINAL},\r\n\r\n # Spiel um Platz 3\r\n {start_at: '17.12.2022 16:00', place: 'Ar-Rayyan', team1_placeholder_name: 'Verlierer HF 1', team2_placeholder_name: 'Verlierer HF 2', group: nil, round: PLACE_3},\r\n\r\n # Finale\r\n {start_at: '18.12.2022 16:00', place: 'Lusail', team1_placeholder_name: 'Sieger HF 1', team2_placeholder_name: 'Sieger HF 2', group: nil, round: FINAL},\r\n ]\r\nend",
"def recalculate\n logger.debug(\"CombinedTimeTrialStandings Recalculate\")\n combined_race = recreate_races\n for race in source.races\n for result in race.results\n if result.place.to_i > 0 && result.time && result.time > 0\n new_combined_result = combined_race.results.create(\n :racer => result.racer,\n :team => result.team,\n :time => result.time,\n :category => race.category\n )\n end\n end\n end\n combined_race.results.sort! do |x, y|\n if x.time\n if y.time\n x.time <=> y.time\n else\n 1\n end\n else\n -1\n end\n end\n place = 1\n for result in combined_race.results\n result.update_attribute(:place, place.to_s)\n place = place + 1\n end\n combined_standings\n end",
"def valid_schedule?(time_blocks)\n time_blocks = quicksort_timeblocks(time_blocks)\n return !exists_overlap?(time_blocks)\n end",
"def existing_reservations\n start_dt = self.start_dt.try(:to_datetime).try(:change, offset: \"+0000\")\n end_dt = self.end_dt.try(:to_datetime).try(:change, offset: \"+0000\")\n room_id = self.room.try(:id)\n results_size = (self.is_block?) ? 1000 : 1\n\n return [] if room_id.blank? || start_dt.blank? || end_dt.blank?\n block_query = [{ term: { is_block: false } }, { range: { end_dt: { gte: Time.zone.now.to_datetime.change(offset: \"+0000\") } } }]\n query =\n {\n query: {\n constant_score: {\n filter: {\n bool: {\n must: [\n { term: { room_id: room_id } },\n { term: { deleted: false }},\n { bool:\n {\n should: [\n {\n bool: {\n must: [\n { range: { start_dt: { gte: start_dt } } },\n { range: { start_dt: { lt: end_dt } } }\n ]\n }\n },\n {\n bool: {\n must: [\n { range: { end_dt: { gt: start_dt } } },\n { range: { end_dt: { lte: end_dt } } }\n ]\n }\n },\n {\n bool: {\n must: [\n { range: { start_dt: { lte: start_dt } } },\n { range: { end_dt: { gte: end_dt } } }\n ]\n }\n }\n ]\n }\n }\n ]\n }\n }\n }\n },\n size: results_size\n }\n query[:query][:constant_score][:filter][:bool][:must] += block_query if self.is_block?\n return Reservation.search(query).results\n end",
"def setFromExistingResourcesSlots(iResourcesSlots, iMinStartDate)\n iResourcesSlots.each do |iDate, iResourcesInfo|\n if (iDate >= iMinStartDate)\n self[iDate] = iResourcesInfo\n end\n end\n end",
"def available_delivery_blocks(time)\n\n unless opens_today\n return []\n end\n\n # Reset date to compare with Postgres Time\n time = time.change(:month => 1, :day => 1, :year => 2000)\n\n lead_time_for_block_time_slots = 1.hour\n\n all_slots = block_slots.select { |slot| slot[:from] >= (time + lead_time_for_block_time_slots) } +\n live_slots.select { |slot| slot[:from] >= (time) }\n\n all_slots.map do |slot|\n {\n :from => slot[:from].strftime('%H:%M'),\n :to => slot[:to].strftime('%H:%M'),\n :type => slot[:type]\n }\n end\n end",
"def timeslot_output(timeslot)\n\t {:id=>timeslot.id,:start_time=>timeslot.start_time,:duration=>timeslot.duration,:boats=>timeslot.assets.map{|asset| asset.id},:availability=>timeslot.availability,:customer_count=>timeslot.customer_count}\n\tend",
"def place\n if !self.start_time\n self.move(self.start_bound)\n self.save\n end\n conflicts = users_events.select{|e| e.start_time < self.end_bound && e.end_time > self.start_bound}.sort{|a,b| a.start_time <=> b.start_time}\n conflicts -= [self]\n if conflicts.empty?\n return move(self.start_bound)\n end\n if to_min(conflicts.first.start_time) - to_min(self.start_bound) >= to_min(self.duration)\n return move(self.start_bound)\n end\n\n (0...conflicts.length).each do |i|\n if i != conflicts.length - 1\n if to_min(conflicts[i+1].start_time) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return move(conflicts[i].end_time)\n end\n else\n if to_min(self.end_bound) - to_min(conflicts[i].end_time) >= to_min(self.duration)\n return move(conflicts[i].end_time)\n end\n end\n end\n return move(self.start_bound)\n end",
"def shifts_between(start_time, end_time)\n start_time = start_time.to_time\n end_time = end_time.to_time\n shifts = Shift.where(\"start >= ? AND end <= ? AND location_id = ? AND active = ?\", start_time, end_time, self.id, true)\n end",
"def verify_availabilities(users, start_day, finish_day, start_hour = Time.parse(\"00:00\"),\n finish_hour = Time.parse(\"23:59\"), slots_size = SocialFramework.slots_size)\n\n return unless finish_day_ok? start_day, finish_day\n\n @slots_size = slots_size\n start_time = start_day.to_datetime + start_hour.seconds_since_midnight.seconds\n finish_time = finish_day.to_datetime + finish_hour.seconds_since_midnight.seconds\n\n build_users(users)\n build_slots(start_time, finish_time, start_hour, finish_hour)\n\n unless @fixed_users.empty?\n build_edges(@fixed_users, start_time, finish_time)\n\n @slots.select! { |slot| slot.edges.count == @fixed_users.count }\n end\n\n build_edges(@users, start_time, finish_time)\n\n @slots.sort_by! { |slot| -slot.attributes[:gained_weight] }\n end",
"def partition_schedules_per_day(schedules, datetime_span)\n date = datetime_span.first.to_date\n end_date = datetime_span.last.to_date\n result = []\n while date <= end_date do \n day_sch = schedules.select do |sch| sch.start_datetime.to_date == date end\n# day_sch = [] if day_sch.nil?\n day_sch.nil? and day_sch = []\n result << [date, day_sch]\n schedules = schedules[day_sch.length..-1]\n date += 1.day\n end\n result\n end",
"def get_unique_permutations annotation_time_slot\r\n\t\treturn annotation_time_slot.uniq.permutation.to_a\r\n\tend",
"def inc_time_slot\n # ex. with 4 bits -> we want range 1..15, \n @lock.synchronize{@current_slot = (@current_slot % @max_slot) + 1}\n end",
"def has_conflict?(ts, days, t_range)\n slot_days = ts.days\n return false if no_matching_days?(slot_days, days)\n\n # We have matching days, so continue on.\n slot_range = get_range_times(ts.start_time, ts.end_time)\n\n collided?(t_range, slot_range)\n end",
"def open_slots_for_select(date)\n open_slots(date).map do |slot|\n [\"#{slot.starts_at.strftime('%d/%m/%Y, %H:%M ')}\", slot.starts_at]\n end\n end",
"def slots\n @slots = Candlestick.slots\n end",
"def time_range\n range_time = []\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 am\"\n range_time << \"#{time}:30 am\"\n end\n (1..12).each do |n|\n time = n == 1 ? 12 : n - 1\n range_time << \"#{time}:00 pm\"\n range_time << \"#{time}:30 pm\"\n end\n range_time\n end",
"def test_slots_pollution\n new_component_class = Class.new(ViewComponent::Base)\n new_component_class.include(ViewComponent::Slotable)\n # this returned:\n # [SlotsComponent::Subtitle, SlotsComponent::Tab...]\n assert_empty new_component_class.slots\n end",
"def generate_tabling_schedule(slots, members)\n puts \"generating schedule\"\n convert_commitments(members)\n puts \"commitments converted\"\n #initialize your assignment hash\n assignments = Hash.new\n assignments[\"manual\"] = Array.new\n manual_assignments = Array.new\n for s in slots\n assignments[s] = Array.new\n end\n curr_member = get_MCV(assignments, members)\n while curr_member != nil do\n puts \"assigning\"\n puts curr_member\n slot = get_LCV(assignments, curr_member)\n if slot != nil\n # assign student to the slot\n assignments[slot] << curr_member\n else\n # you cant assign this member\n manual_assignments << curr_member\n assignments[\"manual\"] << curr_member\n end\n curr_member = get_MCV(assignments, members)\n end\n save_tabling_results(assignments, slots)\n return assignments\n end",
"def reduce_schedule(day_sch, before_hour, before_min, before_value, after_hour, after_min, after_value)\n before_time = OpenStudio::Time.new(0, before_hour, before_min, 0)\n after_time = OpenStudio::Time.new(0, after_hour, after_min, 0)\n day_end_time = OpenStudio::Time.new(0, 24, 0, 0)\n \n # Special situation for when start time and end time are equal,\n # meaning that a 24hr reduction is desired\n if before_time == after_time\n day_sch.clearValues\n day_sch.addValue(day_end_time, after_value)\n return\n end\n\n original_value_at_after_time = day_sch.getValue(after_time)\n day_sch.addValue(before_time,before_value)\n day_sch.addValue(after_time, original_value_at_after_time)\n times = day_sch.times\n values = day_sch.values\n day_sch.clearValues\n\n new_times = []\n new_values = []\n for i in 0..(values.length - 1)\n if times[i] >= before_time and times[i] <= after_time\n new_times << times[i]\n new_values << values[i]\n end\n end\n\n #add the value for the time period from after time to end of the day\n new_times << day_end_time\n new_values << after_value\n\n for i in 0..(new_values.length - 1)\n day_sch.addValue(new_times[i], new_values[i])\n end\n end",
"def from_ranges\n self[:date_time_slot] = RangeSupport.range_to_string(self[:date_time_slot])\n end",
"def overlaps!( other_group, options={} )\n if self.overlaps? other_group, options\n if @start_time <= other_group.start_time\n other_group.overlapped_by += 1\n self.overlapping += 1\n else\n end\n\n end\n end",
"def slot_type(slot)\n type = 0\n day_mult = 1\n time_mult = 1\n case slot.day\n when \"Montag\"\n day_mult = 0\n when \"Dienstag\"\n day_mult = 1\n when \"Mittwoch\"\n day_mult = 2\n when \"Donnerstag\"\n day_mult = 3\n when \"Freitag\"\n day_mult = 4\n end\n\n case slot.start\n when 8\n time_mult = 0\n when 10\n time_mult = 1\n when 12\n time_mult = 2\n when 14\n time_mult = 3\n end\n return time_mult + 4 * day_mult\n\n end",
"def room_items(r)\n (r.z1..r.z2).each { |z|\n ((r.x1 & -16)..r.x2).step(16) { |x|\n ((r.y1 & -16)..r.y2).step(16) { |y|\n df.map_tile_at(x, y, z).mapblock.items_tg.each { |i|\n yield i if i.flags.on_ground and i.pos.x >= r.x1 and i.pos.x <= r.x2 and i.pos.y >= r.y1 and i.pos.y <= r.y2 and i.pos.z == z\n }\n }\n }\n }\n end",
"def room_items(r)\n (r.z1..r.z2).each { |z|\n ((r.x1 & -16)..r.x2).step(16) { |x|\n ((r.y1 & -16)..r.y2).step(16) { |y|\n df.map_tile_at(x, y, z).mapblock.items_tg.each { |i|\n yield i if i.flags.on_ground and i.pos.x >= r.x1 and i.pos.x <= r.x2 and i.pos.y >= r.y1 and i.pos.y <= r.y2 and i.pos.z == z\n }\n }\n }\n }\n end",
"def unfinished_dispatch_time_ranges\n dispatches.where(safe_return: false).map(&:active_time_window)\n end",
"def add_slots(slots)\n slot_hash = BetterAlexaRubyKit.transform_keys_to_symbols(value)\n add_hash_slots(slot_hash)\n end",
"def schedule_slots(params = {})\n scope 'user_schedule'\n post('/schedule/slots/', params)\n end",
"def group\n students = (1...59).to_a\n students.each_slice(5).to_a\n\nend",
"def slice( start, stop )\n \n start_point = create_period( calculate_bucket( TimeSeries.Normalise_Time( start ) ) )\n stop_point = create_period( calculate_bucket( TimeSeries.Normalise_Time( stop ) ) )\n\n # Create a new TimeSeries object with the same resolution as\n # self, and clones of each bucket from start to stop.\n \n new_slice = TimeSeries.new( @resolution_unit )\n\n ( start_point .. stop_point ).each do |period|\n if not @buckets[period].empty? then\n new_slice[period] = @buckets[period].clone\n end\n end\n \n new_slice\n end"
] | [
"0.6928598",
"0.6598432",
"0.6556763",
"0.62836176",
"0.61598545",
"0.61425924",
"0.61248326",
"0.59110165",
"0.5904596",
"0.5904228",
"0.5902116",
"0.58843243",
"0.58529955",
"0.5809075",
"0.5797486",
"0.57824683",
"0.57600373",
"0.57475156",
"0.56936073",
"0.56116503",
"0.553205",
"0.5521786",
"0.5521366",
"0.54984605",
"0.5451708",
"0.5448667",
"0.54288715",
"0.5412445",
"0.53852063",
"0.53506255",
"0.53303427",
"0.52747697",
"0.5269645",
"0.52024364",
"0.519736",
"0.519735",
"0.51948345",
"0.51393145",
"0.5130657",
"0.51189196",
"0.51076055",
"0.5102015",
"0.5092862",
"0.5083708",
"0.5076366",
"0.50741583",
"0.5050223",
"0.5044896",
"0.4998298",
"0.49893922",
"0.49885064",
"0.49741688",
"0.4964385",
"0.4962114",
"0.49568564",
"0.49416658",
"0.49414924",
"0.4924944",
"0.49234346",
"0.49091727",
"0.48993182",
"0.48925832",
"0.48916182",
"0.48865756",
"0.48821455",
"0.4882086",
"0.48807493",
"0.48712525",
"0.48707676",
"0.48664948",
"0.48621354",
"0.48358506",
"0.48329717",
"0.48298603",
"0.48255762",
"0.48254043",
"0.48050922",
"0.48011446",
"0.47963786",
"0.47910684",
"0.47786224",
"0.47610366",
"0.4757413",
"0.4749362",
"0.4741959",
"0.47389406",
"0.47368348",
"0.47360215",
"0.472979",
"0.4728794",
"0.4727929",
"0.4722588",
"0.47126812",
"0.47102335",
"0.47102335",
"0.47069642",
"0.470651",
"0.4703021",
"0.4701679",
"0.46878064"
] | 0.7387607 | 0 |
Given a collection of TimeBlock(s), return only the ones that have no detectable collisions (and thus are valid). +:time_blocks+ All extracted TimeBlock(s) you wish to have validated. | def validate_time_blocks(time_blocks)
b = time_blocks.select(&:collision_free?)
# Test environment has unreliable data entry for start times.
b = b.select(&:in_future?) unless Rails.env.test?
b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def valid_schedule?(time_blocks)\n time_blocks = quicksort_timeblocks(time_blocks)\n return !exists_overlap?(time_blocks)\n end",
"def validate_time_slots times\n time_models = []\n times.each do |time|\n t = TimeSlot.new(from: time[:from], to: time[:to], opinion_poll: @opinion_poll)\n\n bad_request t.errors.messages and return unless t.valid?\n time_models.append t\n end\n time_models\n end",
"def available_delivery_blocks(time)\n\n unless opens_today\n return []\n end\n\n # Reset date to compare with Postgres Time\n time = time.change(:month => 1, :day => 1, :year => 2000)\n\n lead_time_for_block_time_slots = 1.hour\n\n all_slots = block_slots.select { |slot| slot[:from] >= (time + lead_time_for_block_time_slots) } +\n live_slots.select { |slot| slot[:from] >= (time) }\n\n all_slots.map do |slot|\n {\n :from => slot[:from].strftime('%H:%M'),\n :to => slot[:to].strftime('%H:%M'),\n :type => slot[:type]\n }\n end\n end",
"def no_overlap\n self.class.where(user_id: user.id, time_type: time_type).each do |other_time|\n errors.add(:start_time, \"i'm a sad error\") if overlaps?(other_time)\n end\n end",
"def find_not_all(conditions={}, &block)\n all.reject { |item| match_all(item, conditions, &block) }\n end",
"def valid_tickets\n @nearby_tickets.filter_map do |ticket|\n in_ranges = ticket.map do |val|\n merged_rules.map {|val_range| val_range.include?(val)}.include?(true)\n end\n ticket unless in_ranges.include?(false)\n end\n end",
"def first_not_all(conditions={}, &block)\n all.detect { |item| !match_all(item, conditions, &block) }\n end",
"def exists_overlap?(time_blocks)\n (0..time_blocks.size - 2).each do |i|\n if (time_blocks[i].term == time_blocks[i+1].term &&\n time_blocks[i].day == time_blocks[i+1].day &&\n time_blocks[i].end_time > time_blocks[i+1].start_time)\n return true\n end\n end\n return false\n end",
"def without_individual_blocks(options)\n piece = options[:piece]\n game = options[:game]\n board = game.board\n\n collection = clone\n\n collection.coordinates.reject! do |coordinate|\n at_position = board.at_square(coordinate.square_name) \n piece.ally?(at_position) \n end\n\n collection\n end",
"def optimize_time_blocks(time_blocks)\n Optimizer.new.optimize(time_blocks)\n end",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def validate_block(block)\n # check block ready conditions\n # 1. parent block must already be accepted.\n parent_block = get_block(block.parent_hash)\n raise BlockNotReadyError.new(\"can't find parent block by hash #{block.parent_hash.to_hex}\") unless parent_block\n # TODO 2. pow_chain_ref block must already be accepted.\n # 3. local time must greater or equal than minimum timestamp.\n unless (local_timestamp = Time.now.to_i) >= (minimum_timestamp = genesis_time + block.slot_number * SLOT_DURATION)\n raise BlockNotReadyError.new(\"local_timestamp(#{local_timestamp}) must greater than or equal with minimum_timestamp(#{minimum_timestamp})\")\n end\n end",
"def contains_block?(block_of_time)\n if(self.start_time <= block_of_time.start_time &&\n self.end_time >= block_of_time.end_time)\n true\n else\n false\n end\n end",
"def test_blocks_not_consecutive\n block_num_checker = BlockNumChecker::new\n arr = [0,1,2,8,4,5,6]\n assert_equal 1, block_num_checker.check_block(arr)\n end",
"def missing_ranges()\n return [] if @time_map.nil?\n @time_map.missing_ranges()\n end",
"def locked_candidates_1_from_block block, number\n\t\tblock_cells = get_block_cells block\n\t\tblock_cells_with_number = block_cells.select { |i| @candidates[i].include?(number) }\n\t\t\n\t\treturn_bool = false\n\n\t\tif block_cells_with_number.empty?\n\t\t\treturn return_bool\n\t\tend\n\n\t\tblock_cell_rows = block_cells_with_number.map { |i| i / 9 }\n\t\t\n\t\tonly_in_row = block_cell_rows.count(block_cell_rows[0]) == block_cell_rows.length ? true : false\n\n\t\tif only_in_row\n\t\t\tnumber_of_deleted_items = 0\n\t\t\tget_other_row_cells(block_cells_with_number[0]).select { |i| !block_cells_with_number.include?(i) }.each do |i|\n\t\t\t\tdeleted_item = @candidates[i].delete number\n\t\t\t\tnumber_of_deleted_items += 1 if !deleted_item.nil?\n\t\t\tend\n\t\t\treturn_bool = true if number_of_deleted_items > 0\n\t\tend\n\n\t\tblock_cell_cols = block_cells_with_number.map { |i| i % 9 }\n\n\t\tonly_in_col = block_cell_cols.count(block_cell_cols[0]) == block_cell_cols.length ? true : false\n\t\t\n\t\tif only_in_col\n\t\t\tnumber_of_deleted_items = 0\n\t\t\tget_other_col_cells(block_cells_with_number[0]).select { |i| !block_cells_with_number.include?(i) }.each do |i|\n\t\t\t\tdeleted_item = @candidates[i].delete number\n\t\t\t\tnumber_of_deleted_items += 1 if !deleted_item.nil?\n\t\t\tend\n\t\t\treturn_bool = true if number_of_deleted_items > 0\n\t\tend\n\t\t\n\t\treturn return_bool\n\tend",
"def meets_temporal_constraints?(time, &block)\n !find_failed_temporal_constraint(time, &block) &&\n !find_failed_occurence_constraint(true, &block)\n end",
"def check_times\n if start_end_times.count > 0 && !start_end_times.nil?\n start_end_times.each do |t|\n return true if t.check_time_ranges\n end\n\n false\n else\n true\n end\n end",
"def missed_deadlines(current_time)\n result = []\n while !deadlines.empty? && deadlines.first[0] < current_time\n result << deadlines.shift\n end\n result\n end",
"def validate_time_slot_ids times\n\n empty_times if times.size == 0\n\n times.each do |id|\n time_slot = TimeSlot.find(id)\n end\n true\n\n rescue ActiveRecord::RecordNotFound\n r = {times: 'Record Not Found'}\n return not_found r\n end",
"def get_block_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n next if line !~ /^Block times/\n values = []\n # Block times are given as a space-separated list of start,end pairs. They\n # are in units of seconds * 1e5, so convert them to seconds here for\n # consistency.\n if line =~ /^[^:]+: (.*?)\\s*$/\n values = $1.split(\" \").map{|r| r.split(\",\").map{|v| v.to_f / 1e5}}\n end\n to_return << values\n end\n to_return\nend",
"def collide_with_other_blocks\n @game.blocks.each do |block|\n if collide(block)\n return block\n end\n end\n nil\n end",
"def complete_schedule?(time_blocks, courses)\n # check to see that all course requirements have been satisfied\n # this part is more likely to return false than the next part\n courses.each do |course|\n if (!requirement_satisfied?(time_blocks, course))\n return false\n end\n end\n\n # check to see that we haven't added any unnecessary courses\n # this is more of an error check, rather than something that we\n # expect to ever be false\n time_blocks.each do |tb|\n course = tb.section.course\n if (!courses.include? course)\n # we added an unnecessary section\n return false\n end\n end\n end",
"def get_blocks\n @blocks ||= Block.find :all, :conditions => { :show_in_all => '' }\n end",
"def without_set_blocks(options)\n piece = options[:piece]\n game = options[:game]\n\n collection = clone\n collection.sets.map! { |set| set.without_blocks(piece: piece, game: game) }\n collection\n end",
"def conflict?(times)\n\t\treturn false if @tba == true\n\n\t\ttimes.each do |time|\n\t\t\treturn false if time.tba == true\n\t\t\treturn true if \\\n\t\t\t\t\t((time.startTimeInMinutes <= @endTimeInMinutes && time.startTimeInMinutes >= @startTimeInMinutes) \\\n\t\t\t\t\tor (time.endTimeInMinutes >= @startTimeInMinutes && time.endTimeInMinutes <= @endTimeInMinutes) \\\n\t\t\t\t\tor (time.startTimeInMinutes > @startTimeInMinutes && time.endTimeInMinutes < @endTimeInMinutes) \\\n\t\t\t\t\tor (time.startTimeInMinutes < @startTimeInMinutes && time.endTimeInMinutes > @endTimeInMinutes)) \\\n\t\t\t\t\tand (@days & time.days).length > 0\n\t\tend\n\n\t\treturn false\n\tend",
"def find_none(conditions={}, &block)\n all.select { |item| match_none(item, conditions, &block) }\n end",
"def does_not_contain(&block)\n [:does_not_contain, block]\n end",
"def does_not_contain(&block)\n [:does_not_contain, block]\n end",
"def empty_times\n r = {times: 'should not be empty'}\n return not_found r\n end",
"def check_elements_for_compliance(&block)\n assets = flatten\n (assets.size != 0) and (assets.select { |a| yield a }.size == 0)\n end",
"def available_rooms_in_block(block_name:)\n available = reservations.find_all do |reservation|\n reservation.block_name == block_name && reservation.booking_name == nil\n end\n\n return available\n end",
"def verify!(block)\n self.instance_eval(&block)\n expected = Set.new(expected_entries)\n provided = Set.new(provided_entries)\n missing_entries = expected - provided\n extra_entries = provided - expected\n missing_entries_found(missing_entries) if missing_entries.any?\n extra_entries_found(extra_entries) if extra_entries.any?\n end",
"def test_bad_block\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd19\")\r\n\t\t\r\n\t\tassert_equal 0, tb.validate_block\r\n\tend",
"def blank_blocks(filter = writable_mifare_blocks, blks = Array.new(16, 0))\n filter.map do |x|\n [x, blks]\n end\n end",
"def check_bboxes_are_bad(bboxes)\n bboxes.each do |bbox|\n amf_content \"whichways\", \"/1\", bbox\n post :amf_read\n assert_response :success\n amf_parse_response\n\n # pass the response back to the caller's block to be tested\n # against what the caller expected.\n map = amf_result \"/1\"\n yield map, bbox\n end\n end",
"def reservations_exist_in_block\n if timeslot_contains_reservations?\n errors.add(:base, I18n.t('reservation.reservations_exist_in_block'))\n end\n end",
"def number_of_compatible_time_blocks_with(schedule)\n compatibilities = 0\n \n # does user have a schedule and does <tt>schedule</tt> exist\n if self.schedule != nil and schedule != nil\n self_days = self.schedule.days\n schedule_days = schedule.days\n \n # are there days in each schedule\n if self_days != nil and schedule_days != nil\n self_days.each do |self_day|\n schedule_days.each do |schedule_day|\n if self_day.name == schedule_day.name\n # are there time blocks in each day\n if self_day.time_blocks != nil and schedule_day.time_blocks != nil\n self_day.time_blocks.each do |self_block|\n schedule_day.time_blocks.each do |schedule_block|\n if self_block.chunk_of_time == schedule_block.chunk_of_time\n compatibilities += 1\n end\n end\n end\n end\n end\n end\n end\n end\n end\n \n compatibilities\n end",
"def get_unreserved_rooms(date_range)\n unreserved_room_ids = check_reservations(date_range, reservations)\n\n blocks.each do |block|\n block_start = block[:start_date]\n block_end = block[:end_date]\n room_objs = block[:rooms]\n room_ids = room_objs.map {|room| room.room_id}\n\n if date_range[:start_date] >= block_end == true\n next\n else\n if date_range[:end_date] <= block_start == false\n room_ids.each do |id|\n unreserved_room_ids.delete(id)\n end\n end\n end\n end\n\n return unreserved_room_ids.sort.uniq\n end",
"def no_time_overlap\n @other_bookings = Booking.where(:date => date)\n @other_bookings.each do |other_booking|\n if other_booking.time.strftime(\"%I:%M%p\") == time.strftime(\"%I:%M%p\") && other_booking.room_id == room_id\n errors.add(:time, \"Cannot book, overlapping sessions!\")\n end\n end\n end",
"def break_plates_in_blocks(plates)\n\tn_plates = number_of_plates(plates)\n\tplaque_index=0\n\twhile plaque_index<n_plates\n\t\tlog \"breaking plate #{plaque_index}\"\n\t\tall_points = points_of_the_plate(plates,plaque_index)\n\t\tif all_points.count>0\n\t\t\tstart_point = all_points[0]\n\t\t\tmain_block = []\n\t\t\texpand_block(plates,main_block,start_point,plaque_index)\n\t\t\ttoremove = all_points.select {|p| not main_block.include? p}\t\t\t\n\t\t\tif toremove.count>0\n\t\t\t\tlog \"plate to be broken, #{toremove.count} points removed, #{main_block.count} kept\"\n\t\t\t\ttoremove.each {|p| x,y=p; plates.set(x,y,n_plates)}\n\t\t\t\tn_plates += 1\t\t\t\t\n\t\t\tend\t\t\t\n\t\tend\n\t\tplaque_index += 1\n\tend\nend",
"def count_not_all(conditions={}, &block)\n all.count { |item| !match_all(item, conditions, &block) }\n end",
"def check_valid_transactions\n transactions_split = []\n i = 0\n while i < @blocks.count\n # Splits and counts how many transactions there are in a block\n transactions_split = @blocks[i].transaction_string.split(':')\n j = 0\n while j < transactions_split.count\n @transactions = []\n # Splits transaction and saves its data\n transaction_partitions = transactions_split[j].split(/>|[()]/)\n @transactions[j] = Transaction.new(\n transaction_partitions[0],\n transaction_partitions[1],\n transaction_partitions[2].to_i\n )\n\n unless @transactions[j].from_addr.strip.eql? 'SYSTEM'\n @balance[@transactions[j].from_addr] -= @transactions[j].num_billcoins_sent\n end\n\n @balance[@transactions[j].to_addr] += @transactions[j].num_billcoins_sent\n\n if check_valid_format(@blocks[i], @transactions[j]) == false\n puts 'BLOCKCHAIN INVALID'\n exit 0\n end\n\n check_from_addr_length(@blocks[i], @transactions[j])\n check_to_addr_length(@blocks[i], @transactions[j])\n check_from_addr_invalid_char(@blocks[i], @transactions[j])\n check_to_addr_invalid_char(@blocks[i], @transactions[j])\n\n if i == @blocks.count - 1\n if j == transactions_split.count - 1\n unless @transactions[j].from_addr.strip.eql? 'SYSTEM'\n puts \"Line #{@blocks[i].block_number}: the last transaction in #{@transactions[j]\n \t.transaction_string} should be from SYSTEM.\"\n return false\n end\n end\n end\n j += 1\n end\n if check_balances(i) == false\n puts 'BLOCKCHAIN INVALID'\n exit 0\n end\n i += 1\n end\n true\n end",
"def without_blocks(options)\n game = options[:game]\n piece = options[:piece]\n\n board = game.board\n \n coordinates.each_with_index do |coordinate, index|\n at_position = board.at_square(coordinate.square_name)\n \n # Blocked by an opponent. Include this space.\n if piece.opponent?(at_position)\n return set_including_index(index)\n # Blocked by an ally. Do not include this space.\n elsif piece.ally?(at_position)\n return set_before_index(index)\n end\n end\n\n clone\n end",
"def get_all_blocks\n\n @all_blocks = Block.where(is_published: 't')\n\n end",
"def generate_time_slots(time_entries)\n time_entries.map { |entry| extract_available_slots(entry) }.flatten\n end",
"def timeslots\n unless @timeslots.present?\n timeslots = Timeslot\n .timeslots_for(@schedule_range, @form)\n .select { |ts| ts.blocks >= @blocks_needed }\n timeslots = @schedule_range.all_timeslots if timeslots.empty?\n @timeslots = timeslots.sort_by { |ts| [ts.day_id, ts.start_minute] }\n end\n\n @timeslots\n end",
"def unblocked_cells(options = {})\n cells.select {|c, v| v.empty? || v.content == 'R' || v.content == 'C' }\n end",
"def calculate_missed_runs(last_run_time, as_time)\n missed_times = []\n last_time = last_run_time\n while (next_run = next_run_time(last_time, as_time))\n missed_times << next_run\n last_time = next_run\n end\n\n generate_to_enqueue_list(missed_times)\n end",
"def calculate_missed_runs(last_run_time, as_time)\n missed_times = []\n last_time = last_run_time\n while (next_run = next_run_time(last_time, as_time))\n missed_times << next_run\n last_time = next_run\n end\n\n generate_to_enqueue_list(missed_times)\n end",
"def index\n @time_blocks = TimeBlock.all\n end",
"def get_acceptable_call_times\n AvailableTime.all.map{|m|\n if m.pharmacy_id == self.id #should be interger already but casting just in case\n {\"start\" => m.start_time.strftime(\"%H:%M:%S\"), \"stop\" => m.end_time.strftime(\"%H:%M:%S\")}\n else\n nil\n end\n }.compact\n end",
"def valid_appointments(base_time)\n transform_blocks_to_appointments(valid_blocks(base_time))\n end",
"def stripped_text_blocks\n stripped = []\n text_blocks.each do |tb|\n if \"Boston Police Department\" == tb && %r{^\\d+/\\d+/\\d{4} } =~ stripped.last\n # skip\n stripped.pop\n elsif /, Police Commissioner/ =~ tb\n # skip\n elsif /^Selected & Sorted By:/ =~ tb\n # skip\n elsif /^Record Count:/ =~ tb\n # skip\n stripped.pop if /^\\d+$/ =~ stripped.last\n elsif /^(Date:|Reported|Occurred)$/ =~ tb\n # skip\n else\n stripped << tb\n end\n end\n stripped\n end",
"def mark_unavailable\n t = @user_application.interview_availabilities.find_by_time_and_offering_interview_timeblock_id(\n params[:time].to_time, params[:timeblock_id])\n t.destroy\n render :partial => \"timeslot_not_available\", :locals => { :b => params[:timeblock_id], :ti => params[:ti], :time => params[:time] }\n end",
"def no_other_reservations_on_this_time_period\n item_reservations.each do |ir|\n item = ir.item\n amount_available = item.get_availability(pick_up_time.to_datetime, return_time.to_datetime, id)\n if ir.amount > amount_available\n if amount_available > 0\n errors.add(:items, errors.generate_message(:items, :too_few_available, { :item_title => item.title, :count => amount_available.to_s }))\n else\n errors.add(:items, errors.generate_message(:items, :none_available, { :item_title => item.title }))\n end \n end\n end \n end",
"def delete_not_all(conditions={}, &block)\n @items.inject([]) do |items, (key, item)|\n items << @items.delete(key) if !match_all(item, conditions, &block)\n items\n end\n end",
"def add_blocks_to_schedule(time_blocks, schedule, recurring)\n time_blocks.each do |block|\n day_of_week = block.split(\"_\")[0]\n time = block.split(\"_\")[1]\n start_time = Time.utc(\"2011\", nil, nil, time.split(\" - \")[0])\n end_time = Time.utc(\"2011\", nil, nil, time.split(\" - \")[1])\n \n if Day.exists?(day_of_week, schedule.id)\n day = Day.where(:name => day_of_week, :schedule_id => schedule.id).first\n else\n day = Day.new(:name => day_of_week, :schedule_id => schedule.id)\n day.save\n end\n \n if !TimeBlock.exists?(start_time, end_time, day.id, recurring)\n time_block = TimeBlock.new(:start_time => start_time, :end_time => end_time, :day_id => day.id, :recurring => recurring)\n time_block.save\n end\n end\n end",
"def valid?\n blocks = Block.all.order(id: :asc).to_a\n blocks[1..-1].each.with_index(1) do |block, index|\n return false unless neighbor_blocks_valid?(block, blocks[index - 1])\n end\n true\n end",
"def should_not_overlap\n if table.reservations.where(\"time_from <= ? AND time_to > ? AND NOT id = ?\", time_from, time_from, id).count > 0\n errors.add(:time_from, \"shouldn't overlap with existing reservation\")\n end\n if table.reservations.where(\"time_from < ? AND time_to >= ? AND NOT id = ?\", time_to, time_to, id).count > 0\n errors.add(:time_from, \"shouldn't overlap with existing reservation\")\n end\n if table.reservations.where(\"time_from >= ? AND time_to <= ? AND NOT id = ?\", time_from, time_to, id).count > 0\n errors.add(:time_from, \"shouldn't overlap with existing reservation\")\n end\n end",
"def must_choose_at_least_one_time\n \tif compact_times_available.size <= 0\n \t\tself.errors[:base] << \"Must choose at least one time slot\"\n \tend\n end",
"def get_want_blocks\n return if (@want_blocks.length >= MIN_REQUESTS) || @peer_virgin || @peer_choking || !@interested\n\n rej_count = 0\n acc_count = 0\n @controller.claim_blocks do |b|\n break if @want_blocks.length >= MAX_REQUESTS\n if @peer_pieces[b.pindex] && !@want_blocks.member?(b)\n rt_debug \"! #{self}: starting new piece #{@package.pieces[b.pindex]}\" unless @package.pieces[b.pindex].started?\n\n# rt_debug \"#{self}: added to queue block #{b}\"\n# puts \"#{self}: claimed block #{b}\"\n @want_blocks.push b\n acc_count += 1\n true\n else\n# puts \"#{self}: cont offers block #{b} but peer has? #{@peer_pieces[b.pindex]} i already want? #{@want_blocks.member? b}\" if rej_count < 10\n rej_count += 1\n false\n end\n end\n # puts \"#{self}: ... and #{rej_count} more (peer has #{@peer_pieces.inject(0) { |s, p| s + (p ? 1 : 0) }} pieces)... \" if rej_count >= 10\n# puts \"#{self}: accepted #{acc_count} blocks, rejected #{rej_count} blocks\"\n end",
"def block_valid?(block, difficulty = 4)\n block.valid?(difficulty) &&\n block.parent_digest == head_digest &&\n balances([block]).none? { |user, balance| balance < 0 }\n end",
"def valid_times_sorted()\n self.valid_times.sort{|a,b|a.from_time <=> b.from_time}\n end",
"def blocks\n @block_stacks.map { |candidates| candidates&.first }\n end",
"def assert_not_expire_fragments(*names)\n fragment_cache_store.clear\n \n yield *names\n\n raise NoRequestInBlockError.new(\"no request was send while executing block.\") if @controller.nil?\n \n names.each do |name|\n assert_block(\"#{name.inspect} is expired after executing block\") do\n !fragment_cache_store.deleted?(@controller.fragment_cache_key(name))\n end\n end\n \n fragment_cache_store.clear\n end",
"def quicksort_timeblocks(time_blocks)\n if (time_blocks.size <= 1)\n return time_blocks\n end\n\n pivot = time_blocks[0]\n left = []\n right = []\n\n time_blocks[1..time_blocks.size-1].each do |tb|\n if (tb.term.to_i < pivot.term.to_i)\n left.push(tb)\n elsif (pivot.term.to_i < tb.term.to_i)\n right.push(tb)\n elsif (before_in_week(tb.day, pivot.day))\n left.push(tb)\n elsif (before_in_week(pivot.day, tb.day))\n right.push(tb)\n elsif (tb.start_time < pivot.start_time)\n left.push(tb)\n else\n right.push(tb)\n end\n end\n\n sorted_left = quicksort_timeblocks(left)\n sorted_right = quicksort_timeblocks(right)\n time_blocks = sorted_left.push(pivot) + sorted_right\n return time_blocks\n end",
"def all_veins\n mapblock.block_events.grep(BlockSquareEventMineralst)\n end",
"def is_block_valid?(hash)\n if @block_index.block_header_in_index?(hash)\n return true\n end\n !Toshi::Models::Block.main_or_side_branch.where(hsh: hash).empty?\n end",
"def apply_validations_for_time\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time\") if value && (! value.kind_of?(Time))\n end\n end",
"def find_available_rooms_in_block(blocks, group_name, start_date: Date.today, end_date: Date.today + 2)\n return Block.all_available_rooms_in_block(blocks, group_name, start_date: start_date, end_date: end_date)\n end",
"def rooms_available\n avail_block_reservations = []\n \n reservations.each do |reservation|\n if reservation.block_res_taken == false\n avail_block_reservations << reservation\n end\n end\n \n if avail_block_reservations.length == 0\n raise AvailabilityError.new(\"All rooms in this block are reserved.\")\n end\n \n return avail_block_reservations\n end",
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.minutes, time_entry\n\n # Stash the current session onto the slot as well, so it may handle\n # some of it's own session based logic.\n slot.session = session\n\n # finally increment the time for the next iteration\n time = time + block_size.minutes\n\n slot\n end\n\n # Detect deadspace at the TimeSlot layer.\n # If found, we add a final TimeSlot to make up the difference.\n if time < time_entry.end_time\n slots << TimeSlot.new(time, time_entry.end_time, time_entry)\n end\n\n # Return the aggregated slot collection\n slots\n end",
"def passengers_blocked_by(passenger)\n passengers = []\n passengers = @aisle.rows.compact.select{|p| p.assigned_seat.to_i == passenger.assigned_seat.to_i}\n passengers += @waiting_passengers.select{|p| p.assigned_seat.to_i == passenger.assigned_seat.to_i}\n passengers = passengers.select{|p| p != passenger}\n passengers\n end",
"def mark_unavailable\n t = @offering_interviewer.interview_availabilities.find_by_time_and_offering_interview_timeblock_id(\n params[:time].to_time, params[:timeblock_id])\n t.destroy\n render :partial => \"apply/timeslot_not_available\", :locals => { :b => params[:timeblock_id], :ti => params[:ti], :time => params[:time] }\n end",
"def get_broadcasts_for_minute broadcasts, time\n broadcasts.collect { |b| TimeDifference.between( b.start, time).in_minutes < 1 }\n end",
"def available_for_interview?(time, timeblock)\n !interview_availabilities.find_by_time_and_offering_interview_timeblock_id(time.to_time, timeblock).nil?\n end",
"def collisions_for(range)\n collider.detect TimeBlock.new(\n start_time: range.begin,\n end_time: range.end,\n session: @session)\n end",
"def block_way(pm, all_occupied_spaces)\n pm.map do |lc|\n occupied = lc.select { |p| all_occupied_spaces.include?(p) }\n if occupied.empty?\n lc\n else\n lc.keep_if { |p| lc.index(p) <= lc.index(occupied.first) }\n end\n end\n end",
"def test_check_good_block\n line = ['0', '0', 'SYSTEM>569274(100)', '1553184699.650330000', '288d']\n line_num = 1\n assert_output(nil) { @verify.check_block(line, line_num) }\n end",
"def time_collision_validation\n\t\tappointments = Appointment.all\n\n\t\t#if duration is equals to 0, it means it is fixed pay. \n\t\t#Here, duration is set to 0 so it will not be validated \n\t\t#This will execute if is_pay_per hour is set to 0\n\t\tif @start_date.present? && @start_time.present? && duration == 0.to_s\n\t\t\tstart_at = Time.parse(\"#{@start_date} #{@start_time}\") + (1.hours)\n\t\t\t\n\t\t\tappointments.each do |a|\n\t\t\t\t# will ensure that the appointment to compare will not be compared to itself in the database if it exists\n\t\t\t\tif a.id.to_s != @appointment_id.to_s\n\t\t\t\t\t# compare fixed-pay input to pay per hour appointment\n\t\t\t\t\tif a.task.is_pay_per_hour && start_at < a.end_at && start_at >= a.start_at \n\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\terrors.add(:start_date, \"An appointment is already \n\t\t\t\t\t\t\tset at #{a.start_at.strftime(\"%I:%M%p\")}, #{a.start_at.strftime(\"%d/%m/%Y\")} \n\t\t\t\t\t\t\tto #{a.end_at.strftime(\"%I:%M%p\")} on #{a.end_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\tbreak\n\n\n\t\t\t\t\t\t#compare fixed-pay input to fixed pay appointment\n\t\t\t\t\telsif !a.task.is_pay_per_hour && start_at == a.start_at \n\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\terrors.add(:start_date, \"A fixed pay appointment is aleady set at #{a.start_at.strftime(\"%I:%M%p\")}\n\t\t\t\t\t\t\t, #{a.start_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend \t\n\t\t\t\tend \t\n\t\t\tend\n\n\n\t\t\t\t#Here, duration should be present and will be always validated\n\t\t\t\t#This will execute if is_pay_per hour is set to 1\n\t\t\telsif @start_date.present? && @start_time.present? && duration.present?\n\t\t\t\tstart_at = Time.parse(\"#{@start_date} #{@start_time}\") + (1.hours)\n\t\t\t\tend_at = Time.parse(\"#{@start_date} #{@start_time}\") + (@duration.to_f.hours+ (1.hours))\n\n\t\t\t\tappointments.each do |a|\n\t\t\t\t\t# will ensure that the appointment to compare will not be compared to itself in the database if it exists\n\t\t\t\t\tif a.id.to_s != @appointment_id.to_s\n\t\t\t\t\t\t# compare pay per hour input to pay per hour appointment\n\t\t\t\t\t\tif a.task.is_pay_per_hour && start_at < a.end_at && a.start_at < end_at \n\n\t\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\t\terrors.add(:start_date, \"An appointment already \n\t\t\t\t\t\t\t\texists at #{a.start_at.strftime(\"%I:%M%p\")}, #{a.start_at.strftime(\"%d/%m/%Y\")} \n\t\t\t\t\t\t\t\tto #{a.end_at.strftime(\"%I:%M%p\")} on #{a.end_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\t\tbreak\n\n\t\t\t\t\t\t\t#compare pay per hour input to fixed pay appointment\n\t\t\t\t\t\telsif !a.task.is_pay_per_hour && a.start_at <= end_at && a.start_at >= start_at\n\n\t\t\t\t\t\t\terrors.add(:start_time, \"Please select a different date or time.\")\n\t\t\t\t\t\t\terrors.add(:start_date, \"A fixed pay appointment is aleady set at #{a.start_at.strftime(\"%I:%M%p\")}\n\t\t\t\t\t\t\t\t, #{a.start_at.strftime(\"%d/%m/%Y\")}. \n\t\t\t\t\t\t\t\tPlease select a different date or time.\")\n\t\t\t\t\t\t\tbreak\t\t\t\t\n\t\t\t\t\t\tend\t\t\t\n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\tend \n\t\tend",
"def next_clean_time(addr) \n #Figure out side of the street\n side = self.get_side(addr) \n \n #Find all blocks that match Street Address \n all_blocks = self.blocks\n blocks = all_blocks.where(\"side = ? AND bottom <= ? AND top >= ?\", side, addr, addr)\n if blocks == []\n return nil\n else \n #Compute the next cleaning times for the block and pick the smallest(i.e. the soonest) time\n cts = Array.new\n blocks.each{|x|cts << x.ct.next_time}\n best = cts.min\n return best, blocks[0].id\n end\n end",
"def unfinished_dispatch_time_ranges\n dispatches.where(safe_return: false).map(&:active_time_window)\n end",
"def find_higher_blocks_on_the_network\n $logger.info(\"Looking for higher blocks on the network\")\n\n Array(@peers).each do |peer|\n peer_response = JSON.parse(HTTParty.get(\"http://#{peer}/blocks/last\").body)\n\n return if peer_response.nil?\n\n block = Block.initialize_from_json(self, peer_response)\n\n if block.height > last_block_height.to_i\n $logger.info(\"Found an higher block: #{block.height} (from #{last_block_height.to_i})\")\n validate_and_switch_to_fork(peer, block.height)\n end\n end\n end",
"def blocks\n @blocks ||= []\n end",
"def valid_cells(array)\n array.delete_if do |coord| \n !board.valid_coordinate?(coord) || !board.board_hash[coord].empty?\n end\n end",
"def test_invalid_block\n chain = \"SYSTEM>Kurt(50)\"\n block = Blockchain.new(\"5\", \"5\", chain, \"1518892051.812065000\", \"ch78\")\n\n assert_equal 0, block.is_valid\n end",
"def remove_deadline_for(generator, time)\n found = false\n deadlines.delete_if do |deadline, _, gen|\n if found\n false\n else\n found = (deadline > time && generator == gen)\n end\n end\n found\n end",
"def is_block_at?(x, y, z)\n not (x < 0 || y < 0 || z < 0 || x >= size_x || y >= size_y || z >= size_z)\n end",
"def all_game_times\n @rules.collect(&:game_times).flatten.uniq\n end",
"def late_events\n candidate_events.select(&:late?)\n end",
"def process_time_events\n @time_events.delete_if do |time_event|\n next if time_event.process_at > Time.now.to_f * 1000\n \n return_value = time_event.block.call\n \n if return_value.nil?\n true\n else\n time_event.process_at = (Time.now.to_f * 1000).truncate + return_value\n @logger.debug \"Rescheduling time event #{ Time.at(time_event.process_at / 1000.0).to_f }\"\n false\n end\n end\n end",
"def validate\n\t\tif not isEmpty(self.time)\n\t\t\terrors.add(:time, \"is already occupied.\")\n\t\tend\n\t\tif not Schedule.isValidTimeSlot(self.schedule, self.time)\n\t\t\terrors.add(:time, \"is not a valid timeslot.\")\n\t\tend\n\tend",
"def process_block(block, raise_errors=false, current_time=nil)\n result = false\n Toshi::Utils.synchronized(Toshi::Lock::PROCESS_BLOCK) do\n @output_cache.flush\n @storage.current_block = nil\n accepted_parents = []\n begin\n result = process_block_internal(block, raise_errors, current_time)\n if result && @storage.is_block_valid?(block.hash)\n # this block is a valid parent\n accepted_parents = [ block.hash ]\n end\n if !result\n logger.debug {\"process_block_internal false for block: #{block.hash}\"}\n end\n rescue ValidationError\n @storage.current_block = nil\n raise if raise_errors\n return result\n end\n\n # consume the array of parents from beginning to the end.\n while accepted_parent_hash = accepted_parents.shift\n # Try to accept the orphan and remove it from the database.\n @storage.orphan_blocks_with_parent(accepted_parent_hash).each do |orphan|\n accepted_parents += accept_orphan(orphan)\n end\n end # end checking orphans recursively.\n\n @storage.current_block = nil\n\n end # synchronized\n result\n end",
"def blocks\n @blocks ||= []\n end",
"def process_block_internal(block, raise_errors=false, current_time=nil)\n @current_time = current_time\n @processing_start_time = Time.now\n logger.debug{ \"ProcessBlock(): starting %s\" % [block.hash] }\n\n # Check for duplicate.\n # Bitcoind checks all blocks: mainchain, sidechain, orphans.\n if @storage.is_block_processed?(block.hash)\n b = @storage.processed_block_for_hash(block.hash)\n logger.debug{ \"ProcessBlock() : already have block %s\" % [b.hash] }\n return true\n else\n # Store the raw block for later use.\n # This is not the same as AcceptBlock in bitcoind.\n # In fact, the raw block may already be there before processing because it was received from other nodes.\n @storage.store_raw_block(block)\n end\n\n # This will track the reasons of failure and DoS penalties.\n state = ValidationState.new\n\n # Preliminary checks\n if !check_block(block, state)\n return false\n end\n\n # Load the latest mainchain block\n mainchain_tip_hash = @storage.mainchain_tip_hash\n\n # Checkpoints check.\n # Since we store around orphan blocks, we need at least to check that POW is good relative to the latest checkpoint.\n # - Find the last checkpoint hash *before this block*\n # - Find the block for this hash.\n # - if this block's previous hash is not the current tip or nil, verify against checkpoints:\n # - timestamp should be >= the checkpoint time\n # - minimal possible work since checkpoint should be satisfied\n checkpoint_hash = self.latest_checkpoint_hash\n\n # Only check if this block is not built on top of the current tip.\n if !@checkpoints_disabled && checkpoint_hash && block.prev_block_hex != (mainchain_tip_hash || (\"00\"*32))\n checkpoint_block = @storage.processed_block_for_hash(checkpoint_hash)\n time_delta = block.time - checkpoint_block.time\n if time_delta < 0\n raise BlockValidationError, \"ProcessBlock() : block with timestamp before last checkpoint\"\n end\n\n base_work = Bitcoin.decode_compact_bits(checkpoint_block.bits).to_i(16)\n max_target = compute_min_work(base_work, time_delta)\n\n if block.decimaltarget > max_target\n raise BlockValidationError, \"ProcessBlock() : block with too little proof-of-work\"\n end\n end\n\n # If block is orphan (for which we don't have the parent yet), store it for later use and return true (if stored succesfully)\n # Bitcoind: \"If we don't already have its previous block, shunt it off to holding area until we get it\"\n\n prev_block_valid = @storage.is_block_valid?(block.prev_block_hex)\n if !prev_block_valid\n # If it's a genesis block, simply save it right away\n # In Bitcoind this is saved apriori, AFAIU.\n if block.hash == Bitcoin.network[:genesis_hash]\n log_raw_block_events(block.hash, \"process_block => genesis (0)\")\n return persist_block_on_main_branch(block, 0)\n end\n\n # It is an orphan block.\n # Note: Bitcoind saves it if there's a node to request missing blocks from.\n\n # FIXME: maybe we can drop height support from here as we'd have to update all heights anyway when processing the orphans.\n # If we have a parent (which is also orphan), increase the height relative to the parent.\n # Otherwise, use height 0.\n height = @storage.height_for_block(block.prev_block_hex)\n height = height ? (height + 1) : 0\n\n log_raw_block_events(block.hash, \"process_block => orphan (#{height})\")\n\n # Store orphan and return.\n return persist_orphan_block(block, height)\n end\n\n measure_method(:process_block, @processing_start_time)\n\n # Reorg happens inside if needed.\n if !self.accept_block(block, state)\n # Note: if accept_block raises exceptions, this exception will never be raised.\n raise BlockValidationError, \"ProcessBlock() : AcceptBlock FAILED\"\n return false\n end\n\n return true\n rescue ValidationError, BlockValidationError, TxValidationError => e\n log_raw_block_events(block.hash, e)\n msg = \"process_block total time: #{(Time.now - @processing_start_time).to_f}\"\n log_raw_block_events(block.hash, msg)\n raise if raise_errors\n return false\n end",
"def collide_hash_all(hash_rects)\n hash_rects.select { |key,value|\n value.collide_rect?+(self)\n }\n end",
"def each_invalid_attempt(&block)\n invalid_attempts.each(&block)\n end",
"def check_timestamps(block1, block2)\n timestamp_one_string = block1.timestamp_string.split('.')\n timestamp_two_string = block2.timestamp_string.split('.')\n\n timestamp_one_partition = timestamp_one_string.map(&:to_i)\n timestamp_two_partition = timestamp_two_string.map(&:to_i)\n\n if timestamp_two_partition[0] < timestamp_one_partition[0]\n puts \"Line #{block2.block_number}: Previous timestamp #{block1.timestamp_string}\n \t>= new timestamp #{block2.timestamp_string}\"\n return false\n end\n\n if timestamp_two_partition[0] == timestamp_one_partition[0]\n if timestamp_two_partition[1] <= timestamp_one_partition[1]\n puts \"Line #{block2.block_number}: Previous timestamp #{block1.timestamp_string}\n \t >= new timestamp #{block2.timestamp_string}\"\n return false\n end\n end\n true\n end"
] | [
"0.6731134",
"0.60678077",
"0.5977046",
"0.58140635",
"0.5484393",
"0.5484328",
"0.54600245",
"0.534294",
"0.5336923",
"0.5301098",
"0.5291553",
"0.52813506",
"0.52577484",
"0.52175826",
"0.52076405",
"0.5142211",
"0.5131774",
"0.50770044",
"0.507346",
"0.5050142",
"0.5046692",
"0.5045441",
"0.50404817",
"0.5027059",
"0.5020657",
"0.4987285",
"0.49798852",
"0.49677834",
"0.49541187",
"0.49541187",
"0.49306905",
"0.4930058",
"0.4928955",
"0.49202472",
"0.490637",
"0.48914957",
"0.48877314",
"0.4886345",
"0.48813164",
"0.48777",
"0.48732102",
"0.4869516",
"0.48472",
"0.48446563",
"0.4840522",
"0.48380402",
"0.4833049",
"0.48314106",
"0.4826883",
"0.48120943",
"0.48120943",
"0.4800673",
"0.47982606",
"0.47845864",
"0.4776508",
"0.47707823",
"0.47705704",
"0.47620866",
"0.47586113",
"0.47517622",
"0.47445148",
"0.47406504",
"0.47324875",
"0.4730094",
"0.47166148",
"0.46995202",
"0.46974832",
"0.46819472",
"0.46781066",
"0.46770248",
"0.4676193",
"0.467165",
"0.4670267",
"0.4662033",
"0.4656893",
"0.46542683",
"0.4651149",
"0.46476325",
"0.46470365",
"0.46462038",
"0.46422708",
"0.46406996",
"0.4636484",
"0.46302408",
"0.46297657",
"0.46245617",
"0.46217567",
"0.46146968",
"0.45994723",
"0.45985347",
"0.45950198",
"0.45820525",
"0.45807603",
"0.45748356",
"0.45736626",
"0.4572928",
"0.45710653",
"0.4565891",
"0.45616043",
"0.45604712"
] | 0.7842012 | 0 |
Given a collection of TimeBlock(s), return a more optimized subset of the given collection. +:time_blocks: Collection of TimeBlock(s) to be filtered and optimized. | def optimize_time_blocks(time_blocks)
Optimizer.new.optimize(time_blocks)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quicksort_timeblocks(time_blocks)\n if (time_blocks.size <= 1)\n return time_blocks\n end\n\n pivot = time_blocks[0]\n left = []\n right = []\n\n time_blocks[1..time_blocks.size-1].each do |tb|\n if (tb.term.to_i < pivot.term.to_i)\n left.push(tb)\n elsif (pivot.term.to_i < tb.term.to_i)\n right.push(tb)\n elsif (before_in_week(tb.day, pivot.day))\n left.push(tb)\n elsif (before_in_week(pivot.day, tb.day))\n right.push(tb)\n elsif (tb.start_time < pivot.start_time)\n left.push(tb)\n else\n right.push(tb)\n end\n end\n\n sorted_left = quicksort_timeblocks(left)\n sorted_right = quicksort_timeblocks(right)\n time_blocks = sorted_left.push(pivot) + sorted_right\n return time_blocks\n end",
"def filter(array, block)\n return array.select(&block)\nend",
"def filter(array, block)\n return array.select &block\nend",
"def filter(array, block)\n return array.select(&block)\nend",
"def filter(array, block)\n return array.select(&block) # Your code here\nend",
"def available_delivery_blocks(time)\n\n unless opens_today\n return []\n end\n\n # Reset date to compare with Postgres Time\n time = time.change(:month => 1, :day => 1, :year => 2000)\n\n lead_time_for_block_time_slots = 1.hour\n\n all_slots = block_slots.select { |slot| slot[:from] >= (time + lead_time_for_block_time_slots) } +\n live_slots.select { |slot| slot[:from] >= (time) }\n\n all_slots.map do |slot|\n {\n :from => slot[:from].strftime('%H:%M'),\n :to => slot[:to].strftime('%H:%M'),\n :type => slot[:type]\n }\n end\n end",
"def validate_time_blocks(time_blocks)\n b = time_blocks.select(&:collision_free?)\n\n # Test environment has unreliable data entry for start times.\n b = b.select(&:in_future?) unless Rails.env.test?\n\n b\n end",
"def additional_blocks_with_time_report_query\n return @@additional_blocks if defined?(@@additional_blocks)\n\n @@additional_blocks = Dir.glob(\"#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}\").inject({}) do |h,file|\n name = File.basename(file).split('.').first.gsub(/^_/, '')\n\n ################\n # Smile specific : partials overriden in plugin ignored\n unless (\n # Query selection partials ignored : plugins overrides partial\n name.end_with?('_query_selection') ||\n # Core blocks partials ignored : plugins overrides partial\n (name == 'issues') ||\n CORE_BLOCKS.keys.include?(name)\n )\n h[name] = {:label => name.to_sym, :partial => \"my/blocks/#{name}\"}\n else\n Rails.logger.debug \"==>prof additional_blocks_with_time_report_query, overriden by plugin : #{name} partial\"\n end\n\n h\n end\n\n Rails.logger.debug \"==>prof additional_blocks_with_time_report_query #{@@additional_blocks}\"\n @@additional_blocks\n end",
"def reduce_blocks(blks, filter = writable_mifare_blocks)\n if identify_2d_array(blks)\n hsh = blks.to_h\n filter.map { |x| hsh[x] }.compact.flatten\n else\n filter.map { |x| blks[x] }.compact.flatten\n end\n end",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def filter!(&block)\n @rows.select!(&block)\n end",
"def get_blocks\n @blocks ||= Block.find :all, :conditions => { :show_in_all => '' }\n end",
"def blocks_for_block_size\n # We're already done with the last block behavior, if we wanted a small\n # last block, or if we only generated a single block\n return block_list if block_list.size <= 1 || last_block == :small_last\n\n case last_block\n when :truncate_all\n # Implemented in add_for_block_size\n nil\n when :small_last\n # Implemented just above\n nil\n when :truncate_last\n block_list.pop\n else # default to :big_last behavior\n last = block_list.pop\n block_list.last.words.concat(last.words)\n end\n\n block_list\n end",
"def sublist(&block)\n @tasks.select(&block)\n end",
"def get_all_blocks\n\n @all_blocks = Block.where(is_published: 't')\n\n end",
"def batch(items)\n items.select { |i| filter(i) }\n end",
"def first_not_all(conditions={}, &block)\n all.detect { |item| !match_all(item, conditions, &block) }\n end",
"def get_broadcasts_for_minute broadcasts, time\n broadcasts.collect { |b| TimeDifference.between( b.start, time).in_minutes < 1 }\n end",
"def filter\n collection = @collection\n collection = collection.sort_by(&@sort_method) if @sort_method\n collection.reverse! if (@list_order.to_sym == ORDER[:lowest]) ^ @reverse\n collection = collection[((@list_position) - 1)..-1] || []\n\n collection.first(requested_size).tap do |filtered_collection|\n @filtered_size = filtered_collection.size\n end\n end",
"def my_select (collection)\n if block_given?\n i = 0 \n new_collection = []\n \n while i < collection.length \n if yield(collection[i]) \n new_collection << collection[i]\n end\n i += 1\n end\n \n else\n puts \"Hey! No block was given!\"\n end\n new_collection \nend",
"def without_set_blocks(options)\n piece = options[:piece]\n game = options[:game]\n\n collection = clone\n collection.sets.map! { |set| set.without_blocks(piece: piece, game: game) }\n collection\n end",
"def get\n # TODO think about processing entries in batches\n remove_times = @remove_set.to_h\n @add_set.to_a.select do |element, add_time|\n remove_time = remove_times[element]\n !remove_time || remove_time < add_time\n end.map(&:first)\n end",
"def find_every(opts, &block)\n collection = []\n\n all_ids(opts) do |partial_ids, data, partial_opts|\n partial_items = partial_ids.map do |id|\n find_single(id, opts, false)\n end\n\n if block_given?\n yield(instantiate_collection( partial_items ), data, opts)\n end\n\n collection.concat partial_items\n end\n\n instantiate_collection( collection )\n end",
"def get_blocks(options = {block_range: (0..0)}, &block)\n get_block_objects(options.merge(object: :block), block)\n end",
"def contains_block?(block_of_time)\n if(self.start_time <= block_of_time.start_time &&\n self.end_time >= block_of_time.end_time)\n true\n else\n false\n end\n end",
"def records_modified_since(time)\n condition = []\n %w(updated_at created_at).each do |col|\n condition << \"#{col} >= ?\" if column_names.include? col\n end\n if condition.empty?\n logger.warn \"#{self.name}: Override records_modified_since(time) to keep the index up to date with records changed during rebuild.\"\n []\n else\n find :all, :conditions => [ condition.join(' AND '), *([time]*condition.size) ]\n end\n end",
"def find_all(&block)\r\n copy_and_return(@records.select(&block))\r\n end",
"def get_blocks(project_id = nil, span = nil, context_size = nil, sort = false)\n\t\t_blocks = blocks.in_project(project_id).in_span(span)\n\n\t\tif span.present?\n\t\t\tb = span[:begin]\n\t\t\tunless context_size.nil?\n\t\t\t\tb -= context_size\n\t\t\t\tb = 0 if b < 0\n\t\t\tend\n\t\t\t_blocks.each{|a| a.begin -= b; a.end -= b}\n\t\tend\n\n\t\tif sort\n\t\t\t_blocks.sort{|b1, b2| (b1.begin <=> b2.begin).nonzero? || (b2.end <=> b1.end)}\n\t\telse\n\t\t\t_blocks\n\t\tend\n\tend",
"def normalize_regions(regions)\n regions = regions.sort_by { |r| r.start_time }\n filtered_regions = Array.new\n last_region = regions.shift\n regions.each do |r|\n if r.start_time < last_region.end_time\n last_region.end_time = [last_region.end_time, r.end_time].max\n else\n filtered_regions << last_region\n last_region = r\n end\n end\n if last_region\n filtered_regions << last_region\n end\n filtered_regions\n end",
"def select(&block)\n append(Filter.new(&block))\n end",
"def section_filter citems\n filtered_citems = citems.map do |citem|\n citem.section == @section && !citem.hidden? ? citem : nil\n end\n filtered_citems.compact\n end",
"def my_select(&block)\n result = []\n my_each do |elem|\n result << elem if block.call(elem) == true\n end\n result\n end",
"def index\n @time_blocks = TimeBlock.all\n end",
"def get_filtered_activities(filter, time)\n activities(time, filter)\n end",
"def blocks_time\n @measurements[PATH_MEASURES].time if @measurements[PATH_MEASURES]\n end",
"def filter!(collection)\n # Limit by type\n collection = collection.where(type: params[:type]) if params.has_key?(:type)\n\n # Limit by Tracker ID\n if params.has_key? :tracker_id\n tracker_ids = (params[:tracker_id] || '').to_s.split(\",\")\n collection = collection.where(tracker_id: tracker_ids)\n\n # not a perfect place, but should be okay for now...\n Tracker.where(id: tracker_ids).each { |tracker| tracker.delay.remote_sync_if_necessary(state: \"open\", person: current_user) }\n end\n\n # Limit by Tracker Type\n if params.has_key?(:tracker_type)\n constant_names = tracker_constant_names_for_type(params[:tracker_type])\n collection = collection.joins(:tracker).where('trackers.type IN (?)', constant_names) unless constant_names.blank?\n end\n\n # Filter by Tracker owner type and id\n if params.has_key?(:tracker_team_id)\n collection = filter_by_tracker_team_id(collection, params[:tracker_team_id])\n end\n\n # Filter by issue open/closed\n collection = collection.where(can_add_bounty: params[:can_add_bounty].to_bool) if params.has_key?(:can_add_bounty)\n\n #Filter by issue paid_out\n collection = collection.where(paid_out: params[:paid_out].to_bool) if params.has_key?(:paid_out)\n\n # Filter by Featured\n collection = collection.where(featured: params[:featured].to_bool) if params.has_key?(:featured)\n\n # Filter by issue accepting request_for_proposals\n if params[:accepting_proposals].to_bool\n collection = filter_by_accepting_proposals(collection.joins(:request_for_proposal))\n end\n\n if params.has_key?(:bounty_min) || params.has_key?(:bounty_max)\n collection = filter_by_bounty_total(collection)\n end\n\n # Filter by Tracker owner type and id\n if params.has_key?(:thumbed_by_person_id)\n if params[:thumbed_by_person_id] == 'me' && current_user\n person_id = current_user.id\n else\n person_id = params[:thumbed_by_person_id]\n end\n collection = collection.joins(:thumbs).where(\"thumbs.person_id\" => person_id, \"thumbs.downvote\" => false)\n end\n\n collection\n end",
"def select\n a = []\n @set.each do |e,_|\n if yield(e)\n a << e\n end\n end\n a\n end",
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def find_all(conditions={}, &block)\n all.select { |item| match_all(item, conditions, &block) }\n end",
"def time_filter(selection)\n\t\t\tif self.method_defined? :gc_created_at\n\t\t\t\ttime_column = 'gc_created_at'\n\t\t\telsif self.method_defined? :source_created_at\n\t\t\t\ttime_column = 'source_created_at'\n\t\t\telse\n\t\t\t\ttime_column = 'created_at'\n\t\t\tend\n\t\t\t\n\t\t\tif selection.is_a?(Hash)\n\t\t\t\tif selection[:filter] == 'between'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.parse(selection[:from]))\n\t\t\t\t\t\t.where(name_of_class + '.' + time_column + '<= ?', Time.parse(selection[:to]))\n\t\t\t\telse\n\t\t\t\t\tself.all\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tcase selection\n\t\t\t\twhen 'any'\n\t\t\t\t\tself.all\n\t\t\t\twhen 'today'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today)\n\t\t\t\twhen 'yesterday'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today - 1)\n\t\t\t\twhen 'this_week'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.now.beginning_of_week)\n\t\t\t\twhen 'this_month'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.now.beginning_of_month)\n\t\t\t\twhen 'last_month'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Time.now.last_month.beginning_of_month)\n\t\t\t\t\t\t.where(name_of_class + '.' + time_column + '<= ?', Time.now.last_month.end_of_month)\n\t\t\t\twhen 'last_7_days'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today - 7)\n\t\t\t\twhen 'last_30_days'\n\t\t\t\t\tself.where(name_of_class + '.' + time_column + '>= ?', Date.today - 30)\n\t\t\t\telse\n\t\t\t\t\tself.all\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def tasks_by_filters\n to_include = [ :users, :tags, :sheets, :todos, :dependencies, \n :milestone, :notifications, :watchers, \n :customers ]\n to_include << { :work_logs => :user }\n to_include << { :company => :properties }\n to_include << { :project => :customer }\n to_include << { :task_property_values => { :property_value => :property } }\n to_include << { :dependants => [:users, :tags, :sheets, :todos, \n { :project => :customer }, :milestone ] }\n\n conditions = filter\n conditions += \" AND tasks.project_id in (#{ @select_project_ids })\"\n conditions += \" AND #{ @extra_conditions }\" if !@extra_conditions.blank?\n\n Task.find(:all, \n :conditions => [ conditions ],\n :include => to_include, \n :limit => 250,\n :order => \"tasks.id desc\")\n end",
"def blocks_time\n Benchmark::Tms.new\n end",
"def filter(&block)\n result = yield\n return result.map { |o| filter { o } } if result.is_a?(Array)\n result\n end",
"def blocks_for_block_size\n # We're already done with the last block behavior, if we wanted a small\n # last block, or if we only generated a single block\n return @blocks if @blocks.size <= 1 || @last_block == :small_last\n\n # Implement the last block behavior. The :truncate_all behavior is\n # implemented in add_for_block_size.\n case @last_block\n when :big_last\n last = @blocks.pop\n @blocks.last.words += last.words\n when :truncate_last\n @blocks.pop\n end\n\n @blocks\n end",
"def filter(collection)\n collection\n end",
"def filter(collection)\n collection\n end",
"def get_records_with_filter (&block)\n ui2 = @records_unpacked\n records = []\n\n ui2_size = ui2.size\n offset = 0\n ptr = ui2\n\n while(offset < ui2_size) do\n curr_record_type = ptr[0]\n record_size = ptr[1]\n offset += (record_size/2)\n\n yield records, curr_record_type, offset, ptr\n\n ptr = ptr[(record_size/2)..-1]\n end\n\n records\n end",
"def add_timeset(*args, &block)\n if block_given?\n timesets(*args, &block)\n else\n timesets(args.first) {}\n end\n end",
"def filter(*args, &block)\n if args.length == 1\n args = args.first\n else\n args.freeze\n end\n\n with_opts(:filter=>args, :filter_block=>block)\n end",
"def time_block_params\n params[:time_block]\n end",
"def find_none(conditions={}, &block)\n all.select { |item| match_none(item, conditions, &block) }\n end",
"def filter(collection, conditions, negate = false)\n if negate\n conditions.inject(collection) do |a, (key, value)|\n a.where.not(key => value)\n end\n else\n collection.where(conditions)\n end\n end",
"def find_not_all(conditions={}, &block)\n all.reject { |item| match_all(item, conditions, &block) }\n end",
"def transactions_since(block_height: block_height_created_at, reload: false)\n transactions(reload: reload).select { |t| t.block_height.to_i <= 0 || t.block_height > block_height }\n end",
"def filter_departures(departure_times,bartroute_options)\n\t\t# Filter the results of the real-time departures to find those that match the \n\t\t# route options. \n\n\t\tfiltered_departure_times = {}\n\n\t\tdeparture_times.each do |station,times|\n\t\t\tbartroute_options.each do |bartroute_station,v|\n\t\t\t\tif station == bartroute_station\n#\t\t\t\t\tstation_name = Bartstation.where(\"short_name = '#{bartroute_station}'\").pluck(\"station_name\")[0]\n\t\t\t\t\tstation_name = bartroute_station\n\t\t\t\t\tfiltered_departure_times[station_name] = times\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\treturn filtered_departure_times\n\tend",
"def benchmark_block(keywords_arrays)\n Benchmark.bmbm do |x|\n x.report(\"relation w/ 2 joins:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags(*kw_arr) } }\n x.report(\"relation w/ 3 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags_v2(*kw_arr) } }\n x.report(\"relation w/ 2 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags_v3(*kw_arr) } }\n x.report(\"relation w/ 1 subq, 2 joins:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_tags_with_subqueries(*kw_arr) } }\n x.report(\"jsonb w/ 1 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_jsonb_v2(kw_arr) } }\n x.report(\"array w/ 1 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_array_v2(kw_arr) } }\n x.report(\"hstore w/ 1 subq:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_hstore_v2(kw_arr) } }\n x.report(\"jsonb w/ 2 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_jsonb(kw_arr) } }\n x.report(\"hstore w/ 2 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_hstore(kw_arr) } }\n x.report(\"array w/ 2 queries:\") { keywords_arrays.each { |kw_arr| Product.select_products_by_array(kw_arr) } }\n end\nend",
"def select(&block)\n result = empty_copy\n values.select(&block).each{|mach| result << mach}\n result\n end",
"def find_available_rooms_in_block(blocks, group_name, start_date: Date.today, end_date: Date.today + 2)\n return Block.all_available_rooms_in_block(blocks, group_name, start_date: start_date, end_date: end_date)\n end",
"def scope_by_time(time_boundaries)\n start_time, end_time = time_boundaries\n scope_end = num_lines - 1\n # short circuit the search if possible\n if (time_at(0) > end_time) or (time_at(-1) < start_time)\n @lines = []\n return @lines\n end\n scope_begin = find_first(start_time, 0, scope_end)\n scope_end = find_last(end_time, scope_begin, scope_end)\n @lines = @lines[scope_begin..scope_end]\n end",
"def by_star(start_time, end_time, options = {}, &block)\n start_time = parse(start_time) \n end_time = parse(end_time)\n\n\n raise ParseError, \"End time is before start time, searching like this will return no results.\" if end_time < start_time\n field = options.delete(:field)\n ensure_valid_options(options)\n\n scoping = { :conditions => conditions_for_range(start_time, end_time, field) }.merge(options)\n result = scoped(scoping)\n result = result.scoped(block.call) if block_given?\n result\n end",
"def render_timereportquery_block(block, settings)\n @query = TimeReportQuery.visible.find_by_id(settings[:query_id])\n\n if @query\n if params[:debug]\n @query.set_debug(params[:debug])\n end\n\n # Smile comment : no limit to scope\n prepare_report_object\n\n prepare_report_object_hook\n\n render :partial => 'my/blocks/partials/timereport', :locals => {:query => @query, :scope => @scope, :block => block, :settings => settings}\n else\n queries = TimeReportQuery.visible.sorted\n render :partial => 'my/blocks/partials/timereport_query_selection', :locals => {:queries => queries, :block => block, :settings => settings}\n end\n end",
"def filter_for_extended(sets, dictionary_intervals, notes)\n sets.select do |permutation|\n root_index = permutation.index(0)\n extended = dictionary_intervals.select { |n| n if n > 11 }\n reduced_extended = extended.map { |n| n % 12 }\n i = 0\n extended_indexes = permutation.map do |n|\n index = i if reduced_extended.include?(n)\n i += 1\n index\n end\n extended_indexes.compact!\n extended_notes = extended_indexes.map { |i| notes[i] }\n root = notes.at(root_index)\n extended_notes.all? { |note| note.value.number - root.value.number > 12 }\n end\n end",
"def without_individual_blocks(options)\n piece = options[:piece]\n game = options[:game]\n board = game.board\n\n collection = clone\n\n collection.coordinates.reject! do |coordinate|\n at_position = board.at_square(coordinate.square_name) \n piece.ally?(at_position) \n end\n\n collection\n end",
"def test_filter\n d1 = create_driver(CONFIG, 'test.no.change')\n time = @time.to_i\n d1.run do\n d1.filter({'message' => '12 20120402182059'}, time)\n d1.filter({'message' => '34 20120402182100'}, time)\n d1.filter({'message' => '56 20120402182100'}, time)\n d1.filter({'message' => '78 20120402182101'}, time)\n d1.filter({'message' => '90 20120402182100'}, time)\n end\n filtered = d1.filtered_as_array\n assert_equal 5, filtered.length\n\n first = filtered[0]\n assert_equal 'test.no.change', first[0]\n assert_equal Time.parse(\"2012-04-02 18:20:59\").to_i, first[1]\n assert_equal '1', first[2]['x']\n assert_equal '2', first[2]['y']\n assert_equal '12 20120402182059', first[2]['message']\n\n second = filtered[1]\n assert_equal 'test.no.change', second[0]\n assert_equal Time.parse(\"2012-04-02 18:21:00\").to_i, second[1]\n assert_equal '3', second[2]['x']\n assert_equal '4', second[2]['y']\n\n third = filtered[2]\n assert_equal 'test.no.change', third[0]\n assert_equal Time.parse(\"2012-04-02 18:21:00\").to_i, third[1]\n assert_equal '5', third[2]['x']\n assert_equal '6', third[2]['y']\n\n fourth = filtered[3]\n assert_equal 'test.no.change', fourth[0]\n assert_equal Time.parse(\"2012-04-02 18:21:01\").to_i, fourth[1]\n assert_equal '7', fourth[2]['x']\n assert_equal '8', fourth[2]['y']\n\n fifth = filtered[4]\n assert_equal 'test.no.change', fifth[0]\n assert_equal Time.parse(\"2012-04-02 18:21:00\").to_i, fifth[1]\n assert_equal '9', fifth[2]['x']\n assert_equal '0', fifth[2]['y']\n\n d2 = create_driver(%[\n tag parsed\n key_name data\n format /^(?<x>.)(?<y>.) (?<t>.+)$/\n ], 'test.no.change')\n time = @time.to_i\n d2.run do\n d2.filter({'data' => '12 20120402182059'}, time)\n d2.filter({'data' => '34 20120402182100'}, time)\n end\n filtered = d2.filtered_as_array\n assert_equal 2, filtered.length\n\n first = filtered[0]\n assert_equal 'test.no.change', first[0]\n assert_equal time, first[1]\n assert_nil first[2]['data']\n assert_equal '1', first[2]['x']\n assert_equal '2', first[2]['y']\n assert_equal '20120402182059', first[2]['t']\n\n second = filtered[1]\n assert_equal 'test.no.change', second[0]\n assert_equal time, second[1]\n assert_nil second[2]['data']\n assert_equal '3', second[2]['x']\n assert_equal '4', second[2]['y']\n assert_equal '20120402182100', second[2]['t']\n\n d3 = create_driver(%[\n tag parsed\n key_name data\n format /^(?<x>[0-9])(?<y>[0-9]) (?<t>.+)$/\n ], 'test.no.change')\n time = @time.to_i\n d3.run do\n d3.filter({'data' => '12 20120402182059'}, time)\n d3.filter({'data' => '34 20120402182100'}, time)\n d3.filter({'data' => 'xy 20120402182101'}, time)\n end\n filtered = d3.filtered_as_array\n assert_equal 2, filtered.length\n\n d3x = create_driver(%[\n tag parsed\n key_name data\n format /^(?<x>\\\\d)(?<y>\\\\d) (?<t>.+)$/\n reserve_data yes\n ], 'test.no.change')\n time = @time.to_i\n d3x.run do\n d3x.filter({'data' => '12 20120402182059'}, time)\n d3x.filter({'data' => '34 20120402182100'}, time)\n d3x.filter({'data' => 'xy 20120402182101'}, time)\n end\n filtered = d3x.filtered_as_array\n assert_equal 3, filtered.length\n\n d4 = create_driver(%[\n tag parsed\n key_name data\n format json\n ], 'test.no.change')\n time = @time.to_i\n d4.run do\n d4.filter({'data' => '{\"xxx\":\"first\",\"yyy\":\"second\"}', 'xxx' => 'x', 'yyy' => 'y'}, time)\n d4.filter({'data' => 'foobar', 'xxx' => 'x', 'yyy' => 'y'}, time)\n end\n filtered = d4.filtered_as_array\n assert_equal 1, filtered.length\n\n d4x = create_driver(%[\n tag parsed\n key_name data\n format json\n reserve_data yes\n ], 'test.no.change')\n time = @time.to_i\n d4x.run do\n d4x.filter({'data' => '{\"xxx\":\"first\",\"yyy\":\"second\"}', 'xxx' => 'x', 'yyy' => 'y'}, time)\n d4x.filter({'data' => 'foobar', 'xxx' => 'x', 'yyy' => 'y'}, time)\n end\n filtered = d4x.filtered_as_array\n assert_equal 2, filtered.length\n\n first = filtered[0]\n assert_equal 'test.no.change', first[0]\n assert_equal time, first[1]\n assert_equal '{\"xxx\":\"first\",\"yyy\":\"second\"}', first[2]['data']\n assert_equal 'first', first[2]['xxx']\n assert_equal 'second', first[2]['yyy']\n\n second = filtered[1]\n assert_equal 'test.no.change', second[0]\n assert_equal time, second[1]\n assert_equal 'foobar', second[2]['data']\n assert_equal 'x', second[2]['xxx']\n assert_equal 'y', second[2]['yyy']\n end",
"def find_any(conditions={}, &block)\n all.select { |item| match_any(item, conditions, &block) }\n end",
"def bench_filters\n skip 'TODO'\n end",
"def time_to_block(time)\n Rational(time / time_divisor).floor * time_divisor\n end",
"def index\n\n @search = Block.search do\n fulltext params[:search]\n without(:is_floor, true)\n without(:start_at, nil)\n without(:end_at, nil)\n with(:start_at).greater_than_or_equal_to(params[:start_at].to_time) if params[:start_at].present?\n with(:end_at).less_than_or_equal_to(params[:end_at].to_time) if params[:end_at].present?\n with(:fee).greater_than_or_equal_to(params[:fee_start]) if params[:fee_start].present?\n with(:fee).less_than_or_equal_to(params[:fee_end]) if params[:fee_end].present?\n end\n\n @blocks = @search.results\n\n # @blocks = Block.order(:name)\n\n # @blocks = @blocks.where(\"name like ?\", \"%#{params[:search]}%\") if params[:search].present?\n\n # @blocks = @blocks.where(\"start_at >= ?\", params[:start_at]) if params[:start_at].present?\n\n # @blocks = @blocks.where(\"end_at <= ?\", params[:end_at]) if params[:end_at].present?\n\n end",
"def filter(initial_set, task_index)\n\t # WARNING: the value returned by filter is a SUPERSET of the\n\t # possible values for the query. Therefore, the result of\n\t # NegateTaskMatcher#filter is NOT\n\t #\n\t # initial_set - @op.filter(...)\n\t initial_set\n\tend",
"def filter_locations_tu(points)\n filter_locations(points, 15.9.within(0.07), 50.57.within(0.1))\nend",
"def archival_units_filter_by_states(states) \n return Collection.archival_units_filter_by_states(collections, states); \n end",
"def filter_listings(listings)\n cutoff_timestamp = self.last_run_at\n listings.reject { |ll| ll.updated_at < cutoff_timestamp }.sort_by(&:updated_at)\n end",
"def filtered_bets\n filter_bets = Bet.played.traditional\n filter_bets = filter_bets.where('bets.created_at > ?', start_date) if start_date.present?\n filter_bets\n end",
"def first_all(conditions={}, &block)\n all.detect { |item| match_all(item, conditions, &block) }\n end",
"def filter(*query_names, &block)\n each_query(query_names) do |query|\n query.add_filter(block)\n end\n end",
"def unblocked_subsets\n availabilities = Availability.arel_table\n subsets = Subset.arel_table\n account = Membership.arel_table.alias(:account)\n friends = Connection.arel_table.alias(:friends)\n user = Membership.arel_table.alias(:user)\n devices = Device.arel_table\n mutes = Mute.arel_table.alias(:mutes)\n blocked = Mute.arel_table.alias(:blocked)\n sqlblock = \n availabilities. \n join(subsets).on(availabilities[:available_object_id].eq(subsets[:id])).\n join(account).on(subsets[:id].eq(account[:member_id])).\n join(friends).on(account[:account_id].eq(friends[:account_id])).\n join(user).on(user[:account_id].eq(friends[:connectable_id])).\n join(mutes, Arel::Nodes::OuterJoin).on(mutes[:account_id].eq(user[:account_id]).and(mutes[:muted_object_id].eq(subsets[:id]))).\n join(blocked, Arel::Nodes::OuterJoin).on(blocked[:account_id].eq(account[:account_id]).and(blocked[:muted_object_id].eq(user[:account_id]))).\n where(user[:member_type].eq('user').\n and(account[:member_type].eq('subset')).\n and(mutes[:id].eq(nil).or(mutes[:muted_object_type].not_eq('subset'))).\n and(blocked[:id].eq(nil).or(blocked[:muted_object_type].not_eq('account'))).\n and(user[:account_id].eq(self.account.id))\n ).\n project(subsets[:id]).to_sql\n self.connected_subsets.where( id: sqlblock )\nend",
"def filter(arr, &block)\n if arr.empty?\n []\n else\n head, *tail = arr\n if block.call(head) == true\n [head] + filter(tail, &block)\n else\n filter(tail, &block)\n end\n end\nend",
"def includes(time)\n return (@beginTime < time && time < @endTime) ;\n end",
"def trip_filters\n elems = []\n TimeFilterHelper.time_filters.each do |tf|\n elems << {\n :id => 100 + tf[:id],\n :value => tf[:value]\n }\n end\n TripPurpose.all.each do |tp|\n elems << {\n :id => tp.id,\n :value => tp\n } \n end\n return elems \n end",
"def get_block_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n next if line !~ /^Block times/\n values = []\n # Block times are given as a space-separated list of start,end pairs. They\n # are in units of seconds * 1e5, so convert them to seconds here for\n # consistency.\n if line =~ /^[^:]+: (.*?)\\s*$/\n values = $1.split(\" \").map{|r| r.split(\",\").map{|v| v.to_f / 1e5}}\n end\n to_return << values\n end\n to_return\nend",
"def filter(objects) objects end",
"def find(filters, &block)\n ds = db[:tokens.as(:t0)]\n f = filters[0]\n ds = ds.where(:t0__word_id=>f.word) if f.word\n ds = ds.where(:t0__tag_id=>f.tag) if f.tag\n i = 0\n filters[1..-1].each do |f|\n as = \"t#{i+=1}\"\n h = {}\n h[:\"#{as}__word_id\"] = f.word if f.word\n h[:\"#{as}__tag_id\"] = f.tag if f.tag\n g = {}\n g[:\"#{as}__word_id\"] = f.ex_word if f.ex_word\n g[:\"#{as}__tag_id\"] = f.ex_tag if f.ex_tag\n ds = ds.join(:tokens.as(as)){ |j, lj, js| {:text_id.qualify(j) => :text_id.qualify(lj), :position.qualify(j) => :position.qualify(lj) + 1} }.where(h).exclude(g)\n end\n select = ds.select(:t0__text_id.as(:text_id), :t0__src_begin.as(:src_begin), :\"t#{i}__src_end\".as(:src_end),\n :t0__tagged_begin.as(:tagged_begin), :\"t#{i}__tagged_end\".as(:tagged_end), :t0__position.as(:pos_begin), :\"t#{i}__position\".as(:pos_end))\n\n puts select.sql\n puts select.explain\n\n select.to_enum.each do |e|\n block.call [e[:text_id], e[:src_begin], e[:src_end], e[:tagged_begin], e[:tagged_end], e[:pos_begin], e[:pos_end]]\n end\n end",
"def my_select(coll)\n # your code here!\n mod_coll = []\n i=0\n while i < coll.length\n if (yield(coll[i]))\n mod_coll.push(coll[i])\n end\n i = i+1\n end\n mod_coll\nend",
"def filter_out\n result,i = [],0\n while(i < size)\n if yield(e = self.at(i))\n result << e\n delete_at(i)\n else\n i += 1\n end\n end\n result\n end",
"def points_of_subset_fast subset, options={}\n points_of_subset = []\n lower_range_bound = options[:omit_first] ? 2 : 1\n power = 1; while (2**power <= subset) do power +=1 end\n\n (lower_range_bound .. power).each do |i|\n points_of_subset << i if (subset & 2**(i-1) == 2**(i-1))\n end\n points_of_subset\n end",
"def next_clean_time(addr) \n #Figure out side of the street\n side = self.get_side(addr) \n \n #Find all blocks that match Street Address \n all_blocks = self.blocks\n blocks = all_blocks.where(\"side = ? AND bottom <= ? AND top >= ?\", side, addr, addr)\n if blocks == []\n return nil\n else \n #Compute the next cleaning times for the block and pick the smallest(i.e. the soonest) time\n cts = Array.new\n blocks.each{|x|cts << x.ct.next_time}\n best = cts.min\n return best, blocks[0].id\n end\n end",
"def blocks\n unless defined?(@blocks)\n bs = block_sizes\n qst = query.starts\n tst = target.starts\n qseqs = query.seqs\n tseqs = target.seqs\n @blocks = (0...block_count).collect do |i|\n SegmentPair.new(query.size, strand, bs[i],\n qst[i], tst[i], qseqs[i], tseqs[i])\n end\n end\n @blocks\n end",
"def search_by_chunks filters\n\t\tif NSConnector::Config[:use_threads] then\n\t\t\treturn threaded_search_by_chunks(filters)\n\t\telse\n\t\t\treturn normal_search_by_chunks(filters)\n\t\tend\n\tend",
"def filter(*conditions)\n latest = !conditions.select {|item| item === true }.empty?\n filters = translate_conditions(conditions)\n items = list(latest)\n unless filters.empty?\n items = items.select do |item|\n !filters.select {|filter| match_filter(filter, item) }.empty?\n end\n\n end\n items\n end",
"def blank_blocks(filter = writable_mifare_blocks, blks = Array.new(16, 0))\n filter.map do |x|\n [x, blks]\n end\n end",
"def render_timelogquery_block(block, settings)\n query = TimeEntryQuery.visible.find_by_id(settings[:query_id])\n\n if query\n query.column_names = settings[:columns] if settings[:columns].present?\n query.sort_criteria = settings[:sort] if settings[:sort].present?\n\n scope = query.results_scope\n scope = scope.\n preload(:issue => [:project, :tracker, :status, :assigned_to, :priority]).\n preload(:project, :user)\n\n entries = scope.limit(10).to_a\n\n render :partial => 'my/blocks/partials/timelogs', :locals => {:query => query, :scope => scope, :entries => entries, :block => block, :settings => settings}\n else\n queries = TimeEntryQuery.visible.sorted\n render :partial => 'my/blocks/partials/timelog_query_selection', :locals => {:queries => queries, :block => block, :settings => settings}\n end\n end",
"def find_all(&block)\n @asset.representation_utis.each do |uti|\n find_by_uti(uti) do |rep|\n block.call(rep)\n end\n end\n end",
"def eAllContents(&block)\r\n if block\r\n if @_contained_elements\r\n @_contained_elements.each do |e|\r\n res = block.call(e)\r\n e.eAllContents(&block) if res != :prune\r\n end\r\n end\r\n nil\r\n else\r\n result = []\r\n if @_contained_elements\r\n @_contained_elements.each do |e|\r\n result << e\r\n result.concat(e.eAllContents)\r\n end\r\n end\r\n result\r\n end\r\n end",
"def best_items(bib_id, limit = 5)\n return [] unless holdings_exist_for? bib_id\n\n ITEM_TIERS.each do |criteria|\n matches = holdings_data(bib_id).copies.select(&criteria)\n return matches.first(limit) if matches.any?\n end\n end",
"def find_planets(&blk)\n sectors.inject([]) do |a, e|\n a.push(*e.planets.select(&(blk || TRUEBLOCK)))\n end\n end",
"def elements_in_same_block(region_size = 3)\n row_del = @row_idx % region_size\n col_del = @column_idx % region_size\n\n region_shift = region_size -1\n\n start_row_idx = @row_idx - row_del\n start_col_idx = @column_idx - col_del\n\n block_elements = []\n (start_row_idx..start_row_idx+region_shift).each do |row_idx|\n (start_col_idx..start_col_idx+region_shift).each do |col_idx|\n block_elements << @map.element_at(row_idx, col_idx)\n end\n end\n block_elements\n end",
"def subset conditions\n rows = self.select do |row|\n conditions.reduce(true) do |memo, (var, val)|\n memo and row[var] == val\n end\n end\n Dataset.new rows\n end",
"def filtered_sets(type)\n self.class.get(sets).select{|set| set['set_type'] == type}\n end",
"def time_slots_for(time_entry)\n count = (duration_for(time_entry.range) / block_size).floor.to_i\n time = time_entry.start_time\n\n slots = count.times.map do |i|\n # Instantiate a new TimeSlot out of thin air (no backing store)\n slot = TimeSlot.new time, time + block_size.minutes, time_entry\n\n # Stash the current session onto the slot as well, so it may handle\n # some of it's own session based logic.\n slot.session = session\n\n # finally increment the time for the next iteration\n time = time + block_size.minutes\n\n slot\n end\n\n # Detect deadspace at the TimeSlot layer.\n # If found, we add a final TimeSlot to make up the difference.\n if time < time_entry.end_time\n slots << TimeSlot.new(time, time_entry.end_time, time_entry)\n end\n\n # Return the aggregated slot collection\n slots\n end",
"def find_from_query_caches(filters, collection = nil, operator = nil)\n if collection.nil?\n # FIRST RUN\n filters.keys.each do |key|\n collection = [query_cache({key: key, value: filters[key]})]\n end\n end\n\n end"
] | [
"0.5368214",
"0.5326802",
"0.53122807",
"0.52685475",
"0.5181944",
"0.5129373",
"0.5116508",
"0.5077676",
"0.5031447",
"0.49094605",
"0.48733032",
"0.4859573",
"0.48289484",
"0.4816768",
"0.4806716",
"0.47583252",
"0.47385758",
"0.46988118",
"0.46612123",
"0.46600792",
"0.46407554",
"0.4629884",
"0.46262267",
"0.46067443",
"0.45756897",
"0.45454302",
"0.45436493",
"0.4533539",
"0.45294103",
"0.452764",
"0.4524892",
"0.45231104",
"0.4520128",
"0.45112234",
"0.45092833",
"0.4506826",
"0.45019132",
"0.44803965",
"0.4476772",
"0.44677556",
"0.44490647",
"0.4444266",
"0.44396666",
"0.44323713",
"0.4428966",
"0.4428966",
"0.44086888",
"0.44054732",
"0.44025886",
"0.43996638",
"0.43953347",
"0.43933377",
"0.43920285",
"0.4376401",
"0.4354911",
"0.4346631",
"0.43436196",
"0.4337865",
"0.4334323",
"0.43328175",
"0.43230727",
"0.43195194",
"0.43073323",
"0.43034324",
"0.42853367",
"0.42800868",
"0.42800373",
"0.42556834",
"0.42545915",
"0.42470846",
"0.42447907",
"0.4240351",
"0.42397103",
"0.4226059",
"0.4219543",
"0.42187566",
"0.4215533",
"0.420505",
"0.41811252",
"0.4178589",
"0.4174998",
"0.41728488",
"0.4171517",
"0.4168916",
"0.4168443",
"0.41617724",
"0.41569704",
"0.415695",
"0.4149488",
"0.414729",
"0.41463152",
"0.41371182",
"0.41314667",
"0.41312683",
"0.41305658",
"0.41298306",
"0.41254562",
"0.4123618",
"0.4119591",
"0.41153333"
] | 0.67573684 | 0 |
The size of a TimeBlock. Based on the minute duration of the chosen Service. | def block_size
session.chosen_service.duration rescue session.business.services.first.duration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size_time(base = self.date_from)\n\t\t\t\t\t@sizes = {} if @sizes.nil?\n\t\t\t\t\tif @sizes[base.to_s].nil?\n\t\t\t\t\t\tsize = DateTime.parse(\"2000-01-01 00:00:00 +0000\")\n\t\t\t\t\t\tself.reservations(base).each do |reservation|\n\t\t\t\t\t\t\tif reservation.above_line?\n\t\t\t\t\t\t\t\tsize += reservation.size.seconds_since_midnight.seconds\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@sizes[base.to_s] = size\n\t\t\t\t\tend\n\t\t\t\t\treturn @sizes[base.to_s]\n\t\t\t\tend",
"def block_size\n self[:block_size]\n end",
"def block_size\n check_valid\n md.block_size\n end",
"def size(base = self.date_from)\n\t\t\t\t\treturn self.send(\"size_#{self.capacity_type.to_s}\", base)\n\t\t\t\tend",
"def block_size()\n # KB MB\n 4 * 1024 * 1024\n end",
"def block_size\n @disk.block_size\n end",
"def d_size\n @capacity / @blockSize\n end",
"def size\n @size ||= begin\n block_count * block_size unless block_count.nil? || block_size.nil?\n end\n end",
"def block_sizes\n unless defined?(@block_sizes) then\n @block_sizes = split_comma(@data[18]).collect { |x| x.to_i }\n end\n @block_sizes\n end",
"def size\n\t\t\treturn @m.capacity\n\t\tend",
"def size\n\t\treturn @m.capacity\n\tend",
"def size\n\t\t7500\n\tend",
"def size_used\n info[\"size-used\"]\n end",
"def size\n @size \n end",
"def size\n @size \n end",
"def size\n info[\"size\"]\n end",
"def get_size\n\t\treturn @size\n\tend",
"def size\n @info[:size]\n end",
"def sizes\n Vultr::Resource::Plan.new(@faraday)\n end",
"def part_size_in_bytes\n data.part_size_in_bytes\n end",
"def size\n\t\tstat[:size]\n\tend",
"def size\n\t\tstat[:size]\n\tend",
"def size\n @size.size\n end",
"def size_in_bytes\n to_i description['SizeInBytes']\n end",
"def size_mb \n return size / 1048576 # (1024 * 1024) \n end",
"def get_size\n\t\tend",
"def bytes_total\n blocks * block_size\n end",
"def byte_rate\n Rational(size,duration)\n end",
"def calculate_size\n @size = unit_count + holidays_count\n end",
"def size\n vm.hardware_profile.vm_size\n end",
"def d_size\n uint64(header, 'size') / @blockSize\n end",
"def get_size\n @monitors.length\n end",
"def item_size(item_type, item_param)\n return item_type.retrieve_height(item_param)\n end",
"def block_size\n\t\t25\n\tend",
"def size\n self[:size]\n end",
"def size_integer(base = self.date_from)\n\t\t\t\t\t@sizes = {} if @sizes.nil?\n\t\t\t\t\tif @sizes[base.to_s].nil?\n\t\t\t\t\t\tsize = 0\n\t\t\t\t\t\tself.reservations(base).each do |reservation|\n\t\t\t\t\t\t\tif reservation.above_line?\n\t\t\t\t\t\t\t\tsize += reservation.size\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t@sizes[base.to_s] = size\n\t\t\t\t\tend\n\t\t\t\t\treturn @sizes[base.to_s]\n\t\t\t\tend",
"def entry_size; BLOCK_SIZE; end",
"def entry_size; BLOCK_SIZE; end",
"def d_size\n @diskObj.info[:capacity]\n end",
"def total_size\n return @total_size if @total_size\n if @structure.instance_of? Array\n return 0 if @structure.empty?\n @total_size = strip(:size).flatten.inject { |sum, i| sum + i }\n else\n @total_size = size\n end\n end",
"def size\r\n @pack.size\r\n end",
"def block_size; end",
"def size\n @size ||= get_size(\"/yaml\")\n end",
"def size\n @gapi[\"size\"]\n end",
"def size\n return instance_get(:size)\n end",
"def part_size(total_size, part_size, offset)\n if offset + part_size > total_size\n total_size - offset\n else\n part_size\n end\n end",
"def size\n sync{@size[0]}\n end",
"def blksize() end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def length\n seconds.to_runtime\n end",
"def block_length()\n #This is a stub, used for indexing\n end",
"def block_length()\n #This is a stub, used for indexing\n end",
"def size\n @sizes ||= strip(:size)\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size\n @size\n end",
"def size_in_byte\n return @size_in_byte\n end",
"def total_size\n self._total_size(self, 0)\n end",
"def min_size\n @group.min_size\n end",
"def size_in_bytes\n ( file_length * 16 ) / 8\n end",
"def size\n @structure.size\n end",
"def size_in_bytes\n @grpc.size_bytes\n end",
"def size_mum_record\n 8\n end",
"def d_size\n @desc[:size].to_i\n end",
"def getFileSize()\n getRealFileSize(file) / MEGABYTE\n end",
"def mailbox_size\n @strategy.mailbox_size\n end",
"def size\n @size\n end",
"def block_count\n @disk.block_count - @data_start\n end",
"def item_size(item_type, item_param)\n return item_type.retrieve_width(item_param)\n end",
"def size\n Integer(metadata[\"size\"]) if metadata[\"size\"]\n end",
"def size\n @parts.size\n end",
"def duration_block_in_minutes\n 180\n end",
"def size\n @size\n end",
"def total_item_size\n return @total_item_size\n end",
"def block_size\n 1_048_576\n end",
"def getSize() \n @obj.getSize()\n end",
"def size\n stats[:dataSize]\n end"
] | [
"0.6852872",
"0.6738088",
"0.66986936",
"0.6645414",
"0.6619052",
"0.64590394",
"0.64569837",
"0.644224",
"0.6386727",
"0.6282654",
"0.6222423",
"0.6215486",
"0.6212822",
"0.616994",
"0.616994",
"0.6114185",
"0.61123925",
"0.61122954",
"0.6108511",
"0.6100553",
"0.6090947",
"0.6090947",
"0.6085288",
"0.6074602",
"0.6067066",
"0.6041949",
"0.6041905",
"0.60163766",
"0.600858",
"0.6007148",
"0.5994633",
"0.59923625",
"0.59815216",
"0.5966704",
"0.5957823",
"0.59420544",
"0.59327227",
"0.59327227",
"0.59210354",
"0.59198505",
"0.59162295",
"0.5916163",
"0.59121674",
"0.59090674",
"0.5903484",
"0.5902582",
"0.5902015",
"0.5892488",
"0.5887043",
"0.5887043",
"0.5887043",
"0.58822435",
"0.5877092",
"0.5877092",
"0.58709025",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58676744",
"0.58669156",
"0.58616537",
"0.58544534",
"0.5848507",
"0.5844345",
"0.58379775",
"0.5831568",
"0.5826711",
"0.5823165",
"0.58185124",
"0.5816144",
"0.5802777",
"0.579545",
"0.5792563",
"0.57921267",
"0.5788269",
"0.5783973",
"0.5782079",
"0.5760631",
"0.57592",
"0.574964"
] | 0.7701602 | 0 |
Fetch the timezone for the chosen office. While also memoizing the time_zone result as | def time_zone
return @time_zone_cache if @time_zone_cache
# Get the office id from the session json store
id = @session.store[:chosen_office_id]
office = Office
.where(business_id: @session.business_id, id: id)
.first
if office.present?
@time_zone_cache = office.time_zone
end
@time_zone_cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_zone\n @session.chosen_office.time_zone if @session.chosen_office.present?\n end",
"def timezone!\n if @timezone.nil?\n\n tz = get_country! \n # if country have only one zone then return that zone\n if tz.zones.count == 1\n @timezone = TZInfo::Timezone.get(tz.zones[0].name)\n else\n location_fetch! if @latitude.nil? or @longitude.nil?\n # some services returns timezone when fetch location \n tz_name! if @timezone.nil?\n end\n end\n return @timezone\n end",
"def time_zone_offset\n @session.chosen_office.time_zone_offset\n end",
"def timezone\n TimeZoneHelper.info_hash(tzinfo_tz, rails_tz)\n end",
"def tz_timezone ; timezone? ? TZInfo::Timezone.get(@timezone) : nil ; end",
"def tz\n # logger.debug(\"CHC: customer tz called from #{caller.join(\"\\n\")}\")\n if tzb = time_zone_binary\n tzb.to_r / MINS_PER_DAY\n else\n nil\n end\n end",
"def get_time_zone\n return nil if new_record?\n time_zone || lambda{\n _zone = nil\n _zone = GeoIP.new(Rails.root.join('lib', 'geoip_files', 'GeoLiteCity.dat')).city(last_sign_in_ip).try(:timezone) if last_sign_in_ip\n update_column(:time_zone, _zone) if _zone\n _zone\n }.call\n end",
"def tz\n time_zone_adjustment.to_r / (24 * 60)\n end",
"def tz\n time_zone_adjustment.to_r / (24 * 60)\n end",
"def time_zone\n addresses.primary.blank? || addresses.primary.time_zone.blank? ? nil : addresses.primary.time_zone\n end",
"def timezone\n @history.objects.find { |o| o.name == \"tz\" }.val\n end",
"def timezone\n Timezone.get_proxy(@identifier)\n end",
"def current_user_timezone\n app_get_geo_data_by_ip.try(:timezone) || \"America/La_Paz\"\n end",
"def request_time_zone\n facility_id = @request.dig(:facility, :parent_site_code)\n facility = Mobile::VA_FACILITIES_BY_ID[\"dfn-#{facility_id}\"]\n facility ? facility[:time_zone] : nil\n end",
"def find_timezone(city)\n @cities = City.all\n cityObject = @cities.where(name: city.downcase)\n\n timezone=nil\n cityObject.each do |c|\n timezone = c.timezone\n end\n\n return timezone\n end",
"def time_zone; end",
"def time_zone; end",
"def time_zone; end",
"def time_zone; end",
"def time_zone; end",
"def tz\n ActiveSupport::TimeZone.new timezone\n end",
"def time_in_zone\n # Time.zone should be UTC\n Time.zone.at((time+utc_offset)/1000)\n end",
"def get\n @timezone\n end",
"def get\n @timezone\n end",
"def timezone\n data[:timezone]\n end",
"def timezone\n return call('Bugzilla.tomezone')\n end",
"def time_zone\n return @time_zone\n end",
"def time_zone\n @time_zone\n end",
"def calculate(timezone); end",
"def time_zone\n ActiveSupport::TimeZone[\"Wellington\"]\n end",
"def get_timezones(user)\n res = user.session.request(\"CakeMail::API::ClassClient\", \"GetTimezones\", {})\n res['timezone']\n end",
"def time_zone=(_arg0); end",
"def time_zone=(_arg0); end",
"def in_zone(zone_name, &block)\n\n EtOrbi.class_eval do\n @local_tzone = nil\n @local_tzone_tz = nil\n @local_tzone_loaded_at = nil\n end\n\n prev_tz = ENV['TZ']\n\n if zone_name == :no_env_tz\n ENV.delete('TZ')\n elsif zone_name == nil\n ENV['TZ'] = EtOrbi.os_tz\n else\n zone_name = EtOrbi.to_windows_tz(zone_name) if Gem.win_platform?\n ENV['TZ'] = zone_name\n end\n\n block.call\n\nensure\n\n ENV['TZ'] = prev_tz\nend",
"def timezone\n @@tz || @@tz = TZInfo::Timezone.get(Time.now.zone)\n end",
"def timezone\r\n\t\t@usr_timezone\r\n\tend",
"def curr_date_in_timezone\n Time.now.getlocal(address_timezone_offset)\n end",
"def time_zone_for(tzinfo_zone_name)\n ActiveSupport::TimeZone::MAPPING.select {|k, v| v == tzinfo_zone_name}.keys.first\n end",
"def time_zone_name\n @time_zone_name\n end",
"def timezone(identifier); end",
"def timezone(identifier); end",
"def timezone(identifier); end",
"def set_time_zone\n # Make sure blank is always nil\n self.time_zone = nil if time_zone.blank?\n # If there are coordinates, use them to set the time zone, and reject\n # changes to the time zone if the coordinates have not changed\n if georeferenced?\n if coordinates_changed?\n lat = ( latitude_changed? || private_latitude.blank? ) ? latitude : private_latitude\n lng = ( longitude_changed? || private_longitude.blank? ) ? longitude : private_longitude\n self.time_zone = TimeZoneGeometry.time_zone_from_lat_lng( lat, lng ).try(:name)\n self.zic_time_zone = ActiveSupport::TimeZone::MAPPING[time_zone] unless time_zone.blank?\n elsif time_zone_changed?\n self.time_zone = time_zone_was\n self.zic_time_zone = zic_time_zone_was\n end\n end\n # Try to assign a reasonable default time zone\n if time_zone.blank?\n self.time_zone = nil\n self.time_zone ||= user.time_zone if user && !user.time_zone.blank?\n self.time_zone ||= Time.zone.try(:name) unless time_observed_at.blank?\n self.time_zone ||= 'UTC'\n end\n if !time_zone.blank? && !ActiveSupport::TimeZone::MAPPING[time_zone] && ActiveSupport::TimeZone[time_zone]\n # We've got a zic time zone\n self.zic_time_zone = time_zone\n self.time_zone = if rails_tz = ActiveSupport::TimeZone::MAPPING.invert[time_zone]\n rails_tz\n elsif ActiveSupport::TimeZone::INAT_MAPPING[time_zone]\n # Now we're in trouble, b/c the client specified a valid IANA time\n # zone that TZInfo knows about, but it's one Rails chooses to ignore\n # and doesn't provide any mapping for so... we have to map it\n ActiveSupport::TimeZone::INAT_MAPPING[time_zone]\n elsif time_zone =~ /^Etc\\//\n # If we don't have custom mapping and there's no fancy Rails wrapper\n # and it's one of these weird oceanic Etc zones, use that as the\n # time_zone. Rails can use that to cast times into other zones, even\n # if it doesn't recognize it as its own zone\n time_zone\n else\n ActiveSupport::TimeZone[time_zone].name\n end\n end\n self.time_zone ||= user.time_zone if user && !user.time_zone.blank?\n self.zic_time_zone ||= ActiveSupport::TimeZone::MAPPING[time_zone] unless time_zone.blank?\n if !zic_time_zone.blank? && ActiveSupport::TimeZone::MAPPING[zic_time_zone] && ActiveSupport::TimeZone[zic_time_zone]\n self.zic_time_zone = ActiveSupport::TimeZone::MAPPING[zic_time_zone]\n end\n true\n end",
"def timezone\n @attributes.fetch('timezone', nil)\n end",
"def timezone\n ret = {}\n if logged_in?\n puts 'SET TIMEZONE ' + params.inspect\n tz = ActiveSupport::TimeZone[params[:offset].to_i]\n if tz\n puts 'tz=' + tz.name\n current_user.time_zone = tz.name\n current_user.save(:dirty=>true)\n ret[:timezone] = tz.name\n end\n end\n render :json=>ret\n end",
"def user_timezone\n return @user_timezone\n end",
"def timeZone(fileDateTimeOriginal, timeZonesFile )\n # theTimeAhead = \"2050-01-01T00:00:00Z\"\n # puts \"#{lineNum}. timeZones: #{timeZones}.\"\n timeZones = YAML.load(File.read(timeZonesFile)) # should we do this once somewhere else? Let's try that in this new version\n # puts \"#{lineNum}. timeZones.keys: #{timeZones.keys}.\"\n i = timeZones.keys.max # e.g. 505\n j = timeZones.keys.min # e.g. 488\n while i > j # make sure I really get to the end \n theTime = timeZones[i][\"timeGMT\"]\n # puts \"\\n#{lineNum}. (last entry in timeZonesFile) i: #{i}. theTime (of the last entry in GMT): #{theTime}. theTime.class: #{theTime.class}\" # i: 502. theTime: 2011-06-29T01-00-00Z. theTime.class: String\n theTime = Time.parse(theTime) # class: time Wed Jun 29 00:00:00 -0700 2011. Time.parse only seems to do the date part\n # puts \"\\n#{lineNum}. #{i}. fileDateTimeOriginal: #{fileDateTimeOriginal}. theTime (in local time): #{theTime}. fileDateTimeOriginal.class: #{fileDateTimeOriginal.class}. theTime.class: #{theTime.class}\"\n # puts \"Note that these dates are supposed to be UTC, but are getting my local time zone attached.\"\n if fileDateTimeOriginal.to_s > theTime.to_s # What if neither was to_s? TODO\n theTimeZone = timeZones[i][\"zone\"]\n # puts \"#{lineNum}. #{i}. fileDateTimeOriginal: #{fileDateTimeOriginal} fileDateTimeOriginal.class: #{fileDateTimeOriginal.class}. theTimeZone: #{theTimeZone}.\"\n return theTimeZone\n else\n i= (i.to_i-1).to_s\n end\n end # loop\n # theTimeZone = -2 # Was changed on MBP, don't know if needed there or it was a one off\n # puts \"#{lineNum}. #{i}. fileDateTimeOriginal: #{fileDateTimeOriginal} fileDateTimeOriginal.class: #{fileDateTimeOriginal.class}. theTimeZone: #{theTimeZone}. \" return theTimeZone\nend",
"def get_user_timezone(user_id)\n user_timezone = USER_TIMEZONE[user_id: user_id]\n return TZInfo::Timezone.get('Etc/UTC') if user_timezone == nil\n\n begin\n user_timezone = user_timezone[:timezone]\n user_timezone = user_timezone.nil? ? \"NULL\" : user_timezone\n return TZInfo::Timezone.get(user_timezone)\n rescue => e\n return TzInfo::Timezone.get('Etc/UTC')\n end\n end",
"def time_zone\n @attributes[:time_zone]\n end",
"def time_zone\n @attributes[:time_zone]\n end",
"def time_zone\n \"Mountain Time (US & Canada)\"\n #{}\"Eastern Time (US & Canada)\"\n end",
"def zone\n Thread.current[:time_zone] || zone_default\n end",
"def local_time_zone\n\tzone_name = ActiveSupport::TimeZone::MAPPING.keys.find do |name|\n\t ActiveSupport::TimeZone[name].utc_offset == Time.now.utc_offset\n\tend\n\tActiveSupport::TimeZone.find_tzinfo(zone_name).identifier\n end",
"def timezone_enum\n TZInfo::Country.get('US').zones.map{|tz|tz.name}\n end",
"def in_time_zone(tz)\n\n tz_offset = Schedule::Offset.new(Time.now.in_time_zone(tz))\n utc_offset = Schedule::Offset.new(TIMEZONE_ABBREVIATION_NAMES[@timezone] ? Time.now.in_time_zone(TIMEZONE_ABBREVIATION_NAMES[@timezone]) : @timezone, true)\n\n offset = utc_offset\n minute = @minute\n hour = @hour\n day = @day\n\n # This loop firstly changes the minute, hour, and day values to UTC,\n # then changes them from UTC to the timezone in tz\n\n 2.times do\n\n minute += offset.minute\n # Check if the minute value is impossible, i.e. less than 0 or more than 59\n # If so tick increment or decrement the hour value\n if minute < 0\n hour -= 1\n minute = 60 - (-minute)\n elsif minute >= 60\n hour += 1\n minute = minute - 60\n end\n\n hour += offset.hour\n\n if hour < 0\n day -= 1\n hour = 24 - (-hour)\n elsif hour >= 24\n day += 1\n hour = hour - 24\n end\n\n offset = tz_offset\n end\n\n return WeekTime.new(day, hour, minute, second, offset.to_s)\n end",
"def time_zone(latitude, longitude)\n get_lookup(:time_zone).search(latitude, longitude) if valid_input?(latitude, longitude)\n end",
"def browser_timezone\n return nil if cookies[:tzoffset].blank?\n @browser_timezone ||= begin\n min = cookies[:tzoffset].to_i\n TimeZone[-min.minutes]\n end\n end",
"def zone\n if @_utc then\n return \"UTC\"\n else\n return self.to_a[IDX_ZONE]\n end\n end",
"def timezone\n @timezone || Sequel.database_timezone\n end",
"def v_time_zone_inutilisee\n @time_zone ||= (self.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.time_zone])\n end",
"def data_timezone(identifier); end",
"def data_timezone(identifier); end",
"def location_preference_zone\n settings.fetch(:location_preference, {})[:zone]\n end",
"def linked_timezone(identifier); end",
"def linked_timezone(identifier); end",
"def linked_timezone(identifier); end",
"def linked_timezone(identifier); end",
"def timezone(opts = {})\n logger = opts[:logger]\n\n tz_string = @redis.get(\"contact_tz:#{self.id}\")\n tz = opts[:default] if (tz_string.nil? || tz_string.empty?)\n\n if tz.nil?\n begin\n tz = ActiveSupport::TimeZone.new(tz_string)\n rescue ArgumentError\n if logger\n logger.warn(\"Invalid timezone string set for contact #{self.id} or TZ (#{tz_string}), using 'UTC'!\")\n end\n tz = ActiveSupport::TimeZone.new('UTC')\n end\n end\n tz\n end",
"def set_timezone\n offset = [Time.now.beginning_of_year.utc_offset, Time.now.beginning_of_year.change(month: 7).utc_offset].min\n offset *= 3600 if offset.abs < 13\n Time.zone = ActiveSupport::TimeZone.all.select { |zone| zone.utc_offset == offset }.first\nend",
"def time_zone(query)\n response = prepare_response(make_url(:address => \"#{query}\").open('User-Agent' => USER_AGENT).read)\n check_error(response)\n return parse_time_zone(response)\n rescue OpenURI::HTTPError => e\n check_error(prepare_response(e.io.read))\n raise\n end",
"def time_zone\n @options[:use_default_time_zone] ? Time.zone_default : Time.zone\n end",
"def add_timezone\n res = City.get_weather(name)\n\n begin\n self.timezone = Timezone.lookup(res['coord']['lat'], res['coord']['lon']).name\n rescue Timezone::Error::Base => e\n puts \"Timezone Error: #{e.message}\"\n end\n end",
"def time\n \tself[:time].try(:in_time_zone, \"Eastern Time (US & Canada)\")\n end",
"def initialize_timezone\n # my_ip = \"93.172.139.218\" # external IP when using my laptop \n my_ip = request.remote_ip\n my_ip_a = my_ip.split(\".\")\n \n my_ip_as_number = my_ip_a[3].to_i + \n (my_ip_a[2].to_i * 256) + \n (my_ip_a[1].to_i * 256 * 256) +\n (my_ip_a[0].to_i * 256 * 256 * 256)\n \n @ip_to_country = IpToCountry.find_by_sql(\"SELECT \" + \n \"ctry, cntry, country \" +\n \"FROM \" + \n \"ip_to_countries \" + \n \"WHERE \" + \n my_ip_as_number.to_s + \" >= ip_from \" +\n \"and \" + my_ip_as_number.to_s + \" <= ip_to\")\n \n if @ip_to_country\n @ip_to_country = @ip_to_country[0]\n session[:language] = 2 if @ip_to_country && @ip_to_country['ctry'] == \"IL\"\n end\n \n end",
"def find_zoneinfo_dir\n alternate_iso3166_tab_path = self.class.alternate_iso3166_tab_search_path.detect do |path|\n File.file?(path)\n end\n \n self.class.search_path.each do |path|\n # Try without the alternate_iso3166_tab_path first.\n iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(path) \n return path, iso3166_tab_path, zone_tab_path if iso3166_tab_path && zone_tab_path\n \n if alternate_iso3166_tab_path\n iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(path, alternate_iso3166_tab_path) \n return path, iso3166_tab_path, zone_tab_path if iso3166_tab_path && zone_tab_path\n end\n end\n \n # Not found.\n nil\n end",
"def to_zone(aHours=nil)\n\t\taHours ||= utc_offset/3600.0\n\t\tself.in_time_zone(aHours)+self.utc_offset-aHours.to_i.hours\n\tend",
"def timezones\n @timezones.freeze\n end",
"def time_zone=(value)\n if value.is_a? ActiveSupport::TimeZone\n super\n else\n zone = ::Time.find_zone(value) # nil if can't find time zone\n super zone\n end\n end",
"def zone_info\n @info.zones\n end",
"def find_tz(lat, lon)\n city_index = @tree.nearest(lat, lon)\n @cities.at(city_index)\n end",
"def daylight_offset\n return @daylight_offset\n end",
"def timezone(input)\n if Time.parse(input.to_s).isdst\n case input.zone\n when \"-04:00\" then \"EDT\"\n when \"-05:00\" then \"CDT\"\n when \"-06:00\" then \"MDT\"\n when \"-07:00\" then \"PDT\"\n else input.zone\n end\n else\n case input.zone\n when \"-05:00\" then \"EST\"\n when \"-06:00\" then \"CST\"\n when \"-07:00\" then \"MST\"\n when \"-08:00\" then \"PST\"\n else input.zone\n end\n end\n end",
"def time_zone_for_location(location)\n time_zone = @time_zones.find do |country, region, zone|\n if location[:country_code] == 'US' and country == 'US' and region == location[:region]\n true\n elsif country != 'US' and location[:country_code] == country\n true\n end\n end\n \n { :country_code => time_zone[0], :region => time_zone[1], :country_name => time_zone[2] }\n end",
"def utc_offset() end",
"def convert_local_time_to_eastern_timezone(time)\n # Reach through hearing_day for the regional_office timezone\n ro_timezone = if hearing_day.central_office?\n \"America/New_York\"\n else\n RegionalOffice.find!(hearing_day.regional_office).timezone\n end\n\n # Get the timezone abbreviation like \"EDT\", \"PDT\", from the long timezone\n ro_timezone_abbreviation = Time.zone.now.in_time_zone(ro_timezone).strftime(\"%Z\")\n\n # Parse the local time string (like \"09:00 PDT\"), then produce a result in EDT like \"11:30 EDT\"\n Time.zone.parse(\"#{time} #{ro_timezone_abbreviation}\").in_time_zone(\"America/New_York\").strftime(\"%-I:%M %p %Z\")\n end",
"def availability_zone\n @dbi.availability_zone\n end",
"def availability_zone\n @dbi.availability_zone\n end",
"def timezones\n subcomponents[\"VTIMEZONE\"]\n end",
"def availability_zone\n data.availability_zone\n end",
"def set_timezone\n loc = Location.find(self.location_id)\n self.time_zone, self.localGMToffset = loc.time_zone, loc.localGMToffset\n end",
"def to_zone(aHours=nil)\n\t\t\taHours ||= utc_offset/3600.0\n\t\t\tself.in_time_zone(aHours)+self.utc_offset-aHours.to_i.hours\n\t\tend",
"def canonical_zone\n real_timezone.canonical_zone\n end",
"def set_timezone(force = false)\n if self.current_sign_in_ip && (force || self.time_zone.blank?)\n coordinates = Geocoder.search(self.current_sign_in_ip).first.coordinates\n timezone = Timezone::Zone.new(latlon: coordinates) unless [0.0, 0.0]\n self.update_attribute(:time_zone, timezone) if timezone\n end\n end",
"def time_zone\n super\n end",
"def availability_zone\n data[:availability_zone]\n end",
"def get country_code, city, region=\"\", latitude=nil, longitude=nil\n begin\n m = self.new country_code, city, region, latitude, longitude\n m.timezone\n rescue Exception \n nil\n end\n end",
"def availability_zones\n end",
"def availability_zones\n end",
"def time\n Time.zone = self.time_zone\n Time.zone\n end",
"def local_timezone\n tzname = Time.new.zone\n q, r = Time.new.utc_offset.divmod(3600)\n sign = (q < 0) ? '-' : '+'\n tzoffset = sign + \"%02d\" % q.abs.to_s + ':' + r.to_f.div(60).to_s\n \"#{tzname} (UTC#{tzoffset})\"\n end"
] | [
"0.750561",
"0.7415016",
"0.73211753",
"0.68303543",
"0.67889184",
"0.67746866",
"0.6667891",
"0.6656611",
"0.6656611",
"0.65952057",
"0.6561896",
"0.6533011",
"0.64766604",
"0.64741546",
"0.646192",
"0.6433686",
"0.6433686",
"0.6433686",
"0.6433686",
"0.6433686",
"0.64171845",
"0.6412741",
"0.6402361",
"0.6402361",
"0.6379385",
"0.6374292",
"0.63727266",
"0.633077",
"0.6325484",
"0.627452",
"0.62467086",
"0.62448466",
"0.62448466",
"0.62287843",
"0.6209707",
"0.62031806",
"0.61988026",
"0.6195009",
"0.61569166",
"0.6142802",
"0.6142802",
"0.6142802",
"0.6132595",
"0.6103545",
"0.60872954",
"0.6034895",
"0.6015051",
"0.6008712",
"0.59883374",
"0.59883374",
"0.5981763",
"0.5976036",
"0.59529096",
"0.59521204",
"0.5922118",
"0.5913622",
"0.5876873",
"0.5873794",
"0.58727014",
"0.5856568",
"0.5823827",
"0.5823827",
"0.580421",
"0.58035904",
"0.58035904",
"0.58035904",
"0.58035904",
"0.5799233",
"0.57680756",
"0.57576406",
"0.5754837",
"0.57408977",
"0.5737673",
"0.5730542",
"0.5709548",
"0.5695022",
"0.568626",
"0.56776917",
"0.5668362",
"0.56672627",
"0.5665875",
"0.56618947",
"0.5657455",
"0.5649651",
"0.5630851",
"0.56025696",
"0.56025696",
"0.55776465",
"0.5575474",
"0.55456734",
"0.55423975",
"0.55089974",
"0.55041885",
"0.5502715",
"0.54946834",
"0.5493053",
"0.5490982",
"0.5490982",
"0.54837734",
"0.54828924"
] | 0.8218083 | 0 |
Generate a random range to start with. | def random_range_start
base.to_datetime + (rand(1..30) * 30).minutes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rand_in_range(from, to); end",
"def sample_range(range, seed=nil)\n srand seed if seed\n rand * (range.end - range.begin) + range.begin\n end",
"def random_within_range\n\t\t\trand(self.start_num..self.end_num)\n\t\tend",
"def rand_range(min,max)\n return min + (max-min)*rand\nend",
"def random_range(low, high)\n return random(high - low) + low\nend",
"def random_on_interval(min, max)\n min + @prng.rand(max - min)\n end",
"def rand_in_range(from, to)\n rand * (to - from) + from\nend",
"def random(range)\n return rand(range + 1)\nend",
"def get_rand range\n\t\t@random_number = rand(range)\n\tend",
"def lat_range (min, max)\n lat = rand(0..(max - min)) + min\n lat\nend",
"def uniform_int_range(lo, hi)\n lo + rand(hi -lo)\nend",
"def randomf_range(low, high)\n return rand * (high - low) + low\nend",
"def long_range (min, max)\n long = rand(0..(max - min)) + min\n long\nend",
"def rand_between(min, max)\n rand(max - min + 1) + min\nend",
"def random low, high\n $lib_prng.range low, high\nend",
"def intervalRand(min, max)\r\n\treturn rand(max-min)+min\r\nend",
"def get_random(min, max)\r\n rand(min..max)\r\n end",
"def rand_in_bounds(min, max)\n return min + (max-min)*rand()\nend",
"def get_rng\n return @lower + (@upper - @lower) * Kernel.rand\n end",
"def rand_between(low, high)\n return low + rand(high - low)\n end",
"def calc_rand_range\n range = Damage_Settings::RANDOM_RANGE\n rand(range)-range/2\n end",
"def between(from: 1.00, to: 5000.00)\n Faker::Base.rand_in_range(from, to)\n end",
"def random_number(min, max)\n rand(max-min+1)+min\n end",
"def get_random_span(from, to)\n rand(to - from) + from\nend",
"def rand_num(range)\n num = @rng.rand(range) + 1\n num\n end",
"def randomf(range)\n return rand * range\nend",
"def randr(min, max)\n rand(max - min + 1) + min\nend",
"def random_range_end(start)\n start + (rand(1..5) * 30).minutes\n end",
"def roll(min, max)\n return rand(min..max)\nend",
"def random_number(lower_bound, upper_bound)\r\n check_bounds(lower_bound, upper_bound)\r\n return Random.rand(lower_bound..upper_bound)\r\n end",
"def rand_from_range(subject)\n range = get_const(subject, :range)\n range.to_a[Random.new.rand(range.count)]\n end",
"def usw_random(max=-1, min=0)\n Sass::Script::Number.new( max.to_i < 0 ? rand() : rand(min.to_i .. max.to_i ))\n end",
"def generate_random_x\n max_x = @radius\n random_range(-max_x, max_x)\n end",
"def new_random (min, max)\n\treturn (rand * (max-min) + min)\nend",
"def random(min=0, max=0)\n if(min==0 && max==0)\n rand\n else\n min + rand(1+max-min)\n end\nend",
"def sample_index (len)\n # ... excludes the top of the range\n @@random.rand(0...len)\n end",
"def generate_random_string(min, range = 0)\n return (0...min).map { (65 + rand(26)).chr }.join if range == 0\n return (0...(min + rand(range + 1))).map { (65 + rand(26)).chr }.join\n end",
"def get_random floor, ceiling\n rand(floor..ceiling)\nend",
"def number_generator\n rand(1..20)\n end",
"def next\n Time.now + @min + Random.rand(@max - @min)\n end",
"def random_num(min, max)\n rand(max - min + 1) + min\nend",
"def get_start_date\n \n start_of_date_range = \"2005/01/01\" #YYYY/MM/DD\n end_of_date_range = \"2013/01/01\" #YYYY/MM/DD\n #array of all dates in range\n date_range = (Date.parse(start_of_date_range)..Date.parse(end_of_date_range)).to_a\n #pulls out a random date based on the Kernel randomizer going now higher than the array length\n date_range[Kernel.rand(date_range.length-1)].to_s\n \nend",
"def random_num(min, max)\n rand(max - min + 1) + min\nend",
"def rand_start\n @dna = [0] * @target.length\n @dna.map! { |i| @@dna_decoder.keys.sample }\n end",
"def random_num_generator\n return rand(1..100)\nend",
"def random_num_generator\n return rand(1..100)\nend",
"def pick_range(r = 'A'..'Z')\n r.to_a.sample\n end",
"def pick_range(r = 'A'..'Z')\n r.to_a.sample\n end",
"def random_coord(min, max)\n rand * (max-min) + min\nend",
"def rand_in(min, max)\n (rand() * (max - min)) + min\nend",
"def dice(minimum, maximum)\n rand(minimum..maximum)\nend",
"def boundedRand(rand, lowerBound, upperBound)\n proc {\n begin\n\tr=rand.call()\n end until (r>lowerBound) and (r<upperBound)\n r\n }\nend",
"def gen_num\n rand(1..100)\nend",
"def random_time_range(range)\n min = time_to_float(range.min)\n max = time_to_float(range.max)\n time = Time.at(random(min..max))\n\n if defined?(DateTime) && range.min.is_a?(DateTime)\n time = time.to_datetime\n elsif range.min.is_a?(Date)\n time = time.to_date\n end\n\n return time\n end",
"def simulate_roll(min = 1, max = 7)\n rand(max) + min\nend",
"def year(year_range = (1930..1950))\n rand(year_range)\nend",
"def rand_time(from, to=Time.now)\n Time.at(rand(from.to_f..to.to_f))\nend",
"def random_value_between(low, andValue: high)\n rand * (high - low) + low\n end",
"def kick\n rng.rand(value_range)\n end",
"def generate_random_number\n (1..10).to_a.sample\nend",
"def generate_secret_number(range_array)\n\t\trange_array.sample\n\tend",
"def rng\n \"#{first}..#{last}\"\n end",
"def random_time_range\n i = Array((3..20)).sample\n [(Date.current - i.months).iso8601, (Date.current + i.months).iso8601]\n end",
"def gen_date(from=0.0, to=Time.now)\n Time.at(from + rand * (to.to_f - from.to_f))\nend",
"def rand_range(name, range)\n @manager.secrets.set(name, rand(range), @node[:environment])\n end",
"def generateFirepower()\n return (rand(2.0..4.0))\nend",
"def rand(max=0) end",
"def roll\n # code goes here\n range = rand(6) + 1\n \n range = [1,2,3,4,5,6]\n result = range[rand(6)]\n result \nend",
"def initialize\n @offset = rand(0...BOUNDARY)\n end",
"def random_number\n rand 0..20\nend",
"def random_number\n rand(0..20)\n end",
"def range_start; range.first; end",
"def random\n 1 + (10 * rand(0))\n end",
"def simulate_roll(min = 1, max = 5)\n rand(max)\nend",
"def rep_range\n reps = nil\n if movement[:rep_range] == \"High\"\n reps = rand(30..50)\n elsif movement[:rep_range] == \"Moderate\"\n reps = rand(11..29)\n else\n reps = rand(3..10)\n end\n end",
"def n_generator\n number = rand(10..30)\n end",
"def random_age\n rand(20...200)\nend",
"def random_number(seed, range)\n seed = seed.to_i\n return nil if seed <= 0\n rng2 = Random.new(seed)\n num = rng2.rand(range) + 1\n num\n end",
"def price_setter(min, max)\n price_range = []\n (min..max).step(5) { |x| price_range.push(x) }\n return price_range.sample\nend",
"def getRand(a, b)\n return Random.rand(a...b)\nend",
"def generate_attr(desired_value)\n min = desired_value - 2\n min = 0 if min < 0\n max = desired_value + 2\n max = 0 if max < 0\n rand(min..max)\n end",
"def grab_x_loc\n rand 100\n end",
"def value_in_range(range)\n case range.first\n when Integer then number_in_range(range)\n when Time then time_in_range(range)\n when Date then date_in_range(range)\n else range.to_a.rand\n end\n end",
"def random_number\n rand(1..20)\nend",
"def generate\n (0..30).sort{ rand() } .take(@conf)\n end",
"def gen\n (x=rand)>0.5 ? x : (x < rand/2.0) ? 1.0 - x : x\nend",
"def rand_dist(min, max)\n rand(min.to_f..max.to_f).round(1)\nend",
"def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end",
"def make_rand\n Random.new_seed\n return Random.new\n end",
"def age\n n = rand(55..120)\nend",
"def get_rng \n end",
"def range\n @range ||= set_range\n end",
"def start\n @range.start\n end",
"def roll\n rand(1...7)\nend",
"def rand(max)\n max-1\nend",
"def set_random_number\n @lower = Number.find(params[:id]).lower_bound\n @upper = Number.find(params[:id]).upper_bound\n @random_number = rand(@lower..@upper)\n end",
"def sample n=1\n @rng.fill(n)\n end",
"def rng(m, low, high)\n\n # cf. the parameter info at http://www.brighton-webs.co.uk/distributions/triangular.asp\n return nil unless high > low && m > low && m < high\n\n u = rand\n\n if u <= (m-low)/(high-low)\n r = low+ Math.sqrt(u*(high-low)*(m-low))\n else\n r = high - Math.sqrt((1.0-u)*(high-low)*(high-m))\n end\n\nend",
"def sample\n return self if size < 300\n self[0..99] + values_at(*(Array.new(100) {|i| Kernel.rand(size-200)+100}.sort.uniq)) + self[-100..-1]\n end",
"def time_rand(from = 0.0, to = Time.now)\n Time.at(from + rand * (to.to_f - from.to_f))\nend"
] | [
"0.8118395",
"0.80711424",
"0.8059874",
"0.7765297",
"0.7765144",
"0.76988673",
"0.76519865",
"0.75728106",
"0.7521159",
"0.7463479",
"0.7462913",
"0.7447883",
"0.73770154",
"0.7324872",
"0.7288438",
"0.7275461",
"0.7215375",
"0.71746296",
"0.7169924",
"0.7105601",
"0.70365477",
"0.701346",
"0.6974579",
"0.6952049",
"0.693044",
"0.6911465",
"0.6893836",
"0.68748134",
"0.6802816",
"0.6798987",
"0.6792388",
"0.67814124",
"0.67478156",
"0.67433876",
"0.6714741",
"0.6699551",
"0.66096133",
"0.65989494",
"0.6579438",
"0.6530238",
"0.6516716",
"0.6508594",
"0.64938736",
"0.6470063",
"0.6469834",
"0.6469834",
"0.6452881",
"0.6452881",
"0.644876",
"0.6444197",
"0.6441981",
"0.64153385",
"0.64080524",
"0.639932",
"0.63633716",
"0.6362457",
"0.6356322",
"0.6351678",
"0.6283029",
"0.6277608",
"0.6256654",
"0.6248123",
"0.6244524",
"0.62152034",
"0.6214335",
"0.61974555",
"0.6173449",
"0.61582714",
"0.61160904",
"0.6110635",
"0.6102733",
"0.61025447",
"0.60943824",
"0.6073534",
"0.6066874",
"0.6065189",
"0.6057715",
"0.6053324",
"0.6048093",
"0.6043651",
"0.604073",
"0.60225916",
"0.6011243",
"0.60066354",
"0.59946275",
"0.5984991",
"0.5959338",
"0.5923597",
"0.5911951",
"0.59018904",
"0.5888579",
"0.5887135",
"0.58768666",
"0.5873535",
"0.5869346",
"0.58679426",
"0.5862193",
"0.5857735",
"0.5857441",
"0.585502"
] | 0.7592986 | 7 |
Add a random amount of blocks (30min per block) to the end of an existing start. | def random_range_end(start)
start + (rand(1..5) * 30).minutes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_range_start\n base.to_datetime + (rand(1..30) * 30).minutes\n end",
"def add_block block\n block.at self.length\n @blocks << block\n end",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n @single_block += words\n end",
"def add_for_block_size(words)\n # If we're running :truncate_all, then just append the block for this\n # document and return\n if last_block == :truncate_all\n if block_list.empty?\n name = I18n.t('lib.frequency.block_size_dataset',\n num: block_list.size + 1, size: block_size)\n block_list.push(Block.new(words: words[0...block_size],\n name: name))\n end\n return\n end\n\n # Make the first block, if needed\n unless block_list.last\n block_list.push(\n Block.new(\n words: [],\n name: I18n.t('lib.frequency.block_size_dataset',\n num: 1, size: block_size)\n )\n )\n end\n\n # Fill up the last block\n current_left = block_size - block_list.last.words.size\n if current_left.positive?\n block_list.last.words.concat(words.shift(current_left))\n end\n\n # Bail if there weren't enough words in the document to finish that block\n return if block_list.last.words.size < block_size\n\n # Turn the remaining words into blocks and append\n words.in_groups_of(block_size, false).each do |b|\n name = I18n.t('lib.frequency.block_size_dataset',\n num: block_list.size + 1, size: block_size)\n block_list.push(Block.new(words: b, name: name))\n end\n end",
"def add_for_block_size(words)\n # If we're running :truncate_all, then just append the block for this\n # document and return\n if @last_block == :truncate_all\n if @blocks.empty?\n name = I18n.t('lib.frequency.block_size_dataset',\n num: @blocks.size + 1, size: @block_size)\n @blocks << Block.new(words[0...@block_size], name)\n end\n return\n end\n\n # Make the first block, if needed\n unless @blocks.last\n @blocks << Block.new([], I18n.t('lib.frequency.block_size_dataset',\n num: 1, size: @block_size))\n end\n\n # Fill up the last block\n current_left = @block_size - @blocks.last.words.size\n @blocks.last.words += words.shift(current_left) if current_left > 0\n\n # Bail if there weren't enough words in the document to finish that block\n return if @blocks.last.words.size < @block_size\n\n # Turn the remaining words into blocks and append\n words.in_groups_of(@block_size, false).each do |b|\n name = I18n.t('lib.frequency.block_size_dataset',\n num: @blocks.size + 1, size: @block_size)\n @blocks << Block.new(b, name)\n end\n end",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n single_block.concat(words)\n end",
"def create_blocks prev_hash, n, opts = {}\n interval = opts[:interval] || 600\n time = opts[:time] || Time.now.to_i\n bits = opts[:bits] || 553713663\n block = @store.get_block(prev_hash)\n n.times do |i|\n block = create_block block.hash, true, [], @key, 50e8, {\n time: time += interval, bits: bits }\n # block = @store.get_block(block.hash)\n # puts \"#{i} #{block.hash[0..8]} #{block.prev_block.reverse_hth[0..8]} #{Time.at(block.time).strftime('%Y-%m-%d %H:%M:%S')} c: #{block.chain} b: #{block.bits} n: #{block.nonce} w: #{block.work}\"\n end\n block\nend",
"def insert_mines\n @random_spots = []\n @num_of_mine.times do\n\n while @random_spots.length < @num_of_mine\n rand_num = Random.rand(@num_of_tiles**2)\n\n if !@random_spots.include?(rand_num)\n @random_spots << rand_num\n end\n\n end\n end\nend",
"def burst!(times)\n @burst_length += times\n end",
"def generate_random_block_id\n return ((0..9).to_a.sample(5)).join\n end",
"def random_spawn_countdown minimum\n 10.randomize(:ratio, :sign).to_i + 60\n end",
"def generate_blocks(blocks_array)\r\n size=rand(1..3)\r\n index=0\r\n while blocks_array.length<size\r\n case rand(4)\r\n when 0\r\n blocks_array[index]=Obstacle.new(\"media/man.png\", :man)\r\n when 1\r\n blocks_array[index]=Obstacle.new(\"media/tree.png\", :tree)\r\n when 2\r\n blocks_array[index]=Obstacle.new(\"media/bird.png\", :bird)\r\n when 3\r\n blocks_array[index]=Obstacle.new(\"media/bird2.png\", :bird2)\r\n end\r\n\r\n index+=1\r\n end\r\n end",
"def makeDurationBlockRel(relname, var_to_copy, binding, block_dur, skip_blocks)\n block_var = createNewVariable(relname + \"_blocks\", \"block_num\")\n rel_var = make_rel(relname, var_to_copy, 0)\n\n var_to_copy = getVariable(var_to_copy)\n binding = getVariable(binding)\n\n\n block_dur = block_dur * 1000 # Convert to milliseconds\n block_num = 1\n for bindcell in binding.cells\n cell_dur = bindcell.offset - bindcell.onset\n if cell_dur <= block_dur\n cell = block_var.make_new_cell()\n cell.change_arg(\"block_num\", block_num.to_s)\n cell.change_arg(\"onset\", bindcell.onset)\n cell.change_arg(\"offset\", bindcell.offset)\n block_num += 1\n else\n num_possible_blocks = cell_dur / block_dur #Integer division\n if num_possible_blocks > 0\n for i in 0..num_possible_blocks\n if i % skip_blocks == 0\n cell = block_var.make_new_cell()\n cell.change_arg(\"block_num\", block_num.to_s)\n cell.change_arg(\"onset\", bindcell.onset + i * block_dur)\n if bindcell.onset + (i + 1) * block_dur <= bindcell.offset\n cell.change_arg(\"offset\", bindcell.onset + (i + 1) * block_dur)\n else\n cell.change_arg(\"offset\", bindcell.offset)\n end\n block_num += 1\n end\n end\n end\n end\n end\n setVariable(relname + \"_blocks\", block_var)\nend",
"def create_block_of_rooms(start_date, end_date, discounted_rate)\n dates = date_range(start_date, end_date)\n new_block = RoomBlock.new(start_date, end_date, room_cost: discounted_rate)\n new_block.id = assign_block_id\n\n num_of_rooms = 0\n @rooms.each do |room|\n if is_available?(room, dates) && is_not_blocked?(room, dates)\n new_block.add_room(room)\n num_of_rooms += 1\n end\n if num_of_rooms == 5\n break\n end\n end\n\n @room_blocks << new_block\n\n return new_block\n end",
"def create_random_list(limit)\n limit.times do\n add(rand(10))\n end\n end",
"def create_a_block(group_name, num_of_rooms: 5, start_date: Date.today, end_date: Date.today + 2, room_rate: 175)\n if num_of_rooms > 5\n raise ArgumentError.new(\"Only 5 rooms per block.\")\n end\n\n list = Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)\n\n if list.length < num_of_rooms\n raise ArgumentError.new(\"Not enough rooms available. Only #{list.length} room(s) available.\")\n else\n final_list = list[0...num_of_rooms]\n end\n\n new_block = Block.new(group_name, final_list, start_date: start_date, end_date: end_date, room_rate: room_rate)\n\n blocks << new_block\n\n final_list.each do |room_number|\n room = Room.find_room(rooms, room_number)\n room.change_status_of_room(rooms, room_number, start_date: start_date, end_date: end_date)\n end\n\n return new_block\n end",
"def create_blocks(count)\n begin\n create_blocks! count\n rescue\n nil\n end\n end",
"def no_of_blocks\n @highlighted_blocks = \"\"\n blocks = Random.rand(5) + 1\n blocks.times {|count|\n row = Random.rand(5)\n column = Random.rand(5)\n @highlighted_blocks << \"#button_#{row}_#{column} \"\n }\n end",
"def add_blocks_to_schedule(time_blocks, schedule, recurring)\n time_blocks.each do |block|\n day_of_week = block.split(\"_\")[0]\n time = block.split(\"_\")[1]\n start_time = Time.utc(\"2011\", nil, nil, time.split(\" - \")[0])\n end_time = Time.utc(\"2011\", nil, nil, time.split(\" - \")[1])\n \n if Day.exists?(day_of_week, schedule.id)\n day = Day.where(:name => day_of_week, :schedule_id => schedule.id).first\n else\n day = Day.new(:name => day_of_week, :schedule_id => schedule.id)\n day.save\n end\n \n if !TimeBlock.exists?(start_time, end_time, day.id, recurring)\n time_block = TimeBlock.new(:start_time => start_time, :end_time => end_time, :day_id => day.id, :recurring => recurring)\n time_block.save\n end\n end\n end",
"def create_blocks!(count)\n begin\n result = []\n 1.upto count do |i|\n result << create_block\n end\n rescue\n result.each(&:destroy)\n raise\n end\n end",
"def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end",
"def next_duration\n @durations.empty? ? rand(20) : @durations.shift\n end",
"def random_blocks(length, height, odds, kind)\n return unless rand(0..odds) == rand(0..odds)\n block = [[0, 0], [1, 0], [0, 1], [1, 1]]\n length = rand(length - 1)\n block.each do |xy|\n @elements << Element.new(kind, [length + xy[0], height + xy[1]], [0, 0], 1)\n end\n end",
"def next_blocks(*blocks)\n @next_blocks = blocks.dup\n end",
"def random_time_offset(max_minutes_offset=5)\n rand(max_minutes_offset) * (-1).power!(rand(2)) * 60\n end",
"def next\n Time.now + @min + Random.rand(@max - @min)\n end",
"def add_random_mines(num_mines)\n add_mines(get_random_mines(num_mines)) \n end",
"def new_block(check_in, check_out, number_of_rooms, rate)\n block_rooms_ids = []\n\n rooms_available = available_rooms(check_in, check_out)\n\n if number_of_rooms <= 5 && rooms_available.count >= number_of_rooms\n number_of_rooms.times do\n block_rooms_ids << rooms_available[0]\n end\n\n block = BlockRoom.new(check_in, check_out, rate, block_rooms_ids)\n\n @blocks << block\n else\n raise ArgumentError.new(\"Can only block 5 rooms at a time. Can only block available rooms. There are #{available_rooms.count} rooms.\")\n end\n end",
"def insert_new_generation\n (0...@new_generation.size).each do |i|\n evaluate_chromosome @new_generation[i]\n j = rand 0...@chromosomes.size\n @chromosomes.delete_at j\n @chromosomes << @new_generation[i]\n end\n @mating_pool.clear\n @new_generation.clear\n end",
"def generate_next_block(block_data, blockchain)\n previous_block = latest_block(blockchain)\n p previous_block\n block_index = previous_block.block_index + 1\n timestamp = Time.now.to_i.to_s\n block_hash = Digest::SHA256.hexdigest(block_index.to_s + previous_block.block_hash + timestamp + block_data)\n Block.new(block_index, previous_block.block_hash, timestamp, block_data, block_hash)\n end",
"def seed_redemptions\ng = Game.first\nend_date = DateTime.now\n#start_date = g.created_at\nstart_date = DateTime.now - 60.days\nwhile start_date < end_date\n\tstart_date = start_date + 1.days\n\tr = rand(10)\n\tputs \"#{r} coupons/rewards on #{start_date}\"\n\twhile r > 0\n\t\t@ge = GameEarnings.new(\n\t\t\t:game_id => 1, \n\t\t\t:coupon_id => 1, \n\t\t\t:earnings => 0.75, \n\t\t\t:coupon_cost => 0.75,\n\t\t\t:user_id => 1,\n\t\t\t:created_at => start_date\n\t\t)\n\t\t@ge.save\n\t\tr -= 1\n\tend\nend\nend",
"def insert(p, c, n)\n @starter.step(c, rand(n)).insert_next_fitting(c, p)\n end",
"def random_middle(delta, rock_count, now)\n if delta > 100 && rock_count < 1 #rand(5..15)\n rand_x = @window.width * rand(0.4..0.6)\n rand_y = @window.height * rand(0.4..0.6)\n Rock.new(@window, @object_pool, x: rand_x, y: rand_y, vel_x: 0, vel_y: 0, ang_vel: 1)\n @last_spawn = now\n end \n end",
"def addrandomcars(lat0,lon0,lat1,lon1, count )\n Fiber.new do\n count.times do\n lat = (lat1-lat0) * rand() + lat0\n lon = (lon1-lon0) * rand() + lon0\n @pgconn.query(\"insert into cars(lat,lon,avail) values(#{lat},#{lon}, true)\")\n end\n end.resume\n end",
"def gen_speed\n rand + 15.0\n end",
"def test_new\n\n b = Blockchain.new\n\n b << 'Genesis'\n b << 'Transaction Data...'\n b << ['Transaction Data...']\n b << ['Transaction Data...', 'Transaction Data...']\n b << [] ## empty block (no transactions)\n\n ## add do-it-yourself built block\n b << Block.next( b.last, 'Transaction Data...' )\n\n b << 'Transaction Data...'\n\n pp b\n\n assert true ## (for now) everything ok if we get here\nend",
"def build_ends_at(entity, begins_at)\n reservation_periods = entity.reservation_periods.includes(:period_unit)\n if reservation_periods.empty?\n # The entity does not have any reserve periods: insert a temporary fake reserve period of a half hour to use for building the length\n reservation_periods = [build(:reservation_period, period_unit: TimeUnit.find_by!(key: 'half_hour'))]\n end\n\n # Determine minimum and maximum length we want to allow\n min_length = entity.min_reservation_length_seconds || 0\n if entity.max_reservation_length_seconds.present?\n max_length = entity.max_reservation_length_seconds # Use the defined maximum length\n else\n # The max length is 50 times the largest reserve period with a maximum of one year (for performance reasons)\n max_length = [reservation_periods.sort_by(&:length).last.length * 50, 1.year].min\n end\n\n desired_length = min_length + rand(max_length - min_length) # The desired length of the reservation we want to at least achieve. This is a random function that centers between the min and max length.\n\n # Build a length which is a combination of random reserve periods and is at least the desired length (and at most the maximum length)\n length = 0\n while length < desired_length do\n max_remaining_length = max_length - length # Determine the remaining length we can use\n reservation_period = reservation_periods.select { |rp| rp.length < max_remaining_length }.sample # Pick a random reserve period that does not exceed this length\n if reservation_period.present?\n length += reservation_period.length # Apply the reserve period\n else\n break # Stop building length if we cannot find a suitable reservation_period anymore\n end\n end\n\n begins_at + length\nend",
"def build_blocks\n new_blocks = []\n current_rotated_blocks.each do |block|\n block_actor = @stage.create_actor :block,\n x: block[0] * BLOCK_SIZE + @falling_piece.x,\n y: block[1] * BLOCK_SIZE + @falling_piece.y,\n grid_offset_x: block[0],\n grid_offset_y: block[1],\n image: @falling_piece.image\n\n new_blocks << block_actor\n end\n # Destroy ourselves, leaving only the blocks behind\n @falling_piece.remove\n\n new_blocks\n end",
"def blocks_for_block_size\n # We're already done with the last block behavior, if we wanted a small\n # last block, or if we only generated a single block\n return block_list if block_list.size <= 1 || last_block == :small_last\n\n case last_block\n when :truncate_all\n # Implemented in add_for_block_size\n nil\n when :small_last\n # Implemented just above\n nil\n when :truncate_last\n block_list.pop\n else # default to :big_last behavior\n last = block_list.pop\n block_list.last.words.concat(last.words)\n end\n\n block_list\n end",
"def add_block(amount, payer, payee, miner, timestamp, signature, prev_hash, nonce, broadcast)\r\n hash = Digest::SHA256.new.hexdigest(amount.to_s + payer.to_s + payee.to_s + miner.to_s + timestamp.to_s + signature.to_s + prev_hash.to_s + nonce.to_s)\r\n if (hash.start_with?(\"0\" * NONCE_ZEROES)) # Hash Is Valid\r\n block = Block.new(amount.to_f, signature.to_i, timestamp.to_i, prev_hash.to_s, nonce.to_i, hash.to_s, payer.to_i, payee.to_i, miner.to_i)\r\n $blockchain << block\r\n broadcast_block(block) if (broadcast)\r\n puts $blockchain.length.to_s.green\r\n Thread.new { calc_net_worth } # Calculates net worth of all peers\r\n else\r\n puts \"Hash #{hash} Does Not Match Requirements! BLACKLISTING PEER WITH PORT #{payer}\".red\r\n $status = \"Hash #{hash} Does Not Match Requirements! BLACKLISTING PEER WITH PORT #{payer}\"\r\n peer = search_peers_by_port(payer)\r\n peer.node_type = 3 if (peer != -1)\r\n end\r\nend",
"def simulate_roll(min = 1, max = 7)\n rand(max) + min\nend",
"def add_random_courses(user, courses, course_range, per_bin_range)\n #:: Randomly add courses to a users bins\n user_courses = courses.shuffle.take(rand(course_range))\n while user_courses.any?\n bin_courses = user_courses.shift(rand(per_bin_range))\n\n bin = user.add_course(bin_courses.shift)\n bin_courses.each { |course| bin = user.add_course(course, bin) }\n end\n end",
"def append_verified_block(block)\n @chain << block\n @ledger.write(block)\n\n if block.index % BLOCK_REBALANCE_OFFSET == 0\n rebalance_difficulty\n end\n end",
"def add_new\n self.times_used.unshift(0)\n self.save\n end",
"def create_rand_spot\n spot_list = []\n 100.times {\n spot_list << @spot = Spot.new\n }\n spot_list\nend",
"def get_random_span(from, to)\n rand(to - from) + from\nend",
"def blocks_for_block_size\n # We're already done with the last block behavior, if we wanted a small\n # last block, or if we only generated a single block\n return @blocks if @blocks.size <= 1 || @last_block == :small_last\n\n # Implement the last block behavior. The :truncate_all behavior is\n # implemented in add_for_block_size.\n case @last_block\n when :big_last\n last = @blocks.pop\n @blocks.last.words += last.words\n when :truncate_last\n @blocks.pop\n end\n\n @blocks\n end",
"def initialize\n @offset = rand(0...BOUNDARY)\n end",
"def generate_time_blocks(windows)\n results = windows.map do |window|\n\n # Create a date based n todays date, but with the time changed to\n # that of the entry start/end.\n entry_start = base.change(\n hour: window.start_time.hour,\n min: window.start_time.minute)\n\n # By rounding off with #floor, we go the easy route (no partial time blocks)\n # Note: iterator is zero based.\n blocks = (window.duration / block_size).floor.times.map { |i|\n\n start_time = Skej::Warp.zone(\n entry_start + (i * block_size).minutes,\n session.chosen_office.time_zone)\n\n end_time = Skej::Warp.zone(\n start_time + block_size.minutes,\n session.chosen_office.time_zone)\n\n target_day = Skej::NLP.parse(session, window.day)\n .strftime('%A')\n .downcase\n .to_sym\n\n TimeBlock.new(\n session: session,\n time_entry_id: window.time_entry.id,\n business_id: session.business_id,\n time_sheet_id: window.time_sheet_id,\n office_id: window.office_id,\n day: target_day,\n start_time: start_time,\n end_time: end_time)\n\n }\n end.flatten # results\n end",
"def generate_starting_live_cells\n\t\tcells = []\n\t\tcell_count.times do\n\t\t\tstart_x = rand(size) # [0..4]\n\t\t\tstart_y = rand(size) # [0..4]\n\t\t\tcell = Cell.new(start_x, start_y)\n\n\t\t\tcells << cell\n\t\t\tupdate_board(cell)\n\t\tend\n\t\tcells\n\tend",
"def new_rooms\n min_rooms = MIN_NEXT_ROOMS\n max_rooms = MAX_NEXT_ROOMS\n rand(min_rooms..max_rooms).times do\n @next_rooms << Zarta::Room.new(@dungeon)\n end\n end",
"def make_reservation(start_date: Date.today, end_date: Date.today + 2, group_name: \"\", num_of_rooms: 1)\n if group_name != \"\"\n found_block = Block.find_block(blocks, group_name, start_date: start_date, end_date: end_date)\n\n if found_block == nil\n new_block = create_a_block(group_name, start_date: start_date, end_date: end_date)\n else\n new_block = found_block\n end\n\n final_list = Block.all_available_rooms_in_block(blocks, group_name, start_date: start_date, end_date: end_date)\n\n if (final_list == nil) || final_list.length < num_of_rooms\n raise StandardError.new(\"Not enough available rooms for this date range.\")\n else\n num_of_rooms.times do |k|\n room_number = final_list[k]\n new_reservation = Reservation.new(room_number, start_date: start_date, end_date: end_date, room_rate: new_block.room_rate, group_name: group_name)\n # Right here: I am modifying an attribute of the Block class\n # new_block.room_list[room_number] = :UNAVAILABLE\n new_block.change_status(room_number)\n reservations << new_reservation\n end\n end\n else\n room_list = Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)\n\n if room_list.length < num_of_rooms\n raise StandardError.new(\"Not enough available rooms for this date range. Only #{room_list.length} rooms available.\")\n else\n num_of_rooms.times do |j|\n new_reservation = Reservation.new(room_list[j], start_date: start_date, end_date: end_date)\n\n room = Room.find_room(rooms, room_list[j])\n\n room.change_status_of_room(rooms, room_list[j], start_date: start_date, end_date: end_date)\n reservations << new_reservation\n end\n end\n end\n end",
"def random_block\n type = %w(p p p p ul ol dl).sample\n case type\n when 'p'\n self.random_p\n when 'ul'\n self.random_list( 'ul', (rand(2) == 1) )\n when 'ol'\n self.random_list( 'ol', (rand(2) == 1) )\n when 'dl'\n self.random_dl\n end\n end",
"def build_begins_at(entity)\n last_reservation = entity.reservations.where('ends_at >= ?', Time.zone.now).reorder(ends_at: :desc).first\n if last_reservation.present?\n last_reservation.ends_at + rand(72).hours\n else\n (Time.zone.now + 1.hour).beginning_of_hour\n end\nend",
"def generate\n (0..30).sort{ rand() } .take(@conf)\n end",
"def after(interval, &block); end",
"def add_block\n i= 1\n loop do\n instance_variable_set(\"@b#{i}\", Block.next(instance_variable_get(\"@b#{i-1}\"), get_transaction))\n #dans cette loop en demande nouveau blockd'aller prendre les donnée du block précédant\n\n LEDGER << instance_variable_get(\"@b#{i}\")\n\n p \"==============================\"\n pp instance_variable_get(\"@b#{i}\")\n p \"==============================\"\n i += 1\n end\n\nend",
"def add_hazard(hazard, numOfRooms)\n for roomToAdd in 0...numOfRooms\n generatedRandom =random_room\n #Check that the generated room has hazard or not \n while generatedRandom.has?(hazard)\n generatedRandom =random_room\n end\n #Call Room.add(haze)\n generatedRandom.add(hazard) \n end\n \n end",
"def step(n=10, &blk)\n (n-1).times do\n random_join\n yield resulting_maze if block_given?\n\n vertical_connections\n yield resulting_maze if block_given?\n end\n final_row\n yield resulting_maze if block_given?\n\n self\n end",
"def inc_time_slot\n # ex. with 4 bits -> we want range 1..15, \n @lock.synchronize{@current_slot = (@current_slot % @max_slot) + 1}\n end",
"def place_randomly(width=@width, height=@height, nodeset=@nodes)\n nodeset.each_value do |node|\n node.location = Vector[rand(width), rand(height)] if !node.static\n end\n end",
"def next_interval\n if !@last_good_time.nil?\n good_duration = Time.now.to_f - @last_good_time\n @attempts = 0 if good_duration >= @reconnect_reset_interval\n end\n @last_good_time = nil\n target = ([@base_interval * (2 ** @attempts), @max_interval].min).to_f\n @attempts += 1\n if target == 0\n 0 # in some Ruby versions it's illegal to call rand(0)\n else\n (target / 2) + @jitter_rand.rand(target / 2)\n end\n end",
"def simulate\n initWater = Vector[ 500 - @xs[0], 0]\n # while true\n addWater(initWater)\n # end\n # while true\n # self.spawn(initWater)\n # self.update\n # end\n end",
"def simulate_roll(min = 1, max = 5)\n rand(max)\nend",
"def add_spin(attrs)\n # shift everything after\n Spin.where(\"station_id = ? and current_position >= ?\", attrs[:station_id], attrs[:add_position]).update_all(\"current_position = current_position + 1\")\n\n # add the new spin into the newly emptied slot\n spin = self.create_spin({ station_id: attrs[:station_id],\n current_position: attrs[:add_position],\n audio_block_id: attrs[:audio_block_id] })\n \n spin\n end",
"def add_date_chunks_to_schedule(time_blocks, schedule)\n time_blocks.each do |block|\n date = block.split(\"_\")[0]\n chunk_of_time = block.split(\"_\")[1]\n \n if Day.exists?(date, schedule.id)\n day = Day.where(:date => date, :schedule_id => schedule.id).first\n else\n day = Day.new(:date => date, :schedule_id => schedule.id)\n day.save\n end\n \n if !TimeBlock.dexists?(chunk_of_time, day.id)\n time_block = TimeBlock.new(:chunk_of_time => chunk_of_time, :day_id => day.id)\n time_block.save\n end\n end\n end",
"def get_number_block\n\n\tblock = rand(4**4)\n\t#make sure block length is 3 chars\n\n\twhile block.to_s.length != 3\n\t\tblock = rand(4**4)\n\tend\n\n\treturn block\nend",
"def random_on_interval(min, max)\n min + @prng.rand(max - min)\n end",
"def blocks() end",
"def new_block(proof, previous_hash = hash(last_block))\n block = {\n index: chain.length + 1,\n timestamp: Time.now.to_i,\n transactions: current_transactions,\n proof: proof,\n previous_hash: previous_hash,\n }\n\n # Reset the current transactions\n @current_transactions = []\n\n # Add block to the chain\n chain << block\n\n block\n end",
"def new_block blk\n time = Time.now\n res = store_block(blk)\n log.info { \"block #{blk.hash} \" +\n \"[#{res[0]}, #{['main', 'side', 'orphan'][res[1]]}] \" +\n \"(#{\"%.4fs, %3dtx, %.3fkb\" % [(Time.now - time), blk.tx.size, blk.payload.bytesize.to_f/1000]})\" } if res && res[1]\n res\n end",
"def setup_random\n @blocks = Array.new(ROWS) do\n Array.new(COLUMNS) { rand(COLOR_TABLE.size) }\n end\n end",
"def build_slots(current_time, finish_time, start_hour, finish_hour)\n while current_time < finish_time\n slots_quantity = get_slots_quantity(start_hour, finish_hour)\n\n (1..slots_quantity).each do\n verterx = @elements_factory.create_vertex(current_time, current_time.class,\n {gained_weight: 0, duration: @slots_size})\n @slots << verterx\n\n current_time += @slots_size\n break if current_time >= finish_time\n end\n\n current_time = current_time.beginning_of_day + start_hour.seconds_since_midnight.seconds + 1.day if start_hour.seconds_since_midnight > finish_hour.seconds_since_midnight\n end\n end",
"def new_block(proof, previous_hash = nil)\n block = {\n index: @chain.length + 1,\n epoch: Time.now.utc.to_f,\n transactions: @current_transactions,\n cost: @current_transactions.length - 1,\n proof: proof,\n previous_hash: previous_hash || Blockchain.hash(@chain.last)\n }\n @current_transactions = []; @chain << block; block\n end",
"def schedule_break start_time, end_time, rate = 0.0\n check_break start_time, end_time\n\n roadall.insert(-2, [start_time.to_i, nil, roadall.last.last])\n roadall.insert(-2, [end_time.to_i, nil, rate])\n end",
"def push_next_try_at\r\n self.next_try_at = 15.minutes.from_now\r\n end",
"def do_later(random_sleep_max_time = SLEEP_GENERIC, multiplier = 1, min_base = 0, &block)\n Thread.start do\n random_sleep(random_sleep_max_time, multiplier, min_base)\n block.call\n end\n end",
"def makeBlocks(days, startTimeString, endTimeString, info)\n\tblocks = []\n\tdays.split(\"\").each do |d|\n\t\tb = SCHBlock.new(d, startTimeString, endTimeString, info)\n\t\tblocks << b\n\tend\n\t(blocks)\nend",
"def random_incoming(delta, rock_count, now)\n if delta > 100 && rock_count < rand(5..15)\n rand_rot = rand(0.1..0.5) * [-1, 1].sample\n Rock.new(@window, @object_pool, x: @window.width, y: rand(0.0..@window.height), vel_x: rand(-3.0..-2.0), vel_y: rand(-0.5..0.5), ang_vel: rand_rot)\n @last_spawn = now\n end\n end",
"def add_to_lists\n\n [1,2,3,4,5,6,7,8].each do |x|\n list1.add(x)\n end\n [22,4,2].each do |x|\n list2.add(x)\n end\n node1 = list1.head\n (rand(4)+1).times do\n node1 = node1.next\n end\n node2 =list2.head\n while node2.next != nil\n node2 = node2.next\n end\n node2.next = node1\n end",
"def next_move_time\n delay = random.rand.clamp(1, 7)\n Time.current.to_f + delay\n end",
"def valid_blocks(base_time)\n set_base_time(base_time)\n time_entries = time_entries_for(base)\n end",
"def interval(retries)\n JITTER * (rand(2 ** retries - 1) + 1)\n end",
"def sleep_time(attempt)\n 1 + (2**attempt) + rand(2**attempt)\n end",
"def allocate_distance(total)\n\t\t# TODO - should be a range from .5 - .2 incr of .05 - 6 possibilites\n\t\tincr = rand(0..5)\n\t\t@up.target_distance = total * (0.2 + (0.05 * incr))\n\n\t\ttotal -= @up.target_distance\n\n\t\t@down.target_distance = 200\n\t\ttotal -= @down.target_distance\n\n\t\t@main.target_distance = total\n\tend",
"def set_points(count,size)\n if count > size\n raise \"Whow there!\"\n end\n points = []\n x = (0..size-1).to_a.shuffle\n y = (0..size-1).to_a.shuffle\n begin\n points.push([x.shift,y.shift])\n end until points.size == count\n points\nend",
"def sleep_time(attempt)\n 1 + (2**attempt) + rand(2**attempt)\n end",
"def populate_random(n)\n n.times do\n set(rand(0...@x_size), rand(0...@y_size), :alive)\n end\n end",
"def add_slot\n @limit += 1\n end",
"def intervalRand(min, max)\r\n\treturn rand(max-min)+min\r\nend",
"def generate_block_list(state, level=0)\n if @depends.length > 1\n @depends.length.times {\n f = rand(@depends.length)\n @depends.push(@depends.delete_at(f))\n }\n end\n\n @depends.length.times { |cidx|\n\n pass = false\n\n while (not pass)\n\n if (@depends[cidx].generated)\n break\n\n # If this dependent block is a once block and the magic 8 ball turns\n # up zero, skip it and let a later block pick it up. We only do this\n # if we are not the last block to have a dependency on this block.\n elsif ((@depends[cidx].once) and\n (rand(2).to_i == 0) and\n (@depends[cidx].last_reference? == false))\n break\n end\n\n # Generate this block\n @depends[cidx].generate_block_list(state, level+1)\n\n if level != 0\n return\n else\n @depends.length.times {\n f = rand(@depends.length)\n @depends.push(@depends.delete_at(f))\n }\n\n next\n end\n end\n\n next\n }\n\n self.deref\n\n # Assign the instance local state for the duration of this generation\n @state = state\n\n # Select a random permutation\n perm = rand_perm\n\n # Set our block offset to the current state offset\n self.offset = state.curr_offset\n\n # Flag ourselves as having been generated for this iteration.\n self.generated = true\n\n # Adjust the current offset based on the permutations length\n state.curr_offset += perm.length\n\n # Add it to the linear list of blocks\n state.block_list << [ self, perm ]\n\n # Generate all the blocks that follow this one.\n @next_blocks.each { |b|\n b.generate_block_list(state)\n }\n\n # Return the state's block list\n state.block_list\n end",
"def long_range (min, max)\n long = rand(0..(max - min)) + min\n long\nend",
"def add_block(block, state)\n start_time = Time.now\n\n mainchain_tip_hash = @storage.mainchain_tip_hash\n thischain_tip_hash = block.prev_block_hex\n\n mainchain_tip = @storage.block_header_for_hash(mainchain_tip_hash)\n thischain_tip = @storage.block_header_for_hash(thischain_tip_hash)\n\n # If the new work does not exceed the main chain work, stash this block away in a \"side branch\".\n # No further validations will be performed.\n if !thischain_tip.is_more_work?(mainchain_tip, block.hash, block.block_work)\n # This can only be possible on the sidechain, so we simply store the block without further validations.\n # Outputs will be validated when/if this block will become a part of the mainchain (see below).\n @storage.load_output_cache(block.tx)\n return persist_block_on_side_branch(block,\n @storage.height_for_block_header(thischain_tip) + 1,\n @storage.total_work_up_to_block_header(thischain_tip))\n end\n\n # New work is greater. Find the common ancestor block to rebuild the chain from there.\n # Scan both chains up to the common (minimum) height.\n # Then scan from there simultaneously until we hit the same hash.\n\n mainchain_ancestor = mainchain_tip\n thischain_ancestor = thischain_tip\n\n block_hashes_to_disconnect = []\n block_hashes_to_connect = []\n\n # 1. Scan each chain until the common min_height\n min_height = [ @storage.height_for_block_header(mainchain_ancestor),\n @storage.height_for_block_header(thischain_ancestor) ].min\n\n while @storage.height_for_block_header(mainchain_ancestor) > min_height\n block_hashes_to_disconnect << mainchain_ancestor.sha2_hash\n mainchain_ancestor = @storage.previous_block_header_for_block_header(mainchain_ancestor)\n end\n\n while @storage.height_for_block_header(thischain_ancestor) > min_height\n block_hashes_to_connect << thischain_ancestor.sha2_hash\n thischain_ancestor = @storage.previous_block_header_for_block_header(thischain_ancestor)\n end\n\n # 2. Scan both chains simultaneously until we get to the same common ancestor\n while !(thischain_ancestor == mainchain_ancestor)\n block_hashes_to_disconnect << mainchain_ancestor.sha2_hash\n block_hashes_to_connect << thischain_ancestor.sha2_hash\n mainchain_ancestor = @storage.previous_block_header_for_block_header(mainchain_ancestor)\n thischain_ancestor = @storage.previous_block_header_for_block_header(thischain_ancestor)\n end\n\n # Finally we arrive at the common ancestor.\n # Now we need to attempt to disconnect old mainchain blocks and connect new thischain blocks.\n common_ancestor = mainchain_ancestor\n\n # 1. Disconnect the blocks on the mainchain to move them into the sidechain\n # We start from the latest hash and move on to the one right before the common ancestor.\n # Most of the time this array is empty, so no blocks are being disconnected.\n block_hashes_to_disconnect.each do |hash|\n b = @storage.valid_block_for_hash(hash)\n @storage.load_output_cache(b.tx)\n # Wrap disconnect/connect in a DB transaction.\n @storage.transaction do\n if !self.disconnect_block(b, state)\n return false\n end\n end\n end\n\n # 2. Connect the blocks to form the new mainchain.\n # If any block is actually invalid (double-spends some outputs or has an invalid script),\n # this will fail and we would have to abort DB transaction to rollback all changes.\n block_hashes_to_connect.reverse.each do |hash|\n b = @storage.valid_block_for_hash(hash)\n @storage.load_output_cache(b.tx)\n # Wrap disconnect/connect in a DB transaction.\n @storage.transaction do\n begin\n if !self.connect_block(b, state)\n # This will likely never get hit as the above raises exceptions.\n @storage.remove_block_header(block)\n @output_cache.flush\n return false\n end\n rescue ValidationError => ex\n @storage.remove_block_header(b)\n @output_cache.flush\n raise ex\n end\n end\n end\n\n measure_method(:add_block, start_time)\n log_raw_block_events(block.hash, \"add_block processing time: #{(Time.now - start_time).to_f}\")\n\n # Connect this new block too.\n @storage.load_output_cache(block.tx)\n # Wrap disconnect/connect in a DB transaction.\n @storage.transaction do\n begin\n if !self.connect_block(block, state)\n # This will likely never get hit as the above raises exceptions.\n @storage.remove_block_header(block)\n @output_cache.flush\n return false\n end\n rescue ValidationError => ex\n @storage.remove_block_header(block)\n @output_cache.flush\n raise ex\n end\n end\n\n return true\n end",
"def cut_off_random\n\t\n\trand_id = rand(0...@heads)\n\t\t\n\t@heads += 1\n\t\n\t@personalities.insert(rand_id, @@personality_array.sample, @@personality_array.sample)\n\t\n\t\tputs \"Despite slicing off head # #{rand_id}, the vicious #{@name} grows two more! They seem #{@personalities[rand_id]} and #{@personalities[rand_id + 1]}.\"\n\tend",
"def generate_call_center\n self.call_center = rand(Time.now.to_i)\n end",
"def pullRandom\n return nil if size == 0\n ind = rand(size)\n swap(ind,size-1)\n removeEnd\n end",
"def transaction2_insert(num_times)\r\n client = self.connect\r\n dataset = client[:fleet]\r\n r = Random.new\r\n \r\n # transaction start..\r\n client.transaction do\r\n \r\n # insert test..\r\n 1.upto(num_times) do |i|\r\n dataset.insert(:name => 'foo' + r.rand(100).to_s,\r\n :description => 'bar') \r\n end\r\n \r\n # transaction end\r\n end\r\n \r\n # cleanup\r\n puts \"transaction2 insert\"\r\n client.disconnect\r\n \r\n return true\r\n end",
"def place_mines\n\t\t(0...@size).to_a.shuffle.slice(0,@total_mines).each do |rand|\n\t\t\tmine_row = rand / @width\n\t\t\tmine_col = rand % @width\n\t\t\t@cell_at[mine_row][mine_col].risk = :mine\n\t\t\t@cells_with_mines << [mine_row, mine_col]\n\t\tend\n\tend",
"def <<(block)\n blocks << block\n end",
"def addDataToBlock(blockNumber, data, offset, shouldReportToDHT)\r\n assert @numBlocks > blockNumber\r\n blockToUse = @allBlocks[blockNumber]\r\n assert blockToUse\r\n return 0 if blockToUse.done?\r\n amountWritten = blockToUse.addToMe(data, offset)\r\n # not necessarily true if we write 'over' half of something assert amountWritten == data.length\r\n @totalBytesWritten += amountWritten\r\n if blockToUse.done? and shouldReportToDHT\r\n assert !blockToUse.alreadyReportedDoneToDHT\r\n blockToUse.alreadyReportedDoneToDHT = true\r\n @logger.log \"BM next reporting block #{blockNumber} done for #{localIP}:#{@p2pServerPort}\"\r\n blockToUse.set_block_done_in_dht\r\n end\r\n amountWritten\r\n end"
] | [
"0.6101411",
"0.58748794",
"0.578914",
"0.5707435",
"0.57006514",
"0.5687463",
"0.5662635",
"0.56504726",
"0.5633058",
"0.56010556",
"0.55987895",
"0.5523075",
"0.5510154",
"0.5418222",
"0.5354336",
"0.531994",
"0.5262501",
"0.52583444",
"0.52465177",
"0.5210932",
"0.5204403",
"0.5177305",
"0.51727265",
"0.5131196",
"0.5115198",
"0.5062654",
"0.50547314",
"0.50496477",
"0.50422734",
"0.50092775",
"0.4998242",
"0.4995345",
"0.49894258",
"0.49859026",
"0.4966667",
"0.49507415",
"0.4939757",
"0.493087",
"0.4925953",
"0.49241364",
"0.49060723",
"0.48973024",
"0.48935044",
"0.48934624",
"0.48934257",
"0.4889353",
"0.48809153",
"0.4869991",
"0.48695192",
"0.48688772",
"0.48399112",
"0.48354092",
"0.48323843",
"0.48030835",
"0.48025835",
"0.4799522",
"0.478919",
"0.47885215",
"0.47757167",
"0.47693324",
"0.47461823",
"0.47426432",
"0.47413155",
"0.4739034",
"0.4736965",
"0.47332335",
"0.47274667",
"0.47244766",
"0.4718926",
"0.47151938",
"0.47129244",
"0.47102055",
"0.47045657",
"0.4703937",
"0.47003603",
"0.4696816",
"0.46923316",
"0.46892223",
"0.46846518",
"0.46828917",
"0.46817747",
"0.46675888",
"0.46673974",
"0.46657595",
"0.46651974",
"0.46483228",
"0.46475977",
"0.4644843",
"0.4640274",
"0.46401757",
"0.46388102",
"0.4638564",
"0.4638332",
"0.4634232",
"0.46310523",
"0.4630105",
"0.46248007",
"0.46238002",
"0.46160007",
"0.46106985"
] | 0.66548526 | 0 |
The date baseline we are going to be working off of. | def base
@base_time
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def effective_age_calculation_base_date\n age_calculation_base_date || start_date\n end",
"def history_start\n start_dt = case QaServer.config.historical_datatable_default_time_period\n when :month\n history_end_dt - 1.month\n when :year\n history_end_dt - 1.year\n else\n @parent.first_updated_dt\n end\n QaServer::TimeService.pretty_date(start_dt)\n end",
"def get_begin_date\n get_end_date.prev_year\n end",
"def review_history_period_start_date_time\n return @review_history_period_start_date_time\n end",
"def base_date\n @base_date ||= lambda do\n date_base_element = workbook.search('workbookPr').attribute('date1904')\n if date_base_element && date_base_element.value.to_i == 1\n Date.parse('1904-01-01')\n else\n Date.parse('1900-01-01')\n end\n end.call\n end",
"def f_start_date\n\t\tself.expected_start_date.strftime(\"%d / %m / %Y\")\n\tend",
"def current_period_start_date\n Date.new(Date.today.year, Date.today.month, current_day_start_date)\n end",
"def start_date\n return start\n end",
"def start_date\n\t\tDate.new( @year, @month, 1 )\n\tend",
"def base_date\n self.job.close_on || self.job.created_at.to_date\n end",
"def calc_current_age\n Patient.calc_current_age_base(provided_date_of_birth: date_of_birth)\n end",
"def start_date\n @start_date ||= existing_prices.map { |x| Date.strptime(x.split(\" \")[1], DATE_FORMAT) }.max || begin\n stats = `ledger stats` # Most compact way to retrieve this data\n date_str = /Time\\speriod:\\s*([\\d\\w\\-]*)\\s*to/.match(stats)[1]\n return Date.strptime(date_str, \"%y-%b-%d\")\n end\n end",
"def beginning_of_week; end",
"def beginning_of_week; end",
"def dt_start\n @current_date.clone if @current_date\n end",
"def date; end",
"def date; end",
"def date; end",
"def date; end",
"def start_date\n @start_date ||= Date.today - Date.today.wday - 7 * 52\nend",
"def start_date\n return begins if support_deal.nil?\n self.begins ||= support_deal.start_date\n return support_deal.start_date > begins ? support_deal.start_date : begins\n end",
"def date()\n\t\t(@start_date.to_time + (10**9)).to_date\n\tend",
"def immersive_start_date\n @p0_start_date + 63\n end",
"def start_date\n date\n end",
"def start_date_of_roll_period(year, month)\n # todo, to be truly accurate with respect to the description, this should figure out the date of the Tuesday prior to the settlement date, but I think subtracting one day is the real intention.\n vix_futures_settlement_date(year, month) - 1\n # prior_cboe_business_day(vix_futures_settlement_date(year, month))\nend",
"def start\n\tself[:date_start].strftime(\"%d.%m.%Y\") || '-'\n end",
"def post_brew_start_date\n (Time.now.in_time_zone('Asia/Kolkata') + (Brew::POST_BREW_MIN_NUM_DAYS_OUT).days).to_date\n end",
"def initial_date\n self.start_date.strftime('%m-%d-%Y')\n end",
"def start_date\n\t\treturn Date.new(y=year, m=START_MONTH, d=START_DAY)\n\tend",
"def baseline_value\n if (@reference_lines.key?(:baseline))\n @reference_lines[:baseline][:value]\n else\n nil\n end\n end",
"def period_start\n period.begin\n end",
"def determine_end_date\n self.end_date = start_date.next_month.yesterday\n end",
"def intiation_date\n self.initiation\n end",
"def get_time_delta\n return(@rundate - @histodate)\n end",
"def time_base\n self[:time_base].to_f\n end",
"def last_run\n DateTime.parse(\"1 Jan 2007\")\n end",
"def create_default_estimated_date\n Date.today + 7\n end",
"def start_year\n Time.now.year - 75\n end",
"def start_time\n begin_date\n end",
"def end_date_for_top_line\n if(end_date < Date.today) #If it is an old project.\n end_date_for_top_line = [project.maximum_chart_date(self), self.end_date].max\n else\n end_date_for_top_line = [project.maximum_chart_date(self), self.end_date, estimate_at_completion_duration.week.from_now].max\n end\n end",
"def calculate_start_date\n if !@end_date.blank? && @data_amount > 0\n @start_date = @end_date - (@data_amount-1).month\n @start_date.end_of_month\n end\n end",
"def baseline_nonbillable_ratio\n BASELINE_TARGET_HOURS_PER_PERSON / AVAILABLE_HOURS_PER_PERSON\n end",
"def estimated_end_date\n start_date + 12.days\n end",
"def next_date\n next_observance.try(:start_on) || 100.years.from_now.to_date\n end",
"def expected_hand_in\n if self[:end_date].nil?\n Time.now.strftime('%Y-%m-%d')\n else\n d = self[:end_date].to_time + 4.weeks\n d.strftime('%Y-%m-%d')\n end\n end",
"def hr_start_date\n convert_date(start_date.to_s)\n end",
"def beginning_of_week=(_arg0); end",
"def beginning_of_week=(_arg0); end",
"def beginning_date\n Date.new(@number, 1, 1).tuesday? ? Date.new(@number, 1, 2) : Date.new(@number, 1, 1)\n end",
"def new_start(start = Date::ITALY)\n if_period(super) {|p,dt| dt.localize(p) }\n end",
"def baseline_for(klass)\n @baseline_for = klass\n end",
"def deviation_start_in_days\n (real_start_date - planned_start_date).to_i.abs if real_start_date\n end",
"def base_date\n return DATE_SYSTEM_1900 if @xml.nil?\n\n @xml.xpath('//workbook/workbookPr[@date1904]').each do |workbookPr|\n return DATE_SYSTEM_1904 if workbookPr['date1904'] =~ /true|1/i\n end\n\n DATE_SYSTEM_1900\n end",
"def start_year\n Time.now.year - 18\n end",
"def start_date\n weekday = beginning_of_month.cwday\n offset = weekday == 1 ? 0 : (weekday - 1).days\n beginning_of_month - offset\n end",
"def start_time\n Date.today\n end",
"def effective_start_at\n start_at - course&.advance_start_at_duration\n end",
"def past_start_date\n past_start_date = Time.zone.today - 6.days\n past_start_date < charge_start_date ? charge_start_date : past_start_date\n end",
"def start_date\n @raw.first.date\n end",
"def start\n starts_at.strftime(\"%R\")\n end",
"def getPrevPeriodStart(currentStart)\n\t\tprevStart = nil\n\t\tif getIntervalType == 'M'\n\t\t\tprevStart = currentStart - 1.months\n\t\telse\n\t\t\tprevStart = currentStart - 7.days\n\t\tend\n\t\tprevStart\n\tend",
"def date_payroll\n\t\treturn created_at,init_date,end_date,fortnight\n\tend",
"def current_annual_load\n (current_daily_load * 365.2425 / 1000).to_i\n end",
"def yday() end",
"def fiscal_year_start_date\n Date.today.month < 7 ? \"07/01/#{Date.today.year - 1}\" : \"07/01/#{Date.today.year}\"\n end",
"def statistic_up_date\n I18n.l(Time.zone.today.to_date)\n end",
"def start_date\n\t \tTime.at(self.start_time) rescue nil\n\t end",
"def first_period\n return @first_period\n end",
"def get_start_date\n date = Time.new\n year = date.year\n month = date.month < 10 ? \"0\" + date.month.to_s : date.month\n day = date.day < 10 ? \"0\" + date.day.to_s : date.day\n start_date = \"#{year-2}-#{month}-#{day}\"\n start_date\nend",
"def date\n @date ||= Time.utc(*Gem.source_date_epoch.utc.to_a[3..5].reverse)\n end",
"def start_of_planning_year\n start_of_fiscal_year current_planning_year_year\n end",
"def span\n ((end_date - start_date)*Numeric::DAYS).to_f\n end",
"def last_date\n\t\tlast_date_value = expected_end_date\n\t\tif last_report_aux = last_report\n\t\t\tif last_report_aux.created_at > expected_end_date\n\t\t\t\tlast_date_value = last_report_aux.created_at\n\t\t\tend\n\t\tend\n\n\t\tif Date.today > last_date_value\n\t\t\tlast_date_value = Date.today\n\t\tend\n\n\t\treturn last_date_value\n\tend",
"def date() self[:date]; end",
"def deadline\n \"July 4, 2014\"\n end",
"def start_date_time\n return @start_date_time\n end",
"def start_date\n @records.min { |a,b| a[:date] <=> b[:date] }[:date]\n end",
"def base_time\n BASE_TIME\n end",
"def day_end\n\t\tself.at_beginning_of_day + 86399.999999\n\tend",
"def left_senedd\n representations.last.end_log_date\n end",
"def run_date_time\n return @run_date_time\n end",
"def beginning_of_day\n self - self.seconds_since_midnight\n end",
"def stop_date\n\t\t#return Date.new(y=year+1, m=START_MONTH, d=START_DAY) - 1\n\t\treturn start_date.next_year.prev_day()\n\tend",
"def effective_end_datetime\n end_date + 1.day + roster.switchover.minutes\n end",
"def getStartDate\r\n\t\t\t\t\treturn startDate\r\n\t\t\t\tend",
"def start_of_year\n @start_of_year ||= year_start_date\n end",
"def end_date\n \"Calculate End Date\"\n end",
"def default_date_range\n \"#{Hyrax.config.analytics_start_date},#{Time.zone.today}\"\n end",
"def earliest_birthdate\n \n # the earliest possible is 10 years after my youngest parent was born \n earliest = babyhood_date\n if (!earliest.nil?)\n earliest = earliest + 10.years\n end\n \n return earliest\n end",
"def start_datetime(timeframe = nil)\n case timeframe\n when \"1month\" then 1.month.ago.to_datetime\n when \"3months\" then 3.months.ago.to_datetime\n when \"2years\" then 2.years.ago.to_datetime\n else 5.years.ago.to_datetime\n end\n end",
"def start_date\n @start_date ||= respond_to?(:parliamentPeriodStartDate) ? DateTime.parse(parliamentPeriodStartDate) : nil\n end",
"def earliest_deathdate\n earliest = earliest_known_birthdate\n end",
"def interesting_date\n marked_as_fast_growing_at\n end",
"def normalize_date_from\n\t\t\t\t\tstart = RicSeason.start\n\t\t\t\t\tif start\n\t\t\t\t\t\tif self.period.to_sym == :year\n\t\t\t\t\t\t\tfirst_day = Date.parse(\"#{self.from.cwyear}-#{start}\")\n\t\t\t\t\t\t\tif self.from < first_day\n\t\t\t\t\t\t\t\tself.from = first_day - 1.year\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tself.from = first_day\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telsif self.period.to_sym == :month\n\t\t\t\t\t\t\tfirst_day = Date.parse(\"#{self.from.cwyear}-#{self.from.month}-#{start}\")\n\t\t\t\t\t\t\tif self.from < first_day\n\t\t\t\t\t\t\t\tself.from = first_day - 1.month\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tself.from = first_day\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend",
"def start_date_time\n return @start_date_time\n end",
"def start_date_time\n return @start_date_time\n end",
"def start_date_time\n return @start_date_time\n end",
"def start_date_time\n return @start_date_time\n end",
"def start_date_time\n return @start_date_time\n end",
"def start_date_time\n return @start_date_time\n end"
] | [
"0.71690583",
"0.6747204",
"0.6735025",
"0.6399079",
"0.6387229",
"0.63734704",
"0.6343958",
"0.6306791",
"0.62846375",
"0.625235",
"0.6228262",
"0.61988795",
"0.6190504",
"0.6190504",
"0.6183809",
"0.617929",
"0.617929",
"0.617929",
"0.617929",
"0.6167889",
"0.6158597",
"0.6155836",
"0.615017",
"0.61197793",
"0.6103451",
"0.6082861",
"0.6060384",
"0.60028106",
"0.6002473",
"0.59982073",
"0.5996647",
"0.5994864",
"0.5987006",
"0.5981454",
"0.5969077",
"0.59576046",
"0.5950661",
"0.5935394",
"0.5930719",
"0.5926088",
"0.5907578",
"0.59053147",
"0.5902651",
"0.5877237",
"0.5860332",
"0.5853194",
"0.5850117",
"0.5850117",
"0.5845884",
"0.5836339",
"0.58337325",
"0.5822951",
"0.58139837",
"0.5810916",
"0.5803951",
"0.5801844",
"0.57795006",
"0.57632047",
"0.57565135",
"0.5743634",
"0.57319266",
"0.5720471",
"0.57141227",
"0.5709262",
"0.56979156",
"0.56963",
"0.56734407",
"0.5672352",
"0.5667148",
"0.56600237",
"0.5654603",
"0.5652481",
"0.5638657",
"0.563844",
"0.5631448",
"0.5628496",
"0.5614848",
"0.56145126",
"0.5610564",
"0.5608237",
"0.5607865",
"0.5604449",
"0.56039876",
"0.5595537",
"0.5593253",
"0.559304",
"0.5589414",
"0.5587152",
"0.55834746",
"0.5583158",
"0.5582908",
"0.55782485",
"0.5577912",
"0.55772156",
"0.5571848",
"0.5571848",
"0.5571848",
"0.5571848",
"0.5571848",
"0.5571848"
] | 0.64064115 | 3 |
def stakes stks = Stake.where( asset_id: self.id, asset_type: 'Recording' ) stks += Stake.where( asset_id: self.common_work_id, asset_type: 'CommonWork') end | def contributors_share
ps = 0.0
self.recording_ipis.each do |recording_ipi|
ps += recording_ipi.share
end
ps
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recordings\n recording_ids = self.instrument_tags.where(instrument_tagable_type: 'Recording').pluck(:instrument_tagable_id)\n Recording.where(id: recording_ids)\n end",
"def take_winnings(winnings)\n\t\t@bankroll += winnings\n\t\t@net_winnings += winnings\n\tend",
"def add_common_work common_work\n CatalogsCommonWorks.where(catalog_id: self.id, common_work_id: common_work.id)\n .first_or_create(catalog_id: self.id, common_work_id: common_work.id)\n \n common_work.recordings.each do |recording|\n self.attach_recording recording\n end\n end",
"def artworksIn\n\tlistback = []\n\t@art = Artwork.all\n\t@artcreated = ArtworkCreatedBy.all\n\t@art.each do |a|\n\t\t@artcreated.each do |ac|\n\t\t\tif self.artist_id == ac.artist_id\n\t\t\t\tif a.art_id == ac.art_id\n\t\t\t\t\tlistback << a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\tlistback\nend",
"def index\n #sample_ids.each {|x| @studies << Study.find_by_nct_id(x)}\n #@studies\n @studies=Study.completed_since(Date.today-100.days)\n #@studies=Study.sponsored_by('Duke')\n @definitions=Aact::DataDefinition.all\n #@studies=[Aact::Study.find_by_nct_id('NCT01132846')]\n #@studies=Study.all\n end",
"def create_stake shop_product, price_minus_labels_cut\n \n Notifyer.print( 'RecordingIpi#create_stake' , {price_minus_labels_cut: price_minus_labels_cut, recording_uuid: recording.uuid} ) if Rails.env.development?\n \n return unless self.user # !!! make gracefull error handling here \n \n begin\n amount_in_cent = price_minus_labels_cut * self.share * 0.01\n amount_in_pct = amount_in_cent / shop_product.price\n \n stake = Stake.create( \n account_id: self.account_id,\n user_id: self.user_id,\n asset_id: recording.uuid,\n asset_type: 'Recording',\n ip_uuid: self.uuid,\n ip_type: self.class.name,\n split: amount_in_pct,\n flat_rate_in_cent: amount_in_cent.round,\n currency: 'usd',\n email: self.user.email,\n expired: false,\n shop_product_id: shop_product.id,\n description: \"Contributor: #{self.role}\",\n shop_product_id: shop_product.id\n )\n rescue => e\n ErrorNotification.post_object 'RecordingIpi#create_stake', e\n end\n end",
"def related_studies\n _studies = []\n under_supervision_studies.each do |study|\n unless _studies.include?(study)\n _studies.append(study)\n end\n end\n studies.each do |study|\n unless _studies.include?(study)\n _studies.append(study)\n end\n end\n return _studies\n end",
"def songs \n Song.all.select{|song| add_song(song)}.to_a\n # binding.pry\n end",
"def index\n @sours = @swit.sours.all\n \n end",
"def smoked_all_time\n Smoke.by_user(id).sum(:counted) || 0\n end",
"def artworksRefferenced\n\tlistback = []\n\t@art = Artwork.all\n\t@artreffed = ArtReferredBy.all\n\t@art.each do |a|\n\t\t@artreffed.each do |ar|\n\t\t\tif self.ref_id == ar.ref_id\n\t\t\t\tif a.art_id == ar.art_id\n\t\t\t\t\tlistback << a\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\tlistback\nend",
"def my_rounds\n my_rounds = FundingRound.all.select{|rounds| rounds.startup == self}\n end",
"def works\n Work.all.select {|work| work.make_id == id}\n end",
"def show\n \t@recordings = Recording.where(surah_id: @surah.id, user_id: current_user.id)\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def gs\r\n @records = Lot.find_by_sql([\"SELECT l.proj_id, l.notes, lis.identifier as i, o.id, Sum(l.key_specimens) AS nsk, Sum(l.value_specimens) AS nsv, sum(l.key_specimens + l.value_specimens) AS ns\r\n FROM (lots AS l LEFT JOIN lot_identifiers AS lis ON l.id = lis.lot_id) LEFT JOIN otus AS o ON l.otu_id = o.id\r\n GROUP BY lis.identifier, o.id\r\n HAVING (l.proj_id = ?);\", @proj.id])\r\n @tot_unique_ids = Lot.find_by_sql([\"Select distinct lis.identifier FROM (lots AS l LEFT JOIN lot_identifiers AS lis ON l.id = lis.lot_id) Where (l.proj_id = ?);\", @proj.id]).size\r\n @tot_specimens = @records.inject(0) do |sum, o| sum += o.ns.to_i end\r\n end",
"def index\n @saddnesses = Saddness.all\n end",
"def local_spares\n #super.merge(:rear_shock => rear_shock)\n {:rear_shock => rear_shock}\n end",
"def audio_recordings_extract(user)\n user = Access::Validate.user(user)\n\n conditions = audio_recording_conditions(user)\n\n # add conditions to ActiveRecord AudioRecording query\n append_conditions(AudioRecording.all, conditions)\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def shared_stories\n self.joined_stories + self.written_stories\n end",
"def stderrs; end",
"def index\n @albums = Album.where(user_id: current_user.id)\n @shares = Share.where(user_id: current_user.id)\n @shares.each {\n |share| @albums += Album.where(id: share.album.id)\n }\n end",
"def show\n @ski = Ski.find(params[:id])\n\n @inventory = Inventory.where(:ski_id => params[:id])\n\n @image = Image.where(:ski_id => params[:id])\n\n @spec = Spec.where(:ski_id => params[:id])\n\n @stores_array = [] \n @inventory.each do |inventory|\n if !@stores_array.include? inventory.store \n @stores_array.push inventory.store\n end\n end\n\n @images = Image.where(:ski_id => params[:id])\n\n @reviews = Review.where(:ski_id => params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ski }\n end\n end",
"def brand_toy_stock item\n\t$num_stock = 0\n\t$same_brand.each {|item| $num_stock += item[\"stock\"]}\nend",
"def set_saddness\n @saddness = Saddness.find(params[:id])\n end",
"def instruments\n @instruments ||= Instrument.find self.tracks.count(:include => :instrument, :group => 'instrument_id').map(&:first)\n end",
"def get_shares_quantity\n quantity = 0\n LineShare.where(user_id: self.id, available: true).each do |lineshare|\n quantity += lineshare.quantity\n end \n quantity\n end",
"def list_studies\n act = StudyListAction.new(self)\n act.get\n end",
"def initialize_trial_squads_status\n trial_squads.each do |trial_squad|\n trial_squad.trial_mobs.each do |trial_mob|\n trial_mob.hp = trial_mob.max_hp\n trial_mob.sp = trial_mob.max_sp\n trial_mob.save\n end\n end\n end",
"def store_results\n Store.latest.includes(:profile_image).search!(q)\n end",
"def soak\n soak = self.brawn\n\n if self.equipped_armor\n soak += self.equipped_armor.armor.soak\n end\n\n # Then increase based on selected talents.\n self.talent_alterations.each do |talent_id, stat|\n stat.each do |type, value|\n if type == :soak\n soak += value['count']\n end\n end\n end\n\n # Add soak increase from cybenetics.\n self.cybernetics[:bonuses].each do |cb|\n if cb[0] == :soak\n soak += cb[1]\n end\n end\n\n soak\n end",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def index\n @shains = Shain.all\n end",
"def sports\n @records = TUTwitter.find_sports\n end",
"def index\n @sculptures = Sculpture.includes(:images).all\n end",
"def collect_samples\n all_samples = []\n\n all_samples << { item: @beads } if @plan_params[:run_calibration_beads]\n\n CONTROL_NAMES.each do |name|\n controls(name).each do |item|\n all_samples << { item: item, control: name }\n end\n end\n\n other_samples.each do |item|\n all_samples << { item: item }\n end\n\n libraries_to_sort.each do |item|\n all_samples << { item: item, sort: true }\n end\n\n all_samples\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def skeins\n data[:skeins]\n end",
"def stole_item_set(user, ext)\n return false unless ext != nil\n @item_stole = @item_to_steal = @stole_item_index = nil\n steal_success = rand(100) < (Steal_Rate + self.steal_attempt) * user.agi / self.agi\n self.steal_attempt += 1\n return nil if self.steal_items.nil? or self.steal_items == []\n return false unless steal_success\n @item_stole = []\n ext.slice!('STEAL/')\n self.steal_items.each do |item, steal_rate|\n item = item.split('')\n if item[0] == 'i' and not ext == 'GOLD'\n item = item.join\n item.slice!('i')\n @item_stole << $data_items[item.to_i] if rand(1000) < (steal_rate * 10).to_i\n elsif item[0] == 'a' and not ext == 'GOLD'\n item = item.join\n item.slice!('a')\n @item_stole << $data_armors[item.to_i] if rand(1000) < (steal_rate * 10).to_i\n elsif item[0] == 'w' and not ext == 'GOLD'\n item = item.join\n item.slice!('w')\n @item_stole << $data_weapons[item.to_i] if rand(1000) < (steal_rate * 10).to_i\n elsif item[0] == 'g' and not ext == 'ITEM'\n item = item.join\n item.slice!('g')\n @item_stole << item.to_i if rand(1000) < (steal_rate * 10).to_i\n end\n end\n return false if @item_stole == []\n self.steal_attempt = 0\n @stole_item_index = rand(@item_stole.size)\n @item_to_steal = @item_stole[@stole_item_index]\n if Multi_Steal\n self.steal_items.delete_at(@stole_item_index)\n else\n self.steal_items = []\n end\n return @item_to_steal\n end",
"def students\n self.boating_tests.collect{|test| test.student} \n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def trips \n trips_taken = Trip.all.select do |trip|\n trip.listing == self\n end\n end",
"def take\n\n end",
"def index\n @savings = Saving.all\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def create_from_catalog_artworks\n\n forbidden unless current_catalog_user.update_file\n @recording = Recording.find(params[:recording_id])\n @remove_tag = \"#artwork_#{params[:artwork_id]}\"\n \n \n RecordingItem.where( recording_id: @recording.id,\n itemable_id: params[:artwork_id],\n itemable_type: 'Artwork'\n )\n .first_or_create( recording_id: @recording.id,\n itemable_id: params[:artwork_id],\n itemable_type: 'Artwork'\n )\n \n end",
"def stakeholders\n self.stakeholder_ids.collect{|user_id| User.find(user_id)}\n end",
"def sole_authored_works\n @sole_authored_works = []\n works.find(:all, :conditions => 'posted = 1').each do |w|\n if self.is_sole_author_of?(w)\n @sole_authored_works << w\n end\n end\n return @sole_authored_works \n end",
"def return(cards)\n @stockpile += cards\n end",
"def set_study\n @study = Study.find(params[:id])\n @datasets = @study.datasets\n end",
"def index\n @soundnesses = Soundness.where(bridge: @bridge).all\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def show\n @use_case.works << Work.where(use_case_no: @use_case.use_case_no)\n @use_case.hard_infos << HardInfo.where(use_case_no: @use_case.use_case_no)\n @use_case.sales_details << SalesDetail.where(use_case_no: @use_case.use_case_no)\n #calculate id issued / sc count\n @use_case.id_issued = 0\n @use_case.sc_count = 0\n @use_case.hard_infos.each do |hi|\n if hi.id_issued == nil\n hi.id_issued = 0\n end\n if hi.sc_count == nil\n hi.sc_count = 0\n end\n @use_case.id_issued = @use_case.id_issued + hi.id_issued\n @use_case.sc_count = @use_case.sc_count + hi.sc_count\n end\n\n end",
"def trial_guard_squads\n guard_squads = Array.new\n trial_squads.each do |trial_squad|\n guard_squads << trial_squad unless trial_squad.intruder_flg\n end\n guard_squads\n end",
"def show\n @slots = Slot.where(:mouse_rack_id => params[:id]).order('id ASC')\n @holding_cages = HoldingCage.where(:mouse_rack_id => params[:id])\n @mating_cages = MatingCage.where(:mouse_rack_id => params[:id])\n end",
"def spent\n @spent ||= calculate_spent\n @spent.round(2)\n end",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def index\n @spliffs = Spliff.all\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def bought_by\n Tee.where(\"shirt_id = #{self.shirt_id}\").collect(&:who).uniq\n end",
"def funding_rounds\n # helper func that returns all the funding round instances that the startup has gotten\n\n FundingRound.all.select { |funding_round| funding_round.startup == self }\n end",
"def index\n @recordingstations = Recordingstation.all\n end",
"def smoking_progress\n Smoke.by_user(self.id).where(:counted => 0, created_at: 3.days.ago..Time.now).count\n\n # TODO\n #return ['smoked', 3]\n #return ['smoked', 7]\n #return ['smoked', 30]\n #return ['stopped', 3]\n #return ['stopped', 7]\n #return ['stopped', 30]\n\n end",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def set_strokes_expected_shot\n @strokes_expected_shot = StrokesExpectedShot.find(params[:id])\n end",
"def calculated_soak\n soak = brawn\n soak += equipped_armor.armor.soak if equipped_armor\n\n # Then increase based on selected talents.\n talent_alterations.each do |_talent_id, stat|\n stat.each do |type, value|\n soak += value['count'] if type == :soak\n end\n end\n\n cybernetics[:bonuses].each do |cb|\n soak += cb[1] if cb[0] == :soak\n end\n\n soak\n end",
"def shoes\n results = DATABASE.execute(\"SELECT * FROM shoes WHERE category_id = #{@id};\")\n\n store_results = []\n\n results.each do |hash|\n store_results << Shoe.new(hash)\n end\n\n return store_results\n end",
"def storage_all_items\n storage_items + storage_equip_items\n end",
"def funding_rounds\n FundingRound.all.select do |s|\n s.venture_capitalist == self\n end\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def wells\n @wells ||= []\n end",
"def all_recordings\n self.recordings\n end",
"def all_recordings\n self.recordings\n end",
"def shared_inventory\n @weapons + @armors + items_to_obj\n end",
"def take_all; end",
"def trial_intruder_squads\n intruder_squads = Array.new\n trial_squads.each do |trial_squad|\n intruder_squads << trial_squad if trial_squad.intruder_flg\n end\n intruder_squads\n end",
"def strikes\r\n @pitches.select{|pitch| pitch.outcome == 'S'}\r\n end",
"def populateStonks\n @results.keys.each do |stock|\n if Stonk.where(symbol: stock).empty? === true\n then\n s = Stonk.new\n s.symbol = stock\n s.save\n end\n end\n end",
"def show\n @recommendedstickers = Sticker.find(Sticker.pluck(:id).sample)\n end",
"def index\n @shouldersbiceps3s = Shouldersbiceps3.all\n end",
"def index\n @intakes = Intake.all\n end",
"def songs\n #use select to iterate thru songs\n Song.all.select{|song| song.artist == self}\n end",
"def set_skater\n @skater = Skater.includes(:skill, :practices).find(params[:id])\n end",
"def show\n @operations = Operation.includes(:retrieve_account).where(retrieve_account:\n @analytic_account)\n @operations += Operation.includes(:release_account).where(release_account: @analytic_account)\n\n\n end",
"def local_spares\n #{ chain: '10-speed', tire_size: '20', tape_color: tape_color} \n #super.merge({:tape_color => tape_color})\n {:tape_color => tape_color}\n end",
"def index\n track_painter_items = []\n TrackPainter.all.each do |t|\n if t.track_painter_items.count > 1\n t.track_painter_items.map { |tpi| track_painter_items << tpi }\n end\n end\n @track_painter_items = track_painter_items\n end",
"def gal_artist\n beef = paintings.map{|exp| exp.artist.years_active} #accesing artist object in paintings method(mentioned above) and years_active instance_method\n tot = beef.inject{|sum, n| sum + n} #sum of all\n # avg = (beef_tot / beef.length).round(0) #avg of the num of elements(beef_tot) divide by number of arrays we summed up (beef.length)\n # binding.pry\n\n end",
"def shares\n return @shares\n end",
"def shares\n return @shares\n end",
"def relevant_records\n case context\n when \"applicant\" then phase.all_applications\n when \"mentors\" then phase.all_applications.collect(&:mentors).flatten\n when \"group_members\" then phase.all_applications.collect(&:group_members).flatten\n when \"reviewers\" then (phase.all_applications.collect{|a| a.reviewers.without_committee_scores} + offering.reviewers).flatten\n when \"interviewers\" then (phase.all_applications.collect(&:interviewers) + offering.interviewers).flatten\n end\n end",
"def save_and_remove_all(map_id, round)\n records = @store.where(map_id: map_id, round: round)\n uncommitted = records.map { |record| record.link }\n\n unless records.empty?\n records.each do |record|\n previous = SubmissionViewingEvent.where(\n map_id: record.map_id,\n round: record.round,\n link: record.link\n ).first\n\n if previous\n # make sure to add the total time on this record\n # with what may have already been in the database\n previous.update_attribute(:total_time, record.merge(event))\n else\n # if a previous record doesn't exist,\n # we can delegate saving to `LocalStorage`\n @store.hard_save(record)\n end\n\n # once the data is updated or added to the database,\n # remove it from `LocalStorage`\n @store.remove(record)\n end\n end\n\n uncommitted\n end",
"def index\n @shuttle_runs = ShuttleRun.all\n end",
"def get_qr_qwr_wl_lines_by_streams\r\n lines_by_streams = Hash.new\r\n # Create arrays for each stream\r\n Stream.find(:all).each do |s| \r\n # lines_by_streams[s.id] = Array.new\r\n lines_by_streams[s.id] = Hash.new\r\n lines_by_streams[s.id][\"prev\"] = 0\r\n lines_by_streams[s.id][\"sum\"] = 0\r\n lines_by_streams[s.id][\"qs_prev\"] = 0\r\n lines_by_streams[s.id][\"spider_prev\"] = 0\r\n lines_by_streams[s.id][\"qs_sum\"] = 0\r\n lines_by_streams[s.id][\"spider_sum\"] = 0\r\n end\r\n # Add wl_lines to corresponding stream\r\n wl_lines.each { |wl|\r\n if wl.project\r\n # Stream\r\n s = Stream.find_with_workstream(wl.project.workstream)\r\n # Previsional\r\n if(wl.wl_type == 110)\r\n lines_by_streams[s.id][\"prev\"] = lines_by_streams[s.id][\"prev\"] + (wl.project.calcul_qs_previsional.to_f * APP_CONFIG['qs_load'].to_f)\r\n lines_by_streams[s.id][\"qs_prev\"] = lines_by_streams[s.id][\"qs_prev\"] + (wl.project.calcul_qs_previsional.to_f * APP_CONFIG['qs_load'].to_f)\r\n lines_by_streams[s.id][\"qs_sum\"] = lines_by_streams[s.id][\"qs_sum\"] + wl.planned_sum.to_f \r\n lines_by_streams[s.id][\"sum\"] = lines_by_streams[s.id][\"sum\"] + wl.planned_sum.to_f\r\n elsif(wl.wl_type == 120)\r\n lines_by_streams[s.id][\"prev\"] = lines_by_streams[s.id][\"prev\"] + (wl.project.calcul_spider_previsional.to_f * APP_CONFIG['spider_load'].to_f)\r\n lines_by_streams[s.id][\"spider_prev\"] = lines_by_streams[s.id][\"spider_prev\"] + (wl.project.calcul_spider_previsional.to_f * APP_CONFIG['spider_load'].to_f)\r\n lines_by_streams[s.id][\"spider_sum\"] = lines_by_streams[s.id][\"spider_sum\"] + wl.planned_sum.to_f\r\n lines_by_streams[s.id][\"sum\"] = lines_by_streams[s.id][\"sum\"] + wl.planned_sum.to_f\r\n end\r\n end \r\n }\r\n return lines_by_streams\r\n end",
"def list_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end"
] | [
"0.5652778",
"0.54892915",
"0.54211086",
"0.53996325",
"0.52879304",
"0.52835196",
"0.5278367",
"0.52241725",
"0.51919407",
"0.5156141",
"0.51478046",
"0.5129152",
"0.512909",
"0.5113019",
"0.5103297",
"0.5094018",
"0.50792295",
"0.5079123",
"0.5034905",
"0.5028437",
"0.50279844",
"0.50206935",
"0.5015787",
"0.5014774",
"0.5012373",
"0.50081843",
"0.50049585",
"0.5002303",
"0.49709925",
"0.4945717",
"0.49310702",
"0.4927874",
"0.4907403",
"0.49002147",
"0.48984084",
"0.4893577",
"0.4888149",
"0.4885509",
"0.48842162",
"0.4883991",
"0.48735532",
"0.486196",
"0.48616213",
"0.4861565",
"0.48611104",
"0.48587933",
"0.48587933",
"0.48531666",
"0.48484343",
"0.4847452",
"0.48420295",
"0.48395675",
"0.4834964",
"0.48327768",
"0.48286337",
"0.48286337",
"0.48286337",
"0.48272565",
"0.482611",
"0.4823751",
"0.48129535",
"0.48073706",
"0.48061514",
"0.48037577",
"0.4801406",
"0.47988424",
"0.47942188",
"0.47938886",
"0.47921836",
"0.47919008",
"0.47902748",
"0.47881594",
"0.47863042",
"0.47771204",
"0.47766167",
"0.47754171",
"0.47692063",
"0.4761607",
"0.4761607",
"0.4756902",
"0.475676",
"0.47524446",
"0.47522947",
"0.47489026",
"0.47484255",
"0.47474077",
"0.47439182",
"0.4742184",
"0.4731648",
"0.47277844",
"0.47220993",
"0.4720807",
"0.47162974",
"0.47147426",
"0.47147426",
"0.4713932",
"0.47120273",
"0.471172",
"0.47098696",
"0.47094202"
] | 0.48773545 | 40 |
def validate_splits total = 0.0 self.stakes.each do |stake| total += stake.split_in_percent end return total == 1.0 end | def uniqify_fields
begin
self.uniq_title = self.title.to_uniq
self.uniq_position = self.position.to_uniq
self.uniq_playbacks_count = self.playbacks_count.to_uniq
self.uniq_likes_count = self.likes_count.to_uniq
self.uuid = UUIDTools::UUID.timestamp_create().to_s if self.uuid.nil?
rescue
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_total_split\n dinner = Checksplitter.new(20, 20, 4)\n \n assert_equal(dinner.total_split, (dinner.total_cost / dinner.number_of_people))\n end",
"def split_total_amount\n total=0\n reim_split_details.each do |split|\n next if split.marked_for_destruction?\n total+=split.percent_amount if split.percent_amount\n end\n total\n end",
"def check_split\n (meal + ((meal * tip) / 100)) / group\n end",
"def split_the_check\n @split_check = (total_check / diners).round(2)\n end",
"def completeness_score\n sum_score = 0\n passed_checks.each { |check| sum_score += check[:weighting] }\n sum_score\n end",
"def completeness_score\n passed_checks.sum(&:weighting)\n end",
"def grade_percentage\n all_tests = BoatingTest.all.select do |test|\n test.student == self\n end\n passed_tests = all_tests.select do |test|\n test.status == \"passed\"\n end\n passed_tests.length.to_f/all_tests.length.to_f\n end",
"def grade_percentage\n passed_tests.count / my_tests.count\n end",
"def test_split\n assert_equal((46 / 3.0).round(2), @check_test.split.to_f)\n end",
"def percent_passes; end",
"def percent_passes; end",
"def grade_percentage\n # get the number of passing tests as a float\n passing_tests = tests.select { |test| test.test_status == \"passed\" }.length.to_f\n # get total number of all that students tests\n all_tests = tests.length.to_f\n # calculate their passing_tests as a % of their total tests\n passing_tests / all_tests * 100\n end",
"def percent_passes\n 100 - percent_skips - percent_errors_failures\n end",
"def grade_percentage\n passed_tests = boating_tests.select { |tests| tests.test_status == \"Pass\" }\n (passed_tests.count.to_f / boating_tests.count.to_f) * 100\n end",
"def grade_percentage\n tests = BoatingTest.all.select {|test| test.student.first_name == self.first_name}\n passed_tests = tests.select {|test| test.test_status == \"passed\"}\n per = (passed_tests.length.to_f / tests.length.to_f)*100\n \n end",
"def grade_percentage\n (self.passed_tests.length.to_f / self.tests.length * 100).round(2)\n end",
"def grade_percentage\n\t\t#1. Collect all of the tests a student has taken \n\t\t#2. Find the percentage of tests the student has passed.\n\t\t#3. Return the amount as a float.\n\t\tgrade_arr = BoatingTest.all.select do |test|\n\t\t\ttest.student == self\n\t\tend\n\t\t\n\t\tgrade_arr = grade_arr.collect do |test|\n\t\t\ttest.status\n\t\tend\n\t\t(grade_arr.count(\"passed\").to_f/grade_arr.count.to_f) * 100\n\tend",
"def success_count\n examples_total - examples_pending - examples_failed\n end",
"def success_rate\n return 0 if self.product_tests.empty?\n return self.count_passing.to_f / self.product_tests.size\n end",
"def grade_percentage\n studentTests= BoatingTest.all.find_all{|test| test.student.first_name == self.first_name}\n totalTests= studentTests.length.to_f\n totalPassed= studentTests.find_all{|test| test.status == \"passed\"}\n numPassed= totalPassed.length.to_f\n percent= (numPassed/totalTests)*100\n end",
"def grade_percentage\n # This is the total number of tests a student (self) has taken.\n student_tests = BoatingTest.all.select do |test|\n test.student == self\n end\n\n # From the total number of tests taken by that student (self), we just want\n # the one's that have passed.\n passed_test = student_tests.select do |test|\n test.status == \"passed\"\n end\n # From the total number of tests taken by that student (self), we just want\n # the one's that have failed.\n failed_test = student_tests.select do |test|\n test.status == \"failed\"\n end\n\n # Now we need to find the percent of tests that this student (self) has\n # passed compared to the total number of tests they have taken.\n # Multiply by 100 to get a % value instead of decimal.\n # ratio = (passed_test.length.to_f)/(student_tests.length)\n # ratio * 100 SAME AS BELOW\n ratio = \"%.2f\" % (passed_test.length.fdiv(student_tests.length)*100).to_s + \"%\"\n # The \"%.2f\"\n end",
"def grade_percentage\n #Count all tests this student has passed\n tests_passed = BoatingTest.all.select {|test| test.student == self && test.test_status == \"passed\" }.length.to_f\n #Count all tests with this student\n all_tests = BoatingTest.all.select {|test| test.student == self}.length.to_f\n #Calculate percentage as float\n grade_percentage = tests_passed/all_tests\n grade_percentage.round(2)\n end",
"def correct?\n total = 0\n @element_list.each do |element|\n total += element[1]\n end\n total == @target && @element_list.size >= @minimum_size\n end",
"def passes\n count - failures - errors - skips\n end",
"def percent_correct\n # Check for divide by zero. Than calculate the percentage otherwise.\n if @turns.size == 0\n 0.0\n else\n # Calculate percentage, truncate value to one decimal place.\n ((number_correct.to_f / @turns.size.to_f) * 100.0).truncate(1)\n end\n end",
"def self_percent_complete\n if !self.self_check_count.blank?\n if self.designer_completed_checks <= self.self_check_count\n self.designer_completed_checks * 100.0 / self.self_check_count\n else\n 100.0\n end\n else\n 0\n end\n end",
"def test\n false_good, true_bad = get_counts(@testing_bad)\n true_good, false_bad = get_counts(@testing_good)\n\n correct = true_good.length + true_bad.length\n total = correct + false_bad.length + false_good.length\n ratio = format_ratio(1.0 * correct / total)\n\n bad_total = false_good.length + true_bad.length\n bad_ratio = format_ratio(1.0 * true_bad.length / bad_total)\n\n good_total = true_good.length + false_bad.length\n good_ratio = format_ratio(1.0 * true_good.length / good_total)\n\n puts \"Accuracy: #{ratio} (#{correct} of #{total})\"\n\n puts \"Bad commit accuracy: #{bad_ratio} (#{true_bad.length} of #{bad_total})\"\n print_failures(true_bad)\n\n puts \"Good commit accuracy: #{good_ratio} (#{true_good.length} of #{good_total})\"\n print_failures(true_good)\n end",
"def check_train_wagons\n passenger_trains_amount = 0\n cargo_amount = 0\n @trains.each_value do |train|\n train.type == 'cargo' ? cargo_amount += 1 : passenger_trains_amount += 1\n end\n passenger_matches(passenger_trains_amount) || cargo_matches(cargo_amount)\n end",
"def points\n raise \"Not an IOI style task.\" unless task.scoring == \"ioi\"\n total = body.count.to_f\n raise \"Task has no tests.\" unless total > 0\n\n passed = body.count { |test| test[:status] == \"Correct\" }\n ((passed / total) * 100).round\n end",
"def count_passing\n return self.passing_tests.size\n end",
"def goldenCompletion?\n\t\t@cards[TOTAL_UNIQUE_CARDS..2*TOTAL_UNIQUE_CARDS-1].reduce(0) {|memo, card| card.complete? ? memo + 1 : memo} / TOTAL_UNIQUE_CARDS.to_f\n\tend",
"def good?\n @summary[:total_score] <= Constants::THRESHOLDS[\"Project\"]\n end",
"def percent_errors_failures; end",
"def percent_errors_failures; end",
"def grade_percentage\n my_test = BoatingTest.all.select do |test|\n test.student == self \n end \n passed_test = my_test.select do |test|\n test.status == \"passed\" \n end\n passed_test.count.to_f / my_test.count\n #binding.pry \n end",
"def covered_percentages; end",
"def check_for_tot_bal\n val1 = @txt_val1.text.gsub(/[$]/, '$' => '')\n val2 = @txt_val2.text.gsub(/[$]/, '$' => '')\n val3 = @txt_val3.text.gsub(/[$]/, '$' => '')\n val4 = @txt_val4.text.gsub(/[$]/, '$' => '')\n val5 = @txt_val5.text.gsub(/[$]/, '$' => '')\n total_val_expected = [val1, val2, val3, val4, val5].map(&:to_f).inject(:+)\n total_val_actual = @txt_val_ttltext.gsub(/[$]/, '$' => '').to_f\n total_val_expected == total_val_actual\n end",
"def passed?\n @grade >= 2.0\n end",
"def test_total_cost\n dinner = Checksplitter.new(20, 20, 4)\n \n assert_equal(dinner.total_cost, (dinner.meal_cost + dinner.tip).to_f)\n end",
"def complete?\n total = 0\n @element_list.each do |element|\n total += element[1]\n end\n total >= @target\n end",
"def is_valid?\n return 0 if @pokers.size == 0\n @pokers.select{ |p| (@pokers.length == 4 && @sum != 61 ) || (p!= @pokers[0]) }.size > 0 ? 0 : 1\n end",
"def verify_score(score)\n decimal = (score * 60) % 1\n [decimal, 1 - decimal].min < 0.03\nend",
"def success\n (correct_answers_count*100.0/answers_count).round.to_i if answers_count > 0\n end",
"def total_the_check\n @total_check = ((check * tip) + check).round(2)\n end",
"def grade_percentage\n total = 0\n student_tests = BoatingTest.all.select {|test| test.student == self}\n student_tests.each do |test|\n if test.test_status == \"passed\"\n total += 1\n end\n end\n average = total.to_f / student_tests.length\n average * 100\n end",
"def calculate_winnings\n result = 0\n self.bookings.each do |booking|\n if booking.match.status == \"FINISHED\"\n if booking.won\n result += booking.stake * booking.odd.odds\n else\n booking.stake ? result -= booking.stake : result\n end\n end\n end\n return result.round(2)\n end",
"def calculate_completeness_score\n total = 0.0\n counted = 0.0\n fields.keys.each do |key|\n total += 1\n if self[key]\n counted += 1\n end\n end\n\n write_attributes(completeness_score: counted / total)\n end",
"def number_correct\n turns.count do |each_turn|\n each_turn.correct?\n end\n end",
"def check(best, results)\n\t\tmag = best * @threshold\n\t\tamount = 0\n\n\t\tresults.each do |value|\n\t\t\tif value <= mag\n\t\t\t\tamount += 1\n\t\t\tend\n\t\tend\n\n\t\tif amount < @k\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def total_score(play)\n sum = 0;\n play.decision_array.each_with_index{|v, i|\n sum += 1 if v == decision_array[i] && i != 0 # exclude an example\n }\n sum\n end",
"def scoring_needed?\n return false if locked_not_scored.none?\n\n finished = FootballData.fetch(:competitions, :matches, id: 2021, status: 'FINISHED')['count'].to_i\n scored = Score.where.not(points: 0).count / 2\n return false unless finished > scored\n\n true\n end",
"def partial_review_self_check_count\n check_count = 0\n self.sections.each do |s|\n next if !s.dot_rev_check?\n s.subsections.each do |ss|\n next if !ss.dot_rev_check?\n ss.checks.each { |c| check_count += 1 if c.bare_board_design_check? && c.is_self_check? }\n end\n end\n check_count\n end",
"def test_standard_credit_results\n @standard_credit_Value.each { |key, value| assert_in_delta @calc_standard[@row_number][key], value, 0.03 }\n check_count @calc_standard\n end",
"def doGreedy? forceValidation\r\n\t\tif ! @trainTestStruct.equalTestSetAndResults?\r\n\t\t\tif ! forceValidation\r\n\t\t\t\treturn false\r\n\t\t\telse\r\n\t\t\t\tdoValidation \r\n\t\t\tend\r\n\t\tend\r\n\t\ttrue\r\n\tend",
"def expected_grades\n metrics.count * course.students.count\n end",
"def calc_progress\n p = 0.25\n unless self.compile_errors.nil?\n p = 0.5\n end\n\n if self.correct\n p = 1.0\n else\n unless self.results.nil?\n p_tc = 0.0\n self.results.each do |id,result|\n unless result['error']\n p_tc = p_tc + 1\n end\n end\n p = p + ((p_tc/self.results.size) * 0.5)\n end\n end\n\n p\n end",
"def pick_percentage\n self.score.to_f / Matchup.amount_finished.to_f\n end",
"def passing?\n return true if self.product_tests.empty?\n\n passing = self.product_tests.includes(:test_executions).select do |p|\n p.execution_state == :passed\n end\n passing.length == product_tests.length\n end",
"def test_total_cost\n meal_cost = 45\n group = 3\n tip_percentage = 20\n tip_amount = meal_cost.to_f * (tip_percentage/100.0)\n meal1 = CheckSplitter.new(meal_cost: meal_cost, group: group, tip_percentage: tip_percentage)\n assert_equal(54.0, meal1.total_cost)\n end",
"def folding?\n return false if amount_to_call == 0\n if @hand.board.all == []\n starting_hand_rank > @range\n else\n # binding.pry\n amount_to_call > max_bet(winning_percentage)\n end\n end",
"def nbAreteDouble\n nbDouble = 0\n @aretes.each { |x|\n x.estDouble ? nbDouble += 1 : false\n }\n return nbDouble\nend",
"def percent_errors_failures\n ((errors + failures) / count.to_f * 100).to_i\n end",
"def number_correct\n @turns.count do |turn|\n turn.correct?\n end\n end",
"def is_avg_whole?(arr)\n arr.reduce(&:+) % arr.length == 0\nend",
"def success?\n coverage.round(COVERAGE_PRECISION).eql?(config.expected_coverage.round(COVERAGE_PRECISION))\n end",
"def check_words(key_words, words, is_subject = false)\n temp_points = 0\n words.each do |word|\n temp_points += check_key_words(word, key_words, is_subject)\n end\n return temp_points\n end",
"def covered_percent; end",
"def covered_percent; end",
"def tricks_taken \n \t\tself.score-(self.correct*10)\n \tend",
"def getTotalledResult\r\n\t\treturn @totalResult if @totalResult\r\n\t\tdataSet = RegressionDataSet.new nil, @trainTestStruct.trainingData.features\r\n\t\ti \t\t= 0\r\n\t\twhile i < @trainTestStruct.testSetCount\r\n\t\t\tdataSet << @trainTestStruct.testSets(i)\r\n\t\t\ti \t\t+= 1\r\n\t\tend\r\n\t\tinputAndTargets\t= getTargets dataSet\r\n\t\t@totalResult \t= @trainTestStruct.setTotalResult(@machine.validateSet inputAndTargets.first, inputAndTargets.last, @predictionType)\r\n\tend",
"def check_data_validation\r\n if @tx_interest.text.to_f > 0 and \r\n @tx_interest.text.to_f < 0.1 and\r\n @tx_amount.text.to_i >= 1000 and\r\n @tx_years.text.to_i >= 1 then\r\n tf = true\r\n else\r\n tf = false\r\n end\r\n return tf\r\n end",
"def input_completed_percentage\n total_input_days = 0\n total_pending_input = 0\n self.users.each do |user|\n pending_input, input_days = user.pending_input\n total_pending_input += pending_input\n total_input_days += input_days\n end\n # If no users, then input is OK\n return 1 if total_input_days == 0\n ((total_input_days - total_pending_input) / total_input_days.to_f).round(2)\n end",
"def is_avg_whole?(arr)\n sum_of_arr = arr.inject(0) {|sum,x| sum + x }\n\treturn (sum_of_arr / arr.length.to_f)%1==0 ? true : false\nend",
"def full_review_self_check_count\n check_count = 0\n self.sections.each do |s|\n next if !s.full_review?\n s.subsections.each do |ss|\n next if !ss.full_review?\n ss.checks.each { |c| check_count += 1 if c.new_design_check? && c.is_self_check? }\n end\n end\n check_count\n end",
"def passes; end",
"def passes; end",
"def satisfied?\n self.enrollments.group_by(&:quarter).map do |quarter, enrollments|\n units = enrollments.map(&:units).reduce(:+)\n unless MIN_UNITS <= units and MAX_UNITS >= units\n self.errors << quarter.to_s.bold + \" has \" + units.to_s.bold.red + \" units!\"\n end\n end\n self.errors.empty?\n end",
"def points\n return 0 if match.invalid_result?\n return 4 if self.score == match.score\n return 3 if self.goals_diff == match.goals_diff\n return 2 if self.winner == match.winner\n return 0\n end",
"def pass?(num)\n (2..20).each do |factor|\n return false unless (num % factor).zero?\n end\n true\nend",
"def passed_checks\n all_checks_which_pass\n end",
"def failed\n total - successful\n end",
"def is_avg_whole?(arr)\n\tsum = arr.sum\n\tavg_i = sum / arr.count \n\tavg_f = sum / arr.count.to_f\n\tavg_i == avg_f\nend",
"def test_cost_per_person\n meal_cost = 45\n group = 3\n tip_percentage = 20\n tip_amount = meal_cost.to_f * (tip_percentage/100.0)\n meal1 = CheckSplitter.new(meal_cost: meal_cost, group: group, tip_percentage: tip_percentage)\n assert_equal(18.0, meal1.cost_per_person)\n end",
"def test_percentage_home_wins\n assert_equal 0.44, @stat_tracker.percentage_home_wins\n end",
"def passed?\n failures.empty?\n end",
"def finished?\n @round_counter >= @croupier.rules[:rounds]\n end",
"def step_one_points\n\t\tpoints = 0\n\t\tpoints+=50 if !link.blank?\n\t\tpoints+=25 if !title.blank?\n\t\tpoints+=25 if !company.blank?\n\t\tpoints\n\tend",
"def test_total_cost\n assert_equal(46.0, @check_test.total_cost)\n end",
"def compute_best_score(team, pilots, pilot_contests)\n combination = []\n total = 0.0\n total_possible = 0\n puts 'compute_score TBD'\nend",
"def check_phase_estimation\n return false if !life_cycle_phase\n planned_hours_phase = self.project.projects_phases_joins.where(\"life_cycle_phase_id = ?\", self.life_cycle_phase.id).first.planned_hours_phase\n if self.new_record?\n sum_hours_tasks = self.project.tasks.where(\"life_cycle_phase_id = ?\", self.life_cycle_phase.id).sum(\"planned_hours\")\n else\n sum_hours_tasks = self.project.tasks.where(\"life_cycle_phase_id = ? AND id <> ?\", self.life_cycle_phase.id, self.id).sum(\"planned_hours\")\n end\n sum_hours_tasks = sum_hours_tasks + self.planned_hours\n if (sum_hours_tasks) > planned_hours_phase\n errors.add(:planned_hours, I18n.t(\"screens.alerts.tasks_exceeded_in_hours\"))\n return false\n end\n return true\n end",
"def expected_grades\n assignment.course.students.count\n end",
"def test_block_count_correct_true\n assert @bv.block_count_correct?(1, [1,2,3,4,5])\n end",
"def shareholding_percent_valid\n errors.add(:shareholding_percent, 'must be zero for non-shareholder') if ((!self.shareholder) and has_shareholding?)\n \n errors.add(:shareholding_percent, 'must be non zero for shareholder') if (self.shareholder and !has_shareholding?) \n end",
"def next_percent_complete\n (self.completeness_score.to_f + self.failed_checks.first[:weighting]) / self.class.max_completeness_score.to_f * 100\n end",
"def money_enough?\n remaining_sum > 0\n end",
"def test_average_goals_per_game\n\n assert_equal 4.22, @stat_tracker.average_goals_per_game\n end",
"def validate_assignment_questionnaires_weights(attributes)\n total_weight = 0\n attributes.each do |assignment_questionnaire|\n total_weight += assignment_questionnaire[:questionnaire_weight].to_i\n end\n unless total_weight.zero? || total_weight == 100\n @assignment.errors.add(:message, 'Total weight of rubrics should add up to either 0 or 100%')\n @has_errors = true\n end\n end",
"def check(sheet)\n cells = sheet.map {|row| row.split.map {|cell| cell.to_i} }\n\n total = 0\n\n cells.each do |row|\n row.each do |cell|\n row.each do |divisor|\n dividend, modulo = cell.divmod(divisor)\n total += dividend if modulo == 0 && dividend != 1\n end\n end\n end\n\n total\nend",
"def total\n @parts.map {|part| part.abs }.inject(0) {|sum,val| sum + val }\n end",
"def equal_split?(nums)\n total = nums.inject(0, :+)\n return unless total % 2 == 0\n i = 0\n potential_half = 0\n while i < nums.length\n potential_half += nums[i]\n total -= nums[i]\n break if total == potential_half\n i += 1\n end\n if total == potential_half\n # Array.take returns the first x values of an array, whereas Array.drop\n # returns the rest of an array, after removing x values. We use i + 1\n # due to zero-indexing.\n print [nums.take(i + 1), nums.drop(i + 1)]\n else\n print 'Not possible to split'\n end\nend",
"def expected\n\t\t\tBigDecimal(@count) * ((@sides + 1.0) / 2.0)\n\t\tend"
] | [
"0.7098094",
"0.6871112",
"0.68087304",
"0.6792518",
"0.67121935",
"0.66255325",
"0.656732",
"0.65660715",
"0.6357939",
"0.63392276",
"0.63392276",
"0.63287264",
"0.6299747",
"0.62961155",
"0.6229482",
"0.622237",
"0.6183262",
"0.6158475",
"0.6116033",
"0.6082158",
"0.6032678",
"0.60076684",
"0.5992209",
"0.59790474",
"0.59632623",
"0.5956949",
"0.59343624",
"0.5926192",
"0.5923587",
"0.5923353",
"0.58866674",
"0.5872152",
"0.58611715",
"0.58611715",
"0.5858918",
"0.5847184",
"0.58425397",
"0.58385736",
"0.58350205",
"0.5816951",
"0.5805985",
"0.57938135",
"0.57922363",
"0.57899743",
"0.57732254",
"0.5765939",
"0.5765213",
"0.5762212",
"0.5731963",
"0.57284427",
"0.5719791",
"0.5717724",
"0.57165045",
"0.5701554",
"0.5697417",
"0.5683066",
"0.56826043",
"0.56807834",
"0.56740665",
"0.566443",
"0.56609994",
"0.5649789",
"0.5645226",
"0.5643205",
"0.5617856",
"0.5610527",
"0.560364",
"0.560364",
"0.5597737",
"0.5593456",
"0.55839926",
"0.55552393",
"0.55518156",
"0.55444103",
"0.55423295",
"0.55423295",
"0.5539186",
"0.5529551",
"0.5525169",
"0.5523115",
"0.551945",
"0.5509634",
"0.55094236",
"0.55060744",
"0.5505797",
"0.5505208",
"0.5498905",
"0.5495732",
"0.5487225",
"0.5485706",
"0.54855597",
"0.54843473",
"0.5480171",
"0.5477047",
"0.5472466",
"0.5472232",
"0.54703015",
"0.5467552",
"0.5464113",
"0.5463928",
"0.5463909"
] | 0.0 | -1 |
for some reason this is not working forget about it until elastic transcoding is implemented | def update_thumbs
File.open(self.cover_art) do |f|
self.default_cover_art = f
self.default_cover_art.recreate_versions!
self.save!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_es_mapping\n return nil\n end",
"def external_encoding()\n #This is a stub, used for indexing\n end",
"def encoder; end",
"def encoder; end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def transact; end",
"def transcoder\n @transcoder ||= Aws::ElasticTranscoder::Client.new(\n region: Rails.application.secrets.aws_region\n )\n end",
"def transforms; end",
"def transform; end",
"def encoding_found; end",
"def encoding_found; end",
"def encodings; end",
"def enter_transcoding\n # Send variant jobs to codem\n t = Transcoder.available\n if t.any? && send_to_transcoder(t.first)\n update_attribute(:status, :transcoding)\n end\n end",
"def encode\n transform :encode \n end",
"def encoding()\n #This is a stub, used for indexing\n end",
"def decode; end",
"def decode; end",
"def encoder=(_arg0); end",
"def transform\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def content_encoding_hooks; end",
"def content_encoding_hooks; end",
"def encode!; end",
"def acrostic_decoder(coded_message)\n # write code here \nend",
"def acrostic_decoder!(coded_message)\n # write code here \nend",
"def transition_from_pending\n enter_transcoding if Transcoder.available.any?\n end",
"def transformation\n end",
"def encode_string_ex; end",
"def extractData()\n\n @es_client = Elasticsearch::Client.new host: 'http://192.168.59.103:9200/', log: true\n gr = RDF::Vocabulary.new(\"http://purl.org/goodrelations/v1#\")\n s = RDF::Vocabulary.new(\"http://schema.org/address\")\n v = RDF::Vocabulary.new(\"http://www.w3.org/2006/vcard/ns#\")\n l = RDF::Vocabulary.new(\"http://www.linked-usdl.org/ns/usdl-core#\")\n\n company = RDF::Node.new\n addTriple( company , RDF.type, @resume_cv.Company)\n addUSDL(company, RDF.type, gr.BusinessEntity)\n\n # content = @doc.css('div').select{|document| document['id'] == \"inhalt\"}[0]\n company_name = extractAnnotation(\"name\").first\n\n add_annotation(\"name\", company_name)\n # description = @doc.css('div').select{|description| description['id'] == \"text\"}[0]\n\n\n website = extractAnnotation(\"website\").first\n streetAddress = extractAnnotation(\"streetAddress\").first\n postal = extractAnnotation(\"postal\").first\n locality = extractAnnotation(\"locality\").first\n country = extractAnnotation(\"country\").first\n phone = extractAnnotation(\"phone\").first\n mail = extractAnnotation( \"mail\").first\n region = country\n\n extractAnnotation(\"product_categories\").each do |i|\n puts \"i: #{i}\"\n product = RDF::Node.new\n addUSDL(product, RDF.type, gr.ProductOrService)\n addUSDL(product, gr.name, i)\n addUSDL(product, gr.hasManufacturer, company)\n addTriple(company, @resume_cv.produces, i)\n end\n\n extractAnnotation(\"produces\").each do |i|\n puts \"prodcat2 : #{i}\"\n offering = RDF::Node.new\n addUSDL(offering, RDF.type, gr.Offering)\n addUSDL(company, gr.offers, offering)\n addUSDL(offering, gr.name , i)\n\n addTriple(company, @resume_cv.sells , i)\n end\n\n extractAnnotation(\"distr_category\").each do |i|\n puts \"distcat : #{i}\"\n addUSDL(company, gr.category, i)\n addTriple(company, @resume_cv.distribution_type, i)\n end\n\n extractAnnotation(\"distributes_for\").each do |i|\n puts \"distfor : #{i}\"\n addUSDL(company, @resume_cv.distribution_for, i)\n addTriple(company, @resume_cv.distribution_for, i)\n end\n\n extractAnnotation(\"provides\").each do |i|\n puts \"provcat : #{i}\"\n offering = RDF::Node.new\n addUSDL(offering, RDF.type, gr.Offering)\n addUSDL(company, gr.offers, offering)\n addUSDL(offering, gr.name , i)\n addTriple(company, @resume_cv.hasSpeciality , i)\n end\n\n extractAnnotation(\"distributed_by\").each do |i|\n puts \"distfor : #{i}\"\n addUSDL(company, @resume_cv.distributed_by, i)\n addTriple(company, @resume_cv.distributed_by, i)\n end\n\n # addTriple(company , @resume_cv.isIndustry, industry)\n # addUSDL(company, gr.category, industry)\n # addTriple(company, @resume_cv.hasSpeciality, s)\n addTriple(company , @resume_cv.hasWebsite, website)\n addUSDL(company, RDF::FOAF.page, website)\n addTriple( company , @resume_cv.name, company_name)\n addUSDL( company, gr.legalName, company_name)\n # # addTriple(company , @resume_cv.hasType, type)\n # # addTriple(company , @resume_cv.wasFounded, founded)\n # # addTriple(company , @resume_cv.hasSize, compsize)\n address = RDF::Node.new\n addUSDL(address, RDF.type , v.Address)\n addUSDL(company, l.hasCommunicationChannel, address)\n\n telephone = RDF::Node.new\n addUSDL(telephone, RDF.type, v.Voice)\n addUSDL(telephone, v.hasValue, phone)\n\n addUSDL(address, v.country_name, country)\n addUSDL(address, v.locality, locality)\n addUSDL(address, v.postal_code, postal )\n addUSDL(address, v.street_address, streetAddress)\n addUSDL(address, v.has_email ,mail)\n\n addTriple(company , @resume_cv.hasLocality, locality)\n addTriple(company , @resume_cv.hasStreetAddress, streetAddress)\n addTriple(company , @resume_cv.locatedInRegion, region)\n addTriple(company , @resume_cv.postalCode, postal)\n addTriple(company , @resume_cv.country, country)\n\n add_annotation( \"locality\", locality)\n add_annotation( \"street\" , streetAddress)\n add_annotation( \"postal\" , postal)\n add_annotation( \"country\", country)\n add_annotation( \"phone\", phone)\n add_annotation( \"mail\" , mail)\n\n company_name\n end",
"def transformations; end",
"def translate\n translate_matches\n add_meta_charset\n set_encoding\n end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def encoding=(_arg0); end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def _lex_trans_keys; end",
"def decode\n transform :decode\n end",
"def run_and_transform; end",
"def transform(transform)\n end",
"def convert_encoding(content); end",
"def update_parent_chain\n\t\t## okay so there is some deprecation \n\t\t## here on the newer elasticsearch version.\n\t\tcurrent_org = self\n\t\t\n\t\tsearch_request = Organization.search({\n\t\t\tquery: {\n\t\t\t\tterm: {\n\t\t\t\t\tchildren: self.id.to_s\n\t\t\t\t}\n\t\t\t},\n\t\t\taggregations: {\n\t\t\t\tparent_organizations: {\n\t\t\t\t\tterms: {\n\t\t\t\t\t\tfield: \"id_duplicate\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t\n\t\t## so the id can be a base64 slug.\n\t\t## that is created from that ?\n\t\t## we can do something like that. \n\n\t\t#puts \"=-&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&== updating parent chain\"\n\n\n\t\tsearch_request.response.aggregations.parent_organizations.buckets.each do |porg_bucket|\n\n\t\t\torganization_id = porg_bucket[\"key\"]\n\n\t\t\tsource = '''\n\t\t\t\tfor(orphan in params.orphans){\n\t\t\t\t\tctx._source.children.removeIf(item -> item == orphan);\n\t\t\t\t}\n\t\t\t'''\n\t\t\tparams = {\n\t\t\t\torphans: ([self.id.to_s] + (self.children || [])).flatten\n\t\t\t}\n\t\t\tupdate_hash = {\n\t\t\t\tupdate: {\n\t\t\t\t\t_index: self.class.index_name,\n\t\t\t\t\t_type: self.class.document_type,\n\t\t\t\t\t_id: organization_id,\n\t\t\t\t\tdata: { \n\t\t\t\t\t\tscript: \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsource: source,\n\t\t\t\t\t\t\tlang: 'painless', \n\t\t\t\t\t\t\tparams: params\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t#puts \"the delete update hash is :\"\n\t\t\t#puts update_hash.to_s\n\t\t\t#puts \"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"\n\n\t\t\tOrganization.add_bulk_item(update_hash)\n\t\t\tOrganization.flush_bulk\n\t\tend\n\n\t\twhile true\n\t\t\t#puts \"the current org parent id is:\"\n\t\t\t#puts current_org.parent_id.to_s\n\t\t\tbreak unless current_org.parent_id\n\t\t\tparent = Organization.find(current_org.parent_id)\n\t\t\tsource = '''\n\t\t\t\tif(!ctx._source.children.contains(params.child_organization_id)){\n\n\t\t\t\t\tctx._source.children.add(params.child_organization_id);\n\t\t\t\t}\n\t\t\t'''\n\t\t\tparams = {\n\t\t\t\tchild_organization_id: self.id.to_s\n\t\t\t}\n\t\t\tupdate_hash = {\n\t\t\t\tupdate: {\n\t\t\t\t\t_index: self.class.index_name,\n\t\t\t\t\t_type: self.class.document_type,\n\t\t\t\t\t_id: parent.id.to_s,\n\t\t\t\t\tdata: { \n\t\t\t\t\t\tscript: \n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsource: source,\n\t\t\t\t\t\t\tlang: 'painless', \n\t\t\t\t\t\t\tparams: params\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tOrganization.add_bulk_item(update_hash)\n\t\t\t## now add the bulk request.\n\t\t\tcurrent_org = parent\n\t\tend\n\t\tOrganization.flush_bulk\n\tend",
"def run\n super\n\n #\n # This module currently uses the Free API (rate limited / response limited)\n # https://freeapi.robtex.com/ipquery/#{search_ip}\n #\n # Note that a paid version (free up to 10k queries / month) of the API is available at:\n # https://market.mashape.com/robtex/robtex\n #\n\n # Check Robtex API & create entities from returned JSON\n search_ip = _get_entity_name\n search_uri = \"https://freeapi.robtex.com/ipquery/#{search_ip}\"\n\n begin\n details = JSON.parse(http_get_body(search_uri))\n _log \"Got details: #{details}\"\n\n #status\n # Should be \"ok\"\n unless details[\"status\"] == \"ok\"\n _log_error \"Unable to continue\"\n return\n end\n\n #act\n # Active (forward) DNS\n if details[\"act\"]\n details[\"act\"].each do |forward_lookup|\n _create_entity \"DnsRecord\",{\n \"name\" => forward_lookup[\"o\"],\n \"time\" => \"#{Time.at(forward_lookup[\"t\"])}\"\n }\n end\n end\n\n #pas\n # Passive (reverse) DNS\n if details[\"pas\"]\n details[\"pas\"].each do |reverse_lookup|\n _create_entity \"DnsRecord\",{\n \"name\" => reverse_lookup[\"o\"],\n \"time\" => \"#{Time.at(reverse_lookup[\"t\"])}\"\n }\n end\n end\n\n #pash\n # Passive DNS history\n # TODO\n\n #acth\n # Active DNS history\n # TODO\n\n #as\n # Autonomous System Number\n if details[\"as\"]\n _create_entity \"AsNumber\",{\n \"name\" => \"AS#{details[\"as\"]}\",\n \"as_name\" => details[\"asname\"],\n \"as_desc\" => details[\"asdesc\"]\n }\n end\n\n # Netblock\n #\n if details[\"bgproute\"]\n _create_entity \"NetBlock\",{\"name\" => \"#{details[\"bgproute\"]}\"}\n end\n\n rescue JSON::ParserError => e\n _log_error \"Unable to get parsable response from #{search_uri}: #{e}\"\n rescue StandardError => e\n _log_error \"Error grabbing robtex details: #{e}\"\n end\n\n\n end",
"def caesar_decode(word,offset)\n caesar_encode(word,offset*-1)\nend",
"def compression; end",
"def translate_to_svf(object_id,access_token)\n base_64_urn = Base64.strict_encode64(object_id)\n response = RestClient.post(\"#{API_URL}/modelderivative/v2/designdata/job\",\n {\n input: {\n urn: base_64_urn\n },\n output: {\n formats: [\n {\n type: \"svf\",\n views: [\n \"3d\"\n ]\n }\n ]\n }\n }.to_json,\n { Authorization: \"Bearer #{access_token}\", content_type:'application/json' })\n return response\nend",
"def private; end",
"def coder; end",
"def ignore_encoding_error; end",
"def found_encoding; end",
"def found_encoding; end",
"def translate(response)\n end",
"def search\n\n # define the elasticsearch result \"size\" (limit)\n limit = params['limit'].to_i\n # define the elasticsearch result \"from\" (offset)\n offset = params['offset'].to_i\n # Pass through\n hack = params['hack']\n # Default output\n searchResults = ''\n # If we have filters, we need to parse them\n if params['filters'].present?\n filters = []\n # For each of the filters format them and stuff them into an array\n params['filters'].each do |key, filter|\n\n if [\n 'properties.educationalAlignment.properties.targetName',\n 'properties.inLanguage',\n 'properties.isBasedOnUrl',\n 'properties.thumbnailUrl',\n 'properties.timeRequired',\n 'properties.typicalAgeRange',\n 'properties.url',\n 'properties.useRightsUrl'\n ].include?(key)\n searchKey = \"schema-org.#{key}.original\"\n matchTerm = 'term'\n else\n searchKey = \"schema-org.#{key}\"\n matchTerm = 'match'\n end\n\n if filter.keys.count > 1\n # This is more complex because this filter type needs the keys or'd together\n orFilters = []\n filter.keys.each do |f|\n orFilters << { 'query' => { matchTerm => { searchKey => f.to_s } } }\n end\n filters << { 'or' => orFilters }\n else\n # This should be simple, there is only one of this filter key\n filters << { 'query' => { matchTerm => { searchKey => filter.keys.first.to_s } } }\n end\n end\n\n # If the query is present we need to match it\n if params['query'].present?\n query = { 'match' => { '_all' => params['query'] } }\n filter = { 'and' => filters }\n # If no query is present then we can wildcard against anything\n else\n query = { 'match_all' => { } }\n filter = { 'and' => filters }\n end\n # if not filter is present then just match against query\n else\n query = { 'match' => { '_all' => params['query'] } }\n end\n\n # Build the payload from the various parts\n payload = {\n 'size' => limit,\n 'from' => offset,\n 'query' => {\n 'filtered' => {\n 'query' => query,\n 'filter' => filter\n }\n },\n \"facets\" => {\n \"intendedEndUserRole\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.intendedEndUserRole.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"typicalAgeRange\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.typicalAgeRange.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"educationalUse\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.educationalUse.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"interactivityType\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.interactivityType.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"learningResourceType\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.learningResourceType.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n },\n \"mediaType\" => {\n \"terms\" => {\n \"field\" => \"schema-org.properties.mediaType.original\",\n \"global\" => true,\n \"all_terms\" => true\n }\n }\n }\n }\n\n#puts \"PAYLOAD\"; puts Rails.configuration.elastic_search_url; puts payload.to_json\n\n # Okay after all that mess, lets make the request\n request = RestClient::Request.new( :method => :get, :url => Rails.configuration.elastic_search_url, :payload => payload.to_json )\n # Since this can error lets catch it\n begin\n searchResults = request.execute\n results = JSON.parse(searchResults)\n results[:hack] = hack\n\n#puts \"RESPONSE\"; puts results.to_json\n\n respond_to do |format|\n format.json { render json: results }\n end\n rescue => e\n # @TODO Need to return the correct error type and then an error message to be shown to user.\n respond_to do |format|\n format.json { render json: searchResults }\n end\n#puts \"ERROR!\"; puts e.response\n end\n\n end",
"def make_title_searchable\n address = create_title_addressbase_data(@title)\n create_elasticsearch_addressbase_data(address)\n sleep($ELASTICSEARCH_SLEEP.to_f) # elasticsearch changes take a moment\n create_lr_urpn_mapping_data(@title[:lr_uprns])\nend",
"def _lex_trans_actions; end",
"def _lex_trans_actions; end",
"def _lex_trans_actions; end",
"def _lex_trans_actions; end",
"def process_elasticsearch(target)\n {\n :schema => 'iglu:com.snowplowanalytics.snowplow.storage/elastic_config/jsonschema/1-0-0',\n :data => {\n :name => target['name'],\n :host => target['host'],\n :index => target['database'],\n :port => target['port'],\n :type => target['table'],\n :nodesWanOnly => target['es_nodes_wan_only'],\n :purpose => 'FAILED_EVENTS'\n }\n }\nend",
"def transl8 (input,lang) #method to translate incoming text\n translate = Google::Cloud::Translate.new\n detection = translate.detect input.to_s\n #puts input + \"Looks like you're speak in #{detection.language}\"\n #puts \"Confidence: #{detection.confidence}\"\n #translation = translate.translate \"Hello world!\", to: \"la\"\n translation = translate.translate input.to_s, to: lang.to_s\n return \"In #{lang} that's \" + translation\nend",
"def process_result(doc)\n entry = {}\n\n source = {}\n source = doc['_source'] if doc['_source']\n\n @es_fields.each do |field|\n # default empty value\n entry[field] = ''\n\n case field\n when :id\n entry[:id] = doc['_id'] if doc['_id']\n when :lang\n entry[:lang] = source['lang'] if source['lang']\n when :url\n entry[:url] = source['url'] if source['url']\n when :site\n if source['site'] && source['site'].is_a?(Array) \\\n && !source['site'].empty?\n\n # adjust to 2 different 'site' configurations\n if source['site'][0].include?('.')\n entry[:site] = source['site'][0]\n else\n entry[:site] = source['site'].join('.')\n end\n end\n when :keywords\n if source['keywords'] && source['keywords'].is_a?(Array) \\\n && !source['keywords'].empty?\n\n entry[:keywords] = source['keywords'].select{|word| word.size < 30 }\n entry[:keywords] = entry[:keywords].uniq.join(' ')\n end\n when :title\n entry[:title] = source['title'] if source['title']\n when :description\n entry[:description] = source['description'] if source['description']\n when :content\n entry[:content] = source['content'] if source['content']\n when :content_analyzed\n # recover array of [word, stem, pos]\n if source['content_analyzed']\n nlp = source['content_analyzed']\n entry[:content_nlp] = Xi::ML::Tools::Formatter.words_from_nlp(nlp)\n end\n else\n @logger.warn(\"Unknown requested field '#{field}'. \"\\\n 'You should add a new feature to the gem. '\\\n 'Otherwise it will always be empty')\n end\n end\n\n # store only contents of minimum '@min_nchars' characters\n if entry[:content].size < @min_nchars\n entry[:content] = ''\n return entry\n end\n\n # keep a reference content for content duplicate detection\n entry[:raw_content] = entry[:content]\n\n # include words from url, title and keywords into content\n # when present in the es_fields argument\n words = []\n\n if entry[:url] && !entry[:url].nil? && !entry[:url].empty?\n url = Unicode.downcase(entry[:url])\n words.concat(Xi::ML::Tools::Formatter.words_from_url(url).split())\n end\n\n if entry[:title] && !entry[:title].empty?\n title = Unicode.downcase(entry[:title])\n words.concat(title.split())\n end\n\n if entry[:keywords] && !entry[:keywords].empty?\n keywords = Unicode.downcase(entry[:keywords])\n words.concat(keywords.split())\n end\n\n unless words.empty?\n words.uniq!\n entry[:content] << ' ' << words.join(' ')\n end\n\n # replace possible 'new line' characters with a dot\n entry[:content].gsub!(/\\n\\r/, '. ')\n entry[:content].gsub!(/\\n/, '. ')\n\n # return processed entry\n entry\n end",
"def translate_utf8 text, index\n @dict.each { |word| \n key, eng = word[0], word[1][TABLE[index]] \n text.gsub!(key, eng)\n }\n text\n end",
"def transcode(string)\n return string.encode(\"iso-8859-1\").force_encoding(\"utf-8\")\nend",
"def decode=(_arg0); end",
"def decode=(_arg0); end",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def translate()\n\nend",
"def index\n \n #ransack保持用コード\n query = params[:q]\n query ||= eval(cookies[:recent_search_history].to_s) \t\n\t\n \n @construction_code_extract = ConstructionDatum.all #add180830\n #件名の絞り込み addd180830\n if query.present? && query[:customer_id_eq].present?\n @construction_code_extract = ConstructionDatum.where(customer_id: query[:customer_id_eq]).order(\"construction_code desc\")\n end\n ##upd end\n \n #test\n #query = nil\n \n\t#@q = ConstructionDatum.ransack(params[:q])\n #ransack保持用--上記はこれに置き換える\n @q = ConstructionDatum.ransack(query) \n \n #ransack保持用コード\n search_history = {\n value: params[:q],\n expires: 24.hours.from_now\n }\n cookies[:recent_search_history] = search_history if params[:q].present?\n #\n\t\n @construction_data = @q.result(distinct: true)\n \n #kaminari用設定\n @construction_data = @construction_data .page(params[:page])\n\n @customer_masters = CustomerMaster.all\n \n\t$construction_data = @construction_data\n\t\n #add180903\n #資料フォルダを開く\n\tif params[:document_flag] == \"1\"\n openFileDialog\n end\n \n if params[:document_flag] != \"1\"\n respond_to do |format|\n\t format.html\n\t\t\n\t format.pdf do\n \n report = ConstructionListPDF.create @construction_list \n \n # ブラウザでPDFを表示する\n # disposition: \"inline\" によりダウンロードではなく表示させている\n send_data(\n report.generate,\n filename: \"construction_list.pdf\",\n type: \"application/pdf\",\n disposition: \"inline\")\n end\n\t end\n \n end\n end",
"def encode_with(coder); end",
"def test_default_internal_is_honored\n before_enc = Encoding.default_internal\n\n str = \"壁に耳あり、障子に目あり\"\n bson = BSON::BSON_CODER.serialize(\"x\" => str)\n\n silently { Encoding.default_internal = 'EUC-JP' }\n out = BSON::BSON_CODER.deserialize(bson)[\"x\"]\n\n assert_equal Encoding.default_internal, out.encoding\n assert_equal str.encode('EUC-JP'), out\n assert_equal str, out.encode(str.encoding)\n ensure\n silently { Encoding.default_internal = before_enc }\n end",
"def iconv() end",
"def external_encoding; @_external_encoding || _external_encoding; end",
"def decode_body(headers, remote_address, body, default_codec, additional_codecs)\n content_type = headers.fetch(\"content_type\", \"\")\n codec = additional_codecs.fetch(HttpUtil.getMimeType(content_type), default_codec)\n client = Elasticsearch::Client.new(:hosts => \"#{@elastic_scheme}://#{@elastic_host}:#{@elastic_port}\")\n #decode the body to get the relevant info we want from JSON from jenkins\n body_obj = JSON.parse(body)\n\n # Iterate through the jenkins' logs to access all of the fields we need\n if body_obj['jobType'] == \"deploy\"\n \n #client.search utilizes the elasticsearch ruby library to send a query to elasticsearch from the logstash plugin\n lt_response = get_deploy_response(client, body_obj)\n \n lt_response[\"hits\"][\"hits\"].each do |hit|\n lead_time_document = hit[\"_source\"]\n \n deploys = []\n #Determines if the lead_time doc build field exists\n if lead_time_document[\"deploys\"].nil?\n lead_time_document[\"deploys\"] = deploys\n end\n \n #Using the DateTime library, we retrieve the times from the lead-time documents, convert them to epoch format, then converted to an integer\n start_date = DateTime.parse(lead_time_document[\"started_at\"]).to_time.to_i\n create_date = DateTime.parse(lead_time_document[\"created_at\"]).to_time.to_i\n finish_date = DateTime.parse(body_obj['@timestamp']).to_time.to_i\n \n total_time = finish_date - start_date\n progress_time = finish_date - create_date\n \n lead_time_document[\"deploys\"].push(\n {\n result: body_obj['state'],\n completed_at: body_obj['@timestamp'],\n total_time: total_time,\n progress_time: progress_time,\n }\n )\n \n time_obj =\n {\n total_time: total_time,\n progress_time: progress_time\n }\n \n if body_obj['state'] == 'healthy'\n lead = LogStash::Event.new(lead_time_document)\n lead.set('[@metadata][index]', 'lead_time')\n lead.set('[@metadata][id]', hit['_id'])\n @queue << lead\n end\n end\n \n elsif body_obj['jobType'] == nil\n if body_obj['groupID'] != nil && body_obj['appName'] != nil && body_obj['versionNumber'] != nil\n \n lt_response = get_build_response(client, body_obj)\n builds = []\n \n lt_response[\"hits\"][\"hits\"].each do |hit|\n lead_time_document = hit[\"_source\"]\n \n #Determines if the lead_time doc build field exists\n if lead_time_document[\"builds\"].nil?\n lead_time_document[\"builds\"] = builds\n end\n \n lead_time_document[\"builds\"].push(\n {\n artifact:\n {\n id: body_obj['appName'],\n group: body_obj['groupID'],\n name: body_obj['appName'],\n version: body_obj['versionNumber'],\n },\n result: body_obj['state'],\n built_at: body_obj['@timestamp']\n }\n )\n\n if body_obj['state'] == 'healthy'\n lead = LogStash::Event.new(lead_time_document)\n lead.set('[@metadata][index]', 'lead_time')\n lead.set('[@metadata][id]', hit['_id'])\n @queue << lead\n end\n end\n else\n puts \"Build job that isn't a maven job\"\n end\n else\n puts \"Job is neither a build nor deploy\"\n end\n \n codec.flush { |event| push_decoded_event(headers, remote_address, event) }\n true\n rescue => e\n @logger.error(\n \"unable to process event.\",\n :message => e.message,\n :class => e.class.name,\n :backtrace => e.backtrace\n )\n false\n end",
"def obtain_target_from_seq(bioseq_seq)\r\n #we are going to keep all the targets from each gene,\r\n #hash of hashes :)\r\n targets=Hash.new\r\n len_bioseq = bioseq_seq.length + 1\r\n nstrand_targets = []\r\n pstrand_targets = []\r\n for i in (0..bioseq_seq.length-5)\r\n if bioseq_seq.complement[i..i+5] == \"cttctt\"\r\n nstrand_targets << [i,i+5]\r\n end\r\n if bioseq_seq[i..i+5] == \"cttctt\"\r\n pstrand_targets << [i,i+5]\r\n end\r\n end\r\n #im going to obtein the exon sites\r\n bioseq_seq.features.each do |feature|\r\n position = feature.position\r\n #not remote entries\r\n next unless (feature.feature == 'exon' ) && (not position =~ /[A-Z]/)\r\n exon_id = feature.qualifiers[0].value.gsub('exon_id=', '')\r\n #we can find exons in the the complement or the postive strand, so the way for obtaining the data is different\r\n #i wanna keep the strand forward or reverse\r\n if position =~/complement/\r\n exon_site_negative=position.tr('complement()',\"\")\r\n aux=exon_site_negative =~ /\\./ \r\n #we have to change the start and final point, the ebi documentation shows --> x..y, y is the start point and x is the final point\r\n #location 1 --> l1 \r\n #location 2 --> l2\r\n l1= len_bioseq - exon_site_negative[0,aux].to_i\r\n l2= len_bioseq - exon_site_negative[aux+2,exon_site_negative.length].to_i\r\n exon_site_negative=[l2,l1] # they are the location of the exons\r\n #we are going to check if the target that we did before is in the exon site\r\n is_inside_exon = check_target_in_exon(exon_id,nstrand_targets,'reverse',len_bioseq,exon_site_negative)\r\n #is_inside_exon will be a hash with positions, exon_id and the strand for the gff file\r\n unless is_inside_exon.nil? #if the hash is not nil i could keep it in other hash\r\n targets = targets.merge(is_inside_exon)\r\n end\r\n else\r\n exon_site_positive=position\r\n aux=exon_site_positive =~ /\\./ \r\n l1= exon_site_positive[0,aux].to_i\r\n l2= exon_site_positive[aux+2,exon_site_positive.length].to_i\r\n exon_site_positive=[l1,l2]\r\n is_inside_exon = check_target_in_exon(exon_id,pstrand_targets,'forward',len_bioseq,exon_site_positive)\r\n #is_inside_exon will be a hash with positions, exon_id and the strand for the gff file\r\n unless is_inside_exon.nil? #if the hash is not nil i could keep it in other hash\r\n targets = targets.merge(is_inside_exon)\r\n end\r\n end\r\n end\r\n return targets\r\nend"
] | [
"0.5891478",
"0.5870499",
"0.56851023",
"0.56851023",
"0.5649199",
"0.56312656",
"0.5546684",
"0.55393493",
"0.5523018",
"0.54984546",
"0.54984546",
"0.5470984",
"0.5461203",
"0.5437177",
"0.54277074",
"0.53655803",
"0.53655803",
"0.53377247",
"0.53213644",
"0.5319038",
"0.5319038",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.53033966",
"0.52946633",
"0.52946633",
"0.52869964",
"0.5278138",
"0.5231933",
"0.5220725",
"0.5220605",
"0.5218639",
"0.51512235",
"0.514576",
"0.5127556",
"0.5125688",
"0.5125688",
"0.5125688",
"0.5125688",
"0.5125688",
"0.5125324",
"0.5125324",
"0.51191723",
"0.51191723",
"0.51191723",
"0.51191723",
"0.5094573",
"0.5087375",
"0.5087315",
"0.5086447",
"0.50785583",
"0.50689363",
"0.5064136",
"0.5055226",
"0.5053731",
"0.5023214",
"0.5010867",
"0.49837002",
"0.4971126",
"0.4971126",
"0.4944603",
"0.49430192",
"0.49228516",
"0.49153286",
"0.49153286",
"0.49153286",
"0.49153286",
"0.49145213",
"0.48843685",
"0.4882465",
"0.48806736",
"0.48778203",
"0.48749873",
"0.48749873",
"0.4870471",
"0.4870471",
"0.4870471",
"0.4870471",
"0.4870471",
"0.4870471",
"0.4870471",
"0.4870471",
"0.48632717",
"0.48495764",
"0.48393506",
"0.48384345",
"0.483609",
"0.48271656",
"0.48264515"
] | 0.0 | -1 |
remove disk_number, disk_count, track_count, available_date | def update_completeness
RecordingCompleteness.update self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_from_disk; end",
"def remove_check_disk(opts)\n opts = check_params(opts,[:disk_info])\n super(opts)\n end",
"def trim_avail(condensed)\n\t condensed.each do |loc|\n\t ##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) copies = \" + loc[\"copies\"].count.inspect\n\t ##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) copies = \" + loc[\"copies\"].inspect\n\t ##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) copies [0] items keys count = \" + loc[\"copies\"][0][\"items\"].keys.count.inspect\n\t ##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) copies [0] items = \" + loc[\"copies\"][0][\"items\"].inspect\n\t if loc[\"copies\"][0][\"items\"].keys.count > 1 && loc[\"copies\"][0][\"items\"].has_key?('Available')\n\t\t##Rails.logger.debug \"\\nes287_debug line(#{__LINE__}) available exists with more than one status,so we will remove it as unnecessary.\"\n\t\tloc[\"copies\"][0][\"items\"].delete_if {|key, value| key == \"Available\" }\n\t end\n\t end\n\t condensed\n\t end",
"def compute_deltas \n req_disks = @new_resource.disks\n keyed_req = {} # for easy lookup, make a map of the requested disks \n cur = @ring_test\n name = @new_resource.name\n @to_add = []\n @to_rem = []\n \n \n ## figure out which disks need adding\n req_disks.each {|disk| \n key = RingInfo.dev_key disk[:ip],disk[:port],disk[:dev_name]\n @to_add << disk unless cur and cur.devices[key] # add unless present\n keyed_req[key] = disk\n } \n \n ### figure out which disks need removing\n cur.devices.each {|key, d|\n @to_rem << d unless keyed_req[key] # remove unless still requested\n } if cur\n \n Chef::Log.info(\"disks, to add #{@to_add.length} , to remove: #{@to_rem.length}\" ) \n Chef::Log.debug(\"disks, to add #{@to_add.join(\";\")} , to remove: #{@to_rem.join(\";\")}\" )\n \nend",
"def remove_old_stored_csvs\n end",
"def clean_db(prev_versions)\nputs \"CLEAN DB CALLED\"\n if Version.count > prev_versions\n to_remove = Version.count - prev_versions\n puts \"Removing #{to_remove} old versions from database\"\n Version.all(:limit => to_remove, :order => [ :processed.asc ]).each do |old_version|\n old_version.units.all.each do |old_unit|\n #old_unit.images.all.each do |old_image|\n # old_image.destroy\n #end\n old_unit.destroy\n end\n old_version.destroy\n end\n end\n end",
"def prune_index\n# missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}}\n# missing_files.each{|filename, itime|\n# index.writer.delete(:complete_path, filename)\n# index_time_dbm_file.delete(filename)\n# logger.debug \"Removed : #{filename}\"\n# }\n# index.optimize\n end",
"def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end",
"def remove_ignore_disk(opts)\n opts = check_params(opts,[:ignore_disk])\n super(opts)\n end",
"def compute_deltas\n req_disks = @new_resource.disks\n keyed_req = {} # for easy lookup, make a map of the requested disks\n cur = @ring_test\n name = @new_resource.name\n @to_add = []\n @to_rem = []\n\n ## figure out which disks need adding\n req_disks.each {|disk|\n key = RingInfo.dev_key disk[:ip],disk[:port],disk[:dev_name]\n @to_add << disk unless cur and cur.devices[key] # add unless present\n keyed_req[key] = disk\n }\n\n ### figure out which disks need removing\n cur.devices.each {|key, d|\n @to_rem << d unless keyed_req[key] # remove unless still requested\n } if cur\n\n Chef::Log.info(\"disks, to add #{@to_add.length} , to remove: #{@to_rem.length}\")\n Chef::Log.debug(\"disks, to add #{@to_add.join(\";\")} , to remove: #{@to_rem.join(\";\")}\")\n\nend",
"def nfs_prune(valid_ids)\n end",
"def delete_file_parts\n #TODO implementation\n end",
"def cleanup!\r\n got = @ndev.rpc.request_system_storage_cleanup\r\n gone_h = {}\r\n got.xpath('file-list/file').each do |file|\r\n _cleanup_file_to_h( file, gone_h )\r\n end\r\n gone_h\r\n end",
"def delete_files(files)\n not_found = []\n files.each do |file|\n file_stored = Files.where({ '_id' => file[:uuid]}).first\n if file_stored.nil?\n logger.error 'File not found ' + file.to_s\n not_found << file\n else\n if file_stored['pkg_ref'] == 1\n # Referenced only once. Delete in this case\n file_stored.destroy\n del_ent_dict(file_stored, :files)\n file_md5 = Files.where('md5' => file_stored['md5'])\n if file_md5.size.to_i.zero?\n # Remove files from grid\n grid_fs = Mongoid::GridFs\n grid_fs.delete(file_stored['grid_fs_id'])\n end\n else\n # Referenced above once. Decrease counter\n file_stored.update_attributes(pkg_ref: file_stored['pkg_ref'] - 1)\n end\n # file_stored.destroy\n # del_ent_dict(file_stored, :files)\n #\n # # Remove files from grid\n # grid_fs = Mongoid::GridFs\n # grid_fs.delete(file_stored['grid_fs_id'])\n end\n end\n not_found\n end",
"def detach_disks_specs\n detach_disk_array = []\n extra_config = []\n keys = disk_keys.invert\n\n ipool = VCenterDriver::VIHelper.one_pool(OpenNebula::ImagePool)\n disks_each(:detached?) do |d|\n key = d.key.to_s\n source = VCenterDriver::FileHelper.escape_path(d.path)\n persistent =\n VCenterDriver::VIHelper\n .find_persistent_image_by_source(\n source, ipool\n )\n\n op = { :operation => :remove, :device => d.device }\n if !persistent && d.type != 'CDROM'\n op[:fileOperation] = :destroy\n end\n detach_disk_array << op\n\n # Remove reference opennebula.disk if exist from vmx and cache\n extra_config << d.config(:delete) if keys[key]\n end\n\n [detach_disk_array, extra_config]\n end",
"def delete_convention_data\n if self.metadata_file.present? && self.metadata_file.use_metadata_convention\n Rails.logger.info \"Removing convention data for #{self.accession} from BQ\"\n bq_dataset = ApplicationController.big_query_client.dataset CellMetadatum::BIGQUERY_DATASET\n bq_dataset.query \"DELETE FROM #{CellMetadatum::BIGQUERY_TABLE} WHERE study_accession = '#{self.accession}' AND file_id = '#{self.metadata_file.id}'\"\n Rails.logger.info \"BQ cleanup for #{self.accession} completed\"\n SearchFacet.delay.update_all_facet_filters\n end\n end",
"def prune_index\n missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}}\n missing_files.each{|filename, itime|\n index.writer.delete(:complete_path, filename)\n index_time_dbm_file.delete(filename)\n logger.debug \"Removed : #{filename}\"\n }\n index.optimize\n end",
"def trim_requested; end",
"def delete_dates(data) \n ['created_at', 'updated_at', 'timestamp', 'location'].each do |key|\n data.delete key if data[key]\n end\n data\nend",
"def remove_record(record)\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record,record.id)\n\n @storage.remove(atoms)\n end",
"def remove_record(record)\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record,record.id)\n\n @storage.remove(atoms)\n end",
"def remove_no_progress(*params)\n\t\tself.each{|x| safe{x.remove(*params)} if x.respond_to?('remove')}\n\tend",
"def clean_cache!(seconds)\n File.grid.namespace.\n where(filename: /\\d+-\\d+-\\d+(?:-\\d+)?\\/.+/).\n and(:filename.lt => (Time.now.utc - seconds).to_i.to_s).\n delete\n end",
"def compact_hdd(hdd_path)\n execute(@prldisktool_path, 'compact', '--hdd', hdd_path) do |_, data|\n lines = data.split('\\r')\n # The progress of the compact will be in the last line. Do a greedy\n # regular expression to find what we're looking for.\n if lines.last =~ /.+?(\\d{,3}) ?%/\n yield $1.to_i if block_given?\n end\n end\n end",
"def wipe_snapshots_data; end",
"def wipe_snapshots_data; end",
"def eliminate_percipitation\n self.scan() if @filearray == nil\n setcolumntovalue(Present_Weather_Observation, \"0\")\n setcolumntovalue(Present_Weather_Codes,\"999999999\") #no weather. Clear day.\n setcolumntovalue(Snow_Depth,\"0\")\n setcolumntovalue(Liquid_Precipitation_Depth,\"0\")\n setcolumntovalue(Liquid_Precipitation_Quantity,\"0\")\n return self\n end",
"def unsafe_forget_past!\n slices.values.map(&:history).each{|h| h.recent(memory_size)}\n\n if multi_slices?\n to_delete = slices.values.reject{|s| keep_slice?(s)}\n to_delete.map(&:rack_id).map do |rack_id| \n slices.delete(rack_id)\n end\n end\n end",
"def delete_pd(descriptor)\n # # first find dependencies_mapping\n # pkg = FileContainer.find_by('_id' => descriptor['pd']['package_file_uuid'])\n\n # first find dependencies_mapping\n pkg = FileContainer.find_by('_id' => descriptor['pd']['package_file_uuid'])\n\n if pkg['pkg_ref'] == 1\n # Referenced only once. Delete in this case\n pkg.destroy\n tgop_md5 = Files.where('md5' => pkg['md5'])\n if tgop_md5.size.to_i.zero?\n # Remove files from grid\n grid_fs = Mongoid::GridFs\n grid_fs.delete(pkg['grid_fs_id'])\n end\n else\n # Referenced above once. Decrease counter\n pkg.update_attributes(pkg_ref: pkg['pkg_ref'] - 1)\n end\n descriptor.destroy\n del_ent_dict(descriptor, :pd)\n # descriptor.destroy\n # del_ent_dict(descriptor, :pd)\n # grid_fs = Mongoid::GridFs\n # grid_fs.delete(pkg['grid_fs_id'])\n # pkg.destroy\n # descriptor.destroy\n end",
"def cleanup\n case SubutaiConfig.provider\n when :hyper_v\n SubutaiDisk.hyperv_remove_disk\n end\n\n # cleanup virtual disks\n disks = SubutaiConfig.get(:_DISK_PATHES)\n unless disks.nil?\n disks.keys.each do |key|\n if File.exist?(disks[key])\n begin\n File.delete(disks[key])\n puts \"==> default: Deleted file: #{disks[key]}\"\n rescue Errno::EACCES\n puts \"==> default: (Permission denied) Failed delete file: #{disks[key]}\"\n end\n end\n end\n end\n\n # cleanup generated files\n if File.exist?(SubutaiConfig::GENERATED_FILE)\n begin\n File.delete SubutaiConfig::GENERATED_FILE\n puts \"==> default: Deleted file: #{SubutaiConfig::GENERATED_FILE}\"\n rescue Errno::EACCES\n puts \"==> default: (Permission denied) Failed delete file: #{SubutaiConfig::GENERATED_FILE}\"\n end\n end\n end",
"def remove_vdisk(vdiskid)\r\n current = {:errormsg => \"\", :status => \"\", :time => \"\", :vmstatus => \"\"}\r\n\t\t\t\t\t\t \r\n conn_opts=get_cli_connection\r\n Chef::Log.debug(\"#{conn_opts[:host]}...delete VmDiskMapping id=#{vdiskid}\")\r\n Net::SSH.start( conn_opts[:host], conn_opts[:user], :password => conn_opts[:password], :port => conn_opts[:port] ) do|ssh|\r\n output = ssh.exec!(\"delete VmDiskMapping id=#{vdiskid}\")\r\n output.each_line do |line|\r\n if line.match(/Status:/)\r\n current[:status]=line.split[1].strip\r\n elsif line.match(/Time:/)\r\n line[\"Time: \"]=\"\"\r\n current[:time]=line.strip\r\n elsif line.match(/Error Msg:/)\r\n line[\"Error Msg: \"]=\"\"\r\n current[:errormsg]=line.strip\r\n end\r\n end\r\n end\r\n return current\r\n end",
"def remove_gdom_disk(options)\n vds_disk = options['name']+\"_vdisk0\"\n message = \"Information:\\tRemoving disk \"+vds_disk+\" from Virtual Disk Server\"\n command = \"ldm remove-vdisk #{vds_disk} #{options['name']}\"\n execute_command(options,message,command)\n return\nend",
"def clear_back_office_data\n @flbt_type = nil\n @version = nil\n @submitted_date = nil\n @effective_date = nil\n @filing_date = nil\n @ads_included = nil\n @ads_amount = nil\n @number_of_buyers = nil\n end",
"def remove_part\n @part = nil\n @subpart = nil\n @project_number = case @type\n when \"Chinese Standard\"\n @project_number.sub(/\\.\\d+/, \"\")\n else\n @project_number = @project_number.sub(/-\\d+/, \"\")\n end\n end",
"def delete_unknown\n Jhead.call(\"-du\", @match, @pattern)\n end",
"def clean_up_map map\n {\n id: map[0].to_i,\n release: map[1],\n unknown1: map[2],\n component: map[3],\n version: map[4],\n path1: map[5],\n path2: map[6],\n unknown2: map[7],\n mode: map[8],\n type: map[9].to_sym,\n unknown3: map[10]\n }\n end",
"def delete_gdom_disk(options)\n gdom_dir = $ldom_base_dir+\"/\"+options['name']\n client_disk = gdom_dir+\"/vdisk0\"\n message = \"Information:\\tRemoving disk \"+client_disk\n command = \"rm #{client_disk}\"\n execute_command(options,message,command)\n return\nend",
"def outdated_delete\n outdated.delete_all\n end",
"def unmark_transferred!\n update_column(:transferred_at, nil)\n end",
"def cleanTmp\n ts_str = \"/tmp/d\" + Date.today.strftime(\"%Y%m%d\") + \"-*\"\n Gitchefsync.logger.info \"clean up of #{ts_str}\"\n FS.cmdNoError \"sudo rm -fr #{ts_str}\"\n end",
"def cleanup_derivatives\n deleted_files = []\n raster_derivatives = resource.file_metadata.select { |file| file.derivative? || file.thumbnail_file? || file.cloud_derivative? }\n raster_derivatives.each do |file|\n storage_adapter.delete(id: file.file_identifiers.first)\n deleted_files << file.id\n end\n cleanup_derivative_metadata(derivatives: deleted_files)\n generate_mosaic unless deleted_files.empty?\n end",
"def remove_track_before(date_threshold)\n\tplaylist_date\t= Time.parse(@jspf['date']);\n\n\ttime_offset\t= 0;\n\ttmp_arr\t\t= [];\n\t# go thru each track of the playlist_jspf\n\t@jspf['track'].each { |track|\n\t\t# update time_offset\n\t\ttime_offset\t+= track['duration'];\n\t\t# if this track is completed before date_threshold, goto the next\n\t\tif( playlist_date + time_offset/1000 > date_threshold )\n\t\t\t# put this track into the tmp_arr\n\t\t\ttmp_arr.push(track);\n\t\telse\n\t\t\t@jspf['meta']['trackidx_beg']\t+= 1;\n\t\t\t@jspf['date']\t= (playlist_date + track['duration']/1000).to_s;\n\t\tend\n\t}\n\t# copy the tmp_arr into the playlist_jspf\n\t@jspf['track']\t= tmp_arr;\nend",
"def tidy_up\n Dir[\"*nin\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nhr\"].each do |file|\n File.delete(file)\n end\n Dir[\"*nsq\"].each do |file|\n File.delete(file)\n end\n Dir[\"*blast\"].each do |file|\n File.delete(file)\n end\n end",
"def _compact\n nonces = rds.hkeys hpk_tag\n # select all nonces that no longer have corresponding message stored\n toDel = nonces.select { |n| not rds.exists msg_tag n }\n\n # delete all these nonces from hash index\n unless toDel.empty?\n _resetCount()\n runMbxTransaction(@hpk, 'compact') { toDel.each { |n| rds.hdel hpk_tag, n } }\n end\n end",
"def remove\n conf = {:path=>\"#{RAILS_ROOT}/index/#{RAILS_ENV}/rip\"}\n index = Ferret::Index::Index.new(conf)\n\n mrokhashs = params[:parts][:part].collect {|p| p[:mrokhash]}\n parts = Part.find_all_by_mrokhash(mrokhashs)\n logged_in_user.parts.delete(parts)\n parts.each do |part|\n update_user_in_field(:index => index, :part => part, :remove => true)\n remove_cache_pages(part.rip_id) if part.rip_id\n end\n head :ok\n end",
"def compact!\n @list.delete_if {|partition_name, partition| partition.sites.size == 0}\n end",
"def spots_to_remove\n Spot.outdated\n end",
"def cleanup(uploaded_file, file_path)\n File.delete(file_path) if uploaded_file.is_file_upload\n\n # clean up old uploads\n cutoff = Time.now - 1.hour\n lst = UploadedFile.where(status: 'I').all\n lst.each do |u|\n u.update_attribute(:status, 'F') if u.updated_at < cutoff\n end\n end",
"def cleanupTestFiles\n ('A' .. 'F').each { |del| FileUtils.rm(\"#{folder}HR3-Room#{del}.csv\", force: true) } \n end",
"def cleanup\n show do\n title \"Discard stripwells\"\n note \"Please discard all stripwells.\"\n operations.each do |op|\n op.input(\"PCR\").collection.mark_as_deleted\n end\n end\n \n show do\n title \"Make sure machine in parked position\"\n check \"Click \\\"Processes\\\" -> \\\"Parked\\\" icon.\"\n image \"Actions/Fragment Analyzer/frag_an_parked.JPG\"\n end\n end",
"def parts_with_order_remove part\n self.parts_with_order = self.parts_with_order.reject{|master_file| master_file.pid == part.pid }\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove_excess_entry\n TransportPassengerImport.first.destroy if TransportPassengerImport.count > 15\n end",
"def delete!\n update_attribute(:dateSuppression, Time.now)\n end",
"def cleanup_derivatives\n deleted_files = []\n image_derivatives = resource.file_metadata.select { |file| (file.derivative? || file.thumbnail_file?) && file.mime_type.include?(image_mime_type) }\n image_derivatives.each do |file|\n storage_adapter.delete(id: file.id)\n deleted_files << file.id\n end\n cleanup_derivative_metadata(derivatives: deleted_files)\n end",
"def unreserve\n self.showdate = nil\n self.seat = nil\n self.checked_in = false\n save!\n end",
"def remove\n rows = self.open_import_file\n field = rows.first\n rows.each do |row|\n item_identifier = row['item_identifier'].to_s.strip\n if item = Item.where(:item_identifier => item_identifier).first\n item.destroy\n end\n end\n end",
"def remove_distribution_hours_for_user(project_job)\n puts \"coming to remove_distribution_hours_for_user ..........................\"\n past_dates = project_job.job_time_logs.where(\"user_id = ? and log_start_time < ?\",project_job.assigned_to, Date.today).all.map(&:log_start_time).map(&:to_date)\n p past_dates\n if(past_dates.present?)\n ResourceDistribution.where(:project_job_id=>project_job.id, :user_id=>project_job.assigned_to).where(\"allotted_date not in (?)\",past_dates).delete_all\n else\n ResourceDistribution.where(:project_job_id=>project_job.id, :user_id=>project_job.assigned_to).delete_all\n end\n end",
"def removed_unmarked_paths\n #remove dirs\n dirs_enum = @dirs.each_value\n loop do\n dir_stat = dirs_enum.next rescue break\n if dir_stat.marked\n dir_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n #recursive call\n dir_stat.removed_unmarked_paths\n else\n # directory is not marked. Remove it, since it does not exist.\n write_to_log(\"NON_EXISTING dir: \" + dir_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_directory(dir_stat.path, Params['local_server_name'])\n }\n rm_dir(dir_stat)\n end\n end\n\n #remove files\n files_enum = @files.each_value\n loop do\n file_stat = files_enum.next rescue break\n if file_stat.marked\n file_stat.marked = false # unset flag for next monitoring\\index\\remove phase\n else\n # file not marked meaning it is no longer exist. Remove.\n write_to_log(\"NON_EXISTING file: \" + file_stat.path)\n # remove file with changed checksum\n $local_content_data_lock.synchronize{\n $local_content_data.remove_instance(Params['local_server_name'], file_stat.path)\n }\n # remove from tree\n @files.delete(file_stat.path)\n end\n end\n end",
"def remove(name, date)\n if @log.has_key? date\n @log[date].each do |item|\n if name.eql? item.name\n @log[date].delete(item)\n end\n end\n end\n if @log[date].eql? [] ##deletes key if array on date is empty\n @log.delete(date)\n end\n end",
"def prune params = {}\n @connection.post(build_path(\"/volumes/prune\", params))\n end",
"def deletions\n stat[1]\n end",
"def prune\n @set.clear\n end",
"def cleanup?\r\n got = @ndev.rpc.request_system_storage_cleanup( :dry_run => true )\r\n dryrun_h = {}\r\n got.xpath('file-list/file').each do |file|\r\n _cleanup_file_to_h( file, dryrun_h )\r\n end\r\n dryrun_h \r\n end",
"def mark_progresses_for_removal\n self.progresses.each do |p|\n if p.due_date.blank? && p.accuracy.to_i <= 0\n p.mark_for_destruction\n end\n end\n end",
"def ensure_deletion_fixes \n # TO DO\n end",
"def clean_up\n show do\n title 'Store pellets on ice'\n note temp_instructions(ON_ICE)\n\n note 'Keep the labeled cell pellets, in the 24-well aluminum block, on ice until you are ready for FACS.'\n end\n\n buffers = operations.map { |op| op.inputs.select { |i| ALL_BUFFERS.include?(i.name) } }.flatten\n buffers.map! { |b| b.child_item }.uniq!\n\n release(buffers, interactive: true)\n\n show do\n title 'Clean up'\n\n check 'Any items that remain on the bench (other than the labeled cell pellets) can be discarded.'\n check \"Set the refigerated centrifuge back to 25 #{DEGREES_C}.\"\n end\n end",
"def remove(prep_id)\n\t\t@kb.delete_at(prep_id)\n\tend",
"def __remove_cluster_data\n FileUtils.rm_rf arguments[:path_data]\n end",
"def cleanup_old_files\n # make a local copy of to_delete while simultaneously clearing the original (atomicity)\n # local_to_delete = $to_delete.slice!(0..-1).to_a\n local_to_delete = []\n $to_delete.delete_if { |v| local_to_delete << v; true }\n\n $files.each_pair do |uuid, file|\n if file.nil?\n $files.delete uuid\n elsif local_to_delete.include?(uuid) || (Time.now - 60*60) > file.ctime\n file.close # Close it\n file.unlink if file.respond_to? :unlink # Unlink it if we can\n $files.delete uuid\n end\n end\n GC.start\nend",
"def cleanup_derivatives\n deleted_files = []\n pyramidal_derivatives = resource.file_metadata.select { |file| file.derivative? && file.mime_type.include?(\"image/tiff\") }\n pyramidal_derivatives.each do |file|\n storage_adapter.delete(id: file.file_identifiers.first)\n deleted_files << file.id\n end\n cleanup_derivative_metadata(derivatives: deleted_files)\n end",
"def remove(attributes)\n project(header - attributes)\n end",
"def remove_disk\n modify_disks(params[:disk]) do |exists, node, disk|\n if exists.nil? then \n flash.now[:warning] = \"Error: no such Disk in Node\"\n else\n # already enforced in _disks partial, but just in case...\n if node.node_type.is_virtual? and not (node.disks - [disk]).detect{|d| d.mount_point == '/'}\n flash.now[:warning] = \"Error: A virtual node has to have a root disk!\"\n else\n node.disks.delete(disk)\n end\n end\n end\n end",
"def delete_data(type, date, format)\n File.delete(\"#{data_directory}/ssdata-#{type}-#{date.strftime('%Y%m')}.#{format}\")\n end",
"def carve_undelete_file_info\n files = catalog_tree.search_using_journal(leaf_file_record, journal)\n \n for leaf in attribute_tree.search_using_journal\n wrapped_file_key, protection_class = attribute_tree.search_using_journal(leaf_filekey_record, journal)\n file_key = unwrap_using_class_keys_acquired_from_plist(wrapped_file_key, protection_class)\n file_keys << file_key\n end\n \n return files, file_keys\nend",
"def cleanup_dfs\n # clean up vertices attributes set during dfs\n @vertices.values.each do |vertex|\n vertex.color = nil\n vertex.predecessor = nil\n vertex.discovery = nil\n vertex.finish = nil\n end\n @time = 0\n end",
"def delete_safe_times(volumes)\n volumes.keys.each do |volume_id|\n command = \"delete from results where volume_id=?\"\n options = [volume_id]\n volumes[volume_id].each do |time_window|\n command += \"\\n and access_date not between datetime(?) and datetime(?)\"\n options += [time_window[\"start\"].iso8601, time_window[\"end\"].iso8601]\n end\n command += \";\"\n command_literal = command\n options.each { |opt| command_literal.sub!(opt)} # Don't ever do this.\n puts \"Executing: #{command_literal}\\n\"\n @db.execute(command, *options)\n end\n end",
"def remove\n valid = parse_valid(params)\n # puts valid\n choose = $db.search(\"//book[\"+valid+\"]\").remove\n size = 0\n for i in choose\n size += 1\n end\n $file = open PATH, \"w\"\n $file.write $db\n $file.close\n render :soap => \"<result>\"+size.to_s+\"</result>\"\n end",
"def cleanup_parts(file_parts)\n Mongolicious.logger.info(\"Cleaning up file parts.\")\n\n if file_parts\n file_parts.each do |part|\n Mongolicious.logger.info(\"Deleting part: #{part}\")\n begin\n File.delete(part)\n rescue => exception\n Mongolicious.logger.error(\"Error trying to delete part: #{part}\")\n Mongolicious.logger.error(exception.message)\n Mongolicious.logger.error(exception.backtrace)\n end\n end\n end\n end",
"def remove_notes(remove_list)\n \n remove_list.each do |upload_id|\n upload = Upload.find(upload_id)\n if ( @document.uploads.include?(upload) )\n @document.uploads.delete(upload)\n end\n end\n end",
"def remove_custom_chronology_value\n @record.xpath('./datafield[@tag=\"650\"]/subfield[@code=\"a\"]').each do |subfield|\n subfield.parent.remove if subfield.text.start_with?('CHR ')\n end\n end",
"def clean_old_versions( versions_to_keep )\n find( :all, :conditions => [ 'number <= ?', self.maximum( :number ) - versions_to_keep ] ).each do |version|\n version.destroy\n end\n end",
"def clean_up\n #Delete every thing but the most recent config[:screenshot_max_keep] screenshots\n max_screenshots = self.config[:screenshot_max_keep] || 5\n #Delete the last created one while they count is more then the max\n while self.admo_screenshots.count > max_screenshots\n self.admo_screenshots.order_by('created_at asc').first.destroy\n end\n end",
"def rm_cddts_outof_blk\n axes = [@ref_rows, @ref_cols]\n axes.each{|axis|\n axis.each{|ref|\n intrsct_cddts = []\n (self.to_a.flatten & ref).each{|elm|\n intrsct_cddts.push(elm.cddts).flatten!.uniq!\n }\n six_cells_cddts = []\n (self.to_a.flatten - ref).each{|elm|\n six_cells_cddts.push(elm.cddts).flatten!.uniq!\n }\n intrsct_cddts.each{|cddt|\n unless six_cells_cddts.include?(cddt)\n (ref - self.to_a.flatten).each{|elm|\n elm.cddts.delete(cddt)\n# if ProgramConfig[:debug]\n# if elm.fixed == false and elm.cddts.length == 1\n# print \"DEBUG: [#{elm.i}, #{elm.j}] = #{elm.cddts.first}\\n\"\n# end\n# end\n elm.fixed = true if(elm.cddts.length == 1)\n }\n end\n }\n }\n }\n end",
"def delete_from_disk!\n if disk_filename.present?\n diskfile_s3 = diskfile\n Rails.logger.debug(\"Deleting #{diskfile_s3}\")\n RedmicaS3::Connection.delete(diskfile_s3)\n end\n\n Redmine::Thumbnail.batch_delete!(\n thumbnail_path('*').sub(/\\*\\.thumb$/, '')\n )\n end",
"def chef_to_be_removed(chef_server_list)\n servers_up = cloud_server_list\n chef_server_list.delete_if do |name,server|\n puts \"Do not delete #{name}, it's up\" if servers_up[name]\n !! servers_up[name]\n end\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 delete_convention_data(study:, metadata_file:)\n bq_dataset = ApplicationController.big_query_client.dataset CellMetadatum::BIGQUERY_DATASET\n if metadata_file.use_metadata_convention\n bq_dataset.query \"DELETE FROM #{CellMetadatum::BIGQUERY_TABLE} WHERE study_accession = '#{study.accession}' AND file_id = '#{metadata_file.id}'\"\n SearchFacet.delay.update_all_facet_filters\n end\n end",
"def delete_master_data(date)\n format = default_master_server_arguments(nil, date)[:format]\n delete_data(:master, date, format)\n end",
"def remove_data!\n connector.remove_torrent @ids, true\n @deleted = true\n end",
"def destroy\n @inform = @study.inform\n @study.destroy\n\n @all_cups_price = 0\n @inform.studies.each do |study|\n @all_cups_price += study.price * study.factor\n end\n end",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def remove_from_list\n if $selected_files.size > 0\n sz = $selected_files.size\n ch = get_single \"Remove #{sz} files from used list (y)?: \"\n #ch = get_char\n return if ch != \"y\"\n $used_dirs = $used_dirs - $selected_files\n $visited_files = $visited_files - $selected_files\n unselect_all\n $modified = true\n return\n end\n #print\n ## what if selected some rows\n file = $view[$cursor]\n ch = get_single \"Remove #{file} from used list (y)?: \"\n #ch = get_char\n return if ch != \"y\"\n file = File.expand_path(file)\n if File.directory? file\n $used_dirs.delete(file)\n else\n $visited_files.delete(file)\n end\n c_refresh\n $modified = true\nend",
"def drop(w)\r\n @contents.push(w)\r\n show_disk(size,w,@delay)\r\n end",
"def run_removeH(ifns)\n babel = \"/home/jaydy/local/bin/babel\"\n\n tmp = Tempfile.new('/ANCHORS')\n tmp_path = tmp.path\n tmp.close\n\n concatFiles(ifns, tmp_path)\n\n ofn = @work_dir + '_1.sdf'\n removeH(tmp_path, ofn, babel=babel)\n\n tmp.unlink\n\n end",
"def incomplete_delete\n incomplete.delete_all\n end",
"def transfer_and_cleanup\n transfer_and_cleanup_with_block do |type|\n if type == :cover_concept\n self.update_column(:cover_concept_image_processed, true)\n end\n\n if type == :stock_cover_image\n self.update_column(:stock_cover_image_processed, true)\n end\n end\n end",
"def remove_depricated\n self.articles.each do |a|\n unless ((a.created_at + 3.days) > Date.today) \n self.articles.delete(a)\n end\n end\n\tend"
] | [
"0.6063606",
"0.59914505",
"0.56213367",
"0.55551034",
"0.55313075",
"0.5529581",
"0.5519742",
"0.54886246",
"0.54834944",
"0.54627603",
"0.54540735",
"0.5408326",
"0.5401871",
"0.5400049",
"0.5396402",
"0.5373724",
"0.53664243",
"0.52615726",
"0.52565914",
"0.5238672",
"0.5238672",
"0.52310395",
"0.5217865",
"0.5215756",
"0.5205187",
"0.5205187",
"0.52014154",
"0.51728165",
"0.5164944",
"0.51569533",
"0.5155027",
"0.5154888",
"0.514251",
"0.5140265",
"0.512354",
"0.5116488",
"0.51113874",
"0.5099985",
"0.50840354",
"0.5082668",
"0.5070043",
"0.50521845",
"0.5051437",
"0.50497836",
"0.50411046",
"0.5040913",
"0.5038725",
"0.5032056",
"0.5027786",
"0.50261414",
"0.5023248",
"0.5014768",
"0.5014768",
"0.5014768",
"0.5014768",
"0.5011354",
"0.50080556",
"0.5007168",
"0.5004398",
"0.50016814",
"0.49944034",
"0.49846423",
"0.49801436",
"0.49789095",
"0.49745253",
"0.4960969",
"0.49602097",
"0.49566358",
"0.49562517",
"0.49551868",
"0.49524662",
"0.49492764",
"0.49431896",
"0.49412683",
"0.4939678",
"0.4939228",
"0.493855",
"0.4935158",
"0.4924724",
"0.49148554",
"0.4911295",
"0.49112362",
"0.49103397",
"0.49065495",
"0.4904179",
"0.49027053",
"0.49011225",
"0.490085",
"0.48987436",
"0.4898619",
"0.48898435",
"0.4889009",
"0.48814067",
"0.4879742",
"0.48776963",
"0.48751387",
"0.4869537",
"0.48665616",
"0.48643228",
"0.4861225",
"0.48611718"
] | 0.0 | -1 |
add this to environment variables read from yaml file | def download_url(style = nil, expires_in = 90.minutes)
s3 = Aws::S3::Resource.new
secure_url = self.mp3
unless Rails.env.test?
begin
if self.mp3.include?("https://s3-us-west-1.amazonaws.com/digiramp/")
secure_url = self.mp3.gsub('https://s3-us-west-1.amazonaws.com/digiramp/', '')
else
secure_url = self.mp3.gsub('https://digiramp.s3.amazonaws.com/', '')
end
bucket = s3.bucket(Rails.application.secrets.aws_s3_bucket)
s3_obj = bucket.object(secure_url)
secure_url = s3_obj.presigned_url(:get, expires_in: 600)
rescue => e
secure_url = self.mp3
end
end
secure_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_file file\n @config.merge!(YAML::load_file \"#{@@env_dir}/#{file}\")\n end",
"def load_env!(options = {})\n source = load_yaml_file(\"env.yml\")\n source = source.fetch(options[:env_section] || env_section, {})\n \n source.each do |key, value|\n if !ENV.has_key?(key) || options[:overwrite] == true\n ENV[key.to_s.upcase] = value.to_s\n end\n end\n end",
"def add_env_var key, val\n key = key.to_s\n env_file = self[:ssh_env_file]\n escaped_val = Regexp.escape(val).gsub('/', '\\/').gsub(';', '\\;')\n # see if the key/value pair already exists\n if exec(Beaker::Command.new(\"grep ^#{key}=.*#{escaped_val} #{env_file}\"), :accept_all_exit_codes => true).exit_code == 0\n return # nothing to do here, key value pair already exists\n # see if the key already exists\n elsif exec(Beaker::Command.new(\"grep ^#{key}= #{env_file}\"), :accept_all_exit_codes => true).exit_code == 0\n exec(Beaker::SedCommand.new(self['platform'], \"s/^#{key}=/#{key}=#{escaped_val}:/\", env_file))\n else\n exec(Beaker::Command.new(\"echo \\\"#{key}=#{val}\\\" >> #{env_file}\"))\n end\n\n # update the profile.d to current state\n # match it to the contents of ssh_env_file\n mirror_env_to_profile_d(env_file)\n end",
"def _load_env\n require 'yaml'\n r_var = _open_sefile('env3.yml') { |f| YAML.load(f) }\n @var.delete :file_open_raised\n r_var.each { |k,v| @var[k] = v } if r_var\nend",
"def env(key, value)\n @environment_variables[key] = value \n end",
"def load_env(filename)\n Foreman::Env.new(filename).entries do |name, value|\n @env[name] = value\n end\n end",
"def update_env_file!\n present_env = ssh_read_file(app_username, \"#{ app_name }/.env\").to_s\n\n env = {\n \"RAILS_ENV\" => \"production\",\n \"PATH\" => \"/home/#{ app_username }/.rvm/wrappers/#{ app_name }:$PATH\",\n \"SECRET_KEY_BASE\" => SecureRandom.hex(64),\n }.merge(\n Dotenv::Parser.call(present_env)\n ).merge(\n options[:env] || {}\n ).map { |k, v|\n \"export #{ k }=#{ v.inspect }\\n\"\n }.join(\"\")\n\n ssh_write_file(app_username, \"#{ app_name }/.env\", env)\n end",
"def load_environment_file(f)\n do_or_die(File.exists?(f),\"Loading environments from #{f}\",\n \"Environment file #{f} does not exist\")\n supp_envs = YAML.load_file(f)\n supp_envs.each_with_object([]) do |(name,options),envs|\n\n # store the environment name inside its configuration hash\n options[:name] = name\n \n # translate alternative keywords for export filters\n %w(filter filters export-filters).each do |f|\n if options.include?(f) \n options[:export_filters] = options[f].split(/[ ,]/)\n options.delete(f) \n end \n end \n\n options = options.each_with_object({}){|(k,v),h| h[k.to_sym] = v} # symbolise keys\n\n # convert arrays into comma-delimited strings\n options = options.each_with_object({}) do |(k,v),h|\n h[k] = v.is_a?(Array) ? v.join(',') : v\n end\n\n # convert space-delimited into comma-delimited strings\n %i(destination with_tags without_tags).each do |f|\n options[f] = options[f].split(/[ ,]/).join(',') if options.include?(f)\n end\n\n envs << options # add hash to environments array\n end\n end",
"def add_var(key, value)\n put :add_var, {:key => key, :value => value}\n if Bushido::Command.last_command_successful?\n ENV[key.upcase] = value\n end\n end",
"def load_envvars\n Pkg::Params::ENV_VARS.each do |v|\n if var = ENV[v[:envvar].to_s]\n case v[:type]\n when :bool\n self.instance_variable_set(\"@#{v[:var]}\", Pkg::Util.boolean_value(var))\n when :array\n self.instance_variable_set(\"@#{v[:var]}\", string_to_array(var))\n else\n self.instance_variable_set(\"@#{v[:var]}\", var)\n end\n end\n end\n end",
"def add_env_var(gear, key, value)\n args = build_base_gear_args(gear)\n args['--with-key'] = key\n args['--with-value'] = value\n result = execute_direct(@@C_CONTROLLER, 'env-var-add', args)\n parse_result(result, gear)\n end",
"def load config_file\n YAML.load_file(config_file).each do |parameter,value|\n instance_variable_set( \"@#{parameter}\", value )\n end\n end",
"def load_integ_environment_vars\n env_file = File.join(__dir__, 'config/local_env_integ.yml')\n env_key_vals = YAML.load_file(env_file)\n %w[\n SqsQueueIntegTests_QueueUrl\n SqsQueueIntegTests_QueueRegion\n SqsQueueIntegTests_AccessId\n SqsQueueIntegTests_SecretKey\n ].each { |var| ENV[var] = env_key_vals.fetch(var) }\nend",
"def _save_env\n require 'yaml'\n w_var = @var.dup\n @var[:blacklist_env].each { |b| w_var.delete b } if @var[:blacklist_env]\n _open_sefile('env3.yml', 'w') { |f| YAML.dump(w_var, f) }\nend",
"def with_env_vars(filename = nil, &_block)\n original_env_vars = ENV.to_hash\n Dotenv.load(filename) if filename\n yield\nensure\n ENV.replace(original_env_vars)\nend",
"def set_vars(vars_dictionary)\n command = <<~HEREDOC\n echo \"setting Environment Variables\"\n sources ~/.bashec\n HEREDOC\n\n vars_dictionary.each do |key, value|\n command = <<~HEREDOC\n if [ -z \"#{key}\"]; then\n echo \"export#{key}=#{value}\" >> ~/.bashrc\n fi\n HEREDOC\n end\n\n return command\nend",
"def add_env_variables(vars, parent_op=nil)\n Application.run_in_application_lock(self) do\n op_group = PendingAppOpGroup.new(op_type: :update_configuration, args: {\"add_env_vars\" => vars}, parent_op: parent_op, user_agent: self.user_agent)\n self.pending_op_groups.push op_group\n result_io = ResultIO.new\n self.run_jobs(result_io)\n result_io\n end\n end",
"def update_consul_stack_env_vars\n require 'diplomat'\n require 'json'\n data = {}\n @tf_vars_from_env.each_value { |k| data[k] = ENV[k] }\n\n Diplomat.configure do |config|\n config.url = @consul_url\n end\n\n puts \"Writing stack information to #{@consul_url} at: \"\\\n \"#{@consul_env_vars_prefix}\"\n\n redacted_list = (%w[aws_access_key aws_secret_key] +\n @tf_sensitive_vars)\n sanitized_data = data.clone\n @tf_vars_from_env.each do |k, v|\n # We are trying to determine which ENV var maps\n # to the sensitive terraform variable\n sanitized_data[v] = '(redacted)' if redacted_list.include?(k)\n end\n puts JSON.pretty_generate(sanitized_data)\n raw = JSON.generate(data)\n Diplomat::Kv.put(@consul_env_vars_prefix, raw)\n end",
"def apply_variables_to_environment!(options = {})\n variables_to_apply = variables.except(\"RACK_ENV\", \"RAILS_ENV\")\n \n variables_to_apply.each do |key, value|\n if !ENV.has_key?(key.to_s) || options[:overwrite] == true\n ENV[key.to_s] = value.to_s\n end\n end\n \n variables_to_apply\n end",
"def load_config_file_for_environment_key( file_name, options )\n load_config_file( options.merge(:env => true) )\n end",
"def load_environment(*args)\n\t\t\tpath = environment_path(*args)\n\t\t\t\n\t\t\tif File.exist?(path)\n\t\t\t\t# Load the YAML environment file:\n\t\t\t\t@environment = YAML.load_file(path)\n\t\t\t\t\n\t\t\t\t# We update ENV but only when it's not already set to something:\n\t\t\t\tENV.update(@environment) do |name, old_value, new_value|\n\t\t\t\t\told_value || new_value\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def load_env_from_file(path)\n File.readlines(path).each do |line|\n values = line.split(\"=\")\n key = values[0]\n value = values[1, values.length - 1 ].map {|v| v.strip() }.join('=')\n ENV[key] = value\n end\n end",
"def addtoenv(name,w,base)\n if ENV[name[0]] == nil\n ENV[name[0]] = base + \"/\" + w\n elsif ENV[name[0]].index(w) == nil\n ENV[name[0]] += \":\"+base + \"/\"+ w + \"/\"+name[1]\n end\nend",
"def set_env\n env = (container[:env] ||= [])\n\n # static data\n metadata = release_doc_metadata\n [:REVISION, :TAG, :DEPLOY_ID, :DEPLOY_GROUP].each do |k|\n env << {name: k, value: metadata.fetch(k.downcase).to_s}\n end\n\n [:PROJECT, :ROLE].each do |k|\n env << {name: k, value: template[:spec][:template][:metadata][:labels][k.downcase].to_s}\n end\n\n # dynamic lookups for unknown things during deploy\n {\n POD_NAME: 'metadata.name',\n POD_NAMESPACE: 'metadata.namespace',\n POD_IP: 'status.podIP'\n }.each do |k, v|\n env << {\n name: k,\n valueFrom: {fieldRef: {fieldPath: v}}\n }\n end\n\n if needs_secret_sidecar?\n vault_config = VaultClient.client.config_for(@doc.deploy_group.vault_instance)\n raise StandardError, \"Could not find Vault config for #{@doc.deploy_group.permalink}\" unless vault_config\n\n sidecar_env = (sidecar_container[:env] ||= [])\n {\n VAULT_ADDR: vault_config['vault_address'],\n VAULT_SSL_VERIFY: vault_config['tls_verify']\n }.each do |k, v|\n sidecar_env << {\n name: k,\n value: v.to_s\n }\n end\n end\n end",
"def example_env_vars\n Parser.call(read)\n rescue Errno::ENOENT, FormatError\n {}\n end",
"def add_environment_attribute(key, value, options = {})\n @environment_attributes << { key: key, value: value, options: options }\n end",
"def env_config; end",
"def env_config; end",
"def env_config; end",
"def env_config; end",
"def []= key, value\n ENV[envify(key)] = value\n end",
"def initialize( location = 'stage', env_file = File.expand_path(\"#{__FILE__}/../../config/stage.sh\"))\n @location = location\n @env_file = env_file\n envfile_hash = process_env_file( env_file )\n #ENV explicit settings override values found in a locations config file\n @data = Hash[ SQA_ECOMM_SERVER_URL: ENV.fetch( 'SQA_ECOMM_SERVER_URL', envfile_hash['SQA_ECOMM_SERVER_URL'] ),\n SQA_ECOMM_API_SERVER_URL: ENV.fetch( 'SQA_ECOMM_API_SERVER_URL', envfile_hash['SQA_ECOMM_API_SERVER_URL'] ),\n SQA_ECOMM_DB_SERVER: ENV.fetch( 'SQA_ECOMM_DB_SERVER', envfile_hash['SQA_ECOMM_DB_SERVER'] ),\n SQA_ECOMM_DB: ENV.fetch( 'SQA_ECOMM_DB', envfile_hash['SQA_ECOMM_DB'] ),\n SQA_ECOMM_DB_UPDATE_USER: ENV.fetch( 'SQA_ECOMM_DB_UPDATE_USER', envfile_hash['SQA_ECOMM_DB_UPDATE_USER'] ),\n SQA_ECOMM_DB_UPDATE_PW: ENV.fetch( 'SQA_ECOMM_DB_UPDATE_PW', envfile_hash['SQA_ECOMM_DB_UPDATE_PW'] ),\n SQA_ECOMM_DB_READONLY_USER: ENV.fetch( 'SQA_ECOMM_DB_READONLY_USER', envfile_hash['SQA_ECOMM_DB_READONLY_USER'] ),\n SQA_ECOMM_DB_READONLY_PW: ENV.fetch( 'SQA_ECOMM_DB_READONLY_PW', envfile_hash['SQA_ECOMM_DB_READONLY_PW'] ),\n SQA_ORACLE_DB_SERVER: ENV.fetch( 'SQA_ORACLE_DB_SERVER', envfile_hash['SQA_ORACLE_DB_SERVER'] ),\n SQA_ORACLE_DB_UPDATE_USER: ENV.fetch( 'SQA_ORACLE_DB_UPDATE_USER', envfile_hash['SQA_ORACLE_DB_UPDATE_USER'] ),\n SQA_ORACLE_DB_UPDATE_PW: ENV.fetch( 'SQA_ORACLE_DB_UPDATE_PW', envfile_hash['SQA_ORACLE_DB_UPDATE_PW'] ),\n SQA_ORACLE_DB_READONLY_USER: ENV.fetch( 'SQA_ORACLE_DB_READONLY_USER', envfile_hash['SQA_ORACLE_DB_READONLY_USER'] ),\n SQA_ORACLE_DB_READONLY_PW: ENV.fetch( 'SQA_ORACLE_DB_READONLY_PW', envfile_hash['SQA_ORACLE_DB_READONLY_PW'] ),\n SQA_HJ_DB_SERVER: ENV.fetch( 'SQA_HJ_DB_SERVER', envfile_hash['SQA_HJ_DB_SERVER'] ),\n SQA_HJ_DB: ENV.fetch( 'SQA_HJ_DB', envfile_hash['SQA_HJ_DB'] ),\n SQA_HJ_DB_UPDATE_USER: ENV.fetch( 'SQA_HJ_DB_UPDATE_USER', envfile_hash['SQA_HJ_DB_UPDATE_USER'] ),\n SQA_HJ_DB_UPDATE_PW: ENV.fetch( 'SQA_HJ_DB_UPDATE_PW', envfile_hash['SQA_HJ_DB_UPDATE_PW'] ),\n SQA_HJ_DB_READONLY_USER: ENV.fetch( 'SQA_HJ_DB_READONLY_USER', envfile_hash['SQA_HJ_DB_READONLY_USER'] ),\n SQA_HJ_DB_READONLY_PW: ENV.fetch( 'SQA_HJ_DB_READONLY_PW', envfile_hash['SQA_HJ_DB_READONLY_PW'] ),\n SQA_RUDI_SERVER: ENV.fetch( 'SQA_RUDI_SERVER', envfile_hash['SQA_RUDI_SERVER'] ),\n SQA_RUDI_VERSION: ENV.fetch( 'SQA_RUDI_VERSION', envfile_hash['SQA_RUDI_VERSION'] ),\n SQA_UNIBLAB_SERVER: ENV.fetch( 'SQA_UNIBLAB_SERVER', envfile_hash['SQA_UNIBLAB_SERVER'] ),\n SQA_UNIBLAB_VERSION: ENV.fetch( 'SQA_UNIBLAB_VERSION', envfile_hash['SQA_UNIBLAB_VERSION'] ) ]\n end",
"def apply!\n each do |k, v|\n if v =~ /^keyth\\:(.*)/\n ENV[k] = Keyth.get_key_safe(Regexp.last_match[1]) || ''\n else\n ENV[k] = v\n end\n end\n end",
"def load_constants!(options = {})\n source = load_yaml_file(\"env.yml\")\n source = source.fetch(options[:env_section] || env_section, {})\n \n source.each do |key, value|\n constant_name = key.to_s.upcase.to_sym\n \n if !constants.include(constant_name) || options[:overwrite] == true\n constant_set constant_name, value.to_s\n end\n end\n end",
"def cloud_config_data\n env_run_cmds = []\n self.options.each_pair do |key, properties|\n if properties[:environment] && !properties[:value].nil?\n escaped_value = properties[:value].to_s.gsub(/\"/, '\\\\\\\\\\\\\\\\\\\"')\n env_run_cmds.push \"echo \\\"#{key}=\\\\\\\"#{escaped_value}\\\\\\\"\\\" >> /etc/environment\"\n end\n end\n\n user_data_config = self.cloud_config.dup\n user_data_config['runcmd'] ||= []\n user_data_config['runcmd'] = env_run_cmds.concat(user_data_config['runcmd'])\n return \"#cloud-config\\n#{user_data_config.to_yaml}\"\n end",
"def load(path, env)\n yaml_safe_load(File.open(path).read)[env].each do |section, settings|\n section = instance_variable_get(\"@#{section}\")\n next unless section\n settings.each do |setting, value|\n unless section == @index || section == @source\n value = interpolate_string(value, nil)\n end\n setter(section, setting, value)\n end\n end\n end",
"def environment_variables\n global_variables = @config.environment_variables\n process_vars = @config.process_options[@name] ? @config.process_options[@name]['env'] || {} : {}\n process_local_vars = @config.local_process_options[@name] ? @config.local_process_options[@name]['env'] || {} : {}\n global_variables.merge(process_vars.merge(process_local_vars)).each_with_object({}) do |(key, value), hash|\n hash[key.to_s] = value.to_s\n end\n end",
"def with_custom_env_variables(&block)\n saved_env = {}\n begin\n Git::Lib::ENV_VARIABLE_NAMES.each { |k| saved_env[k] = ENV[k] }\n return block.call\n ensure\n Git::Lib::ENV_VARIABLE_NAMES.each { |k| ENV[k] = saved_env[k] }\n end\n end",
"def load_env_variables(project)\r\n @project = project\r\n puts(\"project = #{project}\")\r\n\r\n if project.nil? then\r\n raise \"#{msg_prefix} > No project defined.\\n\"\\\r\n \"Call SET PROJECT=prj, replacing prj with your project.\"\r\n elsif !File.exist?(File.join(SAF::PROJECTS, project)) then\r\n raise \"#{msg_prefix} > Project not found: #{project}.\"\r\n end\r\n\r\n load_yml_config(project)\r\n\r\n @enable_remote_logging = load_boolean(\"ENABLE_REMOTE_LOGGING\", true)\r\n @logstash_host = load_var(\"LOGSTASH_HOST\", \"showinpoc01.fbfs.com\")\r\n @logstash_port = load_var(\"LOGSTASH_PORT\", 5514).to_i\r\n\r\n @aut_host = load_var(\"HOST\")\r\n @test_slave_host = load_var('REMOTE_HOST', 'showinpoc01.fbfs.com')\r\n @test_slave_port = load_var('REMOTE_PORT', 4444).to_i\r\n\r\n @in_browser = load_boolean(\"IN_BROWSER\", true)\r\n\r\n @browser = load_var('BROWSER', 'ie')\r\n\r\n @log_level = load_var(\"LOG_LEVEL\", \"Logger::INFO\")\r\n\r\n @screenshots = load_boolean(\"TAKE_SCREEN_SHOT\", true) # Was ist das?\r\n @screenshots_on_fail = load_boolean(\"TAKE_SCREEN_SHOT_ON_FAIL\", true)\r\n @screenshots_on_warning = load_boolean(\"TAKE_SCREEN_SHOT_ON_WARNING\",\r\n true)\r\n\r\n @yml_config.delete(\"project\")\r\n\r\n unless @yml_config.empty? then\r\n # TODO: Error class\r\n raise \"#{msg_prefix} > Unknown keys in \"\\\r\n \"#{project}'s #{SAF::PROJECT_ENV_YAML}:\\n\"\\\r\n \" #{@yml_config.keys.join(', ')}\"\r\n end\r\n end",
"def load_yaml(file, env_vars, my = nil)\n\n yaml = YAML.load_file(file)\n eval_map_values(yaml, env_vars, file, my || yaml)\n end",
"def environment\n return @vars unless @vars.nil?\n\n # If not set, Try to find them...\n glob_path = File.join(@deployment_home, @settings.env_file_glob_path)\n regexp_find = glob_path.gsub(/\\*/, '(.*)')\n Dir[glob_path].each do | file_name |\n # Get the environment name from the file part of the glob path:\n # e.g. given ./environments/ci_mgt/kb8or.yaml\n # get ci_mgt from ./environments/*/kb8or.yaml\n /#{regexp_find}/.match(file_name)\n env_name = $1\n if env_name == @env_name\n debug \"env=#{env_name}\"\n # Ensure we set the defaults as vars BEFORE we add environment specifics:\n @vars = @settings.defaults\n env_vars = Context.resolve_env_file(file_name)\n @vars = @vars.merge(env_vars)\n @vars = @vars.merge(@overridden_vars)\n @vars['env'] = env_name\n @environment_file = file_name\n break\n end\n end\n # Now finaly, update the settings now we know the environment!\n unless @vars\n @vars = {}\n end\n @settings = @settings.new(@vars)\n update_k8context\n debug \"vars=#{vars}\"\n @vars\n end",
"def setenv(n, v)\n debug \"Adding env: #{n}=#{v}\"\n debug \"prev value: #{@rye_getenv[n]}\"\n @rye_getenv[n] = v\n (@rye_current_environment_variables ||= {})[n] = v\n self\n end",
"def env(name, value)\n Stairs.configuration.env_adapter.set name, value\n end",
"def load_yaml(base=ENV['PWD'], env=\"active\")\n env = \"dev\" if env == \"active\" and not File.exist? \"#{base}/opt/active\"\n @data = ::YAML.load_file(\"#{base}/opt/#{env}/config.yaml\")\n end",
"def add_persistent_property(file, name, value)\n current_config = File.read(file)\n rconfig = JSON.parse(current_config)\n rconfig[name] = value\n File.open(file, 'w') {|f| f.write(JSON.pretty_generate(rconfig))}\n end",
"def update_config\n if File.directory?(yolo_dir) and File.exist?(yaml_path)\n @yaml = YAML::load_file yaml_path\n update_yaml_setting(@yaml, \"deployment\", \"api_token\", \"example\")\n update_yaml_setting(@yaml, \"deployment\", \"team_token\", \"example\")\n end\n end",
"def export_dynatrace_app_environment_variables\n profiled_dir = File.join(@app_dir, '.profile.d')\n FileUtils.mkdir_p(profiled_dir)\n\n variables = {}\n variables[RUXIT_APPLICATION_ID] = application_id\n variables[RUXIT_HOST_ID] = host_id\n\n env_file_name = File.join(profiled_dir, '0dynatrace-app-env.sh')\n env_file = File.new(env_file_name, 'w')\n variables.each do |key, value|\n env_file.puts(\"export #{key}=\\\"${#{key}:-#{value}}\\\"\") # \"${VAR1:-default value}\"\n end\n env_file.close\n end",
"def initialize_from_env\n conf_prefix = self.env_variable_prefix.upcase\n\n ENV.keys.reject { |key|\n key !~ /^#{conf_prefix}/ # Ignore everything that doesn't match the prefix\n }.each { |key|\n variable = key[conf_prefix.size..-1].downcase\n\n self.store(variable, ENV[key])\n }\n\n after_initialize\n dump\n end",
"def parse_config \n path = \"#{Rails.root}/config/mebla.yml\"\n return unless File.exists?(path)\n \n conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]\n \n conf.each do |key,value|\n self.send(\"#{key}=\", value) if self.respond_to?(\"#{key}=\")\n end unless conf.nil?\n end",
"def config_from_env\n CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env_vars|\n if value = option_from_env(option)\n env_vars[option] = value\n end\n end\n end",
"def load_config(configfile)\n config = YAML.load_file(configfile)\n config.each { |key, value|\n instance_variable_set(\"@#{key}\", value) \n }\n end",
"def modify_database_yml_as_needed!\n require 'yaml'\n\n db_yaml_file = File.join('config', 'database.yml')\n db_yaml = YAML.load_file(db_yaml_file)\n\n unless db_yaml[rails_env]\n notify(\"adding environment '#{rails_env}' to database.yml\") do\n test_content = db_yaml['test']\n raise \"No default database.yml entry for 'test'?!?\" unless test_content\n\n db_yaml[rails_env] = test_content.dup\n new_yaml = YAML.dump(db_yaml)\n # Get rid of the silly '---' line that YAML.dump puts at the start.\n new_yaml = new_yaml.split(\"\\n\").map { |l| l unless l =~ /^\\-+$/i }.compact.join(\"\\n\")\n File.open(db_yaml_file, 'w') { |f| f.puts new_yaml }\n end\n end\n end",
"def load_vars\n config = YAML.load_file(@config_file)\n @dev_port = config[\"development\"][\"port\"] ||= @default_dev_port\n @dev_pid = config[\"development\"][\"pid\"] ||= @default_dev_pid\n @dev_log = config[\"development\"][\"log\"] ||= @default_dev_log\n @prod_port = config[\"production\"][\"port\"] ||= @default_prod_port\n @prod_pid = config[\"production\"][\"pid\"] ||= @default_prod_pid\n @prod_log = config[\"production\"][\"log\"] ||= @default_prod_log\nend",
"def parse_config_file(path)\n return unless File.exists?(path)\n \n conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]\n \n conf.each do |key,value|\n self.send(\"#{key}=\", value) if self.respond_to?(\"#{key}=\")\n end unless conf.nil?\n end",
"def load_variables\n options = ActiveSupport::HashWithIndifferentAccess.new(@options.dup)\n options[:blueprint] = @blueprint\n options[:stack] ||= @blueprint\n location = Lono::ConfigLocation.new(\"variables\", options, Lono.env)\n evaluate_variables_file(location.lookup_base) if location.lookup_base\n evaluate_variables_file(location.lookup) if location.lookup # config file\n end",
"def parse envfile\n path = Pathname.new envfile\n update case path.extname\n when '.pl', '.perl' then parse_perl path\n when '.js', '.json' then parse_json path\n when '.yml', '.yaml' then parse_yaml path\n else parse_xaicron path\n end\n end",
"def get_env_data(env)\n config_path = \"#{File.expand_path(\"../../\", __FILE__).gsub('features', '')}config/config.yml\"\n yml = YAML::load(File.read(config_path))\n yml[env.downcase]\nend",
"def load!\n configs = {}\n @array.each_with_index do |obj, idx|\n next unless obj.start_with?('--' + @env_prefix)\n\n value = extract_value(obj, idx + 1)\n key = obj.split('=').first\n .sub(/^--#{@env_prefix}_?/, '')\n .downcase.split('__')\n recursive_set(configs, key, split_env_string(value))\n end\n configs\n end",
"def env_key; end",
"def environment=(env)\n self.config[:environment] = env.to_sym\n end",
"def env=(environment); end",
"def env=(environment); end",
"def env_vars\n { \"OS_CLIENT_CONFIG_FILE\" => os_credentials_file }\n end",
"def setup_docker_env_vars_str\n \"eval \\\"$(docker-machine env #{project_config['docker-machine']['name']})\\\" && \"\nend",
"def read_config\n db_config = YAML.load_file('config/database.yml.production')\n set :db_user, db_config[rails_env][\"username\"]\n set :db_password, db_config[rails_env][\"password\"] \n set :db_name, db_config[rails_env][\"database\"]\nend",
"def read_config\n db_config = YAML.load_file('config/database.yml.production')\n set :db_user, db_config[rails_env][\"username\"]\n set :db_password, db_config[rails_env][\"password\"] \n set :db_name, db_config[rails_env][\"database\"]\nend",
"def to_env\n CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env|\n unless (value = @config[option]).nil?\n env[\"#{ ViteRuby::ENV_PREFIX }_#{ option.upcase }\"] = value.to_s\n end\n end.merge(ViteRuby.env)\n end",
"def read_env(file = '.env')\n if !ENV['ENV']\n File.open(file, \"r\").each_line do |line|\n a = line.chomp(\"\\n\").split('=',2)\n a[1].gsub!(/^\"|\"$/, '') if ['\\'','\"'].include?(a[1][0])\n eval \"ENV['#{a[0]}']='#{a[1] || ''}'\"\n end\n end\n end",
"def set_args_from_yaml(yaml_path)\n yaml = YAML::load( File.open(yaml_path) )\n @login = yaml['login']\n @password = yaml['password']\n @client = yaml['client']\n @project = yaml['project']\n @application = yaml['application']\n @environment = yaml['environment']\n @mmd_url = yaml['mmd_url']\nend",
"def env_vars\n env = {\n \"ANSIBLE_NET_USERNAME\" => auth.userid || \"\",\n \"ANSIBLE_NET_PASSWORD\" => auth.password || \"\",\n \"ANSIBLE_NET_AUTHORIZE\" => auth.authorize ? \"1\" : \"0\"\n }\n\n env[\"ANSIBLE_NET_AUTH_PASS\"] = auth.become_password || \"\" if auth.authorize\n env[\"ANSIBLE_NET_SSH_KEYFILE\"] = network_ssh_key_file if auth.auth_key\n env\n end",
"def load\n Dotenv.load(\n root.join(\".env.local\"),\n root.join(\".env.#{Rails.env}\"),\n root.join(\".env\")\n )\n end",
"def extend_env_vars(from, to)\n env_to_hash(from || []).merge(env_to_hash(to || [])).map { |k,v| [k.to_s, v.to_s].join('=') }\n end",
"def load_data(data)\n data.keys.each do |key|\n if include?(key)\n self[key] = data[key]\n else\n env = DeploymentEnvironment.new\n env.name = key.to_s\n env.load_data(data[key])\n\n environments << key.to_s\n\n # register a child LYC to establish override hierarchy\n register_child(env, key)\n end\n end\n end",
"def import_env_file(path)\n return unless File.file?(path)\n File.readlines(path).each do |line|\n next if line.start_with?('#') || line.strip.empty?\n line_to_env(line)\n end\nend",
"def load_environment!(opts=nil)\n env_path = File.join(root_path, 'sc-config')\n env_path = File.join(root_path, 'sc-config.rb') if !File.exists?(env_path)\n \n @environment = {}\n if File.exists?(env_path)\n f = File.read(env_path)\n eval(f) # execute the config file as if it belongs.\n end\n\n # Override any all options with load_opts\n if build_numbers = @load_opts[:build_numbers]\n @load_opts.delete(:build_numbers)\n build_numbers.each do | bundle_name, build_number |\n env = @environment[bundle_name.to_sym] ||= {}\n env[:build_number] = build_number\n end\n end\n \n (@environment[:all] ||= {}).merge!(@load_opts)\n\n end",
"def load_attributes\n @attributes = YAML.load_file(file).inject({}){|h,(k,v)| h[k.to_sym] = v;h}\n end",
"def initialize\n # Load configuration file\n require 'yaml'\n @env = HashWithIndifferentAccess.new(YAML.load_file(File.join(File.dirname(__FILE__), '..', 'config', 'environments', \"#{ENV['RACK_ENV']}.yml\")))\n end",
"def load!(path)\n return unless defined?(Dotenv::Parser)\n\n contents = ::File.open(path, 'rb:bom|utf-8', &:read)\n parsed = Dotenv::Parser.call(contents)\n\n parsed.each do |k, v|\n next if @env.key?(k)\n\n @env[k] = v\n end\n end",
"def initialize\n configure_via_yaml\n configure_via_env\n end",
"def update_application_rb\n inject_into_file 'config/application.rb', after: \"class Application < Rails::Application\\n\" do <<-'RUBY'\n\n # It setup your social apps\n social_keys = File.join(Rails.root, 'config', 'social_keys.yml')\n CONFIG = HashWithIndifferentAccess.new(YAML::load(IO.read(social_keys)))[Rails.env]\n\n unless CONFIG.nil?\n CONFIG.each do |k,v|\n ENV[k.upcase] ||= v\n end\n end\n\n RUBY\n end\n\n puts 'Just updated your config/initializers/application.rb to config the environment'.colorize(:light_blue)\n end",
"def load_yml_config(project)\r\n @saf_env = ENV[\"SAF_ENV\"] || \"default\"\r\n puts(\"SAF_ENV = #{@saf_env}\")\r\n\r\n env_yml_path = File.join(SAF::PROJECTS, project, SAF::PROJECT_ENV_YAML)\r\n\r\n unless File.exist?(env_yml_path) then\r\n # TODO: File not found error class\r\n raise \"#{msg_prefix} > Could not find #{env_yml_path}\"\r\n end\r\n\r\n all_yml_config = YAML.load(File.read(env_yml_path))\r\n # Throw an error if they specified an illegal install key.\r\n unless all_yml_config.key?(@saf_env) then\r\n raise ArgumentError.new(\"#{caller.first}\\n\"\\\r\n \"SAF env #{@saf_env} not found in project \"\\\r\n \"#{project}.\")\r\n end\r\n @yml_config = all_yml_config[@saf_env]\r\n end",
"def env(key, value, servers = nil)\n servers = Array(servers) if servers\n @environment[[key, servers]] = value\n end",
"def load_configuration (key)\n configuration = YAML.load_file 'variables.yml'\n configuration['vars'][key].map do |package|\n package.kind_of?(Hash) ? package['name'] : package\n end\nend",
"def set_env_variables(env_vars = [])\n env_vars.each do |_v|\n key, value = _v.split(\"=\")\n\n ENV[key] = value\n end\n end",
"def fetch_config\n Rails.logger.debug \"Loading #{@file}::#{@env}\" if Object.const_defined?('Rails') && Rails.logger.present?\n YAML::load_file(@file)[@env.to_s]\n end",
"def config\n @config ||=\n begin\n raise(ConfigError, \"Cannot find config file: #{file_name}\") unless File.exist?(file_name)\n\n env_config = self.class.load_yaml(ERB.new(File.new(file_name).read).result)[env]\n raise(ConfigError, \"Cannot find environment: #{env} in config file: #{file_name}\") unless env_config\n\n env_config = self.class.send(:deep_symbolize_keys, env_config)\n self.class.send(:migrate_old_formats!, env_config)\n end\n end",
"def import_file! file\n # if given a file name, try opening it\n if file.instance_of? String\n _file = File.open file\n elsif file.instance_of? File\n _file = file\n else\n raise \"type not recognized: #{file.class.name}\"\n end\n\n puts \"- Iterating over keys in #{_file.inspect}\" if @verbose\n \n # iterate over keys\n YAML::load(_file).each do |env, env_hash|\n env_hash.each do |app, app_hash|\n app_hash.each do |namespace, namespace_hash|\n namespace_hash.each do |identifier, value|\n k = \"#{namespace}:#{identifier}\"\n set! k, value, app, env\n end\n end\n end\n end\n end",
"def build_environment(env, env_yaml, platform)\n # substitute vcenter resources from vcenter.yml for location defined in environment file\n env_yaml['vcenter'] = platform.vcenter[env_yaml['vcenter']]\n # merge component resources from environment file and platform definition\n # platform info will be inserted where not found in env files, env overrides will be unchanged\n #\n # Note: this function does not do error checking for components that exist in env file but\n # not in Platform definition. Such files will be retained but not have any Platform\n # component info. The Build command will run error checking before building, but to support\n # the debugging value of the list command only hash.merge! is performed at this point.\n platform.components.each do |component, _config|\n env_yaml['components'][component].merge!(platform.components[component]) { |_key, v1, _v2| v1 } unless env_yaml['components'][component].nil?\n end\n # substitute network and components for specified values from platform definition files\n env_yaml['components'].each do |component, _config|\n env_yaml['components'][component]['network'] = platform.network[env_yaml['components'][component]['network']]\n env_yaml['components'][component]['compute'] = platform.compute[env_yaml['components'][component]['compute']]\n unless env_yaml['components'][component]['runlist'].nil?\n env_yaml['components'][component]['runlist'] = run_list(env_yaml['components'][component]['runlist'], env_yaml['components'][component]['componentrole'], component)\n end\n end\n unless env_yaml['vcenter'].nil?\n # append env name to destination folder if appendenv == true\n env_yaml['vcenter']['destfolder'] += (env_yaml['vcenter']['appendenv'] ? '/' + env.to_s : '')\n # prepend app name to domain if appenddomain == true\n env_yaml['vcenter']['appenddomain'] ? env_yaml['vcenter']['domain'] = '.' + platform.name + '.' + env_yaml['vcenter']['domain'] : ''\n end\n env_yaml\n end",
"def add(config = {})\n config.each do |key, value|\n define_setting key.to_sym, value\n end\n end",
"def forward_local_env(env_variable_patterns); end",
"def load_config(filename, environment)\n\t\t\tyaml = YAML.load_file(filename)[environment.to_s]\n\t\t\traise ArgumentError, \"The #{environment} environment does not exist in #{filename}\" if yaml.nil?\n\t\t\tyaml.each { |k, v| config[k.to_sym] = v }\n\t\tend",
"def set_env vars\n command = <<~HEREDOC\n echo \"Setting Environment Variables\"\n source ~/.bashrc\n HEREDOC\n\n vars.each do |key, value|\n command += <<~HEREDOC\n if [ -z \"$#{key}\" ]; then\n echo \"export #{key}=#{value}\" >> ~/.profile\n fi\n HEREDOC\n end\n\n return command\nend",
"def prepend_env(cmd)\n return cmd unless @rye_current_environment_variables.is_a?(Hash)\n env = ''\n @rye_current_environment_variables.each_pair do |n,v|\n env << \"export #{n}=#{Escape.shell_single_word(v)}; \"\n end\n [env, cmd].join(' ')\n end",
"def finish\n super\n @_env[ENV_KEY] = self\n end",
"def load_var(env_name, default = nil, puts_depth = 1)\r\n var = ENV[env_name] || @yml_config[env_name.downcase] ||\r\n @yml_config[env_name.upcase] || default\r\n\r\n # Delete values as we read them so that we can ensure there were no\r\n # unknown values.\r\n @yml_config.delete(env_name.downcase)\r\n @yml_config.delete(env_name.upcase)\r\n\r\n # TODO: Log this!\r\n puts(\"#{env_name.upcase} = #{var.inspect}\", puts_depth)\r\n\r\n return var\r\n end",
"def environment=(env_options)\n env_options.each do |key, value|\n ENV[key] = value\n end\n end",
"def add_config(key, value)\n system(\"git config --global --add #{key} '#{value}'\")\n end",
"def write_environment_variable(cartridge, path, *hash)\n FileUtils.mkpath(path) unless File.exist? path\n\n hash.first.each_pair do |k, v|\n name = \"OPENSHIFT_#{cartridge.short_name.upcase}_#{k.to_s.upcase}\"\n File.open(PathUtils.join(path, name), 'w', 0660) do |f|\n f.write(%Q(export #{name}='#{v}'))\n end\n end\n end",
"def load_environment_file(name, fail_on_missing = false)\n unless File.exists?(name)\n abort(\"Unable to read environment: #{name}\") if fail_on_missing\n return nil\n end\n\n load_env = EC2Launcher::DSL::Environment.new\n load_env.load(File.read(name))\n load_env\n end",
"def load_env(environment=nil)\n environment ||= \"production\"\n load_dot_env \".env\" if environment == \"production\"\n load_dot_env \".env.#{environment}\"\nend",
"def get_env_var_add_job(gear, key, value)\n args = build_base_gear_args(gear)\n args['--with-key'] = key\n args['--with-value'] = value\n job = RemoteJob.new('openshift-origin-node', 'env-var-add', args)\n job\n end"
] | [
"0.74099374",
"0.6782808",
"0.66513526",
"0.65029156",
"0.6471585",
"0.6404137",
"0.62664926",
"0.62444943",
"0.62345785",
"0.6156607",
"0.6081455",
"0.6052262",
"0.60515046",
"0.604998",
"0.60393715",
"0.6034629",
"0.6008228",
"0.60052973",
"0.59906244",
"0.5987529",
"0.59447396",
"0.59094",
"0.5908145",
"0.589389",
"0.58792895",
"0.5848343",
"0.5842545",
"0.5842545",
"0.5842545",
"0.5842545",
"0.58305615",
"0.5821697",
"0.5792714",
"0.57825035",
"0.57722104",
"0.57700616",
"0.5749067",
"0.5742697",
"0.57373476",
"0.57300305",
"0.572433",
"0.5714905",
"0.5712352",
"0.57119715",
"0.5700075",
"0.5683885",
"0.5672011",
"0.5670773",
"0.5665518",
"0.565026",
"0.5646685",
"0.564438",
"0.564144",
"0.56303006",
"0.5630216",
"0.56245995",
"0.56092715",
"0.5598528",
"0.5589433",
"0.55862844",
"0.5585247",
"0.5585247",
"0.55837506",
"0.5574405",
"0.55705565",
"0.55705565",
"0.5568786",
"0.5556869",
"0.5555844",
"0.5548486",
"0.55346054",
"0.5528461",
"0.55228966",
"0.5512012",
"0.55066246",
"0.54982466",
"0.54911274",
"0.54840106",
"0.5476445",
"0.54752207",
"0.54730815",
"0.547246",
"0.5471246",
"0.5469031",
"0.5464791",
"0.54497737",
"0.544446",
"0.5438762",
"0.5436389",
"0.54345876",
"0.5424549",
"0.54238784",
"0.5421364",
"0.5417853",
"0.5412886",
"0.54089844",
"0.5407447",
"0.54057235",
"0.540414",
"0.54032177",
"0.53981936"
] | 0.0 | -1 |
def update_counter_cache self.content_type = document.file.content_type end | def convertToTwoDigitString inInt
if inInt < 10
return "0" + inInt.to_s;
end
inInt.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_content_type\n if file.present? && file_changed?\n self.content_type = file.file.content_type\n end\n end",
"def update_cache_counters\n target.update_column(:reports_counter, target.reports.count) if target_type == 'Content'\n end",
"def cache!(document) \n if document.is_a?(Hash) && document.has_key?(\"base64\") && document.has_key?(\"filename\")\n raise ArgumentError unless document[\"base64\"].present?\n file = FilelessIO.new(Base64.decode64(document[\"base64\"]))\n file.original_filename = document[\"filename\"]\n file.content_type = document[\"filetype\"] \n super(file)\n else\n super(document)\n end\n end",
"def cache!(document)\n if document.is_a?(Hash) && document.has_key?(\"base64\") && document.has_key?(\"filename\")\n raise ArgumentError unless document[\"base64\"].present?\n file = FilelessIO.new(Base64.decode64(document[\"base64\"]))\n file.original_filename = document[\"filename\"]\n file.content_type = document[\"filetype\"] \n super(file)\n else\n super(document)\n end\n end",
"def content_type=(content_type); end",
"def cache_file\n MIME.deprecated(self, __method__)\n ENV['RUBY_MIME_TYPES_CACHE']\n end",
"def counter_cache; end",
"def cache_store_type\n \"file\"\n end",
"def counter\n @counter ||= Counter.find(:item_id => self.id, :item_class => 'Fileentity').first\n if @counter.nil? \n @counter = Counter.create(:item_id => self.id,\n :item_class => 'Fileentity',\n :item_counter_attribute => 'file_counter',\n :flushed_at => Time.now.to_i) \n @counter.incr(:counter, self.file_counter) \n end\n @counter\n end",
"def content_type\n self.file_content_type\n end",
"def document_type\n FileUtility.get_file_type(@file_name)\n end",
"def update_upload_attributes\n if document.present? && document_changed?\n self.content_type = document.file.content_type\n self.file_size = document.file.size\n self.file_name = File.basename(document.url)\n end\n end",
"def []=(content_type, klass); end",
"def cache_content(type, data)\n return nil unless type.present?\n\n Rails.cache.write(type, data, expires_in: 60.minutes)\n rescue StandardError => e\n logger.error(\"Unable to add #{type} to the Rails cache: #{e}.\")\n end",
"def content_type\n# if stat.directory?\n# \"text/html\"\n# else \n# mime_type(file_path, DefaultMimeTypes)\n# end\n @bson['contentType'] || \"text/html\"\n end",
"def mime_type=(_); end",
"def content_type\n @content_type || file.content_type\n end",
"def update_impressions_counter_cache\n return unless Object.const_defined? self.impressionable_type\n impressionable_class = self.impressionable_type.constantize\n return unless impressionable_class.is_a? Class\n\n if impressionable_class.counter_cache_options\n resource = impressionable_class.find(self.impressionable_id)\n resource.try(:update_counter_cache)\n end\n end",
"def attachment_content_type=(value)\n self.content_type=value\n end",
"def content_type=(type)\n\t\t\tif type.index(C_slash)\n\t\t\t\t@content_type = type\n\t\t\telse\n\t\t\t\t@content_type = MIME::Types.type_for(type).first || BINARY_TYPE\n\t\t\tend\n\t\tend",
"def set_content_type(override=false)\n if override || file.content_type.blank?\n File.open(file.path) do |fd|\n data = fd.read(1024) || \"\"\n new_content_type = filemagic.buffer(data)\n if file.respond_to?(:content_type=)\n file.content_type = new_content_type\n else\n file.instance_variable_set(:@content_type, new_content_type)\n end\n end\n end\n end",
"def update_cache(type, id, data)\n end",
"def update_cache(type, id, data)\n end",
"def content_type=(type)\n @content_type = type\n end",
"def update_cache(type, id, data)\n end",
"def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n xml.entry(:xmlns => \"http://www.w3.org/2005/Atom\",\n \"xmlns:cmisra\" => \"http://docs.oasis-open.org/ns/cmis/restatom/200908/\",\n \"xmlns:cmis\" => \"http://docs.oasis-open.org/ns/cmis/core/200908/\") {\n xml.title document.original_filename if document\n xml.summary document_type\n if document\n xml.content(:type => document.content_type) {\n xml.text Base64.encode64(document.read)\n }\n end\n }\n end\n\n url = Document::PATH + \"cmis/i/#{document_id}?alf_ticket=\" + ticket\n\n begin\n RestClient.put url, builder.to_xml, {:content_type => 'application/atom+xml;type=entry'}\n rescue => e\n Rails.logger.info \"#\"*50\n Rails.logger.info \"Error updating file\"\n Rails.logger.info e.message\n Rails.logger.info \"#\"*50\n end\n\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def content_type=(value)\n @content_type = value\n end",
"def update_last_known_file_type\n self.last_known_file_type = Constants::FILE_TYPES_BY_EXTENSION[pathname.extname[1..-1]]\n end",
"def save_content_type_and_size\n model.content_type = file.content_type if model.respond_to?(:content_type) && file.content_type\n model.file_size = file.size if model.respond_to?(:file_size)\n end",
"def type\n @config[:caching][:type]\n end",
"def [](content_type); end",
"def counter_cache=(_arg0); end",
"def update\n replace_entry \"word/document.xml\", doc.serialize(:save_with => 0)\n end",
"def update!(**args)\n @file_type = args[:file_type] if args.key?(:file_type)\n end",
"def document_type\n unless @version\n version = self['VERSION'].to_s\n\n case version\n when '2.1'\n @version = VCARD21\n when '3.0'\n @version = VCARD30\n when '4.0'\n @version = VCARD40\n else\n # We don't want to cache the version if it's unknown,\n # because we might get a version property in a bit.\n return UNKNOWN\n end\n end\n\n @version\n end",
"def file_type\r\n\t\t@file_type\r\n\tend",
"def document_type=(name)\n @document_type = name\n end",
"def document_type=(name)\n @document_type = name\n end",
"def override_content_type_and_save_info\n case File.extname(file.file).delete('.').downcase.to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n when :rar\n file.content_type = 'application/vnd.rar'\n when :zip\n file.content_type = 'application/zip'\n when :bat\n file.content_type = 'application/x-msdos-program'\n when :cmd\n file.content_type = 'application/cmd'\n when :exe\n file.content_type = 'application/x-msdownload'\n when :msi\n file.content_type = 'application/x-msi'\n when :php\n file.content_type = 'application/x-php'\n when :py\n file.content_type = 'application/x-python'\n when :vbs\n file.content_type = 'application/x-vbs'\n end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n end",
"def initialize_file_based_cache\n Dir.mkdir(\"cache\")\n @document_cache = ActiveSupport::Cache::FileStore.new(\"cache\")\n @file_based_cache = true\n end",
"def update_content\n\t\tday = Day.from_identifier(post_params[:day])\n\t\tdocument = Document.for_user(@user.id, day.year, day.month, day.day).first\n\t\traise \"Unknown document\" unless document\n\t\tdocument.content = post_params[:content]\n\t\tdocument.words = count_words(post_params[:content])\n\t\tdocument.save!\n\t\trender_ok\n\tend",
"def update_count(doctype,count)\n verify_doctype(doctype)\n Store.get_store(store_index(doctype)).update_count(docname(doctype), count)\n end",
"def content_type=(new_content_type)\n @content_type = new_content_type\n end",
"def content_type=(_arg0); end",
"def content_type=(_arg0); end",
"def content_type=(_arg0); end",
"def mime_type=(_arg0); end",
"def mime_type=(_arg0); end",
"def mime_type=(_arg0); end",
"def content_type=( type )\n\t\treturn self.headers.content_type = type\n\tend",
"def content_type=( type )\n\t\treturn self.headers.content_type = type\n\tend",
"def register_mime_type(mime_type, ext)\n # Overrides the global behavior to expire the index\n expire_index!\n @trail.append_extension(ext)\n super\n end",
"def content_type=(v) Axlsx::validate_content_type v; @content_type = v end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def content_type; end",
"def set_content_type old_type, old_resource_type, new_type, new_resource_type\n xml=self.ng_xml\n xml.search('/contentMetadata[@type=\\''+old_type+'\\']').each do |node|\n node['type']=new_type\n xml.search('//resource[@type=\\''+old_resource_type+'\\']').each do |resource|\n resource['type']=new_resource_type\n end\n end\n self.content=xml.to_s\n end",
"def content_type\n end",
"def set_file_type\n if self.is_local?\n if self.attachment_content_type.blank?\n self.file_type = \"misc\"\n elsif self.attachment_content_type == 'application/pdf'\n self.file_type = \"pdf\"\n elsif self.attachment_content_type.include?('powerpoint')\n self.file_type = \"presentation\"\n elsif self.attachment_content_type == 'application/zip'\n self.file_type = \"zip\"\n elsif self.attachment_content_type == \"application/rtf\" || self.attachment_content_type == 'text/plain' || self.attachment_content_type == 'application/msword' || self.attachment_content_type.include?('wordprocessing')\n self.file_type = \"document\"\n elsif self.attachment_content_type.include?('spreadsheet') || self.attachment_content_type == 'ms-excel'\n self.file_type = \"spreadsheet\"\n elsif self.attachment_content_type.include?('image')\n self.file_type = \"image\"\n else\n self.file_type = \"misc\"\n end\n end\n end",
"def get_file_and_bump shortened\n @coll.find_one_and_update({ shortened: shortened },\n { \"$inc\" => { \"accessed.count\" => 1 },\n \"$set\" => { \"accessed.time\" => Time.now.utc } },\n return_document: :after )\n end",
"def content_type\n file.try(:content_type)\n end",
"def after_update(doc)\n\t\t# expire_cache_for(doc)\n\tend",
"def type\n document._type = document.class.name if typed?\n end",
"def content_length\r\nsuper.to_i\r\nend",
"def file_type\n self['fileRef']['explicitFileType'] || self['fileRef']['lastKnownFileType']\n end",
"def content_mime_type; end",
"def setContenttype(contenttype)\r\n\t\t\t\t\t@contenttype = contenttype\r\n\t\t\t\tend",
"def toggle_type\n @document = Document.toggle_type(params[:document_id])\n if @document.content_type == 1\n @document.content = markdown_to_html(@document.content)\n @document.save\n else\n @document.content = html_to_markdown(@document.content)\n @document.save\n end\n @task = Task.find(@document.task_id)\n respond_to do |format|\n format.html {render :new }\n end\n end",
"def mime_type; end",
"def mime_type; end",
"def mime_type; end",
"def mime_type; end",
"def get_content_type\n self.content_type\n end",
"def add_content_type(extension, type); end",
"def set_content_type(override=false)\n if override || file.content_type.blank? || generic_content_type?\n new_content_type = ::MIME::Types.type_for(current_path).first.to_s\n if file.respond_to?(:content_type=)\n file.content_type = new_content_type\n else\n file.instance_variable_set(:@content_type, new_content_type)\n end\n end\n rescue ::MIME::InvalidContentType => e\n raise CarrierWave::ProcessingError, I18n.translate(:\"errors.messages.mime_types_processing_error\", :e => e)\n end",
"def content_type=(content_type); @message_impl.setContentType content_type; end",
"def get_counter_for_file(filename)\n CounterFinder.new(filename, @file_extension).counter\n end",
"def content_type\n return @content_type\n end",
"def _flush_cache(*types)\n if types.size == 0 or types.include?(:hash)\n @cache_hash = { }\n @hash_times = Hash.new(0)\n end\n\n if types.size == 0 or types.include?(:file)\n @file_times = Hash.new(0)\n @file_cache = { }\n end\n self\n end",
"def content_type=(new_content_type)\n write_attribute(:content_type, new_content_type)\n end",
"def set_document_type\n @document_type = DocumentType.find(params[:id])\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end",
"def update!(**args)\n @acl_info = args[:acl_info] if args.key?(:acl_info)\n @document_type = args[:document_type] if args.key?(:document_type)\n @file_extension = args[:file_extension] if args.key?(:file_extension)\n @last_content_modified_timestamp = args[:last_content_modified_timestamp] if args.key?(:last_content_modified_timestamp)\n @num_subscribers = args[:num_subscribers] if args.key?(:num_subscribers)\n @num_viewers = args[:num_viewers] if args.key?(:num_viewers)\n @result_info = args[:result_info] if args.key?(:result_info)\n @type_info = args[:type_info] if args.key?(:type_info)\n end",
"def document_type\n instance.class.tire.document_type\n end",
"def cache_content(uri, content)\n clear_cache(uri)\n\n time = Time.now.to_i\n\n cache_store.write(cache_key(uri), time)\n cache_store.write(cache_key([uri, time]), content)\n \n content\n end",
"def content_type=( type )\n\t\treturn self.headers[ :content_type ] = type\n\tend",
"def update_cache\n # Does nothing...up to subclasses to implement.\n end",
"def set_document_type\n @document_type = DocumentType.find(params[:id])\n end",
"def override_content_type_and_save_info\n case File.extname(file.file).delete('.').to_sym\n when :xlsx\n file.content_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n when :docx\n file.content_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n when :pptx\n file.content_type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'\n end\n\n # if File.extname(file.file).delete('.').to_sym == :xlsx\n # file.content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n # end\n # if File.extname(file.file).delete('.').to_sym == :docx\n # file.content_type='application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n # end\n # if File.extname(file.file).delete('.').to_sym == :pptx\n # file.content_type='application/vnd.openxmlformats-officedocument.presentationml.presentation'\n # end\n\n model.file_content_type = file.content_type if file.content_type\n model.file_size = number_to_human_size(file.size) if file.size\n\n tmp_file = file.path\n photo = MiniExiftool.new \"#{tmp_file}\"\n\n model.latitude = dms_to_float(photo.gpslatitude) if photo && photo.gpslatitude\n model.longitude = dms_to_float(photo.gpslongitude) if photo && photo.gpslongitude\n model.photo_created_at = photo.createdate if photo && photo.createdate\n end",
"def process_file\n instance_variable_get(:@fields).keys.each do |locale|\n request = Request.new(\n client,\n process_url(locale),\n {},\n nil,\n version: sys[:version]\n )\n request.put\n end\n sys[:version] += 1\n self\n end",
"def set_content_type\n @content_type = ContentType.find(params[:id])\n end",
"def content_type(path)\r\n ext = File.extname(path).split(\".\").last\r\n CONTENT_TYPE_MAPPING.fetch(ext, DEFAULT_CONTENT_TYPE)\r\nend"
] | [
"0.68738395",
"0.6633051",
"0.6375145",
"0.62822866",
"0.61433023",
"0.6141906",
"0.6043013",
"0.59969115",
"0.5993716",
"0.5977373",
"0.594908",
"0.59289515",
"0.58197963",
"0.5747973",
"0.5738938",
"0.56505215",
"0.5622825",
"0.5615247",
"0.5613524",
"0.5610799",
"0.560218",
"0.5593134",
"0.5593134",
"0.5592482",
"0.55861014",
"0.5568006",
"0.55619335",
"0.55323845",
"0.55176115",
"0.5508644",
"0.5499214",
"0.54927623",
"0.54894",
"0.54880327",
"0.54847234",
"0.54842985",
"0.54709464",
"0.54709464",
"0.5466283",
"0.5453159",
"0.54348797",
"0.5432165",
"0.54198086",
"0.54114914",
"0.54114914",
"0.54114914",
"0.5401812",
"0.5401812",
"0.5401812",
"0.53903204",
"0.53903204",
"0.5387526",
"0.5381712",
"0.53725415",
"0.53725415",
"0.53725415",
"0.53725415",
"0.53725415",
"0.53725415",
"0.53725415",
"0.53725415",
"0.5371062",
"0.53673977",
"0.5366604",
"0.5366016",
"0.5360177",
"0.5359625",
"0.5358807",
"0.5358362",
"0.53553873",
"0.5352972",
"0.53476804",
"0.5347661",
"0.53450143",
"0.53450143",
"0.53450143",
"0.53450143",
"0.53427845",
"0.53207535",
"0.53049326",
"0.5297444",
"0.52845895",
"0.5282353",
"0.5281082",
"0.52802163",
"0.5271536",
"0.52694654",
"0.52694654",
"0.52694654",
"0.52694654",
"0.52694654",
"0.5267348",
"0.52640504",
"0.52455777",
"0.5245249",
"0.5244559",
"0.52319753",
"0.5228349",
"0.52229744",
"0.52167064",
"0.5210364"
] | 0.0 | -1 |
def try_extract_id3_tags if extract_id3_tags && audio_file.present? extract_id3_tags_from_audio_file end end | def check_title
if title.to_s == '' && audio_file.present?
str = File.basename(audio_file_url).gsub(/[_]/, ' ')
self.title = str.gsub(/[.mp3]/, '')
self.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_tag(p_audio_file)\n begin\n\n # Log progress\n log.debug \"[Reader] '#{p_audio_file}' :\"\n\n # Read ID3 Tags from the given file, abort if empty\n id3_tag = ID3LiteWrapper.new(p_audio_file)\n return nil if id3_tag.empty?\n\n # Sanitize the newly read ID3 Tag, log output\n #id3_tag.sanitize!\n log.debug lpp [id3_tag.artist, id3_tag.album, id3_tag.year]\n\n # Derive artist and album from ID3 Tags\n artist = Artist.new(id3_tag)\n album = Album.new(id3_tag, p_audio_file)\n\n log.debug \"Resulting artist: #{artist}\"\n log.debug \"Resulting album: #{album}\"\n\n # Add the album to the given artist\n artist.add_album(album)\n\n # Return processed artist as result\n artist\n\n # Rescue any exception\n rescue Exception => e\n log.error e\n end\n end",
"def extract_metadata\n return unless audio?\n path = upload.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3info|\n self.metadata = mp3info.tag\n end\n end",
"def extract_metadata\n return unless audio?\n path = upload.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3info|\n self.metadata = mp3info.tag\n end\n end",
"def scan_file!(file)\r\n AudioFile.transaction do\r\n\r\n file= File.expand_path(file)\r\n raise \"Unable to derive dirname and basename for #{file.inspect}\" unless file =~ /\\A(^.+)[\\\\\\/](.+)$\\Z/\r\n file_dirname,file_basename= $1,$2\r\n filesize= File.size(file)\r\n tags= []\r\n a= AudioContent.new\r\n content= File.read(file)\r\n file_ext= file_basename.sub(/^.+\\./,'') if file_basename.include?('.')\r\n if file_ext =~ /mp3/i\r\n a.format= 'mp3'\r\n Mp3Info.open(file){|mp3|\r\n start,len= mp3.audio_content\r\n\r\n # Read ID3 tag\r\n tags<< AudioTag.new({\r\n :format => 'id3',\r\n :version => mp3.tag2.version,\r\n :offset => 0,\r\n :data => content[0..start-1],\r\n }) if start > 0 and mp3.tag2\r\n # TODO footer id3 tags not supported\r\n content= content[start..start+len-1]\r\n\r\n # Read APE tag\r\n ape= ApeTag.new(file)\r\n if ape.exists?\r\n raise \"ape.tag_size != ape.raw.size\\n#{ape.inspect}\" unless ape.tag_size == ape.raw.size\r\n tags<< AudioTag.new({\r\n :format => 'ape',\r\n :version => '2',\r\n :offset => filesize - ape.tag_size,\r\n :data => ape.raw,\r\n })\r\n content= content[0..-ape.tag_size-1]\r\n end\r\n }\r\n\r\n # Scan forward to mp3 header\r\n content.sub!(/^\\x00+(?=\\xff)/, '').freeze\r\n\r\n # Read mp3 attributes from raw mp3 without tags\r\n stringio_fake_filename= File.filename_for_stringio(content)\r\n Mp3Info.open(stringio_fake_filename){|mp3|\r\n a.bitrate= mp3.bitrate\r\n a.length= mp3.length\r\n a.samplerate= mp3.samplerate\r\n a.vbr= mp3.vbr\r\n }\r\n else\r\n raise \"Unsupported format: #{file_ext.inspect}\\nFile: #{file}\"\r\n end\r\n\r\n # Albumart on tags\r\n tags.each{|t|\r\n if t.albumart_raw and t.albumart_mimetype\r\n img= Image.find_identical_or_create! :mimetype => t.albumart_mimetype, :data => t.albumart_raw\r\n t.albumart= img\r\n end\r\n }\r\n\r\n # Save audio content\r\n a.size= content.size\r\n a.md5= Digest::MD5.digest(content)\r\n a.sha2= Digest::SHA2.digest(content, 512)\r\n a= a.find_identical_or_save!\r\n\r\n # Save audio file\r\n f= AudioFile.find_identical_or_create!({\r\n :audio_content => a,\r\n :dirname => file_dirname,\r\n :basename => file_basename,\r\n :size => filesize,\r\n :location => @location,\r\n :mtime => File.mtime(file),\r\n })\r\n\r\n # Save tags\r\n albums= []\r\n tags_to_delete= f.audio_tags.dup\r\n tags.each{|t|\r\n t.audio_file= f\r\n\r\n # Save if this is a new tag\r\n matching_tags= f.audio_tags.select{|t2| get_tag_attributes(t) == get_tag_attributes(t2)}\r\n if matching_tags.empty?\r\n t.save!\r\n process_tag t, albums, f\r\n else\r\n matching_tags.each{|t2| tags_to_delete.delete t2}\r\n end\r\n }\r\n f.audio_tags.delete *tags_to_delete unless tags_to_delete.empty?\r\n\r\n # Update albumart on albums\r\n tags.each{|t|\r\n if albumart_raw= t.ta[:albumart]\r\n img= Image.find_identical_or_create! :data => albumart_raw, :size => albumart_raw.size\r\n t.albumart= img\r\n end\r\n }\r\n albums.uniq.each{|album| album.update_albumart!}\r\n\r\n # Remove old versions of the same audio file\r\n old_afs= AudioFile.find :all, :conditions => ['dirname=? AND basename=? AND id!=?',f.dirname, f.basename, f.id]\r\n old_afs.each(&:destroy)\r\n end\r\n\r\n # Remove any errors for this file\r\n ScannerError.delete_all :file => file\r\n end",
"def can_parse_id3?(filename)\n begin\n trash = Mp3Info.open(filename)\n return true\n rescue\n return false\n end\nend",
"def extract_metadata\n return unless audio?\n path = attachment.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3info|\n self.metadata = mp3info.tag\n end\n end",
"def extract_audio_details\n path = audio.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n Mp3Info.open(path, open_opts) do |mp3|\n\t self.title = mp3.tag.title \n\t self.album = mp3.tag.album\n\t self.artist = mp3.tag.artist\n\t self.track = mp3.tag.tracknum\n end\nend",
"def get_tag_information\n unless file_size >= id3.length + 64 \n @has_tag = false\n @tag_start = file_size - id3.length\n return\n end\n file.seek(-32-id3.length, IO::SEEK_END)\n tag_footer = file.read(32)\n unless tag_footer[0...12] == PREAMBLE \n @has_tag = false\n @tag_start = file_size - id3.length\n return\n end\n raise ApeTagError, \"Tag has bad footer flags\" unless tag_footer[21...24] == FOOTER_FLAGS && (tag_footer[20...21] == \"\\x00\" || tag_footer[20...21] == \"\\x01\")\n @tag_footer = tag_footer\n @tag_size, @tag_item_count = tag_footer[12...20].unpack('VV')\n @tag_size += 32\n raise ApeTagError, \"Tag size (#{tag_size}) smaller than minimum size\" if tag_size < 64 \n raise ApeTagError, \"Tag size (#{tag_size}) larger than possible\" if tag_size + id3.length > file_size\n raise ApeTagError, \"Tag size (#{tag_size}) is larger than #{MAX_SIZE}\" if tag_size > MAX_SIZE\n raise ApeTagError, \"Item count (#{tag_item_count}) is larger than #{MAX_ITEM_COUNT}\" if tag_item_count > MAX_ITEM_COUNT\n raise ApeTagError, \"Item count (#{tag_item_count}) is larger than possible\" if tag_item_count > (tag_size-64)/ApeItem::MIN_SIZE\n file.seek(-tag_size-id3.length, IO::SEEK_END)\n @tag_start=file.pos\n @tag_header=file.read(32)\n @tag_data=file.read(tag_size-64)\n raise ApeTagError, \"Missing header\" unless tag_header[0...12] == PREAMBLE && tag_header[21...24] == HEADER_FLAGS && (tag_header[20...21] == \"\\x00\" || tag_header[20...21] == \"\\x01\")\n raise ApeTagError, \"Header and footer size does not match\" unless tag_size == tag_header[12...16].unpack('V')[0] + 32\n raise ApeTagError, \"Header and footer item count does not match\" unless tag_item_count == tag_header[16...20].unpack('V')[0]\n @has_tag = true\n end",
"def extract_metadata\n path = audio.queued_for_write[:original].path\n open_opts = { :encoding => 'utf-8' }\n TagLib::FileRef.open(path) do |fileref|\n tag = fileref.tag\n properties = fileref.audio_properties\n self.update_attributes(:artist => tag.artist,:album=> tag.album,:title => tag.title, :genre => tag.genre, :track_number => tag.track, :year_of_release => tag.year, :comments => tag.comment,:bitrate => properties.bitrate,:no_of_channels => properties.channels,:length=> properties.length,:sample_rate=> properties.sample_rate)\n end\n end",
"def actually_has_id3v2_tag?\n nil != defined?(@id3v2_tag) && nil != @id3v2_tag\n end",
"def add_tags\n if @tags.nil?\n @tags = IFFID3.new\n else\n raise AIFFError, 'an ID3 tag already exists'\n end\n end",
"def retag_album_artist(filename, album_artist_tag)\n Mp3Info.open(filename) do |mp3file|\n print \"Retagging #{filename}...\"\n STDOUT.flush\n if (mp3file.tag2.TPE2)\n puts \"oops!\"\n puts \"Found existing Album Artist tag: #{mp3file.tag2.TPE2}. Skipping file.\"\n return\n end\n mp3file.tag2.TPE2 = album_artist_tag\n puts \"done.\"\n end\nend",
"def read_all_tags(taglib, id3v2_frames, id3v1_tag = nil, **opts)\n frames = []\n id3v2_frames.each { |frame_id| frames += id3v2_frames(taglib, frame_id) }\n\n data = []\n # only check id3v1 if no id3v2 frames found\n if frames.empty?\n data << id3v1_tag(taglib, id3v1_tag) unless id3v1_tag.nil?\n else\n frames.each { |frame| data << data_from_frame(frame, **opts) }\n end\n\n data.compact\n end",
"def extract_metadata\n return unless audio?\n logger.debug(maudio_params[:path])\n logger.debug('It\\'s audio')\n path = maudio_params[:path]\n #url = URI.parse(path) # turn the string into a URI\n #http = Net::HTTP.new(url.host, url.port) \n #req = Net::HTTP::Get.new(url.path) # init a request with the url\n #req.range = (0..4096) # limit the load to only 4096 bytes\n #res = http.request(req) # load the mp3 file\n #child = {} # prepare an empty array to store the metadata we grab\n #open_opts = { :encoding => 'utf-8' }\n #Mp3Info.open( StringIO.open(res.body) ) do |m| #do the parsing\n # child['title'] = m.tag.title \n # child['album'] = m.tag.album \n # child['artist'] = m.tag.artist\n # child['length'] = m.length\n # \n # puts m\n #end\n #logger.debug('*********************')\n \n #logger.debug(child['length'])\n #logger.debug('*********************')\n end",
"def initialize(filename)\n # read in ID3v2 tag, MPEG info, and ID3 tag (if present) in a single pass\n @filename = filename\n file = File.new(@filename, \"rb\")\n \n total_bytes = file.stat.size\n\n while file.pos < total_bytes do\n # try to read tags first, then read MPEG data\n case file.read(3)\n when 'TAG' # ID3 tag at the beginning of the file (unusual)\n file.seek(-3, IO::SEEK_CUR)\n $stderr.puts(\"Mp3Info.initialize TAG found at %#010x\" % file.pos) if $DEBUG\n @id3v1_tag = ID3.from_io(file)\n $stderr.puts(\"Mp3Info.initialize ID3 tag is #{@id3v1_tag.inspect}\") if $DEBUG\n when 'ID3' # ID3v2 tag\n file.seek(-3, IO::SEEK_CUR)\n $stderr.puts(\"Mp3Info.initialize ID3 found at %#010x\" % file.pos) if $DEBUG\n if has_id3v2_tag?\n @id3v2_tag.merge(ID3V2.from_io(file))\n else\n @id3v2_tag = ID3V2.from_io(file)\n end\n else\n file.seek(-3, IO::SEEK_CUR)\n $stderr.puts(\"Mp3Info.initialize scanning for MPEG data at %#010x\" % file.pos) if $DEBUG\n cur_pos = file.pos\n begin\n $stderr.puts(\"Mp3Info.initialize about to call find_next_frame at %#010x\" % file.pos) if $DEBUG\n header_pos, header_data = find_next_frame(file, cur_pos)\n mpeg_candidate = MPEGHeader.new(header_data)\n @mpeg_header = mpeg_candidate if mpeg_candidate.valid?\n \n if mpeg_candidate.valid?\n $stderr.puts(\"mpeg header %#010x found at position %#010x (%s)\" % [header_data.to_binary_decimal, header_pos, mpeg_candidate.to_s]) if $DEBUG\n file.seek(header_pos)\n cur_frame = read_next_frame(file, mpeg_candidate.frame_size)\n $stderr.puts(\"Current frame is %#06x bytes (requested %#06x)\" % [cur_frame.size, mpeg_candidate.frame_size]) if $DEBUG\n \n xing_candidate = XingHeader.new(cur_frame)\n @xing_header = xing_candidate if xing_candidate.valid?\n $stderr.puts(\"Xing header found, is [#{@xing_header.to_s}]\") if $DEBUG && has_xing_header?\n \n lame_candidate = LAMEHeader.new(cur_frame)\n @lame_header = lame_candidate if lame_candidate.valid?\n $stderr.puts(\"LAME header found, is [#{@lame_header.inspect}]\") if $DEBUG && has_lame_header?\n break # we're done trying to read candidates\n end\n rescue MPEGFile::MPEGFileError\n $stderr.puts(\"Mp3Info.initialize guesses there's no MPEG frames in this file.\") if $DEBUG\n file.seek(cur_pos)\n break\n end\n end\n $stderr.puts(\"File position is #{\"%#010x\" % file.pos}\") if $DEBUG\n end\n \n #\n # calculate the CBR bitrate, streamsize, length\n #\n if has_mpeg_header? && !has_xing_header?\n # for cbr, calculate duration with the given bitrate\n @streamsize = file.stat.size - (has_id3v1_tag? ? ID3::TAGSIZE : 0) - ((has_id3v2_tag? ? (@id3v2_tag.tag_length + 10) : 0))\n @length = ((@streamsize << 3) / 1000.0) / bitrate\n if has_id3v2_tag? && @id3v2_tag['TLEN']\n # but if another duration is given and it isn't close (within 5%)\n # assume the mp3 is vbr and go with the given duration\n tlen = (@id3v2_tag['TLEN'].is_a?(Array) ? @id3v2_tag['TLEN'].last : @id3v2_tag['TLEN']).value.to_i / 1000\n if tlen > 0\n percent_diff = ((@length.to_i - tlen) / tlen.to_f)\n if percent_diff.abs > 0.05\n @vbr = true\n @bitrate = (@streamsize / tlen) / 1024\n end\n end\n end\n end\n \n #\n # check for an ID3 tag at the end\n #\n if (total_bytes >= ID3::TAGSIZE)\n file.seek(-ID3::TAGSIZE, IO::SEEK_END)\n if file.read(3) == 'TAG'\n file.seek(-3, IO::SEEK_CUR)\n if has_id3v1_tag?\n @id3v1_tag.update(ID3.from_io(file))\n else\n @id3v1_tag = ID3.from_io(file)\n end\n end\n end\n \n file.close\n \n load_universal_tag!\n \n if !(has_id3v1_tag? || has_id3v2_tag? || has_mpeg_header? || has_xing_header?)\n raise(Mp3InfoError, \"There was no useful metadata in #{@filename}, are you sure it's an MP3?\")\n end\n \n # there should always be tags available for convenience\n @id3v1_tag = ID3.new if nil == defined? @id3v1_tag\n @id3v2_tag = ID3V2.new if nil == defined? @id3v2_tag\n end",
"def id3\n return @id3 unless @id3.nil?\n return @id3 = '' if file_size < 128 || check_id3 == false\n file.seek(-128, IO::SEEK_END)\n data = file.read(128)\n @id3 = data[0...3] == 'TAG' ? data : ''\n end",
"def getMp3Info(file)\n ret = {}\n tagstrings = `eyeD3 --no-color #{file} | grep -P '(title|artist|album)' | sed 's/\\\\t\\\\+/\\\\n/'`.split(\"\\n\")\n tagstrings.each do |line|\n key_val = line.split(\":\")\n ret[(key_val[0].strip.to_sym)] = key_val[1]\n end\n if ret[:artist].nil? || ret[:album].nil? || ret[:title].nil?\n raise \"Error parsing id3 tags on mp3 file - is it possible that eyeD3 output format has changed?\"\n end\n ret\nend",
"def contains_audio?\n result = false\n sample_attachments.map{|sa| result = true if sa.is_audio?}\n result\n end",
"def extract_metadata!\n unless self.title\n Mp3Info.open(self.server_path) do |mp3|\n self.title = mp3.tag.title\n self.artist = mp3.tag.artist\n self.album = mp3.tag.album\n self.year = mp3.tag.year\n self.comm = mp3.tag2.comm\n self.tcom = mp3.tag2.tcom\n self.tcon = mp3.tag2.tcon\n self.tcop = mp3.tag2.tcop\n self.tit2 = mp3.tag2.tit2\n self.tit3 = mp3.tag2.tit3\n self.tcat = mp3.tag2.tcat\n self.trck = mp3.tag2.trck\n self.tyer = mp3.tag2.tyer\n self.tgid = mp3.tag2.tgid\n self.wfed = mp3.tag2.wfed\n end\n\n self.title = \"Untitled\" unless self.title\n\n self.save\n end\n end",
"def update_ID3(attributes)\n begin\n musicFile = TagLib::File.new(self.filePath())\n musicFile.title = attributes[:id3Title]\n musicFile.artist = attributes[:id3Artist]\n musicFile.save()\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end \n end",
"def parse\n # Flac file maybe contain ID3 header on the start, so skip it if exists\n id3_header = ID3::V2Header.new(@file_io)\n id3_header.valid? ? @file_io.seek(id3_header.size) : @file_io.rewind\n\n return if @file_io.read(4) != TAG_ID\n\n loop do\n block = Flac::Block.new(@file_io)\n parse_block(block)\n\n break if block.is_last? || @file_io.eof?\n end\n end",
"def read_unsuccessful(p_audio_file_container)\n begin\n\n # Cache current fire, used frequently\n current_file = p_audio_file_container[:file]\n\n # Check if the allegedly unsuccessful audio file is a usual suspect,\n # e.g. was already flagged as an alternative audio file and return\n # if true.The scanner would have returned the same alternatives,\n # leading to an infinite loop.\n if previously_flagged_as_alternative?(p_audio_file_container)\n log.warn \"[Reader] Alternative '#{current_file}' also empty/unreadable.\"\n return\n end\n\n # Log event\n log.warn \"[Reader] Empty/unreadable ID3 Tags, '#{current_file}'\"\n\n # Scan for two other audio files in the\n upper_folder = File.dirname(current_file)\n other_files = FolderScanner.scan({\n :path => upper_folder,\n :mask => Consts::MP3_MASK,\n :recursive => false,\n :depth => @@settings[:retry_depth]\n })\n\n # Try to retrieve details from other audio files within the same folder\n while !other_files.empty?\n\n # Retrieve new file from the queue, pass if the same file\n current_alternative = other_files.pop\n next if current_alternative[:file].eql?(current_file)\n\n # Enqueue alternate file for later processing\n enqueue_for_retry(p_audio_file_container, current_alternative)\n log.info \"[Reader] Enqueued alternative : '#{current_alternative[:file]}'\"\n end\n\n # Log edge case, no alternatives present\n log.warn \"[Reader] No further alternatives found.\" if other_files.empty?\n\n # Log any errors\n rescue Exception => e\n log.error e\n end\n end",
"def update_id3\n return if id3.empty? && has_tag\n if !id3.empty? || check_id3\n id3_fields = CICPHash.new('')\n id3_fields['genre'] = 255.chr\n fields.values.each do |value|\n case value.key\n when /\\Atrack/i\n id3_fields['track'] = value.string_value.to_i\n id3_fields['track'] = 0 if id3_fields['track'] > 255\n id3_fields['track'] = id3_fields['track'].chr\n when /\\Agenre/i\n id3_fields['genre'] = ID3_GENRES_HASH[value.first]\n when /\\Adate\\z/i\n match = YEAR_RE.match(value.string_value)\n id3_fields['year'] = match[0] if match \n when /\\A(title|artist|album|year|comment)\\z/i\n id3_fields[value.key] = value.join(', ')\n end\n end\n @id3 = [\"TAG\", id3_fields['title'], id3_fields['artist'], id3_fields['album'],\n id3_fields['year'], id3_fields['comment'], \"\\0\", id3_fields['track'],\n id3_fields['genre']].pack(\"a3a30a30a30a4a28a1a1a1\")\n end\n end",
"def tag_info(file_path)\n tag_hash={}\n AudioInfo.open(file_path) do |info|\n tag_hash[:artist]=info.artist\n tag_hash[:album]=info.album\n tag_hash[:title]=info.title\n tag_hash[:tracknum]=info.tracknum\n tag_hash[:bitrate]=info.bitrate\n tag_hash[:length]=info.length\n if info.info.class==Mp3Info\n tag_hash[:comments]=info.info.tag1.comments\n tag_hash[:samplerate]=info.info.samplerate\n tag_hash[:year]=info.info.tag2.TYER\n elsif info.info.class==MP4Info\n tag_hash[:genere]=info.info.GNRE\n tag_hash[:samplerate]=info.info.FREQUENCY\n tag_hash[:comment]=info.info.CMT\n end\n end\n return tag_hash\n end",
"def id3v1_tag\n end",
"def read_track music_file\n\t# fill in the missing code\nend",
"def id3v2_tag\n end",
"def set_tags(file, tags)\n ret = {file => false}\n TagLib::MPEG::File.open(file) do |fh|\n if File.mtime(file).to_s == tags['timestamp']#only write if file has not been modified\n tag = fh.id3v2_tag\n tags.each do |id, value|\n if tags[id] != nil && ['title', 'artist', 'year', 'track', 'album', 'genre', 'comment'].include?(id)\n if tags[id].strip.empty?\n tags[id] = nil\n end\n end\n end\n\n tag.title = tags['title']\n tag.artist = tags['artist']\n tag.album = tags['album']\n tag.year = tags['year'].to_i #taglib doesnt allow set year to nil\n tag.track = tags['track'].to_i #taglib doesnt allow set track to nil\n tag.genre = tags['genre']\n tag.comment= tags['comment']\n\n tags.delete_if{|k,v| k != 'file'} #to return only the filename and save status\n ret[file] = fh.save(TagLib::MPEG::File::ID3v2) #only save v2, v1 will be stripped\n end\n end\n return ret\n end",
"def exists\n if @file && @mp3\n return true\n else\n return false\n end\n end",
"def set_info_from_mp3\n Mp3Info.open(path) do |mp3|\n TagFields.each do |field|\n send(\"#{field}=\", mp3.tag.send(field))\n end\n end\n rescue\n end",
"def initialize(filename, check_id3 = nil)\n if FILE_OBJ_METHODS.each{|method| break unless filename.respond_to?(method)}\n @file = filename\n @check_id3 = check_id3.nil? ? @@check_id3 : check_id3 \n else\n @filename = filename.to_s\n @check_id3 = check_id3.nil? ? (MP3_RE.match(@filename) ? true : nil) : check_id3 \n end\n end",
"def tag\n\t\t\tbegin\n\n\t\t\t\t# Retrieve ID3 Tag if not yet read\n\t\t\t\t@tag = ID3Lib::Tag.new(@path) if @tag.nil?\n\n # Return result\n @tag\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e \n\t\t\t\tlog.error e\n\t\t\tend\n end",
"def clean_audio_file\n FileUtils.rm audio_filepath_fragmented if File.exist? audio_filepath_fragmented\n end",
"def getMP3\n return @MP3Files || []\n end",
"def worked?\n if @discFound.getTitle.empty?\n puts \"Disco no encontrado\"\n return false\n end\n\n for i in (0..@mp3Dir.getMP3.count-1)\n trackNumber = i+1\n trackNumber = trackNumber < 10 ? '0' + trackNumber.to_s : trackNumber\n mp3File = @directorio + '/' + @mp3Dir.getMP3[i]\n track = @discFound.getTracks[i]\n\n system \"eyeD3 --remove-all \\\"#{mp3File}\\\"\"\n\n tag = ID3Lib::Tag.new mp3File\n\n tag.title = track.getName\n tag.performer = @discFound.getArtist\n tag.year = @release_year.empty? ? @discFound.getYear : @release_year\n tag.track = i+1\n tag.composer = @discFound.getArtist\n tag.album = @discFound.getTitle + (@album_title_extra.empty? ? '' : @album_title_extra)\n tag.comment = 'Tagged using rtag v1.3.0'\n\n cover = {\n :id => :APIC,\n :mimetype => 'image/jpeg',\n :picturetype => 3,\n :description => 'Disc Cover',\n :textenc => 0,\n :data => File.read('folder.jpg')\n }\n\n tag << cover\n tag.update!\n\n name = track.getName\n name.gsub! /\\//, ''\n \n name.sub! '*','#'\n name.sub! '?',''\n\n targetFile = @directorio + \"/\" + trackNumber.to_s + \". \" + name + \".mp3\"\n\n File.rename mp3File, targetFile\n end\n File.rename 'folder.jpg', @directorio + '/folder.jpg'\n return true\n end",
"def load(filename, **kwargs)\n @filename = filename\n\n begin\n @tags = IFFID3.new filename, **kwargs\n rescue Mutagen::ID3::ID3Error\n @tags = nil\n end\n\n File.open(filename, 'rb') do |fileobj|\n @info = AIFFInfo.new fileobj\n end\n end",
"def process_audio\n `ffmpeg -y #{debug_settings} -i #{@filename} -c:a libfdk_aac -b:a 128k -vn #{audio_filepath}`\n `mp4fragment #{audio_filepath} #{audio_filepath_fragmented}`\n FileUtils.rm audio_filepath\n end",
"def do_process(audio)\n SPF::Gateway::Audio.identify(audio)\n end",
"def correct_tag_values?\n validate_tags(info.our_tags)\n validate_album_disc(info.album, file.dirname.basename.to_s)\n end",
"def audio_tag(*sources); end",
"def audio_without_closed_captions?\n audio? && closed_captions.blank?\n end",
"def initialize(filename)\n $stderr.puts(\"#{self.class}::new() does not take block; use #{self.class}::open() instead\") if block_given?\n raise(Mp3InfoError, \"empty file\") unless File.stat(filename).size? #FIXME\n @filename = filename\n @vbr = false\n @file = File.new(filename, \"rb\")\n @tag2 = {}\n @tag1 = gettag1\n @tag_orig = @tag1.dup\n\n ##########################\n # ID3v2\n ##########################\n tag2_len = 0\n @file.rewind\n if @file.read(3) == \"ID3\"\n version_maj, version_min, flags = @file.read(3).unpack(\"CCB4\")\n unsync, ext_header, experimental, footer = (0..3).collect { |i| flags[i].chr == '1' }\n @tag2[\"version\"] = \"2.#{version_maj}.#{version_min}\"\n tag2_len = size_syncsafe(@file.read(4))\n if ext_header\n ext_size = size_syncsafe(@file.read(4)) - 6\n @file.read(2)\n @file.read(ext_size)\n end\n loop do\n break if @file.pos >= tag2_len\n name = @file.read(4)\n #break if name == \"\\000\\000\\000\\000\"\n size = @file.read(4).unpack(\"N\")[0]\n flags = @file.read(2)\n data = @file.read(size)\n type = data[0]\n name = ID2TAGS[name] || name\n if name != \"\\000\\000\\000\\000\"\n @tag2[name] = data[1..-1]\n end\n end\n else\n @file.rewind\n end\n ##########################\n # END OF ID3v2\n ##########################\n\n\n begin\n find_frame_sync\n head = @file.read(4)\n raise(Mp3InfoInternalError) if not check_head(head)\n @first_frame_pos = @file.pos - 4\n h = extract_infos_from_head(head)\n h.each { |k,v| eval \"@#{k} = #{v.inspect}\" }\n seek =\n if @mpeg_version == 3 # mpeg version 1\n if @channel_num == 3\n 15 # Single Channel\n else\n 30\n end\n else # mpeg version 2 or 2.5\n if @channel_num == 3 # Single Channel\n 7\n else\n 15\n end\n end\n @file.pos += seek\n\n if @file.read(4) == \"Xing\" # This is a VBR file\n @vbr = true\n @file.pos += 4 #we have the frames number after\n #if @file.read(4).unpack(\"N\")[0] == 0xF\n #end\n @frames = @file.read(4).unpack(\"N\")[0]\n medframe = @file.stat.size / @frames.to_f\n @bitrate = ( (medframe * @samplerate) / ( 1000 * ( layer==3 ? 12 : 144) ) ).to_i\n end\n\n @frame_num = 0\n @length = (( (8 * @file.stat.size) / 1000.0) / @bitrate)\n rescue Mp3InfoInternalError\n retry\n rescue\n @file.close\n raise\n end\n\n end",
"def queue_files_for_processing( args )\n\t\t# only queue up files that can have id3 tags to begin with.\n\t\tfiles = clean_file_list( args )\n\n\t\t# add the files to the queue\n\t\tif( files.length == 0 )\n\t\t\tputs \"None of the files were MP3s!!\"\n\t\t\t#FIXME: should this be an exception?\n\t\telse\n\n\t\t\t# Set the track number limits\n\t\t\tcount \t\t\t\t= @renumber_start_at\n\t\t\t@total_tracks = files.length\n\n\t\t\tfiles.each { |x|\n\t\t\t\tputs \"checking #{x}...\"\n\n\t\t\t\t# list its current id3 tag contents.\n\t\t\t\tputs \"\\tid3v2 says this:\"\n\t\t\t\tputs \"\\t\\t#{ID3Tagger::list_file( x )}\"\n\n\t\t\t\t# tell the user what the program intends to change\n\t\t\t\tputs build_proposal_string( count ) + \"\\n\"\n\n\t\t\t\t# add the file to the queue\n\t\t\t\tadd( x, count )\n\t\t\t\tcount = count + 1\n\t\t\t}\n\n\t\t\t# keep files in order\n\t\t\t@files.rehash\n\t\tend\n\tend",
"def audio?\n not audio_formats.empty?\n end",
"def flac_with_m4a?\n asset.content_type == \"audio/flac\" && asset.file_derivatives.has_key?(:m4a)\n end",
"def getMp4Info(file)\n def get_val(string)\n string.split(\":\")[1]\n end\n\n ret = {}\n tagstrings = `AtomicParsley #{file} -t | grep -Pi '(art|alb|nam)'`.split(\"\\n\")\n ret[:artist] = get_val(tagstrings.grep(/ART\" contains/i)[0])\n ret[:title] = get_val(tagstrings.grep(/nam\" contains/i)[0])\n\n tmp = tagstrings.grep(/alb\" contains/i)[0]\n ret[:album] = (tmp.nil?) ? $default_album : tmp.split(\":\")[1]\n if ret[:artist].nil? || ret[:album].nil? || ret[:title].nil?\n raise \"Error parsing m4a tags - is it possible that AtomicParsley output format has changed?\"\n end\n ret\nend",
"def dump(filename)\n puts \"Handling #{filename}\"\n if (File.directory?(filename))\n puts \"Skipping directory #{filename}.\"\n end\n begin \n puts YAML::dump(Mp3Info.open(filename))\n rescue Mp3InfoError\n puts \"Could not parse #{filename} for ID3 tags, skipping.\"\n end\nend",
"def upload_file\n \n # remember the filename\n tempfile = params[\"file_to_upload\"]\n \n # wenn ich keinen string bekommen habe und auch ueberhaupt was ankam (kein tag_edit)\n unless tempfile.nil?\n \n # if just a string arrived\n if tempfile.instance_of?(String)\n flash[:notice] = \"please select a valid file\"\n redirect_to :action => \"index\"\n \n # when a file arrived\n elsif tempfile.instance_of?(Tempfile)\n \n # delete file if too big\n if File.size?(tempfile) > MAX_FILESIZE\n File.delete(tempfile.local_path)\n flash[:notice] = \"File too large (maximal 10 MB allowed)\"\n redirect_to :action => \"index\"\n\n # if it is a valid mp3\n else\n # save variable for view\n @original_name = tempfile.original_filename\n # read id3 information\n @tag = ID3Lib::Tag.new(tempfile.local_path)\n # copy the file to the upload directory\n FileUtils.copy(params[:file_to_upload].local_path, tmp_filename)\n logger.info(\"new file from #{current_user.login} copied to : #{tmp_filename}\")\n\n flash[:notice] = \"File Uploaded\"\n end\n end\n else\n \n # hier komme ich hin, wenn nichts hochgeladen wurde, sondern der tag editiert\n \n if params[\"original_name\"].nil?\n flash[:notice] = \"No File selected (depp)\"\n redirect_to :action => \"index\"\n else \n @original_name = params[\"original_name\"]\n @tag = ID3Lib::Tag.new(tmp_filename)\n end\n end\n end",
"def change_file_metadata(song)\n Mp3Info.open(song[:path]) do |mp3|\n #song.dance=params['genre']\n mp3.tag2.TCON=song.dance\n #song.title=params['title']\n mp3.tag.title=song.title\n #song.artist=params['artist']\n mp3.tag.artist=song.artist\n #song.rating=params['rating'].to_i\n mp3.tag2.POPM=song.rating\n #song.save\n end\nend",
"def load_notetags_bubs_mix\n @mix = false\n @mix_type = :none\n @unmixable = false\n @mix_max_select = 2\n \n if self.is_a?(RPG::Item)\n @unmixable = Bubs::Mix::UNMIXABLE_ITEMS.include?(self.id)\n end\n \n self.note.split(/[\\r\\n]+/).each { |line|\n case line\n when Bubs::Regexp::MIX_TAG\n @mix = true\n @mix_max_select = $1.to_i unless $1.nil?\n \n when Bubs::Regexp::MIX_TYPE_TAG\n next unless self.is_a?(RPG::Item)\n @mix_type = $1.to_sym\n $data_mix.test_item_type_symbol(self)\n \n when Bubs::Regexp::UNMIXABLE_TAG\n @unmixable = true\n \n end # case\n } # self.note.split\n end",
"def extract_audio(infile)\n\n infile = Path[infile]\n \n p infile\n \n unless infile.exists?\n STDERR.puts \"Couldn't find #{infile}\"\n return\n end\n\n #unless VALID_EXTS.include? infile.ext\n # STDERR.puts \"Unrecognized video format: #{infile.ext}\"\n # return\n #end\n \n if infile =~ %r{^/dev/fd/}\n outfile = Path.pwd/\"#{infile.filename}.mp3\" \n else \n outfile = infile.with(:ext=>\"mp3\")\n end\n\n if outfile.exists?\n puts \"Error: #{outfile} exists!\"\n return\n end \n \n puts\n puts \"Input: #{infile}\"\n puts \"Output: #{outfile}\"\n puts\n \n # -lameopts q=5\n cmd = %w[mencoder -of rawaudio -oac mp3lame -ovc copy -o] + [outfile.to_s, infile.to_s]\n system(*cmd)\n \nend",
"def audio?\n filename =~ /^audio/\n end",
"def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend",
"def strip(tags=TagLib::FLAC::File::AllTags)\n end",
"def untag!(tags)\n original_tags = info.tags\n\n Mp3Info.open(info.file) do |mp3|\n mp3.removetag1\n mp3.removetag2\n\n original_tags.except(*tags).each do |k, v|\n mp3.tag2[k.upcase] = v\n end\n end\n end",
"def metadata\n puts \"Adding Metadata...\"\n doc = Nokogiri::HTML(open(\"http://www.last.fm/search?q=#{query}&type=track\"))\n url = doc.css(\"span.chartlist-ellipsis-wrap\").first.css(\"a.link-block-target\").first.attr('href')\n ch = url.gsub('/music/', \"\")\n artist, title = ch.split(\"/_/\")\n artist = artist.gsub('+', \" \")\n title = title.gsub('+', \" \")\n doc = Nokogiri::HTML(open(\"http://www.last.fm#{url}\"))\n album = doc.css(\"h3 a\").first\n begin\n Mp3Info.open(\"#{query.gsub(\"+\",\"-\")}.mp3\") do |mp3|\n mp3.tag.title = \"#{URI.unescape(title)}\".strip\n mp3.tag.artist = \"#{URI.unescape(artist)}\".strip\n mp3.tag.album = \"#{URI.unescape(album.content)}\".strip\n end\n puts \"Done\"\n rescue\n puts \"Fail\"\n end\n end",
"def is_audio?\n result = false\n if !mime_type.blank?\n splits = mime_type.split('/')\n if splits[0] == AUDIO\n result = true\n end\n end\n \n result\nend",
"def convert_to_mp3\n\t\tputs \"\\n=> look for m4a files and convert it to mp3\\n\"\n\t\t\n\t\t# grab directory names.\n\t\tdir_names = Dir.entries @@dir_temp\n\t\t# remove .prefixes\n\t\tdir_names = self.remove_hidden_files dir_names\n\t\t\n\t\t# go thru each sub directories.\n\t\tdir_names.each do |current_dir|\n\t\t\tputs \"\\n=> at \" + @@dir_temp + current_dir + \"\\n\"\n\t\t\t\n\t\t\t# grabs the files in the directory\n\t\t\tcurrent_files = Dir.entries(@@dir_temp + \"/\" + current_dir)\n\t\t\t\n\t\t\t# remove the . prefixes.\n\t\t\tcurrent_files = self.remove_hidden_files current_files\n\t\t\t\n\t\t\t# cycle thru the file\n\t\t\tcurrent_files.each do |current_file|\n\t\t\t\t# file names\n\t\t\t\tsrc_file = \"\"\n\t\t\t\tdest_file = \"\"\n\t\t\t\n\t\t\t\t# checks if it has a m4a extension\n\t\t\t\tif self.is_m4a? current_file\t\t\n\t\t\t\t\tputs \"\\n=> encoding \" + current_file\n\t\t\t\t\t\n\t\t\t\t\t# creating src and dest files.\n\t\t\t\t\tsrc_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + self.ext_to_mp3(current_file)\n\t\t\t\t\t\n\t\t\t\t\t#src_file = \"'\" + src_file + \"'\" \n\t\t\t\t\t#dest_file = \"'\" + dest_file + \"'\" \n\t\t\t\t\t\n\t\t\t\t\t# escape the names.\n\t\t\t\t\tsrc_file = self.escaped_file_name(src_file)\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\t\t\n\t\t\t\t\tputs \"=> src \" + src_file \n\t\t\t\t\tputs \"=> dest \" + dest_file\n\t\t\t\t\t\n\t\t\t\t\t# lame encoding.\n\t\t\t\t\tself.lame_str(@@opt_lame, src_file, dest_file)\n\t\t\t\telse\n\t\t\t\t\tdest_file = @@dir_temp + current_dir + '/' + current_file\n\t\t\t\t\tdest_file = self.escaped_file_name(dest_file)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# split the mp3...\n\t\t\t\tself.mp3splt_str(@@opt_mp3splt, dest_file)\n\t\t\t\t\n\t\t\t\t# delete the source file.\n\t\t\t\t# only want the split files.\n\t\t\t\tself.rm_str(\"\", dest_file)\n\t\t\t\tif (src_file != \"\")\n\t\t\t\t\tself.rm_str(\"\", src_file)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def is_mp3?\n if filename != nil\n filename.ends_with?('.mp3')\n else\n false\n end\nend",
"def audio_assets(authored_only = false)\n assets = segments.collect { |e| e.audio_asset }\n authored_only ? assets.select { |a| a.authored? } : assets\n end",
"def parse_atx_header_gfm_quirk; end",
"def do( argv )\n\t\tid3v2 = process_options argv\n\n\t\t# Add all taggable files to the queue.\n\t\t# TODO: Will throw exceptions in the future. (3/29/04: why?)\n\t\tid3v2.do( argv )\n\tend",
"def init_validation\n @media_element = Valid.get_association self, :id\n @user = Valid.get_association self, :user_id\n @inner_tags =\n if @tags.blank?\n Tag.get_tags_for_item(self.id, 'MediaElement')\n else\n resp_tags = []\n prev_tags = []\n @tags.split(',').each do |t|\n if t.present?\n t = t.to_s.strip.mb_chars.downcase.to_s\n if !prev_tags.include? t\n tag = Tag.find_or_initialize_by(:word => t)\n resp_tags << tag if tag.valid?\n end\n prev_tags << t\n end\n end\n resp_tags\n end\n end",
"def read(filename)\n f = File.open(filename, 'r')\n f.seek(-ID3::ID3v1tagSize, IO::SEEK_END)\n hastag = (f.read(3) == 'TAG')\n if hastag\n f.seek(-ID3::ID3v1tagSize, IO::SEEK_END)\n @raw = f.read(ID3::ID3v1tagSize)\n\n # self.parse!(raw) # we should use \"parse!\" instead of duplicating code!\n\n if (raw.getbyte(ID3v1versionbyte) == 0) \n @version = \"1.0\"\n else\n @version = \"1.1\"\n end\n else\n @raw = @version = nil\n end\n f.close\n #\n # now parse all the fields\n\n ID3::SUPPORTED_SYMBOLS[@version].each{ |key,val|\n if val.class == Range\n # self[key] = @raw[val].squeeze(\" \\000\").chomp(\" \").chomp(\"\\000\")\n self[key] = @raw[val].strip\n elsif val.class == Fixnum\n self[key] = @raw.getbyte(val).to_s\n else \n # this can't happen the way we defined the hash..\n # printf \"unknown key/val : #{key} / #{val} ; val-type: %s\\n\", val.type\n end\n }\n hastag\n end",
"def audio_source_is_provided\n if self.external_url.blank? &&\n self.mp3.file.nil? &&\n self.enco_number.blank? &&\n self.enco_date.blank?\n self.errors.add(:base,\n \"Audio must have a source (upload, enco, or URL)\")\n end\n end",
"def close\n $stderr.puts(\"Mp3Info.close\") if $DEBUG\n \n prepare_universal_tag!\n save_id3v1_changes!\n update_file_with_changed_id3v2!\n end",
"def get_unique_tag_values(tag)\n values = []\n @files.each { |mp3| \n values << mp3.tags.tag if mp3.tags.tag.length\n }\n values.sort!\n end",
"def tag\n @log.info \"Tagging file....\"\n if @metadata[:episodeNumber] != \"\"\n fullTitle = \"#{@metadata[:episodeNumber]}. #{@metadata[:episodeTitle]}\"\n else\n fullTitle = \"#{@metadata[:episodeTitle]} - #{@metadata[:episodeInfo]}\"\n end\n atp_command = \"AtomicParsley \\\"#{@out_file}.mp4\\\" --TVNetwork \\\"Channel4/4od\\\" --TVShowName \\\"#{@metadata[:brandTitle]}\\\" --stik \\\"TV Show\\\" --description \\\"#{@metadata[:description]}\\\" --TVEpisode \\\"#{@metadata[:epId]}\\\" --title \\\"#{fullTitle}\\\" --overWrite\"\n\n if @metadata[:seriesNumber] != \"\"\n atp_command += \" --TVSeasonNum #{@metadata[:seriesNumber]}\"\n end\n if @metadata[:episodeNumber] != \"\"\n atp_command += \" --TVEpisodeNum #{@metadata[:episodeNumber]}\"\n end\n\n #If it exists, download the image and store in metadata\n if @metadata[:imagePath] != \"\"\n begin\n image_path = File.join(@out_dir,File.basename(@metadata[:imagePath]))\n download_image(\"http://www.channel4.com#{@metadata[:imagePath]}\", image_path)\n atp_command += \" --artwork \\\"#{image_path}\\\"\"\n rescue\n @log.warn \"Error downloading thumbnail - video will be tagged without thumbnail\"\n end\n end\n\n @log.debug \"#{atp_command}\"\n success = system(atp_command)\n\n if @metadata[:imagePath] != \"\" && File.exists?(image_path)\n File.delete(image_path)\n\n end\n\n if not success\n raise \"Something went wrong running AtomicParsley :(. Your file may not be properly tagged.\"\n end\n end",
"def ok_to_add_file(file, file_path)\n file_tags = file[\"tags\"] || []\n (files.size == 0 || files.any_matches?(file_path)) &&\n !exclude_files.any_matches?(file_path) &&\n (tags.size == 0 || (cross_any_matches?(file_tags, tags)) &&\n !cross_any_matches?(file_tags, exclude_tags))\n end",
"def tag\n super('TagLib::FLAC::File')\n end",
"def getAudioUri\n return @data.scan(/https:\\/\\/.*?\\.mp3/)[0]\nend",
"def previously_flagged_as_alternative?(p_audio_file_container)\n\n # Don't bother if there are no alternatives stored\n return false if @audio_file_alternatives.empty?\n\n # Search for the audio file within the cache, delete if found\n idx = @audio_file_alternatives.index(p_audio_file_container)\n found = (!idx.nil?)\n\n # If found, issue log message and delete from array\n @audio_file_alternatives.delete_at(idx) if found\n\n # Return result\n found\n end",
"def extract_tags!\n @tagmap = {}\n data.gsub!(/(.?)\\[\\[(.+?)\\]\\]([^\\[]?)/m) do\n if $1 == \"'\" && $3 != \"'\"\n \"[[#{$2}]]#{$3}\"\n elsif $2.include?('][')\n if $2[0..4] == 'file:'\n pre = $1\n post = $3\n parts = $2.split('][')\n parts[0][0..4] = \"\"\n link = \"#{parts[1]}|#{parts[0].sub(/\\.org/,'')}\"\n id = Digest::SHA1.hexdigest(link)\n @tagmap[id] = link\n \"#{pre}#{id}#{post}\"\n else\n $&\n end\n else\n id = Digest::SHA1.hexdigest($2)\n @tagmap[id] = $2\n \"#{$1}#{id}#{$3}\"\n end\n end\n nil\n end",
"def if_missing_dependencies\n #TODO: Test on Linux\n missing = []\n [['ffmpeg','-version'], ['mp3splt', '-v'], ['mp3wrap']].each do |cmdline|\n begin\n out, err, status = Open3.capture3(*cmdline)\n rescue\n missing.push(cmdline.first)\n end #begin\n end #...].each do |cmdline|\n yield(missing) unless missing.empty?\n end",
"def audio_tracks\n tracks.select { |t| t.audio? }\n end",
"def audio_tracks\n tracks.select { |t| t.audio? }\n end",
"def ingestAudioRecording(audiofilename, dateformat) #dateformat should be optional\n # For ingesting the \"Raw\" audio file. Can be cut in to segments later or separately, then imported and connected to the recording node\n \n # Check if a JSON already exists. If so, use it\n # if not, get the metadata, generate the JSON, and use it\n # IF dateformat nil, set it to \"%Y%m%d_%H%M%S%z\" (Double-check this)\n # Mark the STRFTIME format so that the time can be re-parsed from the filename programically\n # Parse JSON metadata\n # Map the JSON to the properties we care about\n # Set name\n # Set date\n # Set location, if it exists\n # Set ingest date to now\n # set ingestedFile to the file\n # set ingestedMetadataFile to the JSON file\n\nend",
"def parse_file(music_dir_path , path)\n begin\n\n begin\n # Get the relative path of the file\n relative_path = path.relative_path_from( music_dir_path ).to_s\n rescue\n puts \"File cannot be readed. Wrong file name?: #{path.to_s}\"\n return nil\n end\n\n # Do nothing if the song is already stored\n return nil if @songs[relative_path]\n\n absolute_path = path.to_s\n TagLib::MPEG::File.open( absolute_path ) do |file|\n # Create the song\n song = Song.new\n song.fill( relative_path , file , File.size(absolute_path) )\n\n # Get the artist and album\n song.artist = get_artist( file.tag.artist )\n if !song.artist\n puts \"*** #{relative_path}: Artist not found\"\n return nil\n end\n\n song.album = get_album( file.tag )\n if !song.album\n puts \"*** #{relative_path}: Album not found\"\n return nil\n end\n\n @songs[song.path] = song\n return song\n end\n rescue\n Log.log_last_exception(\"Error reading file #{path.to_s}\")\n return nil\n end\n end",
"def has_audios?\n audios[I18n.locale.to_sym].length + attached_audios[I18n.locale.to_sym].length > 0\n end",
"def initialize(p_path)\n\n\t\t\t# The (absolute) path of the mp3 file, \n\t\t\t# used to read ID3 Tag-related information\n\t\t\t@path = p_path\n\t\t\t\n\t\t\t# Initialize the tag, an ID3Lib::Tag instance (a ID3 v1.x/v2.y Tag)\n\t\t\t@tag = nil\n\t\tend",
"def parsed_included_tags\n @parsed_included_tags ||= parse_named_tags(\n %i[fandom_names character_names relationship_names freeform_names\n other_tag_names]\n )\n end",
"def irrelevant?\n video.nil? && manuscript.nil? && external_reference_link.blank?\n end",
"def tags\n @audio_file = AudioFile.find(params[:id])\n @tags = @audio_file.tags\n\n respond_to do |format|\n format.html # tags.html.erb\n format.xml { render :xml => @tags }\n format.json { render :json => @tags }\n end\n end",
"def processing_audio\n list.select {|l| l[:status] == 35 }\n end",
"def audio\n @audio ||= URI.parse(\"#{AUDIO_SERVICE_URL}/#{@language.slug}/#{URI::encode(@text)}.mp3\")\n end",
"def disunity_extract(src: nil)\n end",
"def has_audio?\n return !!get_audio\n end",
"def extract_metadata; end",
"def wp_get_audio_extensions\n # Filters the list of supported audio formats.\n apply_filters('wp_audio_extensions', ['mp3', 'ogg', 'flac', 'm4a', 'wav'])\n end",
"def check_tag_present\n entries = get_entries\n entries.each do |entry|\n if entry[\"data-mention-id\"].eql?(@stream_post_id)\n tags = entry.all(input_elements[:tag_link_on_stream])\n tags.each do |tag_on_stream|\n return true if tag_on_stream.text.include?(@used_tag)\n end\n return false\n end\n end\n return false\n end",
"def include?(id)\n !(blob = find_blob(id)).nil? && !blob.find(id).nil?\n end",
"def is_audio(str)\n str.match(/\\A\\w*.(mp3|flac|alac|aac)\\Z/) != nil\nend",
"def initialize(fn, encoding = 'utf-8')\n raise(AudioInfoError, \"path is nil\") if fn.nil?\n @path = fn\n ext = File.extname(@path)\n raise(AudioInfoError, \"cannot find extension\") if ext.empty?\n @extension = ext[1..-1].downcase\n @musicbrainz_infos = {}\n @encoding = encoding\n\n begin\n case @extension\n\twhen 'mp3'\n\t @info = Mp3Info.new(fn, :encoding => @encoding)\n\t default_tag_fill\n\t#\"TXXX\"=>\n\t#[\"MusicBrainz TRM Id\\000\",\n\t #\"MusicBrainz Artist Id\\000aba64937-3334-4c65-90a1-4e6b9d4d7ada\",\n\t #\"MusicBrainz Album Id\\000e1a223c1-cbc2-427f-a192-5d22fefd7c4c\",\n\t #\"MusicBrainz Album Type\\000album\",\n\t #\"MusicBrainz Album Status\\000official\",\n\t #\"MusicBrainz Album Artist Id\\000\"]\n\t if (arr = @info.tag2[\"TXXX\"]).is_a?(Array)\n\t fields = MUSICBRAINZ_FIELDS.invert\n\t arr.each do |val|\n\t if val =~ /^MusicBrainz (.+)\\000(.*)$/\n\t\tshort_name = fields[$1]\n\t @musicbrainz_infos[short_name] = $2\n\t end\n\t end\n\t end\n @bitrate = @info.bitrate\n\t i = @info.tag.tracknum\n\t @tracknum = (i.is_a?(Array) ? i.last : i).to_i\n\t @length = @info.length.to_i\n\t @date = @info.tag[\"date\"]\n\t @vbr = @info.vbr\n\t @info.close\n\n\twhen 'ogg'\n\t @info = OggInfo.new(fn, @encoding)\n\t default_fill_musicbrainz_fields\n\t default_tag_fill\n @bitrate = @info.bitrate/1000\n @tracknum = @info.tag.tracknumber.to_i\n\t @length = @info.length.to_i\n\t @date = @info.tag[\"date\"]\n\t @vbr = true\n\t @info.close\n\t \n\twhen 'mpc'\n\t fill_ape_tag(fn)\n\t \n\t mpc_info = MpcInfo.new(fn)\n @bitrate = mpc_info.infos['bitrate']/1000\n\t @length = mpc_info.infos['length']\n\n when 'ape'\n\t fill_ape_tag(fn)\n\n when 'wma'\n\t @info = WmaInfo.new(fn, :encoding => @encoding)\n\t @artist = @info.tags[\"Author\"]\n\t @album = @info.tags[\"AlbumTitle\"]\n\t @title = @info.tags[\"Title\"]\n\t @tracknum = @info.tags[\"TrackNumber\"].to_i\n\t @date = @info.tags[\"Year\"]\n\t @bitrate = @info.info[\"bitrate\"]\n\t @length = @info.info[\"playtime_seconds\"]\n\t MUSICBRAINZ_FIELDS.each do |key, original_key|\n\t @musicbrainz_infos[key] = \n @info.info[\"MusicBrainz/\" + original_key.tr(\" \", \"\")] ||\n @info.info[\"MusicBrainz/\" + original_key]\n\t end\n \n\twhen 'aac', 'mp4', 'm4a'\n\t @info = MP4Info.open(fn)\n\t @artist = @info.ART\n\t @album = @info.ALB\n\t @title = @info.NAM\n\t @tracknum = ( t = @info.TRKN ) ? t.first : 0\n\t @date = @info.DAY\n\t @bitrate = @info.BITRATE\n\t @length = @info.SECS\n\t mapping = MUSICBRAINZ_FIELDS.invert\n\n\t `faad -i #{fn.shell_escape} 2>&1 `.grep(/^MusicBrainz (.+)$/) do\n\t name, value = $1.split(/: /, 2)\n\t key = mapping[name]\n\t @musicbrainz_infos[key] = value\n\t end\n\t\n\twhen 'flac'\n\t @info = FlacInfo.new(fn)\n tags = convert_tags_encoding(@info.tags, \"UTF-8\")\n\t @artist = tags[\"ARTIST\"]\n\t @album = tags[\"ALBUM\"]\n\t @title = tags[\"TITLE\"]\n\t @tracknum = tags[\"TRACKNUMBER\"].to_i\n\t @date = tags[\"DATE\"]\n\t @length = @info.streaminfo[\"total_samples\"] / @info.streaminfo[\"samplerate\"].to_f\n\t @bitrate = File.size(fn).to_f*8/@length/1024\n\t #default_fill_musicbrainz_fields\n\n\telse\n\t raise(AudioInfoError, \"unsupported extension '.#{@extension}'\")\n end\n\n if @tracknum == 0\n @tracknum = nil\n end\n\n @musicbrainz_infos.delete_if { |k, v| v.nil? }\n @hash = { \"artist\" => @artist,\n\t\"album\" => @album,\n\t\"title\" => @title,\n\t\"tracknum\" => @tracknum,\n\t\"date\" => @date,\n\t\"length\" => @length,\n\t\"bitrate\" => @bitrate,\n }\n\n rescue Exception, Mp3InfoError, OggInfoError, ApeTagError => e\n raise AudioInfoError, e.to_s, e.backtrace\n end\n\n @needs_commit = false\n\n end",
"def load\n chunked pattern do |subpattern|\n @songs.merge! extract_from(id3 subpattern)\n end\n end",
"def included_tag_names\n parsed_included_tags[:missing]\n end",
"def tagged?; end",
"def extension_whitelist\n %w[mp3]\n end",
"def check_embedding!\n if embedded?\n response.headers.except! 'X-Frame-Options'\n end\n end",
"def validate_audio\n errors, analysis = validate(source_format, source, options)\n info = { errors: errors, analysis: analysis }\n completed_with info\n end",
"def update\n @song = Song.find(params[:id])\n unless @song.songtype.name == \"mp3\"\n flash[:error] = \"It doesn't work on that song type\"\n redirect_to(songs_url)\n end\n if (@song && tag = (Tagger.new(@song.file)) )\n ## Title\n title_tag = params[:title]\n if title_tag\n tag.title= title_tag\n params[:song][:title] = title_tag\n end\n ## Artist\n artist_tag = params[:artist]\n if artist_tag\n artist = (Artist.find_by_name artist_tag) || Artist.new({:name=>artist_tag})\n if artist.new_record?\n artist.save\n end\n params[:song][:artist] = artist\n tag.artist= artist_tag\n end\n ## Genre\n genre_tag = params[:genre]\n if genre_tag\n genre = (Genre.find_by_name genre_tag) || Genre.new({:name=>genre_tag})\n if genre.new_record?\n genre.save\n end\n params[:song][:genre] = genre\n tag.genre= genre_tag\n end\n genre ||= tag.lookup_genre\n genre_tag ||= genre.name\n ## Album\n\n album_tag = params[:album]\n if album_tag\n album = (Album.find_by_name album_tag) || Album.new({:name=>album_tag})\n if album.new_record?\n album = Album.new({:name=>album_tag, :genre=> genre})\n album.save\n album.artists.push artist\n else\n unless album.artists.include? artist\n album.artists.push artist\n end\n end\n params[:song][:album] = album\n tag.album= album_tag\n end\n tag.saveChanges\n b = Tagger.new(@song.file)\n unless ( ( params[:title] && b.title == params[:title]) && ( params[:artist] && b.artist == params[:artist]) && (params[:album] && b.album == params[:album]) && (params[:genre] && b.lookup_genre == params[:genre]) )\n flash[:error] = \"Song file did not save\"\n redirect_to edit_song_path(@song)\n end\n params[:song][:filemod] = Time.now\n respond_to do |format|\n if @song.update_attributes(params[:song])\n flash[:note] = 'Song was successfully updated.'\n format.html { redirect_to(@song) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @song.errors, :status => :unprocessable_entity }\n end\n end\n else\n flash[:error] = \"Song or its file Was not found\"\n redirect_to(songs_url)\n end\n end"
] | [
"0.68592495",
"0.6494725",
"0.6494725",
"0.6465142",
"0.63511527",
"0.6302102",
"0.6200568",
"0.6193943",
"0.6111035",
"0.60735345",
"0.60433966",
"0.5947027",
"0.59442955",
"0.59060854",
"0.5891916",
"0.58830315",
"0.5879336",
"0.5844284",
"0.5783888",
"0.5780949",
"0.5734073",
"0.5639953",
"0.56243855",
"0.56086236",
"0.54761046",
"0.54741675",
"0.5458913",
"0.5436026",
"0.5378185",
"0.53778714",
"0.5363986",
"0.5353977",
"0.5332715",
"0.5296458",
"0.52952665",
"0.52902645",
"0.5289103",
"0.5276023",
"0.5275699",
"0.5218781",
"0.52029514",
"0.5197029",
"0.5195571",
"0.519307",
"0.5192951",
"0.5168478",
"0.5167304",
"0.5159527",
"0.51547486",
"0.51326054",
"0.513076",
"0.5124733",
"0.5119498",
"0.51137155",
"0.51025075",
"0.5102276",
"0.50875765",
"0.50840616",
"0.50838727",
"0.5077493",
"0.5060204",
"0.50507575",
"0.50340706",
"0.5031232",
"0.50211287",
"0.5014773",
"0.49872357",
"0.49813995",
"0.49813566",
"0.49721774",
"0.49709806",
"0.49446395",
"0.49238628",
"0.492365",
"0.49222603",
"0.49222603",
"0.49192917",
"0.49144527",
"0.49064642",
"0.49015436",
"0.4889504",
"0.48880413",
"0.48849872",
"0.48748776",
"0.48715997",
"0.48609996",
"0.4845711",
"0.4834721",
"0.48331946",
"0.4831348",
"0.48200464",
"0.4817791",
"0.48046815",
"0.47839564",
"0.47819015",
"0.4781175",
"0.4777692",
"0.4773419",
"0.47727233",
"0.47609234"
] | 0.48618716 | 85 |
add hvac Add the daylighting controls for lobby, cafe, dinning and banquet | def add_daylighting_controls(building_vintage)
space_names = ['Banquet_Flr_6','Dining_Flr_6','Cafe_Flr_1','Lobby_Flr_1']
space_names.each do |space_name|
space = self.getSpaceByName(space_name).get
space.addDaylightingControls(building_vintage, false, false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addDaylightingControls()\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started adding daylighting controls.')\n \n # Add daylighting controls to each space\n self.getSpaces.sort.each do |space|\n added = space.addDaylightingControls(self.template, false, false)\n end\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding daylighting controls.')\n \n end",
"def add_hl_hl\n end",
"def add_a_hl\n end",
"def set_clocks\n now = DateTime.now\n $current_time.value = now.strftime(DateTimeFormat)\n $universal_time.value = now.new_offset.strftime(DateTimeFormat)\n $lunar_date.value = '%4d\\'%02d\\'%02d' % LunarYear.lunar_date(now.to_date)\n now\nend",
"def daylight_params\n params.require(:daylight).permit(:start, :stop)\n end",
"def set_vacation_hours_event\n @vacation_hours_event = VacationHoursEvent.find(params[:id])\n end",
"def create\n @daylight = Daylight.new(daylight_params)\n\n respond_to do |format|\n if @daylight.save\n format.html { redirect_to @daylight, notice: 'Daylight was successfully created.' }\n format.json { render json: @daylight, status: :created, location: @daylight }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daylight.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_hl_de\n end",
"def hours\n\n today = Date.today\n hours = {}\n #if @traveler.is_visitor? or @traveler.is_api_guest? #Return a wide range of hours\n if not @traveler or not @traveler.registered?\n (0..30).each do |n|\n hours[(today + n).to_s] = {open: \"07:00\", close: \"22:00\"}\n end\n\n else # This is not a guest, check to see if the traveler is registered with a service\n\n # NOTE(wilsonj806) For now this implementation does not let registered users\n #...book trips on weekends. Eventually we want to change that so they can do so\n\n if @traveler.booking_profiles.count > 0 #This user is registered with a service\n booking_profile = @traveler.booking_profiles.first\n service = booking_profile.service\n\n min_notice_days = (service.booking_details[:min_days] || 2).to_i\n max_notice_days = (service.booking_details[:max_days] || 14).to_i\n\n \n if service.booking_details[:trusted_users] and booking_profile.external_user_id.in? service.booking_details.try(:[], :trusted_users).split(',').map{ |x| x.strip }\n (1..21).each do |n|\n hours[(today + n).to_s] = {open: \"00:00\", close: \"23:59\"}\n end\n elsif service.schedules.count > 0 #This user's service has listed hours. This is the most common case.\n \n #Find out if we are past the cutoff for today. If so, start counting from tomorrow\n if service.booking_details[:cutoff_time] and (Time.now.in_time_zone.seconds_since_midnight > service.booking_details[:cutoff_time].to_i)\n day = Time.now + 1.days \n else\n day = Time.now\n end\n \n biz_days_count = 0\n (0..max_notice_days).each do |n|\n if service.open_on_day? day\n if biz_days_count >= min_notice_days\n schedule = service.schedules.where(day: day.wday).first\n if schedule\n hours[day.strftime('%Y-%m-%d')] = {open: schedule.schedule_time_to_military_string(schedule.start_time), \n close: schedule.schedule_time_to_military_string(schedule.end_time)}\n end\n end\n biz_days_count += 1\n end\n day = day + 1.days \n end\n\n else #This user is registered with a service, but that service has not entered any hours\n\n (min_notice_days..max_notice_days).each do |n|\n unless (today + n).saturday? or (today + n).sunday?\n hours[(today + n).to_s] = {open: \"08:00\", close: \"17:00\"}\n end\n end\n\n end\n\n else #This user is logged in but isn't registered with a service\n\n (1..14).each do |n|\n unless (today + n).saturday? or (today + n).sunday?\n hours[(today + n).to_s] = {open: \"08:00\", close: \"17:00\"}\n end\n end\n\n end # if #traveler.user_profile.user_services.count > 0\n end # if @travler.is_visitor\n\n render status: 200, json: hours\n\n end",
"def add_veth veth\n cmd = \"#{@vzctl} set #{@ctid} --netif_add #{veth[:ifname]},#{veth[:mac]},#{veth[:host_ifname]},\" \\\n \"#{veth[:host_mac]}, #{veth[:bridge]}\"\n execute(cmd)\n end",
"def add_exterior_lights(building_type, building_vintage, climate_zone, prototype_input)\n # TODO Standards - translate w/linear foot of facade, door, parking, etc\n # into lookup table and implement that way instead of hard-coding as\n # inputs in the spreadsheet.\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started adding exterior lights')\n\n # Occupancy Sensing Exterior Lights\n # which reduce to 70% power when no one is around.\n unless prototype_input['occ_sensing_exterior_lighting_power'].nil?\n occ_sens_ext_lts_power = prototype_input['occ_sensing_exterior_lighting_power']\n occ_sens_ext_lts_sch_name = prototype_input['occ_sensing_exterior_lighting_schedule']\n occ_sens_ext_lts_name = 'Occ Sensing Exterior Lights'\n occ_sens_ext_lts_def = OpenStudio::Model::ExteriorLightsDefinition.new(self)\n occ_sens_ext_lts_def.setName(\"#{occ_sens_ext_lts_name} Def\")\n occ_sens_ext_lts_def.setDesignLevel(occ_sens_ext_lts_power)\n occ_sens_ext_lts_sch = self.add_schedule(occ_sens_ext_lts_sch_name)\n occ_sens_ext_lts = OpenStudio::Model::ExteriorLights.new(occ_sens_ext_lts_def, occ_sens_ext_lts_sch)\n occ_sens_ext_lts.setName(\"#{occ_sens_ext_lts_name} Def\")\n occ_sens_ext_lts.setControlOption('AstronomicalClock')\n end\n\n # Building Facade and Landscape Lights\n # that don't dim at all at night.\n unless prototype_input['nondimming_exterior_lighting_power'].nil?\n nondimming_ext_lts_power = prototype_input['nondimming_exterior_lighting_power']\n nondimming_ext_lts_sch_name = prototype_input['nondimming_exterior_lighting_schedule']\n nondimming_ext_lts_name = 'NonDimming Exterior Lights'\n nondimming_ext_lts_def = OpenStudio::Model::ExteriorLightsDefinition.new(self)\n nondimming_ext_lts_def.setName(\"#{nondimming_ext_lts_name} Def\")\n nondimming_ext_lts_def.setDesignLevel(nondimming_ext_lts_power)\n nondimming_ext_lts_sch = self.add_schedule(nondimming_ext_lts_sch_name)\n nondimming_ext_lts = OpenStudio::Model::ExteriorLights.new(nondimming_ext_lts_def, nondimming_ext_lts_sch)\n nondimming_ext_lts.setName(\"#{nondimming_ext_lts_name} Def\")\n nondimming_ext_lts.setControlOption('AstronomicalClock')\n end\n\n # Fuel Equipment, As Exterior:FuelEquipment is not supported by OpenStudio yet,\n # temporarily use Exterior:Lights and set the control option to ScheduleNameOnly\n # todo: change it to Exterior:FuelEquipment when OpenStudio supported it.\n unless prototype_input['exterior_fuel_equipment1_power'].nil?\n fuel_ext_power = prototype_input['exterior_fuel_equipment1_power']\n fuel_ext_sch_name = prototype_input['exterior_fuel_equipment1_schedule']\n fuel_ext_name = 'Fuel equipment 1'\n fuel_ext_def = OpenStudio::Model::ExteriorLightsDefinition.new(self)\n fuel_ext_def.setName(\"#{fuel_ext_name} Def\")\n fuel_ext_def.setDesignLevel(fuel_ext_power)\n fuel_ext_sch = self.add_schedule(fuel_ext_sch_name)\n fuel_ext_lts = OpenStudio::Model::ExteriorLights.new(fuel_ext_def, fuel_ext_sch)\n fuel_ext_lts.setName(\"#{fuel_ext_name}\")\n fuel_ext_lts.setControlOption('ScheduleNameOnly')\n end\n\n unless prototype_input['exterior_fuel_equipment2_power'].nil?\n fuel_ext_power = prototype_input['exterior_fuel_equipment2_power']\n fuel_ext_sch_name = prototype_input['exterior_fuel_equipment2_schedule']\n fuel_ext_name = 'Fuel equipment 2'\n fuel_ext_def = OpenStudio::Model::ExteriorLightsDefinition.new(self)\n fuel_ext_def.setName(\"#{fuel_ext_name} Def\")\n fuel_ext_def.setDesignLevel(fuel_ext_power)\n fuel_ext_sch = self.add_schedule(fuel_ext_sch_name)\n fuel_ext_lts = OpenStudio::Model::ExteriorLights.new(fuel_ext_def, fuel_ext_sch)\n fuel_ext_lts.setName(\"#{fuel_ext_name}\")\n fuel_ext_lts.setControlOption('ScheduleNameOnly')\n end\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished adding exterior lights')\n \n return true\n end",
"def set_vhp_ctas\n #ctas =\n\n end",
"def add_cont name,telephone,\n\t\t\t\t\t\t@agenda << {name: name, telephone: telephone}\n\t\t\t\t\tend",
"def add_vic_com\n if @vic_com != nil and @common_events[@vic_com] != nil\n @common_event_q += @common_events[@vic_com].list\n end\n if @common_events[GTBS::VIC_COM] != nil\n @common_event_q += @common_events[GTBS::VIC_COM].list\n end\n end_battle(0)\n end",
"def defineSaturdaySundayAndWendnesdayAsHoliday\n Setting['plugin_redmine_workload']['general_workday_monday'] = 'checked';\n Setting['plugin_redmine_workload']['general_workday_tuesday'] = 'checked';\n Setting['plugin_redmine_workload']['general_workday_wednesday'] = '';\n Setting['plugin_redmine_workload']['general_workday_thursday'] = 'checked';\n Setting['plugin_redmine_workload']['general_workday_friday'] = 'checked';\n Setting['plugin_redmine_workload']['general_workday_saturday'] = '';\n Setting['plugin_redmine_workload']['general_workday_sunday'] = '';\n end",
"def zone() end",
"def vac(hours = 1)\n vac = bac(hours) - eac(hours)\n vac.round(1)\n end",
"def set_default_times\n if !self.start\n return\n end\n\n if self.start.hour == 0 # hour set to 0 if not otherwise defined...\n self.start = self.start + 9.hours\n end\n\n if !self.end\n if self.online?\n self.end = self.start + 1.hour\n else\n diff = 17 - self.start.hour\n self.end = self.start + diff.hours\n end\n end\n # TODO: Set timezone for online events. Where to get it from, though?\n # TODO: Check events form to add timezone autocomplete.\n # Get timezones from: https://timezonedb.com/download\n\n end",
"def update\n @vacation = Vacation.find(params[:id])\n set_tz_offset(:vacation)\n\n respond_to do |format|\n if @vacation.update_attributes(params[:vacation])\n format.html { redirect_to @vacation, :notice => 'Vacation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @vacation.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test\n WorkCalendar.configure do |c|\n c.weekdays = %i(mon tue wed thu fri)\n c.holidays = [Date.new(2015, 1, 1), Date.new(2015, 7, 3), Date.new(2015, 12, 25)]\n end\n end",
"def day\n @client = Client.new\n @title = @current_user.name\n @view = 'day'\n # TODO is Date.parse in current time zone? If not add.\n @date = params[:date].nil? ? Date.current : Date.parse(params[:date])\n # TODO: brakeman is warning of security problem with this line\n @nav_title = @date.strftime(NAV_TITLE[@view.to_sym])\n # TODO: should employees stay or go?\n @employees = [1]\n\n @appointments_by_hour = Hash.new\n r = Appointment.where(time: @date.in_time_zone.beginning_of_day..@date.in_time_zone.end_of_day).order(:time).includes(:client)\n r.each do |appointment| #.order(:time).group_by(&:time)\n k = appointment.time.hour\n if @appointments_by_hour.has_key?(k)\n @appointments_by_hour[k].push(appointment)\n else\n @appointments_by_hour[k] = [appointment]\n end\n end\n\n render 'index'\n end",
"def add_to_region\r\n western_states = [\"Arizona\", \"Colorado\", \"Idaho\", \"Montana\", \"Nevada\", \"New Mexico\", \"Utah\", \"Wyoming\", \"Alaska\", \"California\", \"Hawaii\", \"Oregon\", \"Washington\"]\r\n southern_states = [\"Alabama\", \"Arkansas\", \"Delaware\", \"Florida\", \"Georgia\", \"Kentucky\", \"Louisiana\", \"Maryland\", \"Mississippi\", \"North Carolina\", \"Oklahoma\", \"South Carolina\", \"Tennessee\", \"Texas\", \"Virgina\", \"West Virginia\"]\r\n eastern_states = [\"Maine\", \"New Hampshire\", \"Vermont\", \"Massachusetts\", \"Rhode Island\", \"Connecticut\", \"New York\", \"Pennsylvania\", \"New Jersey\"]\r\n midwest_states = [\"Wisconsin\", \"Michigan\", \"Illinois\", \"Indiana\", \"Ohio\", \"North Dakota\", \"South Dakota\", \"Nebraska\", \"Kansas\", \"Minnesota\", \"Iowa\", \"Missouri\"]\r\n\r\n if western_states.include?(name)\r\n @@wregion[:confirmed_cases] += self.confirmed_cases\r\n @@wregion[:overall_deaths] += self.overall_deaths\r\n elsif southern_states.include?(name)\r\n @@sregion[:confirmed_cases] += self.confirmed_cases\r\n @@sregion[:overall_deaths] += self.overall_deaths\r\n elsif eastern_states.include?(name)\r\n @@eregion[:confirmed_cases] += self.confirmed_cases\r\n @@eregion[:overall_deaths] += self.overall_deaths\r\n elsif midwest_states.include?(name)\r\n @@mregion[:confirmed_cases] += self.confirmed_cases\r\n @@mregion[:overall_deaths] += self.overall_deaths\r\n end\r\n\r\n end",
"def add_all_lights\n all_lights = []\n overview[\"lights\"].each do |id, light|\n all_lights << add_light(id.to_i, light[\"name\"])\n end\n all_lights\n end",
"def add_all_lights\n all_lights = []\n overview[\"lights\"].each do |id, light|\n all_lights << add_light(id.to_i, light[\"name\"])\n end\n all_lights\n end",
"def add_hl_bc\n end",
"def ajust_weather_switches\n weather = current_weather\n $game_switches[::Yuki::Sw::WT_Rain] = (weather == 1)\n $game_switches[::Yuki::Sw::WT_Sunset] = (weather == 2)\n $game_switches[::Yuki::Sw::WT_Sandstorm] = (weather == 3)\n $game_switches[::Yuki::Sw::WT_Snow] = (weather == 4)\n $game_switches[::Yuki::Sw::WT_Fog] = (weather == 5)\n end",
"def index\n @vacation_hours_events = VacationHoursEvent.all\n end",
"def load_calendar agency_id=nil\n expanded_calendar = {}\n\n #=========GET SERVICE_IDs, ASSOCIATE THEM WITH INTs=====\n sid_numbers = load_service_ids\n\n #=========FIGURE OUT THE SERVICE DAY BOUNDS=============\n\n day_bounds = conn.exec <<-SQL\n select min(departure_time), max(arrival_time) from gtf_stop_times\n SQL\n\n #convert day_bounds to seconds since beginning of local midnight\n sid_start = GoogleTransitFeed::parse_time( day_bounds[0][0] )\n sid_end = GoogleTransitFeed::parse_time( day_bounds[0][1] )\n\n #pop an error if service days overlap\n #if sid_end-sid_start > SECONDS_IN_DAY then raise \"Service day spans #{day_bounds[0][0]} to #{day_bounds[0][1]}; Service days may not overlap\" end\n\n #=========GET TIMEZONE INFORMATION======================\n if agency_id then\n timezone = conn.exec \"SELECT agency_timezone FROM gtf_agency WHERE agency_id='#{agency_id}'\"\n else\n timezone = conn.exec \"SELECT agency_timezone FROM gtf_agency\"\n end\n timezone = TZInfo::Timezone.get( timezone[0][0] ) #convert timezone string (eg \"America/New York\") to timezone\n tz_offset = timezone.current_period.utc_offset #number of seconds offset from UTC (eg -18000)\n dst_offset = timezone.current_period.std_offset #number of seconds changed during daylight savings eg 3600\n\n #=========EXPAND calendar TABLE INTO HASH===============\n dates = conn.exec <<-SQL\n SELECT service_id, monday, tuesday, wednesday, thursday, friday, saturday, sunday, start_date, end_date from gtf_calendar\n SQL\n\n #for each service_id in the calendar table\n dates.each do |service_id, mon, tue, wed, thu, fri, sat, sun, start_date, end_date|\n #convert to boolean daymask\n daymask = [mon.to_i, tue.to_i, wed.to_i, thu.to_i, fri.to_i, sat.to_i, sun.to_i].collect do |day| day == 1 end\n\n #Find the UTC date, as if we're in London\n i = GoogleTransitFeed::parse_date( start_date.to_s ) #date as parsed to UTC\n n = GoogleTransitFeed::parse_date( end_date.to_s ) #end date is inclusive\n\n #the expanded calendar is a hash with the dates where services run as keys and\n #the service_ids of particular services running each day as values, grouped in arrays\n #for each day in the service_id date range\n while i <= n do\n if daymask[ i.wday ] then\n expanded_calendar[i] ||= []\n expanded_calendar[i] << sid_numbers[service_id]\n end\n\n i += SECONDS_IN_DAY\n end\n end\n\n #=========APPLY EXCEPTIONS FROM calendar_dates TO expanded_calendar HASH=============\n single_dates = conn.exec <<-SQL\n SELECT service_id, date, exception_type from gtf_calendar_dates\n SQL\n\n single_dates.each do |service_id, date, exception_type|\n #returns UTC date, as if we're in London\n i = GoogleTransitFeed::parse_date( date.to_s )\n expanded_calendar[i] ||= []\n\n if exception_type.to_i == 1 then\n expanded_calendar[i] << sid_numbers[service_id]\n elsif exception_type.to_i == 2 then\n expanded_calendar[i].delete sid_numbers[service_id]\n end\n end\n\n #========CONVERT EXPANDED CALENDAR TO SORTED ARRAY===================================\n expanded_calendar = expanded_calendar.to_a\n expanded_calendar.sort! do |a,b|\n a.first <=> b.first\n end\n\n #========CONVERT SORTED ARRAY INTO CALENDAR OBJECT===================================\n ret = Calendar.new\n expanded_calendar.each do |day, service_ids|\n local_daystart = day.to_i-tz_offset\n #if daylight savings is in effect\n if timezone.period_for_utc( day.to_i ).dst? then\n local_daystart -= dst_offset\n daylight_savings = dst_offset\n else\n daylight_savings = 0\n end\n\n ret.append_day( local_daystart+sid_start, local_daystart+sid_end, service_ids, daylight_savings )\n end\n\n return ret.rewind!\n end",
"def control_init(controls = {})\r\n @init_end << add_control(GSmallMapControl.new) if controls[:small_map]\r\n @init_end << add_control(GLargeMapControl.new) if controls[:large_map]\r\n @init_end << add_control(GSmallZoomControl.new) if controls[:small_zoom]\r\n @init_end << add_control(GScaleControl.new) if controls[:scale]\r\n @init_end << add_control(GMapTypeControl.new) if controls[:map_type]\r\n @init_end << add_control(GOverviewMapControl.new) if controls[:overview_map]\r\n end",
"def create\n @gotodate = params[:vacation][:starts_at].to_time.to_i * 1000\n set_tz_offset(:vacation)\n @user = User.find(params[:user_id])\n @vacation = @user.vacations.build(params[:vacation])\n\n\n respond_to do |format|\n if @vacation.save\n format.js { render 'update_listing', :layout => false }\n else\n format.js { render :partial => 'shared/error', :locals => {:target => @vacation} }\n end\n end\n end",
"def insert_calendar(opts = {})\n end",
"def add_hl_sp\n end",
"def index\n @time_controls = TimeControl.all\n end",
"def update_calendar(opts = {})\n end",
"def puede_coger_vacaciones\n if start_time.past?\n errors.add(:pasado, \": aun no inventamos vacaciones al pasado\")\n end\n\n if empleado.periodo_vacacionals.count > 0\n if empleado.periodo_vacacionals.count > 1\n errors.add(:periodos, \": tienes demasiados\")\n else\n primer_periodo = empleado.periodo_vacacionals.first\n dias_restantes = (primer_periodo.end_time - primer_periodo.start_time).to_int\n if dias_restantes < 8\n errors.add(:dias, \": has pedido demasiados\")\n end\n end\n\n acts_en_periodo = empleado.actividads\n .where(\"start_time <= ?\", end_time)\n .where(\"end_time >= ?\", start_time)\n .where(finalizado: false)\n .count\n\n vacs_en_periodo = empleado.periodo_vacacionals\n .where(\"start_time <= ?\", end_time)\n .where(\"end_time >= ?\", start_time)\n .count\n\n if acts_en_periodo > 0 && vacs_en_periodo > 0\n errors.add(:tareas, \": tienes tareas pendientes esas fechas\")\n end\n end\n end",
"def setup_availabilities\n Availability::DAYS.each do |day|\n availabilities.create(day_name: day)\n end\n end",
"def cfgadd(fabrickey, cfgname, *zonenames)\n result = @zones.altercfg(fabrickey, 'ADD', cfgname, *zonenames)\n result[1]\n end",
"def special_time\n begin\n @select_date = params[:special_day]\n condition_id = params[:condition_id]\n\n @condition = nil\n @time_zones = RestaurantManage.get_time_zones(condition_id)\n if !condition_id.blank? && condition_id.to_i != 0\n @condition = SupplyCondition.find(condition_id.to_i)\n @is_vacation = @condition.is_vacation\n end\n render 'restaurant_manage/_time_zones', :layout => false\n rescue => e\n Rails.logger.error APP_CONFIG['error'] + \"(#{e.message})\" + \",From:app/controllers/restaurant_manage_controller.rb ,Action:special_time\"\n @time_zones = RestaurantManage.get_time_zones(nil)\n end\n end",
"def initialize(time_zone_id=nil,from=\"09:00\",to=\"17:00\")\n\t\tif @time_zone_id.nil? || @time_zone_id.strip.empty?\n\t\t\t@time_zone = DateTimeZone.getDefault\n\t\telse\n\t\t\t@time_zone = DateTimeZone.forID(time_zone_id)\n\t\tend\n\t\t@start_hour,@start_minutes = CommunicationDateClassifier.parse_hour_minutes_string(from)\n\t\t@end_hour,@end_minutes = CommunicationDateClassifier.parse_hour_minutes_string(to)\n\n\t\t@parent_tag = \"Office Hours\"\n\t\t@before_tag = \"Before Office Hours\"\n\t\t@during_tag = \"During Office Hours\"\n\t\t@after_tag = \"After Office Hours\"\n\t\t@weekend_tag = \"Weekend\"\n\n\t\t@office_days = {\n\t\t\t\"MONDAY\" => true,\n\t\t\t\"TUESDAY\" => true,\n\t\t\t\"WEDNESDAY\" => true,\n\t\t\t\"THURSDAY\" => true,\n\t\t\t\"FRIDAY\" => true,\n\t\t\t\"SATURDAY\" => false,\n\t\t\t\"SUNDAY\" => false,\n\t\t}\n\n\t\t@week_day_names = {\n\t\t\t1 => \"MONDAY\",\n\t\t\t2 => \"TUESDAY\",\n\t\t\t3 => \"WEDNESDAY\",\n\t\t\t4 => \"THURSDAY\",\n\t\t\t5 => \"FRIDAY\",\n\t\t\t6 => \"SATURDAY\",\n\t\t\t7 => \"SUNDAY\",\n\t\t}\n\n\t\t@record_week_day = false\n\tend",
"def set_time_control\n @time_control = TimeControl.find(params[:id])\n end",
"def apply_multizone_vav_outdoor_air_sizing()\n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started applying HVAC efficiency standards.')\n \n # Multi-zone VAV outdoor air sizing\n self.getAirLoopHVACs.sort.each {|obj| obj.apply_multizone_vav_outdoor_air_sizing} \n\n end",
"def save_days_off\n if params[:company]\n days_off = DayOff.where(\"company = ?\", true)\n redirect = holidays_path(:company => true)\n day_hours = DayHour.first\n day_hours.hours = params[:day_hours]\n day_hours.save!\n else\n days_off = DayOff.where(\"project_id = ?\", session[:actual_project])\n redirect = holidays_path\n ap = actual_project\n ap.hours_day = params[:day_hours]\n ap.save!(:validate => false) #por las dudas le pongo que skip validations, no vaya a ser que de un error\n end\n days_off.each do |day|\n day.off = true\n case day.wday\n when 0: day.off = false unless params[:wday_domingo]\n when 1: day.off = false unless params[:wday_lunes]\n when 2: day.off = false unless params[:wday_martes]\n when 3: day.off = false unless params[:wday_miercoles]\n when 4: day.off = false unless params[:wday_jueves]\n when 5: day.off = false unless params[:wday_viernes]\n when 6: day.off = false unless params[:wday_sabado]\n end\n day.save!\n end\n redirect_to(redirect, :notice => t(\"screens.notice.successfully_created\"))\n end\n\nend",
"def fix_setpoint_inversion(htg_hrly, clg_hrly, hvac, weather, model, runner)\n cooling_season = hvac.get_season(model, weather, runner, Constants.ObjectNameCoolingSeason)\n heating_season = hvac.get_season(model, weather, runner, Constants.ObjectNameHeatingSeason)\n\n year_description = model.getYearDescription\n run_period = model.getRunPeriod\n start_month = run_period.getBeginMonth - 1\n end_month = run_period.getEndMonth - 1\n\n day_e = 0\n days_in_month = Constants.NumDaysInMonths(year_description.isLeapYear)\n (start_month..end_month).to_a.each do |i|\n day_s = day_e + 1\n day_e = day_s + days_in_month[i] - 1\n hr1 = (day_s - 1) * 24\n hr2 = day_e * 24 - 1\n\n htg_hrly_month = htg_hrly[hr1..hr2]\n clg_hrly_month = clg_hrly[hr1..hr2]\n\n if (heating_season[i] == 1) && (cooling_season[i] == 1)\n htg_hrly[hr1..hr2] = htg_hrly_month.zip(clg_hrly_month).map { |h, c| c < h ? (h + c) / 2.0 : h }\n clg_hrly[hr1..hr2] = htg_hrly_month.zip(clg_hrly_month).map { |h, c| c < h ? (h + c) / 2.0 : c }\n elsif heating_season[i] == 1 # heating only seasons; cooling has minimum of heating\n htg_hrly[hr1..hr2] = htg_hrly_month.zip(clg_hrly_month).map { |h, c| c < h ? h : h }\n clg_hrly[hr1..hr2] = htg_hrly_month.zip(clg_hrly_month).map { |h, c| c < h ? h : c }\n elsif cooling_season[i] == 1 # cooling only seasons; heating has maximum of cooling\n htg_hrly[hr1..hr2] = htg_hrly_month.zip(clg_hrly_month).map { |h, c| c < h ? c : h }\n clg_hrly[hr1..hr2] = htg_hrly_month.zip(clg_hrly_month).map { |h, c| c < h ? c : c }\n end\n end\n end",
"def new\n @daylight = Daylight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daylight }\n end\n end",
"def evening_civil_twilight\n create_time @data['evening']['twilight']['civil']\n end",
"def create\n @time_control = TimeControl.new(time_control_params)\n\n respond_to do |format|\n if @time_control.save\n format.html { redirect_to @time_control, notice: 'Time control was successfully created.' }\n format.json { render action: 'show', status: :created, location: @time_control }\n else\n format.html { render action: 'new' }\n format.json { render json: @time_control.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_status_controls\n @control_help_window.add_control(Vocab::CAPACITIES, Input::Keys::A) \n @control_help_window.add_control(Vocab::BACK, Input::Keys::B)\n @control_help_window.add_control(Vocab::REMOVE_ALL, Input::Keys::X)\n @control_help_window.add_control(Vocab::CHANGE_ACTOR, Input::Keys::L, Input::Keys::R)\n end",
"def index\n # 画面データ連携用ハッシュ\n @mkintai = {}\n\n # ログイン社員番号\n @@shain_no = '007'\n \n # 処理対象年月取得\n now = Time.current\n @@yyyy = now.strftime(\"%Y\")\n @@mm = now.strftime(\"%m\")\n # 対象年月の月初月末日取得\n cur_day = now.beginning_of_month\n end_day = now.end_of_month\n\n # 対象年月の勤怠データ取得\n @kintais = Kintai.where(shain_no: @@shain_no, yyyy: @@yyyy, mm: @@mm)\n @tkintai = Hash[@kintais.map{|kintai| [kintai.dd, kintai.attributes]}]\n\n # 祭日取得\n holidays = Holiday.where(yyyy: @@yyyy, mm: @@mm)\n holidayname = Hash[holidays.map{|holiday| [holiday.dd, holiday.attributes]}]\n \n # サマリ項目\n @defoult_working_days_cnt = (end_day - cur_day).to_i/(60*60*24) + 1\n @working_days_cnt = 0\n @working_hours_sum = 0\n @extra_hours_sum = 0\n \n while(cur_day < end_day)\n id = \"\"\n dd = cur_day.strftime(\"%d\")\n ww = cur_day.strftime(\"%w\")\n dw = cur_day.strftime(\"%d(#{%w(日 月 火 水 木 金 土)[cur_day.wday]})\")\n kintai_kbn = \"\"\n start_time = \"\"\n end_time = \"\"\n normal_hours = \"\"\n break_hours = \"\"\n working_hours = \"\"\n extra_hours = \"\"\n \n holiday_name = \"\"\n \n # 行背景カラー設定\n line_bk_color = \"\"\n # 土曜日\n if ww == \"6\" then\n line_bk_color = \"aliceblue\"\n end\n # 日曜日\n if ww == \"0\" then\n line_bk_color = \"lavenderblush\"\n end\n # 休日\n if holidayname[dd] != nil then\n line_bk_color = \"lavenderblush\"\n holiday_name = holidayname[dd][\"name\"]\n @defoult_working_days_cnt = @defoult_working_days_cnt - 1\n end\n # 本日\n if cur_day.strftime(\"%Y%m%d\") == now.strftime(\"%Y%m%d\") then\n line_bk_color = \"lightyellow\"\n end\n \n # 要出勤日数算出\n if ww == \"6\" or ww == \"0\" then\n @defoult_working_days_cnt = @defoult_working_days_cnt - 1\n end\n\n # 勤怠登録がある日\n if @tkintai[dd] != nil\n # Table表文言作成\n id = @tkintai[dd][\"id\"]\n kintai_kbn = @tkintai[dd][\"kintai_kbn_cd\"]\n start_time = @tkintai[dd][\"start_time\"] == nil ? \"\" : @tkintai[dd][\"start_time\"].strftime(\"%H:%M\")\n end_time = @tkintai[dd][\"end_time\"] == nil ? \"\" : @tkintai[dd][\"end_time\"].strftime(\"%H:%M\")\n normal_hours = @tkintai[dd][\"normal_hours\"]\n break_hours = @tkintai[dd][\"break_hours\"]\n working_hours = (@tkintai[dd][\"start_time\"] == nil or @tkintai[dd][\"end_time\"] == nil) ? \"\" : (@tkintai[dd][\"end_time\"] - @tkintai[dd][\"start_time\"])/60/60 - @tkintai[dd][\"break_hours\"]\n extra_hours = (@tkintai[dd][\"start_time\"] == nil or @tkintai[dd][\"end_time\"] == nil) ? \"\" : (@tkintai[dd][\"end_time\"] - @tkintai[dd][\"start_time\"])/60/60 - @tkintai[dd][\"break_hours\"] - @tkintai[dd][\"normal_hours\"]\n\n # 実績サマリ項目算出\n # 出勤日数\n if kintai_kbn == \"0\" then\n @working_days_cnt = @working_days_cnt + 1\n end\n # 合計勤務時間\n @working_hours_sum = @working_hours_sum + working_hours.to_f\n # 合計残業時間\n @extra_hours_sum = @extra_hours_sum + extra_hours.to_f\n end\n \n @mkintai[cur_day.strftime(\"%d\")] = {\n \"id\" => id \\\n , \"dd\" => dd \\\n , \"dw\" => dw \\\n , \"holiday_name\" => holiday_name \\\n , \"kintai_kbn\" => kintai_kbn \\\n , \"start_time\" => start_time \\\n , \"end_time\" => end_time \\\n , \"normal_hours\" => normal_hours \\\n , \"break_hours\" => break_hours \\\n , \"working_hours\" => working_hours \\\n , \"extra_hours\" => extra_hours \\\n , \"line_bk_color\" => line_bk_color \\\n }\n cur_day += 1.day\n end\n\n @kintais = Kintai.all\n end",
"def zoneadd_standard(fabrickey, zonename, *aliases)\n result = @zones.alterzoning_standard(fabrickey, 'ADD', zonename, *aliases)\n result[1]\n end",
"def bussines_hour_params\n params.require(:setting).permit(:id, business_hours_attributes: [:id, :day, :h_start, :h_end, :h_start2, :h_end2, :is_active, :active, :_destroy])\n end",
"def setup_uk_holidays\n gb_holidays = holidays_for_region(:gb)\n oxford_holidays_2017 = [22,23,24,27,28,29,30,31].map do |day|\n Date.parse(\"#{day}-12-2017\")\n end\n oxford_holidays_2018 = [ Date.parse('02-01-2018') ]\n uk_hols = gb_holidays | oxford_holidays_2017 | oxford_holidays_2018\n @uk_holidays = Set.new(uk_hols)\n end",
"def zone; end",
"def load_zone_information(data, index)\n @zone = index\n # We store this zone as the zone where to warp if it's possible\n @warp_zone = index if data.warp_x && data.warp_y\n # We store this zone as the master zone if there's a pannel\n @master_zone = index if data.panel_id&.>(0)\n # We memorize the fact we visited this zone\n @visited_zone << index unless @visited_zone.include?(index)\n # We memorize the fact we visited this worldmap\n @visited_worldmap << data.worldmap_id unless @visited_worldmap.include?(data.worldmap_id)\n # We store the zone worldmap\n @worldmap = data.worldmap_id\n # We store the new switch info\n $game_switches[Yuki::Sw::Env_CanFly] = (!data.warp_disallowed && data.fly_allowed)\n $game_switches[Yuki::Sw::Env_CanDig] = (!data.warp_disallowed && !data.fly_allowed)\n return unless data.forced_weather\n if data.forced_weather == 0\n $game_screen.weather(0, 0, $game_switches[Yuki::Sw::Env_CanFly] ? 40 : 0)\n else\n $game_screen.weather(0, 9, 40, psdk_weather: data.forced_weather)\n end\n end",
"def neutovr_alrm; catdet.form(:name, 'rpcControlApsSettingForm').text_field(:name, 'ecNeutralThrshldOverAlarm'); end",
"def update\r\n handle_venda_update\r\n end",
"def set_downtime\n @title = TITLE\n @downtime_active = 'active'\n @downtime = Downtime.find(params[:id])\n end",
"def add_track_indicator\n @forecast = Forecast.find(params[:id])\n #session[:forecast_id] = @forecast.id\n\n render :inline => %{\n\t\t<% @content_header_caption = \"'add track slms indicator for forecast: \" + @forecast.id.to_s + \": farm:\" + @forecast.farm_code + \", season: \" + @forecast.season.to_s + \" '\"%>\n\n\t\t<%= build_track_indicator_form(@forecasts_track_slms_indicator,'save_forecasts_track_slms_indicator','save')%>\n\n\t\t}, :layout => 'content'\n end",
"def add_new_holiday_with_supplies(holiday_hash, season, holiday_name, supply_array)\n holiday_hash[:fall]={:columbus_day =>[\"Flags\", \"Italian Food\", \"Parade Floats\"]}\n holiday_hash[:winter]={:valentines_day =>[\"Candy Hearts\", \"Cupid Cut-Out\"]}\nend",
"def run(model, runner, user_arguments)\r\n super(model, runner, user_arguments)\r\n \r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(model), user_arguments)\r\n return false\r\n end\r\n\r\n spaces_with_daylight_potential = 0\r\n spaces_daylight_sensors_added_to = []\r\n \r\n #record the number of spaces that had daylighting control to start\r\n initial_spaces_with_daylight_sensors = 0\r\n model.getSpaces.each do |space|\r\n initial_spaces_with_daylight_sensors += space.daylightingControls.size\r\n end\r\n \r\n #loop through all spaces in the model \r\n model.getSpaces.each do |space|\r\n runner.registerInfo(\"CHECKING DAYLIGHTING FOR: #{space.name.get}\")\r\n num_ext_windows = 0\r\n total_daylight_area_m2 = 0\r\n existing_daylighting_controls = 0\r\n daylight_windows = {}\r\n \r\n \r\n #find a floor in the space for later use\r\n floor_surface = nil\r\n space.surfaces.each do |surface|\r\n #find a floor in the space for later use in determining window size\r\n if surface.surfaceType == \"Floor\"\r\n floor_surface = surface\r\n break \r\n end\r\n end\r\n if not floor_surface\r\n runner.registerWarning(\"could not find a floor in the space #{space.name.get}\")\r\n next #next space\r\n end\r\n \r\n #find all exterior windows in the space and calculate their daylighting areas\r\n space.surfaces.each do |surface|\r\n if surface.outsideBoundaryCondition == \"Outdoors\" and surface.surfaceType == \"Wall\"\r\n surface.subSurfaces.each do |sub_surface|\r\n if sub_surface.outsideBoundaryCondition == \"Outdoors\" and (sub_surface.subSurfaceType == \"FixedWindow\" or sub_surface.subSurfaceType == \"OperableWindow\")\r\n num_ext_windows += 1\r\n net_area_m2 = sub_surface.netArea\r\n runner.registerInfo(\"#{sub_surface.name.get}, area = #{net_area_m2}m^2\")\r\n \r\n #find the head height and sill height of the window\r\n vertex_heights_above_floor = []\r\n sub_surface.vertices.each do |vertex|\r\n vertex_on_floorplane = floor_surface.plane.project(vertex)\r\n vertex_heights_above_floor << (vertex - vertex_on_floorplane).length\r\n end\r\n sill_height_m = vertex_heights_above_floor.min\r\n head_height_m = vertex_heights_above_floor.max\r\n runner.registerInfo(\"---head height = #{head_height_m}m, sill height = #{sill_height_m}m\")\r\n \r\n #find the width of the window\r\n if not sub_surface.vertices.size == 4\r\n runner.registerWarning(\"cannot handle windows with #{sub_surface.vertices.size} vertices; skipping window\")\r\n next\r\n end\r\n prev_vertex_on_floorplane = nil\r\n max_window_width_m = 0\r\n sub_surface.vertices.each do |vertex|\r\n vertex_on_floorplane = floor_surface.plane.project(vertex)\r\n if not prev_vertex_on_floorplane\r\n prev_vertex_on_floorplane = vertex_on_floorplane\r\n next\r\n end\r\n width_m = (prev_vertex_on_floorplane - vertex_on_floorplane).length\r\n if width_m > max_window_width_m\r\n max_window_width_m = width_m\r\n end\r\n end\r\n \r\n #find the width of the wall containing the window\r\n if not sub_surface.vertices.size == 4\r\n runner.registerWarning(\"cannot handle walls with #{sub_surface.vertices.size} vertices; skipping wall\")\r\n next\r\n end\r\n prev_vertex_on_floorplane = nil\r\n max_wall_width_m = 0\r\n sub_surface.vertices.each do |vertex|\r\n vertex_on_floorplane = floor_surface.plane.project(vertex)\r\n if not prev_vertex_on_floorplane\r\n prev_vertex_on_floorplane = vertex_on_floorplane\r\n next\r\n end\r\n width_m = (prev_vertex_on_floorplane - vertex_on_floorplane).length\r\n if width_m > max_wall_width_m\r\n max_wall_width_m = width_m\r\n end\r\n end\r\n \r\n #if window + 2ft on each side is extends out of the space, don't add it to the daylight area width\r\n max_width_plus_side_m = nil\r\n if (max_window_width_m + OpenStudio::convert(4,\"ft\",\"m\").get) >= max_wall_width_m\r\n max_width_plus_side_m = max_window_width_m\r\n runner.registerInfo(\"---adding 2ft on sides extends daylight area outside space, not adding to daylight area width\") \r\n else\r\n max_width_plus_side_m = max_window_width_m + OpenStudio::convert(4,\"ft\",\"m\").get\r\n runner.registerInfo(\"---width plus 2ft on sides = #{max_width_plus_side_m}m\")\r\n end\r\n\r\n #find the daylighting area of the window\r\n window_daylight_area_m2 = head_height_m * max_width_plus_side_m\r\n runner.registerInfo(\"---daylight area = #{window_daylight_area_m2}m^2\")\r\n total_daylight_area_m2 += window_daylight_area_m2\r\n \r\n #record the azimuth of the window\r\n group = sub_surface.planarSurfaceGroup\r\n if group.is_initialized\r\n group = group.get\r\n site_transformation = group.buildingTransformation\r\n site_vertices = site_transformation * sub_surface.vertices\r\n site_outward_normal = OpenStudio::getOutwardNormal(site_vertices)\r\n if site_outward_normal.empty?\r\n runner.registerError(\"could not compute outward normal for #{sub_surface.name.get}\")\r\n return false\r\n end\r\n site_outward_normal = site_outward_normal.get\r\n north = OpenStudio::Vector3d.new(0.0,1.0,0.0)\r\n if site_outward_normal.x < 0.0\r\n azimuth = 360.0 - OpenStudio::radToDeg(OpenStudio::getAngle(site_outward_normal, north))\r\n else\r\n azimuth = OpenStudio::radToDeg(OpenStudio::getAngle(site_outward_normal, north))\r\n end\r\n end\r\n #TODO will need to modify to work for buildings in the southern hemisphere\r\n if (azimuth >= 315.0 or azimuth < 45.0)\r\n facade = \"4-North\"\r\n elsif (azimuth >= 45.0 and azimuth < 135.0)\r\n facade = \"3-East\"\r\n elsif (azimuth >= 135.0 and azimuth < 225.0)\r\n facade = \"1-South\"\r\n elsif (azimuth >= 225.0 and azimuth < 315.0)\r\n facade = \"2-West\"\r\n else\r\n runner.registerError(\"window #{sub_surface.name.get} appears to face directly upward or downward.\")\r\n return false\r\n end\r\n \r\n #log the window properties to use when creating daylight sensors\r\n window_properties = {:facade => facade, :daylight_area_m2 => window_daylight_area_m2, :handle => sub_surface.handle, :head_height_m => head_height_m}\r\n daylight_windows[sub_surface] = window_properties\r\n \r\n #TODO handle overlapping daylighting areas \r\n \r\n end \r\n end #next sub-surface\r\n end\r\n end #next surface\r\n\r\n #find existing daylighting controls\r\n existing_daylighting_controls = space.daylightingControls.size\r\n\r\n #warn if daylight area greater than space floor area\r\n #this could happen with tall rooms, large windows on all sides, etc\r\n if total_daylight_area_m2 > space.floorArea\r\n runner.registerWarning(\"daylight area > floor area; floor area is 100% daylightable\")\r\n total_daylight_area_m2 = space.floorArea\r\n end\r\n \r\n #convert daylight area to IP\r\n total_daylight_area_ft2 = OpenStudio::convert(total_daylight_area_m2,\"m^2\",\"ft^2\").get\r\n \r\n #report out a summary of the space\r\n runner.registerInfo(\"Daylighting Summary\")\r\n runner.registerInfo(\"---space has #{num_ext_windows} exterior windows\")\r\n runner.registerInfo(\"---space has #{existing_daylighting_controls} existing daylighting controls\")\r\n runner.registerInfo(\"---space has #{total_daylight_area_ft2}ft^2 of daylight area\")\r\n \r\n #Conditions for daylighting to be applicable\r\n # 1. Has vertical fenestration\r\n # 2. Without daylighting controls\r\n # 3. Daylight Area exceeds 250 sq.ft \r\n if num_ext_windows > 0 and total_daylight_area_ft2 > 250.0 and existing_daylighting_controls == 0\r\n spaces_with_daylight_potential += 1\r\n runner.registerInfo(\"---Daylighting: APPLICABLE\")\r\n \r\n #find the space type and determine the corresponding daylight setpoint\r\n space_name = space.name.get\r\n daylight_stpt_lux = nil\r\n if space_name.match(/post_office/)# Post Office 500 Lux\r\n daylight_stpt_lux = 500\r\n elsif space_name.match(/medical_office/)# Medical Office 3000 Lux\r\n daylight_stpt_lux = 3000\r\n elsif space_name.match(/office/)# Office 500 Lux\r\n daylight_stpt_lux = 500\r\n elsif space_name.match(/school/)# School 500 Lux\r\n daylight_stpt_lux = 500\r\n elsif space_name.match(/retail/)# Retail 1000 Lux\r\n daylight_stpt_lux = 1000\r\n elsif space_name.match(/warehouse/)# Warehouse 200 Lux\r\n daylight_stpt_lux = 200\r\n elsif space_name.match(/hotel/)# Hotel 300 Lux\r\n daylight_stpt_lux = 300\r\n elsif space_name.match(/apartment/)# Apartment 200 Lux\r\n daylight_stpt_lux = 200\r\n elsif space_name.match(/courthouse/)# Courthouse 300 Lux\r\n daylight_stpt_lux = 300\r\n elsif space_name.match(/library/)# Library 500 Lux\r\n daylight_stpt_lux = 500\r\n elsif space_name.match(/community_center/)# Community Center 300 Lux\r\n daylight_stpt_lux = 300\r\n elsif space_name.match(/senior_center/)# Senior Center 1000 Lux\r\n daylight_stpt_lux = 1000\r\n elsif space_name.match(/city_hall/)# City Hall 500 Lux\r\n daylight_stpt_lux = 500\r\n else\r\n runner.registerWarning(\"Space #{space_name} is an unknown space type, assuming office and 300 Lux daylight setpoint\")\r\n daylight_stpt_lux = 300\r\n end\r\n \r\n #get the zone that the space is in\r\n zone = space.thermalZone\r\n if zone.empty?\r\n runner.registerError(\"Space #{space.name.get} has no thermal zone\")\r\n return false\r\n else\r\n zone = space.thermalZone.get\r\n end\r\n \r\n #add the daylight sensors\r\n sorted_daylight_windows = daylight_windows.sort_by { |handle, vals| vals[:facade] }\r\n \r\n #primary sensor controlled fraction\r\n pri_daylight_window_info = sorted_daylight_windows[0][1]\r\n pri_daylight_area = pri_daylight_window_info[:daylight_area_m2]\r\n pri_ctrl_frac = pri_daylight_area/space.floorArea\r\n runner.registerInfo(\"primary daylighting control fraction = #{pri_ctrl_frac}\")\r\n \r\n #secondary sensor controlled fraction\r\n sec_daylight_window_info = nil\r\n sec_ctrl_frac = nil\r\n if sorted_daylight_windows.size > 1\r\n sec_daylight_window_info = sorted_daylight_windows[1][1]\r\n sec_daylight_area = sec_daylight_window_info[:daylight_area_m2]\r\n sec_ctrl_frac = sec_daylight_area/space.floorArea\r\n runner.registerInfo(\"secondary daylighting control fraction = #{sec_ctrl_frac}\")\r\n end\r\n \r\n #find all exterior windows in the space and calculate their daylighting areas\r\n space.surfaces.each do |surface|\r\n if surface.outsideBoundaryCondition == \"Outdoors\" and surface.surfaceType == \"Wall\"\r\n surface.subSurfaces.each do |sub_surface|\r\n if sub_surface.handle == pri_daylight_window_info[:handle]\r\n #this is the primary daylight window\r\n runner.registerInfo(\"primary daylight window = #{sub_surface.name.get}\")\r\n pri_light_sensor = OpenStudio::Model::DaylightingControl.new(model)\r\n pri_light_sensor.setName(\"#{space.name.get} Pri Daylt Sensor\")\r\n pri_light_sensor.setSpace(space)\r\n pri_light_sensor.setIlluminanceSetpoint(daylight_stpt_lux)\r\n pri_light_sensor.setLightingControlType(\"2\") #2 = stepped controls\r\n pri_light_sensor.setNumberofSteppedControlSteps(3) #all sensors 3-step per design\r\n window_outward_normal = sub_surface.outwardNormal\r\n window_centroid = OpenStudio::getCentroid(sub_surface.vertices).get\r\n window_outward_normal.setLength(pri_daylight_window_info[:head_height_m])\r\n vertex = window_centroid + window_outward_normal.reverseVector\r\n vertex_on_floorplane = floor_surface.plane.project(vertex)\r\n floor_outward_normal = floor_surface.outwardNormal\r\n floor_outward_normal.setLength(OpenStudio::convert(3.0, \"ft\", \"m\").get)\r\n sensor_vertex = vertex_on_floorplane + floor_outward_normal.reverseVector\r\n pri_light_sensor.setPosition(sensor_vertex)\r\n #TODO rotate sensor to face window (only needed for glare calcs)\r\n zone.setPrimaryDaylightingControl(pri_light_sensor)\r\n zone.setFractionofZoneControlledbyPrimaryDaylightingControl(pri_ctrl_frac)\r\n runner.registerInfo(\"added daylight sensor at point #{sensor_vertex.x},#{sensor_vertex.y},#{sensor_vertex.z}\")\r\n elsif sec_daylight_window_info and sub_surface.handle == sec_daylight_window_info[:handle]\r\n #this is the secondary daylight window\r\n runner.registerInfo(\"secondary daylight window = #{sub_surface.name.get}\")\r\n sec_light_sensor = OpenStudio::Model::DaylightingControl.new(model)\r\n sec_light_sensor.setName(\"#{space.name.get} Sec Daylt Sensor\")\r\n sec_light_sensor.setSpace(space)\r\n sec_light_sensor.setIlluminanceSetpoint(daylight_stpt_lux)\r\n sec_light_sensor.setLightingControlType(\"2\") #2 = stepped controls\r\n sec_light_sensor.setNumberofSteppedControlSteps(3) #all sensors 3-step per design\r\n window_outward_normal = sub_surface.outwardNormal\r\n window_centroid = OpenStudio::getCentroid(sub_surface.vertices).get\r\n window_outward_normal.setLength(pri_daylight_window_info[:head_height_m])\r\n vertex = window_centroid + window_outward_normal.reverseVector \r\n vertex_on_floorplane = floor_surface.plane.project(vertex)\r\n floor_outward_normal = floor_surface.outwardNormal\r\n floor_outward_normal.setLength(OpenStudio::convert(3.0, \"ft\", \"m\").get)\r\n sensor_vertex = vertex_on_floorplane + floor_outward_normal.reverseVector\r\n sec_light_sensor.setPosition(sensor_vertex)\r\n #TODO rotate sensor to face window (only needed for glare calcs)\r\n zone.setSecondaryDaylightingControl(sec_light_sensor)\r\n zone.setFractionofZoneControlledbySecondaryDaylightingControl(sec_ctrl_frac) \r\n runner.registerInfo(\"added daylight sensor at point #{sensor_vertex.x},#{sensor_vertex.y},#{sensor_vertex.z}\") \r\n end\r\n end #next sub_surface\r\n end\r\n end #next surface\r\n \r\n #record the fact daylight sensors were added to this zone\r\n spaces_daylight_sensors_added_to << space.name.get\r\n \r\n else\r\n runner.registerInfo(\"---Daylighting: NOT Applicable\")\r\n end\r\n \r\n #blank lines for output readability\r\n runner.registerInfo(\"-\")\r\n runner.registerInfo(\"-\")\r\n \r\n end #next space\r\n \r\n #record the building's initial condition\r\n if spaces_with_daylight_potential == 0\r\n runner.registerAsNotApplicable(\"The building has no spaces with daylighting potential, this measure is not applicable.\")\r\n return true\r\n else\r\n runner.registerInitialCondition(\"The building started with #{initial_spaces_with_daylight_sensors} spaces with daylight controls. There are #{spaces_with_daylight_potential} additional spaces where daylight controls could be used.\")\r\n end\r\n\r\n #record the building's final condition\r\n spaces_daylight_sensors_added_to_json = []\r\n spaces_daylight_sensors_added_to.each do |space_name|\r\n spaces_daylight_sensors_added_to_json << \"space_name\\\":\\\"#{space_name},\\\"\"\r\n end\r\n runner.registerFinalCondition(\"{\\\"affected_spaces\\\": [#{spaces_daylight_sensors_added_to_json}]}\")\r\n \r\n return true\r\n \r\n end",
"def zoneadd_peerzone(fabrickey, zonename, **wwns)\n result = @zones.alterzoning_peerzone(fabrickey, 'ADD', zonename, **wwns)\n result[1]\n end",
"def set_status_controls\n @control_help_window.add_control(Vocab::EQUIP, Input::Keys::A) \n @control_help_window.add_control(Vocab::BACK, Input::Keys::B)\n @control_help_window.add_control(Vocab::OPTIMIZE, Input::Keys::X)\n @control_help_window.add_control(Vocab::CHANGE_ACTOR, Input::Keys::L, Input::Keys::R)\n end",
"def inc_hl\n end",
"def local_middle_of_day\n change_local(hour: 12)\n end",
"def add_zone!(name)\n zone = add_zone(name)\n zone.save!\n zone\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def home\n # Calculate the total days including weekends\n # Calculate the days left without weekends and arbitrary time off\n ### Todo: Use MST, MDT to ensure the proper day\n ### Todo: Use pro-rated calculation to determine number of days off\n @days_gross = (DateTime.new(2014,9,30) - Date.today).to_i\n @days_left = @days_gross - (@days_gross / 7 * 2)\n @days_left = @days_left - 10\n\n # Calculate the partial day\n time_now = Time.now.in_time_zone(\"Mountain Time (US & Canada)\")\n @time_now_formatted = time_now.strftime(\"%A - %B %d, %Y; %I:%M%p %Z\")\n @hours_left = 0\n @minutes_left = 0\n @seconds_left = 0\n unless time_now.saturday? || time_now.sunday?\n # The end of the day is 5:00 PM today\n partial_day = FIVE_PM - time_now.seconds_since_midnight\n if partial_day > 0\n # Since we are using Time, we need to truncate (remove) the decimal\n @hours_left = (partial_day / ONE_HOUR).truncate\n @minutes_left = ((partial_day % ONE_HOUR) / ONE_MINUTE).truncate\n @seconds_left = ((partial_day % ONE_HOUR) % ONE_MINUTE).truncate\n end\n end\n\n render :action => \"countdown\"\n end",
"def add_zone(zone)\n if @hash.key? 'zone'\n @hash['zone'].append(zone)\n else\n @hash['zone'] = [zone]\n end\n end",
"def set_admin_vacancy\n @admin_vacancy = Vacancy.find(params[:id])\n end",
"def create_thermal_zones(building_type,building_vintage, climate_zone)\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Started creating thermal zones')\n\n # This map define the multipliers for spaces with multipliers not equals to 1\n case building_type\n when 'LargeHotel'\n space_multiplier_map = define_space_multiplier\n else\n space_multiplier_map ={}\n end\n\n # Create a thermal zone for each space in the self\n self.getSpaces.each do |space|\n zone = OpenStudio::Model::ThermalZone.new(self)\n zone.setName(\"#{space.name} ZN\")\n if space_multiplier_map[space.name.to_s] != nil\n zone.setMultiplier(space_multiplier_map[space.name.to_s])\n end\n space.setThermalZone(zone)\n \n # Skip thermostat for spaces with no space type\n next if space.spaceType.empty?\n \n # Add a thermostat\n space_type_name = space.spaceType.get.name.get\n thermostat_name = space_type_name + ' Thermostat'\n thermostat = self.getThermostatSetpointDualSetpointByName(thermostat_name)\n if thermostat.empty?\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Thermostat #{thermostat_name} not found for space name: #{space.name}\")\n return true\n end\n zone.setThermostatSetpointDualSetpoint(thermostat.get)\n end\n\n OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', 'Finished creating thermal zones')\n \n return true\n\n end",
"def cwday\n end",
"def create_timer\n add_cr_world\n create_world_map\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def create\n\n expire_action :action => [:shadyside, :south_side, :lawrenceville, :oakland, :bloomfield, :strip_district, :downtown]\n @event = current_user.events.build(event_params)\n #@event = Event.new(event_params)\n if @event.day == \"Weekdays\"\n @event.day = \"Monday\"\n @event_tue = current_user.events.build(event_params)\n @event_tue.day = \"Tuesday\"\n @event_wed = current_user.events.build(event_params)\n @event_wed.day = \"Wednesday\"\n @event_thu = current_user.events.build(event_params)\n @event_thu.day = \"Thursday\"\n @event_fri = current_user.events.build(event_params)\n @event_fri.day = \"Friday\"\n\n\n respond_to do |format|\n if @event.save && @event_tue.save && @event_wed.save && @event_thu.save && @event_fri.save\n #EventMailer.sample_email(current_user, @event).deliver\n\n Venue.where(id: @event.venue_id).first.update_attribute(:venue_verify, Time.now)\n format.html { redirect_to Venue.where(id: @event.venue_id).first, notice: 'Hour was successfully created.' }\n format.json { head :no_content }\n format.js { render :layout => false }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n elsif @event.day == \"Everyday\"\n @event.day = \"Monday\"\n @event_tue = current_user.events.build(event_params)\n @event_tue.day = \"Tuesday\"\n @event_wed = current_user.events.build(event_params)\n @event_wed.day = \"Wednesday\"\n @event_thu = current_user.events.build(event_params)\n @event_thu.day = \"Thursday\"\n @event_fri = current_user.events.build(event_params)\n @event_fri.day = \"Friday\"\n @event_sat = current_user.events.build(event_params)\n @event_sat.day = \"Saturday\"\n @event_sun = current_user.events.build(event_params)\n @event_sun.day = \"Sunday\"\n\n\n respond_to do |format|\n if @event.save && @event_tue.save && @event_wed.save && @event_thu.save && @event_fri.save && @event_sat.save && @event_sun.save\n #EventMailer.sample_email(current_user, @event).deliver\n\n Venue.where(id: @event.venue_id).first.update_attribute(:venue_verify, Time.now)\n format.html { redirect_to Venue.where(id: @event.venue_id).first, notice: 'Hour was successfully created.' }\n format.json { head :no_content }\n format.js { render :layout => false } \n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n elsif @event.day == \"Weekend\"\n @event_sat = current_user.events.build(event_params)\n @event_sat.day = \"Saturday\"\n @event_sun = current_user.events.build(event_params)\n @event_sun.day = \"Sunday\"\n\n respond_to do |format|\n if @event.save && @event_sun.save\n #EventMailer.sample_email(current_user, @event).deliver\n\n Venue.where(id: @event.venue_id).first.update_attribute(:venue_verify, Time.now)\n format.html { redirect_to Venue.where(id: @event.venue_id).first, notice: 'Hour was successfully created.' }\n format.json { head :no_content }\n format.js { render :layout => false }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n if @event.save\n #EventMailer.sample_email(current_user, @event).deliver\n\n Venue.where(id: @event.venue_id).first.update_attribute(:venue_verify, Time.now)\n format.html { redirect_to Venue.where(id: @event.venue_id).first, notice: 'Hour was successfully created.' }\n format.json { head :no_content }\n format.js { render :layout => false }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create_new_air_loop\n loop = OpenStudio::Model::AirLoopHVAC.new(@model)\n loop.setName(\"Chilled Beam DOAS\")\n # modify system sizing properties\n sizing_system = loop.sizingSystem\n \n #These next two paramters configure the airloop to operate as a 100% Outside Air Unit\n sizing_system.setTypeofLoadtoSizeOn(\"VentilationRequirement\")\n sizing_system.setMinimumSystemAirFlowRatio(1.0) \t\t\n sizing_system.setCentralCoolingDesignSupplyAirTemperature(OpenStudio::convert(65, \"F\", \"C\").get)\n sizing_system.setAllOutdoorAirinCooling(true)\n sizing_system.setAllOutdoorAirinHeating(true)\n sizing_system.setCentralCoolingDesignSupplyAirHumidityRatio(0.004)\n sizing_system.setSystemOutdoorAirMethod(\"VentilationRateProcedure\")\n \n \n # Add an outdoor air system to the loop\n outdoor_air_control = OpenStudio::Model::ControllerOutdoorAir.new(@model)\n outdoor_air_control.setName(\"100% OA Outdoor Air Controller - No Economizer\")\n outdoor_air_control.setEconomizerControlType(\"NoEconomizer\")\n outdoor_air_control.autosizeMinimumOutdoorAirFlowRate() # This will set to AutoSize\n outdoor_air_control.autosizeMaximumOutdoorAirFlowRate() # This will set to AutoSize\n outdoor_air_control.setMinimumFractionofOutdoorAirSchedule(@model.alwaysOnDiscreteSchedule())\n outdoor_air_control.setMaximumFractionofOutdoorAirSchedule(@model.alwaysOnDiscreteSchedule())\n \n # create outdoor air system\n system_OA = OpenStudio::Model::AirLoopHVACOutdoorAirSystem.new(@model, outdoor_air_control)\n system_OA.setName(\"DOAS Outdoor Air Management System\")\n system_OA.addToNode(loop.supplyInletNode)\n\n # Create an Air<->Air heat exchanger\n # Note that these settings for this rotary energy exchange device are reasonable but do not represent performance of a \n # specific product and should be customized to reprsent specific modeling scenarios. \n \n heat_exchanger = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(@model)\n heat_exchanger.setName(\"Aluminum Film Substrate Passive Dehumidification Wheel\")\n heat_exchanger.setSensibleEffectivenessat100HeatingAirFlow(0.76) \n heat_exchanger.setLatentEffectivenessat100HeatingAirFlow(0.68)\n heat_exchanger.setSensibleEffectivenessat100CoolingAirFlow(0.76)\n heat_exchanger.setLatentEffectivenessat100CoolingAirFlow(0.68)\n heat_exchanger.setNominalElectricPower(250)\n heat_exchanger.setHeatExchangerType(\"Rotary\")\n heat_exchanger.setFrostControlType(\"None\")\n heat_exchanger.addToNode(system_OA.outboardOANode.get)\n\n\n # Create a setpoint manager for the heat exchanger\n # This setpoint manager will attempt deliver 68F Air to the inlet of active chilled beam terminal units. \n exchanger_setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Passive Dehumidication Wheel LAT 68F Schedule\", 68))\n exchanger_setpoint_manager.setName(\"Passive Dehumidification Wheel (Free reheat) Setpoint Manager\")\n exchanger_setpoint_manager.addToNode(system_OA.outdoorAirModelObject.get.to_Node.get)\n\t\n\t# Create a cooling water coil\n\t# The purpose of this coil is to deeply cool the air to wring the maximum amount of moisture from the OA airstream\n\t# In many cases, this will overcool the 100% OA airstream, requiring either parasitic reheat or free reheat from a \n\t# downstream sensible recovery wheel. \n\tdehumidification_coil = OpenStudio::Model::CoilCoolingWater.new(@model, @model.alwaysOnDiscreteSchedule())\n\tdehumidification_coil.setName(\"Multirow Deep Dehumidification Coil\")\n\tdehumidification_coil.setHeatExchangerConfiguration(\"Crossflow\")\n\tdehumidification_coil.addToNode(system_OA.outboardOANode.get)\n\t\n\t# Create a setpoint manager for the cooling/dehumidification coil\n\t# The setpoint manager for this coil will operate to attempt to drive the coil temp to the specificed chilled beam\n\t# entering water temperature (user argument), since this temperature will likely set the temperature of most \n\t# efficienct chilled water generation (without requiring mixing to serve the chilled beams a lower entering \n\t# chilled water temperature.)\n\t\n dehumid_coil_setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Dehumidication Coil Schedule\", @design_inlet_water_temperature))\n dehumid_coil_setpoint_manager.setName(\"Setpoint Manager for Controlling Deep Dehumidification Coil Leaving Air Temp\")\n dehumid_coil_setpoint_manager.addToNode(dehumidification_coil.airOutletModelObject.get.to_Node.get)\n\t\n # Create a second Air to Air Energy Exchange device representing a total energy wheel\n # Note that settings for this rotary energy exchange device are reasonable but do not represent performance of a \n # specific product and should be customized to reprsent specific modeling scenarios. \n # Frost control strategies (used for heating only) may need to be modified based on specific design winter conditions\n heat_exchanger2 = OpenStudio::Model::HeatExchangerAirToAirSensibleAndLatent.new(@model)\n heat_exchanger2.setName(\"Enthalpy Recovery Wheel\")\n heat_exchanger2.setSensibleEffectivenessat100HeatingAirFlow(0.76)\n heat_exchanger2.setLatentEffectivenessat100HeatingAirFlow(0.68)\n heat_exchanger2.setSensibleEffectivenessat100CoolingAirFlow(0.76)\n heat_exchanger2.setLatentEffectivenessat100CoolingAirFlow(0.68)\n heat_exchanger2.setHeatExchangerType(\"Rotary\")\n heat_exchanger2.setNominalElectricPower(250)\n heat_exchanger2.setFrostControlType(\"MinimumExhaustTemperature\")\n heat_exchanger2.setThresholdTemperature(1.7)\n heat_exchanger2.addToNode(system_OA.outboardOANode.get)\n\n # Create a setpoint manager for the heat exchanger\n # This setpoint manager will attempt deliver 65F Air to the inlet of the downstream deep dehumidification coil. \n exchanger2_setpoint_manager = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Enthalpy Wheel Leaving Air Temp Schedule\", 65))\n exchanger2_setpoint_manager.setName(\"Enthalpy Wheel Leaving Supply Air Temperature Controller\")\n exchanger2_setpoint_manager.addToNode(heat_exchanger2.primaryAirOutletModelObject.get.to_Node.get)\n\n # Create a variable volume SUPPLY fan - configured for constant volume\n supply_fan = OpenStudio::Model::FanVariableVolume.new(@model, @model.alwaysOnDiscreteSchedule())\n supply_fan.setName(\"Chilled Beam DOAS Supply Fan\")\n inchesH2OtoPa = 1.0/0.00401463\n supply_fan.setPressureRise(@new_airloop_fan_pressure_rise / 2 * inchesH2OtoPa)\n supply_fan.autosizeMaximumFlowRate()\n supply_fan.setFanPowerMinimumFlowFraction(1.0)\n supply_fan.setFanPowerMinimumFlowRateInputMethod(\"Fraction\")\n supply_fan.addToNode(loop.supplyOutletNode)\n \n # Create a variable volume EXHAUST fan - configured for constant flow\n exhaust_fan = OpenStudio::Model::FanVariableVolume.new(@model, @model.alwaysOnDiscreteSchedule())\n exhaust_fan.setName(\"Chilled Beam DOAS Exhaust Fan\")\n exhaust_fan.setPressureRise(@new_airloop_fan_pressure_rise / 2 * inchesH2OtoPa)\n exhaust_fan.autosizeMaximumFlowRate()\n exhaust_fan.setFanPowerMinimumFlowFraction(1.0)\n exhaust_fan.setFanPowerMinimumFlowRateInputMethod(\"Fraction\")\n exhaust_fan.addToNode(system_OA.outboardReliefNode.get)\n \n # make a constant 65F schedule and assign it to a setpoint manager for this loop\n loop_setpoint = OpenStudio::Model::SetpointManagerScheduled.new(@model, make_constant_schedule(\"Chilled Beam Air Loop Outlet Schedule\", 65))\n loop_setpoint.setName(\"Constant 65 Degree Air Temp\")\n loop_setpoint.addToNode(loop.supplyOutletNode)\n \n return loop, dehumidification_coil\n end",
"def morning_civil_twilight\n create_time @data['morning']['twilight']['civil']\n end",
"def add_a_h\n end",
"def create\n @machine_historic = MachineHistoric.new(params[:machine_historic])\n @machine_historic.status = \"aberto\"\n \n @machine_initial = VehicleDaily.select(\"\n SUM(vehicle_dailies.km) as km_sum,\n ifnull(SUM(vehicle_dailies.hour), 0) as hour_sum,\n cmod_oil.km,\n cmod_oil.hour\n \").joins(\"\n INNER JOIN\n vehicles veh ON veh.id = vehicle_dailies.vehicle_id\n INNER JOIN\n carmodels cmod ON cmod.id = veh.carmodel_id \n INNER JOIN\n machine_historics mhis ON mhis.vehicle_id = veh.id \n INNER JOIN\n oils oil ON oil.id = mhis.oil_id\n INNER JOIN\n carmodel_oils cmod_oil ON cmod_oil.carmodel_id = cmod.id AND cmod_oil.oil_id = oil.id\n \").where(\"\n vehicle_dailies.vehicle_id = '#{@machine_historic.vehicle_id}'\n \").group(\"\n mhis.id, mhis.oil_id\n \").find(:first)\n \n if @machine_initial.blank?\n @machine_historic.hour_initial = \"0\"\n elsif @machine_initial.km.blank?\n @machine_historic.hour_initial = @machine_initial.hour_sum\n else\n @machine_item = CarmodelOil.find(:first, :conditions => [\"carmodel_id = '#{@machine_historic.vehicle.carmodel_id}' AND oil_id = '#{@machine_historic.oil_id}'\"])\n @machine_historic.hour_initial = @machine_initial.km_sum.to_f * @machine_item.hour.to_f / @machine_item.km.to_f + @machine_initial.hour_sum.to_f\n end\n \n respond_to do |format|\n if @machine_historic.save\n format.html { redirect_to(@machine_historic, :notice => 'Vehicle historic was successfully created.') }\n format.xml { render :xml => @machine_historic, :status => :created, :location => @machine_historic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @machine_historic.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_status_controls\n @control_help_window.add_control(Vocab::MODIFY, Input::Keys::A) \n @control_help_window.add_control(Vocab::BACK, Input::Keys::B)\n @control_help_window.add_control(Vocab::CHANGE_ACTOR, Input::Keys::L, Input::Keys::R)\n end",
"def create_chronics\n\t\tcreate_influenza_data\n\tend",
"def create\n @vacation_hours_event = VacationHoursEvent.new(vacation_hours_event_params)\n\n respond_to do |format|\n if @vacation_hours_event.save\n format.html { redirect_to vacation_hours_events_path, notice: 'Vacation hours event was successfully created.' }\n format.json { render :show, status: :created, location: @vacation_hours_event }\n else\n format.html { render :new }\n format.json { render json: @vacation_hours_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_vacation_day\n @request = Request.new\n\n @request.user_id = current_user.id\n @request.allotment_id = params[:allotment_id]\n @request.length = params[:length].gsub(\"_\",\" \").downcase\n @request.request_type = \"vacation\"\n save_status = @request.save\n\n if save_status == true\n redirect_to(\"/schedule_vacation\", :notice => \"Request updated successfully.\")\n end\n end",
"def adjust_carry_forwards\n @public_holiday_collection.each do |ph|\n if ph.must_be_taken_after?\n new_date = next_working_day_after(ph.date)\n @public_holiday_hash.delete(ph.date)\n ph.adjust_date(new_date)\n @public_holiday_hash[new_date] = ph\n elsif ph.must_be_taken_before?\n new_date = last_working_day_before(ph.date)\n @public_holiday_hash.delete(ph.date)\n ph.adjust_date(new_date)\n @public_holiday_hash[new_date] = ph\n end\n\n end\n end",
"def set_flds\n self.status = 'active' if status.blank?\n self.status = 'scheduled' if has_appt? && !is_completed?\n self.status = 'completed' if is_completed?\n end",
"def set_vacancy\n @vacancy = Vacancy.find(params[:id])\n end",
"def show\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daylight }\n end\n end",
"def form_escolher\n lst_from.select 'London'\n lst_on.select 'December'\n lst_month.select '20'\n lst_arriving.select 'Acapulco'\n lst_returning.select 'October'\n lst_month_returning.select '21'\n check_port.click\n lst_airline.select 'Blue Skies Airlines'\n end",
"def set_add_hour\n @add_hour = AddHour.find(params[:id])\n end",
"def init_calendar\n @cal = Icalendar::Calendar.new\n @cal.prodid = \"DoC Timetable\"\n set_calendar_name\n set_calendar_timezones\n end",
"def timezone=(timezone)\n validator = EnumAttributeValidator.new('String', [\"Pacific/Niue\", \"Pacific/Pago_Pago\", \"Pacific/Honolulu\", \"Pacific/Rarotonga\", \"Pacific/Tahiti\", \"Pacific/Marquesas\", \"America/Anchorage\", \"Pacific/Gambier\", \"America/Los_Angeles\", \"America/Tijuana\", \"America/Vancouver\", \"America/Whitehorse\", \"Pacific/Pitcairn\", \"America/Dawson_Creek\", \"America/Denver\", \"America/Edmonton\", \"America/Hermosillo\", \"America/Mazatlan\", \"America/Phoenix\", \"America/Yellowknife\", \"America/Belize\", \"America/Chicago\", \"America/Costa_Rica\", \"America/El_Salvador\", \"America/Guatemala\", \"America/Managua\", \"America/Mexico_City\", \"America/Regina\", \"America/Tegucigalpa\", \"America/Winnipeg\", \"Pacific/Galapagos\", \"America/Bogota\", \"America/Cancun\", \"America/Cayman\", \"America/Guayaquil\", \"America/Havana\", \"America/Iqaluit\", \"America/Jamaica\", \"America/Lima\", \"America/Nassau\", \"America/New_York\", \"America/Panama\", \"America/Port-au-Prince\", \"America/Rio_Branco\", \"America/Toronto\", \"Pacific/Easter\", \"America/Caracas\", \"America/Asuncion\", \"America/Barbados\", \"America/Boa_Vista\", \"America/Campo_Grande\", \"America/Cuiaba\", \"America/Curacao\", \"America/Grand_Turk\", \"America/Guyana\", \"America/Halifax\", \"America/La_Paz\", \"America/Manaus\", \"America/Martinique\", \"America/Port_of_Spain\", \"America/Porto_Velho\", \"America/Puerto_Rico\", \"America/Santo_Domingo\", \"America/Thule\", \"Atlantic/Bermuda\", \"America/St_Johns\", \"America/Araguaina\", \"America/Argentina/Buenos_Aires\", \"America/Bahia\", \"America/Belem\", \"America/Cayenne\", \"America/Fortaleza\", \"America/Godthab\", \"America/Maceio\", \"America/Miquelon\", \"America/Montevideo\", \"America/Paramaribo\", \"America/Recife\", \"America/Santiago\", \"America/Sao_Paulo\", \"Antarctica/Palmer\", \"Antarctica/Rothera\", \"Atlantic/Stanley\", \"America/Noronha\", \"Atlantic/South_Georgia\", \"America/Scoresbysund\", \"Atlantic/Azores\", \"Atlantic/Cape_Verde\", \"Africa/Abidjan\", \"Africa/Accra\", \"Africa/Bissau\", \"Africa/Casablanca\", \"Africa/El_Aaiun\", \"Africa/Monrovia\", \"America/Danmarkshavn\", \"Atlantic/Canary\", \"Atlantic/Faroe\", \"Atlantic/Reykjavik\", \"Etc/GMT\", \"Europe/Dublin\", \"Europe/Lisbon\", \"Europe/London\", \"Africa/Algiers\", \"Africa/Ceuta\", \"Africa/Lagos\", \"Africa/Ndjamena\", \"Africa/Tunis\", \"Africa/Windhoek\", \"Europe/Amsterdam\", \"Europe/Andorra\", \"Europe/Belgrade\", \"Europe/Berlin\", \"Europe/Brussels\", \"Europe/Budapest\", \"Europe/Copenhagen\", \"Europe/Gibraltar\", \"Europe/Luxembourg\", \"Europe/Madrid\", \"Europe/Malta\", \"Europe/Monaco\", \"Europe/Oslo\", \"Europe/Paris\", \"Europe/Prague\", \"Europe/Rome\", \"Europe/Stockholm\", \"Europe/Tirane\", \"Europe/Vienna\", \"Europe/Warsaw\", \"Europe/Zurich\", \"Africa/Cairo\", \"Africa/Johannesburg\", \"Africa/Maputo\", \"Africa/Tripoli\", \"Asia/Amman\", \"Asia/Beirut\", \"Asia/Damascus\", \"Asia/Gaza\", \"Asia/Jerusalem\", \"Asia/Nicosia\", \"Europe/Athens\", \"Europe/Bucharest\", \"Europe/Chisinau\", \"Europe/Helsinki\", \"Europe/Istanbul\", \"Europe/Kaliningrad\", \"Europe/Kiev\", \"Europe/Riga\", \"Europe/Sofia\", \"Europe/Tallinn\", \"Europe/Vilnius\", \"Africa/Khartoum\", \"Africa/Nairobi\", \"Antarctica/Syowa\", \"Asia/Baghdad\", \"Asia/Qatar\", \"Asia/Riyadh\", \"Europe/Minsk\", \"Europe/Moscow\", \"Asia/Tehran\", \"Asia/Baku\", \"Asia/Dubai\", \"Asia/Tbilisi\", \"Asia/Yerevan\", \"Europe/Samara\", \"Indian/Mahe\", \"Indian/Mauritius\", \"Indian/Reunion\", \"Asia/Kabul\", \"Antarctica/Mawson\", \"Asia/Aqtau\", \"Asia/Aqtobe\", \"Asia/Ashgabat\", \"Asia/Dushanbe\", \"Asia/Karachi\", \"Asia/Tashkent\", \"Asia/Yekaterinburg\", \"Indian/Kerguelen\", \"Indian/Maldives\", \"Asia/Calcutta\", \"Asia/Kolkata\", \"Asia/Colombo\", \"Asia/Katmandu\", \"Antarctica/Vostok\", \"Asia/Almaty\", \"Asia/Bishkek\", \"Asia/Dhaka\", \"Asia/Omsk\", \"Asia/Thimphu\", \"Indian/Chagos\", \"Asia/Rangoon\", \"Indian/Cocos\", \"Antarctica/Davis\", \"Asia/Bangkok\", \"Asia/Hovd\", \"Asia/Jakarta\", \"Asia/Krasnoyarsk\", \"Asia/Saigon\", \"Indian/Christmas\", \"Antarctica/Casey\", \"Asia/Brunei\", \"Asia/Choibalsan\", \"Asia/Hong_Kong\", \"Asia/Irkutsk\", \"Asia/Kuala_Lumpur\", \"Asia/Macau\", \"Asia/Makassar\", \"Asia/Manila\", \"Asia/Shanghai\", \"Asia/Singapore\", \"Asia/Taipei\", \"Asia/Ulaanbaatar\", \"Australia/Perth\", \"Asia/Pyongyang\", \"Asia/Dili\", \"Asia/Jayapura\", \"Asia/Seoul\", \"Asia/Tokyo\", \"Asia/Yakutsk\", \"Pacific/Palau\", \"Australia/Adelaide\", \"Australia/Darwin\", \"Antarctica/DumontDUrville\", \"Asia/Magadan\", \"Asia/Vladivostok\", \"Australia/Brisbane\", \"Australia/Hobart\", \"Australia/Sydney\", \"Pacific/Chuuk\", \"Pacific/Guam\", \"Pacific/Port_Moresby\", \"Pacific/Efate\", \"Pacific/Guadalcanal\", \"Pacific/Kosrae\", \"Pacific/Norfolk\", \"Pacific/Noumea\", \"Pacific/Pohnpei\", \"Asia/Kamchatka\", \"Pacific/Auckland\", \"Pacific/Fiji\", \"Pacific/Funafuti\", \"Pacific/Kwajalein\", \"Pacific/Majuro\", \"Pacific/Nauru\", \"Pacific/Tarawa\", \"Pacific/Wake\", \"Pacific/Wallis\", \"Pacific/Apia\", \"Pacific/Enderbury\", \"Pacific/Fakaofo\", \"Pacific/Tongatapu\", \"Pacific/Kiritimati\"])\n unless validator.valid?(timezone)\n fail ArgumentError, \"invalid value for \\\"timezone\\\", must be one of #{validator.allowable_values}.\"\n end\n @timezone = timezone\n end",
"def index\n @traffics = Traffic.order(:state, monday_start: :desc)\n @traffics.each { |traffic|\n if traffic.state == \"published\"\n begin\n traffic.planed_dates = Calendar.planed_dates(30, :traffic, traffic.id)\n rescue Exception => e\n traffic.planed_dates = []\n\n end\n else\n traffic.planed_dates = []\n end\n }\n end",
"def update\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n if @daylight.update_attributes(daylight_params)\n format.html { redirect_to @daylight, notice: 'Daylight was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @daylight.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @events = Event.all\n\n file_names = Dir.glob('config/*.yml')\n exist = false\n file_names.each do |file_name|\n exist = true if(file_name == 'config/settings.local.yml')\n end\n holiday(params[:start], params[:end]) if !params[:start].nil? && !params[:end].nil? && exist\n end",
"def tbs_start_era\n create_windows_tb_era\n end",
"def before_connected_to_strava_at(tt = 8.hours)\n dt = connected_to_strava_at\n dt -= tt if dt\n dt\n end",
"def date_and_time(rule_name, info)\n\n # Get to the advanced page.\n self.goto_advanced(rule_name, info)\n \n # Get to the \"Date and Time\" page.\n begin\n @ff.link(:text, 'Date and Time').click\n self.msg(rule_name, :info, 'Date and Time', 'Reached page \\'Date and Time\\'.')\n rescue\n self.msg(rule_name, :error, 'Date and Time', 'Did not reach \\'Date and Time\\' page')\n return\n end\n \n # Check the key.\n if ( info.has_key?('section') &&\n info.has_key?('subsection') ) then\n # Right,go on.\n else\n self.msg(rule_name,:error,'date_and_time','Some key NOT found.')\n return\n end\n \n # Clock Set Add by Robin 2009.4.17\n if info.has_key?('action') \n case info['action']\n when 'Clock SET'\n @ff.link(:text, 'Clock Set').click\n # hour\n if info.key?('hour') \n @ff.text_field(:name, 'hour').value=(info['hour'])\n self.msg(rule_name, :info, 'date_and_time()->hour', 'hour= '+info['hour'])\n else\n self.msg(rule_name, :info, 'date_and_time()->hour', 'No hour key found')\n end\n # minute\n if info.key?('minute') \n @ff.text_field(:name, 'min').value=(info['minute'])\n self.msg(rule_name, :info, 'date_and_time()->minute', 'minute= '+info['minute'])\n else\n self.msg(rule_name, :info, 'date_and_time()->minute', 'No minute key found')\n end\n # sec\n if info.key?('sec') \n @ff.text_field(:name, 'sec').value=(info['sec'])\n self.msg(rule_name, :info, 'date_and_time()->sec', 'sec= '+info['sec'])\n else\n self.msg(rule_name, :info, 'date_and_time()->sec', 'No sec key found')\n end\n # year\n if info.key?('year')\n @ff.select_list(:id, 'year').select_value(info['year']) \n self.msg(rule_name, :info, 'date_and_time()->year', \"year = \"+info['year'])\n else\n self.msg(rule_name, :info, 'date_and_time()->year', 'year undefined')\n end\n # month\n if info.key?('month')\n case info['month']\n when 'Jan'\n @ff.select_list(:id, 'month').select_value('0') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Feb'\n @ff.select_list(:id, 'month').select_value('1') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Mar'\n @ff.select_list(:id, 'month').select_value('2') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Apr'\n @ff.select_list(:id, 'month').select_value('3') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'May'\n @ff.select_list(:id, 'month').select_value('4') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Jun'\n @ff.select_list(:id, 'month').select_value('5') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Jul'\n @ff.select_list(:id, 'month').select_value('6') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Aug'\n @ff.select_list(:id, 'month').select_value('7') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Sep'\n @ff.select_list(:id, 'month').select_value('8') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Oct'\n @ff.select_list(:id, 'month').select_value('9') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Nov'\n @ff.select_list(:id, 'month').select_value('10') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n when 'Dec'\n @ff.select_list(:id, 'month').select_value('11') \n self.msg(rule_name, :info, 'date_and_time()->month', \"month = \"+info['month'])\n else\n self.msg(rule_name, :info, 'date_and_time()->month', 'month undefined')\n end\n end\n # day\n if info.key?('day')\n @ff.select_list(:id, 'day').select_value(info['day']) \n self.msg(rule_name, :info, 'date_and_time()->day', \"day = \"+info['day'])\n else\n self.msg(rule_name, :info, 'date_and_time()->day', 'day undefined')\n end\n # click 'Apply' button to complete setup\n @ff.link(:text, 'Apply').click\n\tif not @ff.text.include?('Input Errors') then\n\t self.msg(rule_name,:info,'Set Time','SUCCESS')\n else\n\t @ff.tables.each do |t|\n\t\tif ( (t.text.include? 'value') and (not t.text.include? 'Input Errors')) then\n\t\t t.each do |row|\n\t\t\tif row.text.include? 'value' then\n\t\t\t self.msg(rule_name,:error,row[1].to_s.gsub(':',''),row[2]);\n\t\t\tend\n\t\t end\n\t\tend\n\t end\n end\n\treturn\n else\n self.msg(rule_name,:error,'Date and Time','Did NOT find the value in \\'action\\'.')\n return \n end # end of case \n end # end of if \n \n # \"Time Zone\"\n if info.has_key?('Time Zone')\n \n case info['Time Zone']\n \n when 'Other'\n \n # Set \"Other\"\n @ff.select_list(:name,'time_zone').select_value(\"\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone'])\n \n when 'Alaska_Time'\n \n # Set \"Alaska_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Alaska_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone'])\n \n when 'Central_Time'\n \n # Set \"Central_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Central_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone']) \n \n when 'Eastern_Time'\n \n # Set \"Eastern_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Eastern_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone']) \n \n when 'Greenwich_Mean_Time'\n \n # Set \"Greenwich_Mean_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Greenwich_Mean_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone']) \n \n when 'Hawaii_Time'\n \n # Set \"Hawaii_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Hawaii_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone']) \n \n when 'Mountain_Time'\n \n # Set \"Mountain_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Mountain_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone']) \n \n when 'Pacific_Time'\n \n # Set \"Pacific_Time\"\n @ff.select_list(:name,'time_zone').select_value(\"Pacific_Time\")\n self.msg(rule_name,:info,'Time Zone',info['Time Zone']) \n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'Date and Time','Did NOT find the value in \\'Time Zone\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # \"GMT Offset\"\n if info.has_key?('GMT Offset')\n \n # Is there?\n if not @ff.text.include?'GMT Offset'\n # Error here.\n self.msg(rule_name,:error,'Date and Time','No option \\'GMT Offset\\'.')\n return\n end\n \n # Set \"GMT Offset\"\n @ff.text_field(:name,'gmt_offset').set(info['GMT Offset'])\n self.msg(rule_name,:info,'GMT Offset',info['GMT Offset'])\n \n end\n \n # \"Daylight Enable\"\n if info.has_key?('Daylight Enable')\n \n case info['Daylight Enable']\n \n when 'on'\n \n # Set \"Daylight Enable\"\n @ff.checkbox(:name,'is_dl_sav').set\n self.msg(rule_name,:info,'Daylight Enable',info['Daylight Enable'])\n \n when 'off'\n \n # Clear \"Daylight Enable\"\n @ff.checkbox(:name,'is_dl_sav').clear\n self.msg(rule_name,:info,'Daylight Enable',info['Daylight Enable'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'date_and_time','Did NOT find the value in \\'Daylight Enable\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Start Month\"\n if info.has_key?('Start Month')\n \n case info['Start Month']\n \n when 'Jan'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"0\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Feb'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"1\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Mar'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"2\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Apr'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"3\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'May'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"4\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Jun'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"5\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Jul'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"6\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Aug'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"7\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Sep'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"8\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Oct'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"9\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Nov'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"10\")\n self.msg(rule_name,:info,'Start Month',info['Start Month'])\n \n when 'Dec'\n \n # Set \"Start Month\"\n @ff.select_list(:name,'dst_mon_start').select_value(\"11\")\n self.msg(rule_name,:info,'Start Month',info['Start Month']) \n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'','Did NOT find the value in \\'Start Month\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Start Date\"\n if info.has_key?('Start Date')\n \n case info['Start Date']\n \n when '1'\n @ff.select_list(:name,'dst_day_start').select_value(\"1\")\n when '2'\n @ff.select_list(:name,'dst_day_start').select_value(\"2\")\n when '3'\n @ff.select_list(:name,'dst_day_start').select_value(\"3\")\n when '4'\n @ff.select_list(:name,'dst_day_start').select_value(\"4\")\n when '5'\n @ff.select_list(:name,'dst_day_start').select_value(\"5\")\n when '6'\n @ff.select_list(:name,'dst_day_start').select_value(\"6\")\n when '7'\n @ff.select_list(:name,'dst_day_start').select_value(\"7\")\n when '8'\n @ff.select_list(:name,'dst_day_start').select_value(\"8\")\n when '9'\n @ff.select_list(:name,'dst_day_start').select_value(\"9\")\n when '10'\n @ff.select_list(:name,'dst_day_start').select_value(\"10\")\n when '11'\n @ff.select_list(:name,'dst_day_start').select_value(\"11\")\n when '12'\n @ff.select_list(:name,'dst_day_start').select_value(\"12\")\n when '13'\n @ff.select_list(:name,'dst_day_start').select_value(\"13\")\n when '14'\n @ff.select_list(:name,'dst_day_start').select_value(\"14\")\n when '15'\n @ff.select_list(:name,'dst_day_start').select_value(\"15\")\n when '16'\n @ff.select_list(:name,'dst_day_start').select_value(\"16\")\n when '17'\n @ff.select_list(:name,'dst_day_start').select_value(\"17\")\n when '18'\n @ff.select_list(:name,'dst_day_start').select_value(\"18\")\n when '19'\n @ff.select_list(:name,'dst_day_start').select_value(\"19\")\n when '20'\n @ff.select_list(:name,'dst_day_start').select_value(\"20\")\n when '21'\n @ff.select_list(:name,'dst_day_start').select_value(\"21\")\n when '22'\n @ff.select_list(:name,'dst_day_start').select_value(\"22\")\n when '23'\n @ff.select_list(:name,'dst_day_start').select_value(\"23\")\n when '24'\n @ff.select_list(:name,'dst_day_start').select_value(\"24\")\n when '25'\n @ff.select_list(:name,'dst_day_start').select_value(\"25\")\n when '26'\n @ff.select_list(:name,'dst_day_start').select_value(\"26\")\n when '27'\n @ff.select_list(:name,'dst_day_start').select_value(\"27\") \n when '28'\n @ff.select_list(:name,'dst_day_start').select_value(\"28\")\n when '29'\n @ff.select_list(:name,'dst_day_start').select_value(\"29\")\n when '30'\n @ff.select_list(:name,'dst_day_start').select_value(\"30\")\n when '31'\n @ff.select_list(:name,'dst_day_start').select_value(\"31\") \n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'','Did NOT find the value in \\'Start Date\\'.')\n return\n \n end # end of case\n \n self.msg(rule_name,:info,'Start Date',info['Start Date'])\n \n end # end of if \n\n # \"Start Hour\"\n if info.has_key?('Start Hour')\n \n # Set\n @ff.text_field(:name,'dst_hour_start').set(info['Start Hour'])\n self.msg(rule_name,:info,'Start Hour',info['Start Hour'])\n \n end \n \n # \"Start Minute\"\n if info.has_key?('Start Minute')\n \n # Set\n @ff.text_field(:name,'dst_min_start').set(info['Start Minute'])\n self.msg(rule_name,:info,'Start Minute',info['Start Minute'])\n \n end \n \n # \"End Month\"\n if info.has_key?('End Month')\n \n case info['End Month']\n \n when 'Jan'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"0\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Feb'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"1\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Mar'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"2\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Apr'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"3\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'May'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"4\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Jun'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"5\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Jul'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"6\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Aug'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"7\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Sep'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"8\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Oct'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"9\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Nov'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"10\")\n self.msg(rule_name,:info,'End Month',info['End Month'])\n \n when 'Dec'\n \n # Set \"End Month\"\n @ff.select_list(:name,'dst_mon_end').select_value(\"11\")\n self.msg(rule_name,:info,'End Month',info['End Month']) \n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'','Did NOT find the value in \\'End Month\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"End Date\"\n if info.has_key?('End Date')\n \n case info['End Date']\n \n when '1'\n @ff.select_list(:name,'dst_day_end').select_value(\"1\")\n when '2'\n @ff.select_list(:name,'dst_day_end').select_value(\"2\")\n when '3'\n @ff.select_list(:name,'dst_day_end').select_value(\"3\")\n when '4'\n @ff.select_list(:name,'dst_day_end').select_value(\"4\")\n when '5'\n @ff.select_list(:name,'dst_day_end').select_value(\"5\")\n when '6'\n @ff.select_list(:name,'dst_day_end').select_value(\"6\")\n when '7'\n @ff.select_list(:name,'dst_day_end').select_value(\"7\")\n when '8'\n @ff.select_list(:name,'dst_day_end').select_value(\"8\")\n when '9'\n @ff.select_list(:name,'dst_day_end').select_value(\"9\")\n when '10'\n @ff.select_list(:name,'dst_day_end').select_value(\"10\")\n when '11'\n @ff.select_list(:name,'dst_day_end').select_value(\"11\")\n when '12'\n @ff.select_list(:name,'dst_day_end').select_value(\"12\")\n when '13'\n @ff.select_list(:name,'dst_day_end').select_value(\"13\")\n when '14'\n @ff.select_list(:name,'dst_day_end').select_value(\"14\")\n when '15'\n @ff.select_list(:name,'dst_day_end').select_value(\"15\")\n when '16'\n @ff.select_list(:name,'dst_day_end').select_value(\"16\")\n when '17'\n @ff.select_list(:name,'dst_day_end').select_value(\"17\")\n when '18'\n @ff.select_list(:name,'dst_day_end').select_value(\"18\")\n when '19'\n @ff.select_list(:name,'dst_day_end').select_value(\"19\")\n when '20'\n @ff.select_list(:name,'dst_day_end').select_value(\"20\")\n when '21'\n @ff.select_list(:name,'dst_day_end').select_value(\"21\")\n when '22'\n @ff.select_list(:name,'dst_day_end').select_value(\"22\")\n when '23'\n @ff.select_list(:name,'dst_day_end').select_value(\"23\")\n when '24'\n @ff.select_list(:name,'dst_day_end').select_value(\"24\")\n when '25'\n @ff.select_list(:name,'dst_day_end').select_value(\"25\")\n when '26'\n @ff.select_list(:name,'dst_day_end').select_value(\"26\")\n when '27'\n @ff.select_list(:name,'dst_day_end').select_value(\"27\") \n when '28'\n @ff.select_list(:name,'dst_day_end').select_value(\"28\")\n when '29'\n @ff.select_list(:name,'dst_day_end').select_value(\"29\")\n when '30'\n @ff.select_list(:name,'dst_day_end').select_value(\"30\")\n when '31'\n @ff.select_list(:name,'dst_day_end').select_value(\"31\") \n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'','Did NOT find the value in \\'End Date\\'.')\n return\n \n end # end of case\n \n self.msg(rule_name,:info,'End Date',info['End Date'])\n \n end # end of if \n\n # \"End Hour\"\n if info.has_key?('End Hour')\n \n # Set\n @ff.text_field(:name,'dst_hour_end').set(info['End Hour'])\n self.msg(rule_name,:info,'End Hour',info['End Hour'])\n \n end \n \n # \"End Minute\"\n if info.has_key?('End Minute')\n \n # Set\n @ff.text_field(:name,'dst_min_end').set(info['End Minute'])\n self.msg(rule_name,:info,'End Minute',info['End Minute'])\n \n end \n \n # \"Offset\"\n if info.has_key?('Offset')\n \n # Set\n @ff.text_field(:name,'dst_offset').set(info['Offset'])\n self.msg(rule_name,:info,'Offset',info['Offset'])\n \n end \n \n # \"Automatic Enabled\"\n if info.has_key?('Automatic Enabled')\n \n case info['Automatic Enabled']\n \n when 'on'\n \n # Set \"Automatic Enabled\"\n @ff.checkbox(:name,'is_tod_enabled').set\n self.msg(rule_name,:info,'Automatic Enabled',info['Automatic Enabled'])\n \n when 'off'\n \n # Clear \"Automatic Enabled\"\n @ff.checkbox(:name,'is_tod_enabled').clear\n self.msg(rule_name,:info,'Automatic Enabled',info['Automatic Enabled'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'Date and Time','Did NOT find the value in \\'Automatic Enabled\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Time Of Day\"\n if info.has_key?('Time Of Day')\n \n case info['Time Of Day']\n \n when 'on'\n \n # Set \"Time Of Day\"\n @ff.radio(:id,'tod_prot_type_1').set\n self.msg(rule_name,:info,'Time Of Day',info['Time Of Day'])\n \n when 'off'\n \n # Clear \"Time Of Day\"\n @ff.radio(:id,'tod_prot_type_1').clear\n self.msg(rule_name,:info,'Time Of Day',info['Time Of Day'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'Date and Time','Did NOT find the value in \\'Time Of Day\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n # \"Network Time Protocol\"\n if info.has_key?('Network Time Protocol')\n \n case info['Network Time Protocol']\n \n when 'on'\n \n # Set \"Network Time Protocol\"\n @ff.radio(:id,'tod_prot_type_2').set\n self.msg(rule_name,:info,'Network Time Protocol',info['Network Time Protocol'])\n \n when 'off'\n \n # Clear \"Network Time Protocol\"\n @ff.radio(:id,'tod_prot_type_2').clear\n self.msg(rule_name,:info,'Network Time Protocol',info['Network Time Protocol'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'Date and Time','Did NOT find the value in \\'Network Time Protocol\\'.')\n return\n \n end # end of case\n \n end # end of if \n\n # \"Update Every\"\n if info.has_key?('Update Every')\n \n #\n @ff.text_field(:name,'tod_update_period').set(info['Update Every'])\n self.msg(rule_name,:info,'Update Every',info['Update Every'])\n \n end \n \n # \"Sync Now\"\n if info.has_key?('Sync Now')\n \n case info['Sync Now']\n \n when 'on'\n \n # Set \"Sync Now\"\n @ff.link(:text,'Sync Now').click\n @ff.wait\n self.msg(rule_name,:info,'Sync Now',info['Sync Now'])\n \n when 'off'\n \n # Clear \"Sync Now\"\n # Do nothing here.\n self.msg(rule_name,:info,'Sync Now',info['Sync Now'])\n \n else\n \n # Wrong here\n self.msg(rule_name,:error,'Date and Time','Did NOT find the value in \\'Sync Now\\'.')\n return\n \n end # end of case\n \n end # end of if \n \n if info.has_key?('Remove Time Server')\n\t@ff.links.each do |l|\n\t if ( l.href.to_s.include? 'remove_time_server') then\n\t\t@ff.link(:href,l.href.to_s).click\n\t end\n\tend\n end\n if info.has_key?('Add Time Server')\n\t@ff.link(:href,'javascript:mimic_button(\\'add_time_server: ...\\', 1)').click\n\t@ff.text_field(:name,'tod_server').value = info['Add Time Server']\n\t@ff.link(:text,'Apply').click\n end\n \n if info.has_key?('Add Multi Time Servers')\n \tfor i in 0...info['Add Multi Time Servers'].to_i\n\t @ff.link(:href,'javascript:mimic_button(\\'add_time_server: ...\\', 1)').click\n\t @ff.text_field(:name,'tod_server').value = \"ntp.testurl\" + i.to_s + \".com\"\n\t @ff.link(:text,'Apply').click\n\tend\n end\n\n \n if info.has_key?('Read Sync Status')\n\t@ff.tables.each do |t|\n\t if ( (t.text.include? 'Status') and (t.text.include? 'Time Server') and (t.row_count > 5)) then\n\t\tt.each do |row|\n\t\t if row.text.include? 'Status' then\n\t\t\tself.msg(rule_name,:info,row[1].to_s.gsub(':',''),row[2])\t\n\t\t end\n\t\tend\n\t end\n\tend\n end\n\n # Apply for the change\n @ff.link(:text,'Apply').click\n \n # Output the result\n if not @ff.text.include?('Input Errors') then\n\tself.msg(rule_name,:info,'Date and Time','SUCCESS')\n else\n\t@ff.tables.each do |t|\n\t if ( (t.text.include? 'value') and (not t.text.include? 'Input Errors')) then\n\t\tt.each do |row|\n\t\t if row.text.include? 'value' then\n\t\t\tself.msg(rule_name,:error,row[1].to_s.gsub(':',''),row[2])\n\t\t end\n\t\tend\n\t end\n\tend\n end\n \n end"
] | [
"0.71322644",
"0.5209009",
"0.5202599",
"0.5136928",
"0.5112874",
"0.5109905",
"0.4953279",
"0.49216655",
"0.49124262",
"0.48623702",
"0.4854162",
"0.48344964",
"0.47726038",
"0.4744203",
"0.47417986",
"0.47315714",
"0.47222507",
"0.46913967",
"0.4673408",
"0.46558735",
"0.46505213",
"0.46459463",
"0.4637779",
"0.4637779",
"0.46262956",
"0.46082819",
"0.45961088",
"0.45913056",
"0.45757276",
"0.45744005",
"0.4568864",
"0.4560808",
"0.45521423",
"0.4535703",
"0.45341802",
"0.45288345",
"0.45273197",
"0.4520539",
"0.4511097",
"0.45109624",
"0.4503701",
"0.44909018",
"0.4486792",
"0.4479575",
"0.4471764",
"0.44687298",
"0.44661483",
"0.4459208",
"0.44575876",
"0.4457029",
"0.44535983",
"0.4444009",
"0.44414398",
"0.4437208",
"0.4434453",
"0.44339445",
"0.4431147",
"0.44299287",
"0.4423333",
"0.4407438",
"0.44059122",
"0.44037366",
"0.44032627",
"0.43978086",
"0.43917868",
"0.43881997",
"0.43862557",
"0.43845615",
"0.43825462",
"0.43779722",
"0.4375682",
"0.43730953",
"0.43730953",
"0.43730953",
"0.43730953",
"0.43730953",
"0.43730953",
"0.4358391",
"0.43525752",
"0.43482667",
"0.43446717",
"0.43441084",
"0.43435442",
"0.4343143",
"0.43427578",
"0.43414024",
"0.43398377",
"0.4338032",
"0.43324214",
"0.43223384",
"0.43160784",
"0.431482",
"0.4311356",
"0.43104926",
"0.43088397",
"0.43063903",
"0.43050754",
"0.43009248",
"0.42987984",
"0.42946747"
] | 0.70055264 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_recipe
@recipe = Recipe.find params[:id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def default_action; end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def call\n setup_context\n super\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.5330087",
"0.5311993",
"0.5297402",
"0.5296789",
"0.52957207",
"0.52596015",
"0.5245442",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5237084",
"0.5235431",
"0.5231888",
"0.5226663",
"0.52220625",
"0.5217086",
"0.52137345",
"0.5208314",
"0.5205469",
"0.5175606",
"0.5174914",
"0.5173361",
"0.51662856",
"0.5161792",
"0.51572216",
"0.5153063",
"0.5152982",
"0.5152632",
"0.51435786",
"0.5139829",
"0.51346594",
"0.511372",
"0.511372",
"0.51136476",
"0.51083213",
"0.5108011",
"0.5091935",
"0.5089297",
"0.5081576",
"0.50807106",
"0.50656676",
"0.50548106",
"0.50537366",
"0.505074",
"0.505074",
"0.5033361",
"0.5025158",
"0.5020441",
"0.5015611",
"0.50142473",
"0.5000281",
"0.50001067",
"0.49989453",
"0.4989465",
"0.4989465",
"0.4985425",
"0.49805096",
"0.49795893",
"0.49783278",
"0.49676263",
"0.49656346",
"0.49579078",
"0.4955427",
"0.49554235",
"0.49536413",
"0.49523768",
"0.49457142",
"0.49433607",
"0.4933641",
"0.49320185",
"0.49265638",
"0.49262375",
"0.49259067",
"0.4922456",
"0.49201223",
"0.49165115",
"0.49158815",
"0.49151883",
"0.49149552",
"0.4914386"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def recipe_params
params.require(:recipe).permit(:title, :ingredients, :instructions, :category_id, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289145",
"0.62875307",
"0.6280997",
"0.62420976",
"0.62388235",
"0.6216686",
"0.62122375",
"0.6208949",
"0.619173",
"0.6176307",
"0.6173907",
"0.6170346",
"0.616111",
"0.6150513",
"0.6150023",
"0.61446756",
"0.6120429",
"0.6112975",
"0.6104845",
"0.6102966",
"0.6087884",
"0.6079323",
"0.60699135",
"0.60602236",
"0.60191786",
"0.60170597",
"0.60100305",
"0.6009527",
"0.60052776",
"0.60052776",
"0.600042",
"0.5999317",
"0.59933805",
"0.5991528",
"0.5991221",
"0.5990094",
"0.5979497",
"0.5966058",
"0.5958738",
"0.59579456",
"0.5957759",
"0.5956938",
"0.5951788",
"0.59511644",
"0.59423065",
"0.59373474",
"0.59361076",
"0.59361076",
"0.59331447",
"0.5928005",
"0.5924882",
"0.5924011",
"0.59169155",
"0.5908037",
"0.5907541",
"0.59061426",
"0.59056246",
"0.5897408",
"0.58960444",
"0.58951247",
"0.5893136",
"0.5892312",
"0.5890385",
"0.58853275",
"0.58801144",
"0.58784765",
"0.5872648",
"0.58682626",
"0.5867028",
"0.58661693",
"0.586578",
"0.58643955",
"0.5863193",
"0.58609086",
"0.5859997",
"0.5858935",
"0.5858632",
"0.5853379",
"0.5852741",
"0.584806",
"0.5847703"
] | 0.0 | -1 |
Generate a planet based on user's inputs | def generate_planet
puts "\nLet's create a planet from scratch."
print "Please enter its name first: "
name = gets.chomp
print "What's its diameter of this planet in km? "
diameter = gets.chomp.to_f
print "What's its mass in kg? (example of input format: 3.30 x 10^23 ) "
mass = gets.chomp
print "What's the year length of this planet in days? "
yr_length = gets.chomp.to_f
print "What's the distance from the sun to this planet in km? "
dis_from_sun = gets.chomp.to_f
print "How many moons does this planet have? Enter 0 if there is none. "
moons = gets.chomp.to_i
planet = Planet.new({"name" => name, "diameter" => diameter, "mass" => mass, "yr_length" => yr_length, "dis_from_sun" => dis_from_sun, "moons" => moons})
return planet
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_planet()\n puts \"\\nAdding planet. Please tell me more about this planet.\"\n \n print \"Enter the planet name: \"\n name = gets.chomp.capitalize\n \n print \"\\nEnter the planet color: \"\n color = gets.chomp.downcase\n \n print \"\\nEnter planet mass in kg: \"\n mass_kg = gets.chomp.to_f\n \n print \"\\nEnter planet's distance from the sun in km: \"\n distance_from_sun_km = gets.chomp.to_f\n \n print \"\\nEnter a fun fact about the planet: \"\n fun_fact = gets.chomp\n \n return Planet.new(name, color, mass_kg, distance_from_sun_km, fun_fact)\n end",
"def create_planet(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\n return Planet.new(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\nend",
"def define_new_planet\n print \"\\nWhat is the name of the planet? \"\n planet_name = gets.chomp.capitalize\n print \"What is the diameter of #{planet_name} (in miles)? \"\n planet_diameter = gets.chomp.to_i\n print \"What is #{planet_name}'s distance from the sun (in millions of miles): \"\n planet_distance_from_sun = gets.chomp.to_f\n print \"What is the #{planet_name}'s year length (in Earth years)? \"\n planet_year_length = gets.chomp.to_f\n print \"How many moon's does #{planet_name} have? \"\n planet_moons = gets.chomp.to_i\n return new_planet = Planet.new(planet_name, planet_diameter, planet_distance_from_sun, planet_year_length, planet_moons)\nend",
"def create_planet\n puts \"\\nPlease input the following information about your new planet:\"\n\n puts \"Name of Planet:\"\n new_planet_name = gets.chomp.capitalize\n\n puts \"Distance from sun (in million km):\"\n new_planet_distance_from_sun = gets.chomp.to_i\n\n puts \"Year length (in days):\"\n new_planet_year_length = gets.chomp.to_i\n\n puts \"Diameter (in km):\"\n new_planet_diameter = gets.chomp.to_i\n\n puts \"Affiliated Zodiac Sign\"\n new_planet_zodiac = gets.chomp.capitalize\n\n puts \"Number of moons:\"\n new_planet_num_moons = gets.chomp.to_i\n\n return Planet.new(new_planet_name, new_planet_distance_from_sun, new_planet_year_length, new_planet_diameter, new_planet_zodiac, new_planet_num_moons)\nend",
"def gen_planet(class_map)\n class_map[\"colour\"] = PLANET_COLOURS[class_map[\"type\"].downcase]\n text = \"//#{class_map[\"package\"]} class: #{class_map[\"name\"]}\n#{class_map[\"indexed_name\"]}.setValues({\n name: \\\"#{class_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{class_map[\"radius\"]+0.01}, 10, 10),\n material: new THREE.MeshLambertMaterial({emissive: 0x888888, color: #{class_map[\"colour\"]}, map: planet_texture}),\n origin: #{class_map[\"package\"]}, \n orbitradx: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{class_map[\"orbit\"]}, \n orbitrady: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{class_map[\"orbit\"]}, \n #{(Random.rand(2) == 0)? \"ysin: false\" : \"xsin:false\"},\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01,\n tfactor: #{1 + Random.rand}});\ncelestials[celestials.length] = #{class_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def user_planet(solar_system)\n puts \"Your new planet will need a name: \"\n name = gets.chomp\n puts \"Tell me more about planet #{name}! Just hit return (enter) on your keyboard if don't know the value.\"\n puts \"Position from its star (star is position 0): \"\n position = gets.chomp\n puts \"Mass: \"\n mass = gets.chomp\n puts \"Radius: \"\n radius = gets.chomp\n puts \"Orbital Period (days to get around the star once): \"\n orbital_period = gets.chomp\n star = solar_system\n\n user_planet = Planet.new(name, position, mass, radius, orbital_period, star)\n end",
"def create_planet\n new_planet ={}\n\n print \"\\nWhat is the name of the planet? \"\n new_planet[:name] = gets.chomp.downcase\n\n print \"How old is #{new_planet[:name].each_first_letters} in Earth years? \"\n new_planet[:age] = gets.chomp.to_i\n\n print \"What is the size of #{new_planet[:name].each_first_letters}? \"\n new_planet[:size] = gets.chomp\n\n print \"How many visitors does #{new_planet[:name].each_first_letters} get? \"\n new_planet[:visitor_count] = gets.chomp\n\n print \"Who or what are #{new_planet[:name].each_first_letters} inhabitants? \"\n new_planet[:inhabitants] = gets.chomp\n\n new_planet = Planet.new(new_planet)\n\n return new_planet\nend",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def create_planet(array_of_planets)\n puts \"Tell us some information about your planet.\"\n print \"Name: \"\n name = gets.chomp\n print \"Length of Year: \"\n year_length = gets.chomp\n print \"Distance from the Sun: \"\n distance_from_sun = gets.chomp\n puts \"We have found that most planets known to humankind share certain characteristics. If the given information is true of your planet, type YES. If its not, give us the correct information for your planet.\"\n puts \"Language: Meowish\"\n language = gets.chomp\n if language == \"YES\"\n language = \"Meowish\"\n else\n language = language\n end\n puts \"Inhabitants: Cats\"\n inhabitants = gets.chomp\n if inhabitants == \"YES\"\n inhabitants = \"Cats\"\n else\n inhabitants = inhabitants\n end\n puts \"Primary Export: Catnip\"\n primary_export = gets.chomp\n if primary_export == \"YES\"\n primary_export = \"Catnip\"\n else\n primary_export = primary_export\n end\n array_of_planets << Planet.new(name, year_length, distance_from_sun, language: language, inhabitants: inhabitants, primary_export: primary_export)\nend",
"def create_user_planet\n puts \"What do you call your planet?:\"\n user_planet_name = gets.chomp\n\n puts \"What is the radius of your planet?:\"\n user_planet_radius = gets.chomp\n\n puts \"What is the length of day for #{user_planet_name}?:\"\n user_planet_lod = gets.chomp\n\n puts \"How far away is #{user_planet_name} from the sun?:\"\n user_planet_distance_sun = gets.chomp\n\n puts \"What is the year length?:\"\n user_planet_year_length = gets.chomp\n\n\n puts \"What is the mass for #{user_planet_name}?:\"\n user_planet_mass = gets.chomp\n\n user_planet = Planets.new(user_planet_name, user_planet_radius, user_planet_lod, user_planet_distance_sun, user_planet_year_length, user_planet_mass)\nreturn user_planet\nend",
"def add_planet_from_user\n print \"What is the name of the planet you would like to add? \"\n name = gets.chomp.capitalize\n\n print \"What color is the planet? \"\n color = gets.chomp.downcase\n\n print \"What is the mass of the planet in kilograms? \"\n mass = gets.chomp.to_i\n\n print \"How far away is the planet from the sun in kilometers? \"\n distance = gets.chomp.to_i\n\n print \"Let's add a fun fact about the planet! Complete the sentence. #{name}..\"\n fact = gets.chomp.downcase\n\n new_planet = Planet.new(name, color, mass, distance, fact)\n return new_planet\n end",
"def user_create_planet(solar_system)\n\tputs \"What is the name of the planet?\"\n\tuser_planet_name = gets.chomp.capitalize\n\n\tputs \"What color is #{user_planet_name}?\"\n\tuser_planet_color = gets.chomp.downcase\n\n\tputs \"What is its mass in kilograms?\"\n\tuser_planet_mass = verify_number(gets.chomp)\n\n\tputs \"What distance is the planet from the sun (in kilometers)?\"\n\tuser_planet_distance = verify_number(gets.chomp)\n\n\tputs \"Can you share a fun fact about #{user_planet_name}?\"\n\tuser_planet_fun_fact = gets.chomp.capitalize\n\n\tuser_planet = Planet.new(user_planet_name,user_planet_color, user_planet_mass,user_planet_distance,user_planet_fun_fact)\n\tsolar_system.add_planet(user_planet)\nend",
"def add_planet\n planet = Planet.new(get_planet_name, get_planet_distance, get_planet_rotation, get_planet_moons)\n return planet\nend",
"def add_new_planet our_solar_system\n puts \"Please enter the planet name\"\n planet_name = gets.chomp.capitalize\n print \"Please enter the length of time the planet takes to go around its star in earth days. ➤ \"\n year_length = gets.chomp.to_f.round(2)\n print \"Please enter how far is the planet from the sun in kilometers. ➤ \"\n distance_from_the_sun = gets.chomp.to_f.round(2)\n print \"Please enter the mass of a planet in kilograms. ➤ \"\n mass = gets.chomp\n print \"Please enter a diameter of the planet in kilometers. ➤ \"\n diameter = gets.chomp.to_f.round(2)\n print \"Please enter what is the composition of the atmosphere. ➤ \"\n atmospheric_components = gets.chomp\n\n new_planet = Planet.new(planet_name, year_length, distance_from_the_sun, mass, diameter, atmospheric_components)\n our_solar_system.add_planet(new_planet)\n puts \"New planet #{planet_name} is added.\".red\nend",
"def set_planet\n end",
"def manual_add_planet(sol)\n puts \"What is the name of the planet? \"\n name = valid_name(gets.chomp)\n puts \"What is the mass(unit: 1e+24 kg) of the planet #{name}?\"\n mass = valid_float(gets.chomp)\n puts \"What is the diameter(unit: km) of the planet #{name}?\"\n diameter = valid_float(gets.chomp).abs\n puts \"How many moons does the planet #{name} have?\"\n number_of_moons = valid_integer(gets.chomp)\n puts \"What is the distance(unit: 1e+6 km) between the sun and the planet #{name}?\"\n distance_from_the_sun = valid_float(gets.chomp).abs\n puts \"What is the rate of the solar rotation for the planet #{name} in Earth hours?\"\n rate_of_solar_rotation = valid_float(gets.chomp)\n puts \"What is the orbital period for the planet #{name} in Earth days?\"\n orbital_period = valid_float(gets.chomp)\n\n sol.add_planet(\n Planet.new(\n {\n name: name,\n mass: mass,\n diameter: diameter,\n number_of_moons: number_of_moons,\n distance_from_the_sun: distance_from_the_sun,\n rate_of_solar_rotation: rate_of_solar_rotation,\n orbital_period: orbital_period\n }\n )\n )\n return sol\nend",
"def planet\n fetch('stargate.planets')\n end",
"def build_system(name, planet)\n @planets[name] = planet\n end",
"def add_planet (solar_system)\n print\"Enter a planet name: \"\n planet_name = gets.chomp # ask them for the name of the planet they wish to learn about\n planet = solar_system.find_planet_by_name(planet_name)\n if planet.nil?\n # Ask the user for details about the planet (W3.3)\n puts\"What is the planet color? \"\n planet_color = gets.chomp #\n\n puts\"What is the planet mass kg?: \"\n planet_mass = gets.chomp.to_i #\n\n puts\"What is the planet distance from sun? \"\n planet_distance = gets.chomp.to_i #\n\n puts\" What is a fun fact about the planet?\"\n planet_fun_fact = gets.chomp #\n # Create a new instance of Planet with that info, and add to solar_system(W3.3)\n new_planet = Planet.new(planet_name, planet_color, planet_mass, planet_distance, planet_fun_fact)\n solar_system.add_planet(new_planet)\n puts \"Planet added with success!\"\n puts new_planet.summary\n else\n puts \"That planet already exists!\"\n puts planet.summary\n end\nend",
"def show_planet(number)\n selected = @solar_system[number-1]\n\n # Calculate planet related ages\n age = 4.5e9/(selected.rotation_time/12.0)\n age = age.to_i.to_s\n age = age.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n\n # Calculate the closest neighboring planets\n # Collect names and distances of planets\n distance_and_name = []\n @solar_system.length.times do |i|\n planet_info = {}\n planet_info[:name] = @solar_system[i].name\n planet_info[:distance] = @solar_system[i].distance_from_the_sun\n distance_and_name << planet_info\n end\n # Get only the distances and sort them\n planet_distances = []\n @solar_system.each do |planet|\n planet_distances << planet.distance_from_the_sun\n end\n ordered_planets = planet_distances.sort\n number_index = ordered_planets.index(selected.distance_from_the_sun).to_i\n\n # Find the select planet's distance neighbors (2)\n if (number_index+1) == @solar_system.length\n neighbor1_distance = 0\n neighbor1_difference = 0\n else\n neighbor1_distance = ordered_planets[(number_index+1)]\n neighbor1_difference = (selected.distance_from_the_sun - neighbor1_distance).abs.round(2)\n end\n if (number_index-1) < 0\n neighbor2_distance = 0\n neighbor2_difference = 0\n else\n neighbor2_distance = ordered_planets[(number_index-1)]\n neighbor2_difference = (selected.distance_from_the_sun - neighbor2_distance).abs.round(2)\n end\n neighbor1_name = \"\"\n neighbor2_name = \"\"\n distance_and_name.each do |planet|\n if neighbor1_distance == planet[:distance]\n neighbor1_name << planet[:name]\n end\n if neighbor2_distance == planet[:distance]\n neighbor2_name << planet[:name]\n end\n end\n if neighbor1_distance == 0 && neighbor2_distance == 0\n true_neighbor = \"not to be found\"\n true_distance = \"both infinity and negative infinity\"\n elsif neighbor1_distance == 0 && neighbor2_distance > 0\n true_neighbor = neighbor2_name\n true_distance = neighbor2_difference\n elsif neighbor2_distance == 0 && neighbor1_distance > 0\n true_neighbor = neighbor1_name\n true_distance = neighbor1_difference\n else\n true_neighbor = \"#{neighbor2_name} and #{neighbor1_name}\"\n true_distance = \"#{neighbor2_difference} and #{neighbor1_difference}\"\n end\n\n # Text summary shown to user\n text = \"\\nThe planet \\[#{selected.name}\\] is #{selected.distance_from_the_sun} Astronomical Units from the sun.\n \\rThe closest neighboring planet(s) is/are #{true_neighbor}, which is/are #{true_distance} AU away.\n \\rIt orbits the sun once every #{selected.rotation_time} Earth months, or #{(selected.rotation_time/12.0).round(2)} Earth years.\n \\rSince our sun is 4.5 billion Earth years old, this planet's age is #{age}!\n \\r#{selected.name} also enjoys #{selected.moon_count} moon(s) orbitin' around it.\\n\"\n return text\n end",
"def planet_info #(there's no parameter here)\n puts \"#{@name} has #{@orbital} days in one of its years, weighs #{@mass} earth, has #{@moons}, and is #{@distance_from_sun} million miles from the sun.\"\n end",
"def add_planet\n\t\tputs \"Would you like to add a planet? Enter Y/N\".colorize(:blue)\n\t\tanswer = gets.chomp.downcase\n\t\tif answer == \"y\"\n\t\t\tputs \"Great! Please enter the name of planet.\"\n\t\t\tname = gets.chomp\n\t\t\tputs \"Now enter the diameter of your planet.\"\n\t\t\tdiameter = gets.chomp\n\t\t\tputs \"What is the mass of your new planet?\"\n\t\t\tmass = gets.chomp\n\t\t\tputs \"How many moons?\"\n\t\t\tmoons = gets.chomp\n\t\t\tputs \"Is there life on your planet? Please enter \\\"Y\\\" or \\\"N\\\".\"\n\t\t\tlife = gets.chomp.downcase\n\t\t\t\tif life == \"y\"\n\t\t\t\t\tlife = true\n\t\t\t\telse \n\t\t\t\t\tlife = false\n\t\t\t\tend\n\t\t\tputs \"Finally, what is the solar rotation of your planet?\"\n\t\t\trotation = gets.chomp\n\t\t\t@new_planet = Planet.new(name: name, diameter: diameter, mass: mass, moons: moons, life: life, rotation: rotation)\n\t\t\t@planets.push(new_planet)\n\t\t\tputs \"Great! #{name} is born!\".colorize(:blue)\n\t\telse\n\t\t\tputs \"Fine. I didn't want your planets anyway.\".colorize(:blue)\n\t\tend\n\tend",
"def show_planets our_solar_system\n all_planets = our_solar_system.planets\n puts \"Choose which planet:\"\n all_planets.length.times do |index|\n puts \"#{index+1}: #{all_planets[index].name}\"\n end\n puts \"Which planet info you want\"\n planet_choice = gets.chomp.to_i\n if planet_choice >=1 && planet_choice <= all_planets.length\n # Display all the planet objects in array.\n puts all_planets[planet_choice - 1].print_planet_info\n # Local variable which is assigned the planet that is selected\n choosen_planet = all_planets[planet_choice -1]\n all_planets.length.times do |index|\n # Skips the selected planet\n if planet_choice - 1 != index\n # Output the distance from other planet.\n puts \"✹ The distance from #{all_planets[index].name} is #{choosen_planet.distance_from_the_planet(all_planets[index])} km.\".bold\n puts \"\"\n end\n end\n end\nend",
"def user_add_planet(solar_system)\n print \"What planet do you want to add?\"\n name = gets.chomp\n print \"what is the color of the planet?\"\n color = gets.chomp\n print \"what is the mass in kg of the planet? \"\n mass_kg = gets.chomp.to_i\n print \"what is the distance from the sun for the planet?\"\n distance_sun = gets.chomp.to_i\n print \"what is a fun fact about the planet?\"\n fun_fact= gets.chomp\n\n user_planet = Planet.new(name,color,mass_kg,distance_sun,fun_fact)\n solar_system.add_planets(user_planet)\n\nend",
"def add_planet(solar_system)\n print \"\\nPlease enter the following details about your planet.\\nPlanet name: \"\n name = gets.chomp\n print \"Planet color: \"\n color = gets.chomp\n print \"Planet mass (kg): \"\n mass = gets.chomp.to_i\n while mass <= 0\n print \"Please enter an integer greater than 0. Planet mass (kg): \"\n mass = gets.chomp.to_i\n end\n print \"Distance from star (km): \"\n distance = gets.chomp.to_i\n while distance <= 0\n print \"Please enter an integer greater than 0. Planet distance from star (kg): \"\n distance = gets.chomp.to_i\n end\n print \"Fun fact: \"\n fact = gets.chomp\n \n new_planet = Planet.new(name, color, mass, distance, fact)\n solar_system.add_planet(new_planet)\nend",
"def main\n solar_system = SolarSystem.new('Sol')\n pluto = Planet.new(\"Pluto\", \"Blue\", 1.309e22, 4.67e9,\n \"It's not really a planet!\")\n solar_system.add_planet(pluto)\n earth = Planet.new('Earth', 'blue-green', 5.972e24, 1.496e8,\n 'Only planet known to support life')\n solar_system.add_planet(earth)\n mars = Planet.new(\"Mars\", \"Red\", 6.39e23, 2.279e8,\n \"We may live on it someday\")\n solar_system.add_planet(mars)\n\n puts \"\\nWould you like to do:\\\n \\n(1) list the planets\\\n \\n(2) learn about planet details\\\n \\n(3) add a planet to the solar system\\\n \\n(4) exit?\"\n action = gets.chomp.downcase\n\n until action == \"exit\" || action.include?(\"4\")\n if action.include?(\"list\") || action.include?(\"1\")\n puts solar_system.list_planets\n elsif action.include?(\"details\") || action.include?(\"2\")\n puts \"\\nName a planet you wish to learn about.\"\n found_planet = solar_system.find_planet_by_name(gets.chomp.capitalize)\n if found_planet == nil\n puts \"This planet is not currently in our system. \" <<\n \"Consider adding this planet.\"\n else\n puts found_planet.summary\n end\n elsif action.include?(\"add\") || action.include?(\"3\")\n puts \"\\nPlease answer the following information:\"\n print \"Name:\"\n name = gets.chomp\n print \"Color:\"\n color = gets.chomp\n print \"Mass in km:\"\n mass = gets.chomp.to_f\n print \"Distance from sun in km:\"\n distance = gets.chomp.to_f\n print \"Fun fact:\"\n fun_fact = gets.chomp\n\n new_planet = Planet.new(name, color, mass, distance, fun_fact)\n solar_system.add_planet(new_planet)\n end\n\n puts \"\\nWould you like to do:\\\n \\n(1) list the planets\\\n \\n(2) learn about planet details\\\n \\n(3) add a planet to the solar system\\\n \\n(4) exit?\"\n action = gets.chomp.downcase\n end\n\nend",
"def planets()\n pseed = @seed.clone\n Enumerator.new do |yielder|\n loop do\n name, new_seed = planet_name(pseed)\n yielder.yield name\n break if new_seed==@seed\n pseed = new_seed\n end\n end\n end",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def add_a_planet(solar_system)\n print \"Please enter the planet name: \"\n name = gets.chomp\n print\"What is #{name}'s color? \"\n color = gets.chomp\n print \"What is the mass of #{name}? \"\n mass_kg = gets.chomp\n print \"What is the #{name}'s distance from the sun? \"\n distance_from_sun_km = gets.chomp\n print \"What's a fun fact about #{name}? \"\n fun_fact = gets.chomp\n new_planet = Planet.new(name, color, mass_kg, distance_from_sun_km, fun_fact)\n solar_system.add_planet(new_planet)\n puts\n return \"Here is the info you entered about this new planet: \\n\" + new_planet.summary\n end",
"def initialize\n\t\t@planets = [gallifrey, xander] # initialize hard coded planets\n\t\t#@planets.push(@new_planet) # adds new planets via user input to planets array\n\t\t@number_planets = @planets.length #counts planets by counting array elements\n\t\t@formation_year = rand(-3000000..2015)\n\t\t@age_of_system = 2015 - @formation_year\n\t\t\t\n\tend",
"def planet\n fetch('dune.planets')\n end",
"def add_planet(solar_system)\n# Ask the user for details about the planet\n print \"Enter the name of the planet: \"\n name = gets.chomp\n name = check_String(name)\n print \"Enter the color of the planet: \"\n color = gets.chomp\n color = check_String(color)\n print \"Enter the mass in kg: \"\n mass_kg = gets.chomp.to_i\n mass_kg = check_number(mass_kg)\n\n print \"Enter the distance from sun in km: \"\n distance_from_sun_km = gets.chomp.to_i\n distance_from_sun_km = check_number(distance_from_sun_km)\n print \"Enter a fun fact: \"\n fun_fact = gets.chomp\n fun_fact = check_String(fun_fact)\n# Create a new instance of Planet with that info\n # binding.pry\n planet_added = Planet.new(name, color, mass_kg, distance_from_sun_km,fun_fact)\n# Add it to the SolarSystem\n solar_system.add_planet(planet_added)\n return solar_system\nend",
"def add_initial_planets(solar_system)\n earth = Planet.new('Earth', 'blue-green', 5.972e24, 1.496e16, 'Only planet known to support life')\n cyborg = Planet.new('Cyborg', 'neon green', 10.993e24, 2.496e90, 'Humans have not yet discovered this planet' )\n mars = Planet.new('Mars', 'red', 9.972e24, 2.496e16, 'This planet was named after the Roman god of war')\n solar_system.add_planet(earth)\n solar_system.add_planet(cyborg)\n solar_system.add_planet(mars)\nend",
"def create_solar_system\n\n # Instantiate Solar System\n solar_system = SolarSystem.new('Sun')\n\n # Add instances of planets to instance of solar system\n mercury = Planet.new('Mercury','dark grey',3.30e23, 57.9, 'Is hot, but not too hot for ice')\n solar_system.add_planet(mercury)\n\n mars = Planet.new('Mars','pale yellow', 6.42e23, 227.9,'Had a thicker atmosphere in the past')\n solar_system.add_planet(mars)\n\n venus = Planet.new('Venus','pale yellow', 4.87e24, 108.2,'A day on Venus is longer than a year')\n solar_system.add_planet(venus)\n\n earth = Planet.new('Earth','blue',5.97e24, 149.6, 'Is the only planet known to support life!')\n solar_system.add_planet(earth)\n\n return solar_system\nend",
"def main\n solar_system = SolarSystem.new('Women of Code')\n\n earth = Planet.new(\"Earth\", \"Green\", 1000, 430, \"It's hot\")\n solar_system.add_planet(earth)\n\n bay = Planet.new(\"Bay\", \"Purple\", 4000, 342, \"Largest flea market capitol of the world\")\n solar_system.add_planet(bay)\n\n sasquatch = Planet.new(\"Sasquatch\", \"Brown\", 3400, 234, \"It's really fuzzy\")\n solar_system.add_planet(sasquatch)\n\n hammock = Planet.new(\"Hammock\", \"Rainbow\", 5646, 642, \"Everyone lives on a Hammock\")\n solar_system.add_planet(hammock)\n\n santa = Planet.new(\"Santa\", \"Ocean\", 1040, 378, \"The fountain of youth lives here\")\n solar_system.add_planet(santa)\n\n #test to check if planet exisist in solar_system\n # santaCruz = Planet.new(\"SantaCruz\", \"Dummy\", 4839, 034, \"There is no place like home\")\n # solar_system.add_planet(santaCruz)\n\n # found_planet = solar_system.find_planet_by_name(\"sdf\")\n # puts found_planet\n # # => #<Planet:0x00007fe7c2868ee8>\n # puts found_planet.summary\n\n #prompt user for what they would like to do in the SolarSystem program\n puts \"Please select what you would like to learn about Women of Code Solar System by number ex.(1)\"\n puts \"1. List Planets\\n2. Add Your Own Planet\\n3. Exit\"\n print \"Number: \"\n user_input = gets.chomp.to_i\n puts\n\n #selections of option based on user reponse\n #The number 3 will exit the program\n until user_input == 3\n\n #slection 1 prints the planets listed in solar_system\n if user_input == 1\n list = solar_system.list_planets\n puts list\n\n #prompt user to type the planet they are intersted in looking up\n #if planet is found the summary of the planet will be printed\n #reprompt user is the there input does not match a planet in the solar_system\n puts \"What Planet would you like to learn about? Please type your planet ex(Earth).\\n\\n\"\n print \"Planet: \"\n planet = gets.chomp\n found_planet = solar_system.find_planet_by_name(planet)\n if found_planet.class == Planet\n puts found_planet.summary\n end\n\n #user adds a planet to the solar_system program\n elsif user_input == 2\n puts \"What would you like to name your planet?\"\n name = gets.chomp\n puts \"What color(s) is your planet?\"\n color = gets.chomp\n puts \"Your planet Mass in Kg:\"\n mass_kg = gets.chomp\n puts \"Distance from the Sun\"\n distance_from_sum_km = gets.chomp\n puts \"Fun Facts\"\n fun_fact = gets.chomp\n\n new_planet = Planet.new(name, color, mass_kg, distance_from_sum_km, fun_fact)\n #stores planet in solar_system program for user to recall until they exit\n solar_system.add_planet(new_planet)\n end\n\n #reprompt user until they exit\n puts \"\\nPlease select what you would like to learn about Women of Code Solar System\"\n puts \"1. List Planets\\n2. Add Your Own Planet\\n3. Exit\"\n print \"Number: \"\n user_input = gets.chomp.to_i\n end\nend",
"def new_planet(planet)\n @planets[planet.name] = planet\n end",
"def planet_params\n params.require(:planet).permit(:name, :rotation_period, :orbital_period, :diameter, :climate, :gravity, :terrain, :surface_water, :population)\n end",
"def run_solar_system_program(solar_system)\n # method outside of any class that takes user input to create a new planet\n # then add it to the solar system\n def create_planet(solar_system)\n puts \"Alright! What is the name of your planet?\"\n name = gets.chomp.capitalize\n puts \"How many moons does #{name} have?\"\n moons = gets.chomp\n puts \"How many Earth years does it take to revolve around its star?\"\n year_length = gets.chomp\n puts \"How far is #{name} from its star in million miles? Please enter a number.\"\n distance_from_sun = gets.chomp\n puts \"How much mass does the planet have in kg?\"\n mass = gets.chomp\n puts \"What is the diameter measured in miles?\"\n diameter = gets.chomp\n puts \"Finally, does its name relate to any mythological dieties?\"\n diety = gets.chomp\n new_planet = {name: name, moons: moons, year_length: year_length, distance_from_sun: distance_from_sun, mass: mass, diameter: diameter, diety: diety}\n solar_system.add_planet(Planet.new(new_planet))\n end\n # method to select planet then print its attributes\n def planet_choice_and_details(the_solar_system)\n puts \"What planet would you like to learn about? Please enter the name.\"\n puts the_solar_system.return_planets\n planet_name = gets.chomp\n decoration\n puts the_solar_system.planet_information(planet_name)\n end\n\n # method to confirm user interest to continue\n # and give them opportunity to do another action\n def continue?\n decoration\n puts \"Do you want to learn about another planet? y or n?\"\n puts \"Or would you like to add your own planet? Enter any other key.\"\n yes_or_no = gets.chomp.downcase\n decoration\n return yes_or_no\n end\n\n # start of program that introduces the solar system and prompt user\n puts \"Welcome to this program about the #{solar_system.name}.\"\n puts \"The #{solar_system.name} is #{solar_system.solar_age} billion Earth years old.\"\n puts decoration\n puts \"Are you ready to learn about some planets? y or n\"\n puts \"Or would you like to add your own planet? Enter any other key.\"\n start_learning = gets.chomp.downcase\n decoration\n # loop the determines what the program does:\n # 1. presents list of planets and a chosen planets detailed_summary\n # 2. add a new planet to solar system\n # 3. ends program\n until start_learning == \"n\"\n if start_learning == \"y\"\n planet_of_choice = planet_choice_and_details(solar_system)\n start_learning = continue? # calling method to determine next step in program\n decoration\n elsif start_learning != \"n\"\n create_planet(solar_system)\n start_learning = continue? # calling method again\n decoration\n end\n end\n puts \"Bye now, go out and discover the stars.\"\nend",
"def pick_a_planet\n display_planet = nil\n puts \"\\nPlease choose from the following list of planets.\"\n planet_names = []\n @planets.each do |planet| # gets the names of the planets that currently exist in solar system\n planet_names << planet.name\n end\n puts planet_names\n\n # get planet choice and validate\n print \"\\nWhich planet would you like to \\\"learn\\\" more about? \"\n planet_choice = gets.chomp.capitalize\n planet_choice = planet_choice.gsub(\" \", \"\")\n while !planet_names.include? planet_choice\n print \"Sorry, which planet? \"\n planet_choice = gets.chomp.capitalize\n end\n\n # print the planet info for the chosen planet\n @planets.each do |planet|\n if planet.name == planet_choice\n puts planet.print_planet_data\n end\n end\n\n continue_or_quit\n end",
"def planet_choice_and_details(the_solar_system)\n puts \"What planet would you like to learn about? Please enter the name.\"\n puts the_solar_system.return_planets\n planet_name = gets.chomp\n decoration\n puts the_solar_system.planet_information(planet_name)\n end",
"def users_created_planet(solar_system)\n puts \"Let's add your planet! We need some information first.\"\n puts \"Please enter the name of your planet.\"\n user_planet = gets.chomp.capitalize\n puts \"What is the color of #{user_planet}?\"\n user_color = gets.chomp.capitalize\n puts \"#{user_color}, how glorious!\"\n puts \"What is the mass, or size of #{user_planet}?\"\n user_planet_size = gets.chomp.to_i\n puts \"Now that we know #{user_planet}'s color, and size, can you tell me how far away it is from you right now?\"\n user_distance = gets.chomp.to_i\n puts \"Perfect. Last info I need to create your planet: what is a fun fact about your planet?\"\n user_fun_fact = gets.chomp\n \n # added new instance of user's planet, along with details\n user_new_planet = Planet.new(user_planet, user_color, user_planet_size, user_distance, user_fun_fact)\n \n # added user's new planet to the solar_system\n solar_system.add_planet(user_new_planet)\nend",
"def gen_moon(method_map)\n text = \"//#{method_map[\"class\"]} function: #{method_map[\"name\"]}\nvar #{method_map[\"indexed_name\"]} = new Celestial({\n name: \\\"#{method_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{method_map[\"radius\"]+0.01}, 8, 8),\n material: new THREE.MeshLambertMaterial({emissive: 0x888888, color: 0xbb8800, map: planet_texture}),\n origin: #{method_map[\"class\"]},\n orbitradx: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{method_map[\"orbit\"]}, \n orbitrady: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{method_map[\"orbit\"]}, \n #{(Random.rand(2) == 0)? \"ysin: false\" : \"xsin:false\"},\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01,\n tfactor: #{2 + Random.rand * 2}});\ncelestials[celestials.length] = #{method_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def add_planet_by_name(name)\n planet = get_space_body_by_name(name)[0]\n Planet.new(planet)\n end",
"def look_up_planet (choice)\n @planets.each do |planet|\n if planet[:name] == choice\n return planet\n end\n end\n end",
"def main\n solar_system = SolarSystem.new('Sol')\n loop do\n # collects input from user\n puts \"Hello, you can choose to list planets, see planet details, add a planet or exit?\"\n puts \"Choose what you would like to do (list / details / exit / add): \"\n input = gets.chomp\n # stop if user decides to exit the program\n break if input == \"exit\"\n # prints a list of planets if the user chooses list -\n # This is where we use instance of solar system using list_planets method\n if input == \"list\"\n planet_list = solar_system.list_planets\n puts planet_list\n\n elsif input == \"details\"\n # This is where we collect name of planet from user\n print \"Name a planet: \"\n planet = gets.chomp.downcase\n # We use find_planet_by_name instance method of Solar System to find planet and print details\n found_planet = solar_system.find_planet_by_name(planet)\n if found_planet\n puts found_planet.summary\n else\n puts \"Planet not found.\"\n end\n end\n # Here we collect new information to add an imaginary new planet\n if input == \"add\"\n print \"Create an imaginary planet. Give your planet a name: \"\n new_planet_name = gets.chomp\n print \"Give your planet a color: \"\n color = gets.chomp\n print \"Give your planet a mass in kg (i.e 6 or 9 ): \"\n mass_kg = gets.chomp.to_i\n print \"Give your planet distance from sun in km (i.e 10 or 8): \"\n distance_from_sun_km = gets.chomp.to_i\n print \"Provide fun fact about your new planet: \"\n fun_fact = gets.chomp\n # adds an imaginary planet to planet list in solar system using the Planet and SolarSystem classes.\n new_planet = Planet.new(new_planet_name, color, mass_kg, distance_from_sun_km, fun_fact)\n solar_system.add_planet(new_planet)\n puts \"#{new_planet.name} has been added to list\"\n end\n end\n\nend",
"def main\n xandar = Planet.new(\"XANDAR\",\"aquamarine powder blue\", 6.39e23, 2.279e8,\n \"It's been known to host living creatures that are closely related to smurfs\")\n onurb = Planet.new(\"ONURB\", \"shades of lemon, light salmon, and honeydew\",\n 1.898e27, 7.785e8, \"It does not have a true surface, as the planet is mostly swirling gases and liquids\")\n\n solar_system = SolarSystem.new(\"Anirtak\")\n solar_system.add_planet(xandar)\n solar_system.add_planet(onurb)\n\n # loop until user quits\n user_play = \"Y\"\n while user_play == \"Y\"\n print \"Enter A, B, C, D or Q: \"\n user_input = gets.chomp.strip.upcase\n while user_input !='A' &&\n user_input != 'B' &&\n user_input != 'C' &&\n user_input != 'D' &&\n user_input != 'Q'\n print \"EEP. Please try again: \"\n user_input = gets.chomp.strip.upcase\n end\n list = solar_system.list_planets\n\n if user_input == 'A'\n puts list\n\n elsif user_input == 'B'\n puts \"Let's begin our wild adventure! \"\n puts \"What planet would you like to learn about?\"\n puts list\n print \"Please enter the name of the planet: \"\n user_planet = gets.chomp.strip.upcase\n found_planet = solar_system.find_planet_by_name(user_planet)\n\n if found_planet\n puts \"Your choice is OUT OF THIS WORLD! Here's everything you need to know about #{found_planet.name}\"\n puts found_planet.summary\n end\n\n elsif user_input == 'C'\n puts \"Let's make a planet!\"\n print \"What is the name of the planet? \"\n new_planet_name = gets.chomp.strip.upcase\n\n print \"What is #{new_planet_name}'s color: \"\n new_planet_color = gets.chomp.strip\n\n print \"What is #{new_planet_name}'s mass in kg? \"\n new_planet_mass = gets.chomp.strip.to_f\n while new_planet_mass <= 0 || new_planet_mass.to_s == \"0.0\"\n puts \"Invalid, please enter a positive number\"\n print \"What is #{new_planet_name}'s mass in kg? \"\n new_planet_mass = gets.chomp.strip.to_f\n end\n\n print \"What is #{new_planet_name}'s distance from the sun in km? \"\n new_planet_distance_sun = gets.chomp.strip.to_f\n while new_planet_distance_sun <= 0 || new_planet_distance_sun.to_s == \"0.0\"\n puts \"Invalid, please enter a positive number\"\n print \"What is #{new_planet_name}'s distance from the sun in km? \"\n new_planet_distance_sun = gets.chomp.strip.to_f\n end\n\n print \"What is a fun fact about #{new_planet_name}? \"\n new_planet_fact = gets.chomp.strip\n\n new_planet = Planet.new(new_planet_name, new_planet_color, new_planet_mass,\n new_planet_distance_sun, new_planet_fact)\n solar_system.add_planet(new_planet)\n\n elsif user_input == 'D'\n puts list\n puts \"Please choose two planets from the above list\"\n print \"Please enter the name of the first planet: \"\n user_first_planet = gets.chomp.strip.upcase\n print \"Please enter the name of the second_planet: \"\n user_second_planet = gets.chomp.strip.upcase\n\n first_user_planet_found = solar_system.find_planet_by_name(user_first_planet)\n second_user_planet_found = solar_system.find_planet_by_name(user_second_planet)\n\n if first_user_planet_found && second_user_planet_found\n puts solar_system.distance_between(first_user_planet_found, second_user_planet_found)\n end\n\n elsif user_input == 'Q'\n puts \"Thank you for playing! Come back again for another adventure!\"\n puts\n exit\n end\n\n puts \"Would you like to keep exploring (Y/N)?\"\n user_play = gets.chomp.upcase\n end\n\n puts \"Thank you for playing! Come back again for another adventure!\"\n exit\nend",
"def main\n moon = Planet.new('Moon','white', 3.972e24, 1.212e8, 'water-ice on surface')\n earth = Planet.new('Earth', 'blue-green', 5.972e24, 1.496e8, 'Only planet known to support life')\n mars = Planet.new('Mars', 'red-yellow', 9.972e24, 2.496e8, 'The second largest planet in this solar system')\n solar_system = SolarSystem.new('Sol')\n solar_system.add_planet(earth)\n solar_system.add_planet(moon)\n solar_system.add_planet(mars)\n\n puts \"Welcome to solar_system.\"\n puts \"What to do next?\\n1. List the planet\\n2. Planet details\\n3. Add Planet\\n4. Exit\\n\\n\"\n user_input = gets.chomp.to_i\n\n while user_input != 4\n if user_input == 1\n puts solar_system.list_planets\n puts \"\"\n elsif user_input == 2\n planet_details(solar_system)\n puts \"\"\n elsif user_input == 3\n solar_system = add_planet(solar_system)\n else\n puts \"Invalid input, please enter 1-4 to do the selection.\"\n end\n puts \"What to do next?\\n1. List the planet\\n2. Planet details\\n3. Add Planet\\n4. Exit\\n\\n\"\n user_input = gets.chomp.to_i\n end\nend",
"def main\n solar_system = SolarSystem.new('Sun')\n\n earth = Planet.new('Earth', 'blue-green', 5.972e24, '149.6 mil', 'Only planet known to support life')\n solar_system.add_planet(earth)\n\n mars = Planet.new('Mars', 'red', 6.39e23, '227.9 mil', 'Second smallest planet in the solar system')\n solar_system.add_planet(mars)\n\n venus = Planet.new('Venus', 'red-brown', 4.867e24, '108.2 mil', 'Second brightest object in the night sky')\n solar_system.add_planet(venus)\n\n\n options = [\"add planet\", \"planet details\", \"list planets\", \"exit\"]\n\n puts \"What would you like to do?\"\n puts \"Please choose from the following options:\"\n puts options\n command = gets.chomp.downcase\n\n while options.include? command\n case command\n when \"add planet\"\n puts solar_system.new_planet\n when \"planet details\"\n puts solar_system.planet_details.summary\n when \"list planets\"\n puts solar_system.list_planets\n when \"exit\"\n exit\n end\n\n puts \"What would you like to do next?\"\n command = gets.chomp.downcase\n end\nend",
"def planet_params\n params.require(:planet).permit(:name, :distance_from_earth, :nearest_star)\n end",
"def create\n @planet = Planet.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to @planet, notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @planet = Planet.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to @planet, notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def print_planet_info\n puts \"☛ Planet #{@name} takes #{@year_length} earth days to go around its star.✰\".bold\n puts \"\"\n puts \"◆ It is #{@distance_from_the_sun} kilometers away from the sun ☀️ and has a mass of #{@mass} kilogram.\".bold\n puts \"\"\n puts \"◆ It's diameter is #{@diameter} kilometer and it has these atmospheric components: #{@atmospheric_components}.\".bold\n puts \"\"\n end",
"def show\n @planet=Planet.find(params[:id])\n \n end",
"def each_planet_return\n return \"#{@name} is a planet in the solar system that is #{@distance_from_sun} million miles from the sun and has a year length of #{@planet_year} days.\\n\"\n end",
"def return_planet\n terrraform_info = \"\"\n if @terraform_state\n terrraform_info = \"Additionally, it has been terraformed.\"\n else\n terrraform_info = \"Additionally, it has not been terraformed.\"\n end\n planet_info = \"#{@name} is a planet located in the #{@location} galaxy. It is a #{@temperature} planet, whose atmosphere is #{@atmosphere} to humans. #{terrraform_info}\"\n return planet_info\n end",
"def choose_planet\n\n puts \"Select a planet by number:\"\n print \" > \".blink.colorize(:yellow)\n choice = nil\n while !((1..9).include? choice)\n choice = gets.chomp.to_i\n case choice\n when 1 then planet1 = @mercury\n when 2 then planet1 = @venus\n when 3 then planet1 = @earth\n when 4 then planet1 = @mars\n when 5 then planet1 = @jupiter\n when 6 then planet1 = @saturn\n when 7 then planet1 = @uranus\n when 8 then planet1 = @neptune\n when 9 then planet1 = @pluto\n else\n puts \"Not a choice, please enter a valid number for a planet:\".blink.colorize(:yellow)\n end\n\n end\n return planet1\nend",
"def planet_params\n params.require(:planet).permit(:name)\n end",
"def select_planet\n puts \"Hello! What planet do you want to learn about?\"\n puts \"Select 1:Mercury, 2:Venus, 3:Earth, 4:Mars, 5:Jupiter, 6: Saturn, 7:Uranus, 8:Neptune, 9:Pluto, 10:Exit\"\n while user_input = gets.chomp.downcase\n if user_input == \"1\"\n puts \"Mercury, Mass: 0.330 e24 kg, Diameter: 4879 km, Distance_from_Sun: 57.9 e6 km, Num_Moons: 0, Gravity: 3.7, Year_Length: 88.0 days\"\n elsif user_input == \"2\"\n puts \"Venus: Mass: 4.87 10e24kg, Diameter: 12,104 km, Distance_from_Sun: 108.2 e6km, Num_Moons:0, Gravity: 8.9, Year_Length: 224.7\"\n elsif user_input == \"3\"\n puts \"Earth: Mass: 5.97 e24kg, Diameter: 12,756 km, Distance_from_Sun: 149.6 e6km, Num_Moons:1, Gravity: 9.8, Year_Length: 365.2 days\"\n elsif user_input == \"4\"\n puts \"Mars: Mass: 0.642 e24kg, Diameter: 6792 km, Distance_from_Sun: 227.9 e6km, Num_Moons:2, Gravity: 1.6, Year_length: 687.0 days\"\n elsif user_input == \"5\"\n puts \"Jupiter: Mass: 1898 e24kg, Diameter: 142,984 km, distance_from_Sun: 778.6 e6km, Num_Moons:67, Gravity: 23.1, Year_length: 4331 days\"\n elsif user_input == \"6\"\n puts \"Saturn: Mass: 568 e24kg, Diameter: 120536 km, Distance_from_Sun: 1433.5 e6km, Num_Moons:62, Gravity: 9.0, Year_length: 10747 days.\"\n elsif user_input == \"7\"\n puts \"Uranus: Mass: 86.8 e24kg, Diameter: 511 km, Distance_from_Sun: 2872.5 e6km, Num_Moons:27, Gravity: 8.7, Year_Length: 30589 days\"\n elsif user_input == \"8\"\n puts \"Neptune: Mass: 102 e24kg, Diameter: 49528 km, Distance_from_Sun: 4495.1 e6km, Num_Moons:14, Gravity: 11.0, Year_Length: 59800 days\"\n elsif user_input == \"9\"\n puts \"Pluto: Mass: 0.014 6e24kg, Diameter: 2370 km, Distance_from_Sun: 5906.4 e6km, Num_Moons:5, Gravity: 0.7, Year_Length: 90560 days\"\n elsif\n user_input == \"10\"\n puts \"Hope you enjoyed learning about planets, GOOD-BYE\"\n break\n end\n end\n end",
"def set_planet\n @planet = Planet.find(params[:id])\n end",
"def set_planet\n @planet = Planet.find(params[:id])\n end",
"def find_planet_by_name\n puts \"What planet would you like to know more about? \"\n search = \"undefined\" ###\n\n # User input validation for available planets\n until @planets.include? (search.capitalize) do\n print \"Please enter a known planet in our solar system: \"\n search = gets.chomp.downcase\n\n # Iterate over @planets to match input to Planet instance\n @planets.each do |planet|\n if search != planet.name.downcase\n next\n elsif search == planet.name.downcase\n found_planet = planet\n end\n\n return found_planet\n end\n\n end\n end",
"def get_planet_info\n \"#{@name} has a mass of #{@mass} kilograms, a mean diameter of \" +\n \"#{@diameter} kilometers, and #{@moons} moon(s). It is #{@sun_distance}\" +\n \" million kilometers from the sun and one planetary year on #{@name} is\" +\n \" equal to #{@planetary_year} Earth days. If you were to stand on the \" +\n \" surface of #{@name}, you would experience a gravitational force of \" +\n \"#{@gravity} meters per second squared and a mean temperature of \" +\n \"#{@temp} degrees Kelvin. That's approximately \" +\n \"#{kelvin_to_fahrenheit(@temp).to_i} degrees Fahrenheit! \"\n end",
"def create\n @backend_planet = Backend::Planet.new(params[:backend_planet])\n\n respond_to do |format|\n if @backend_planet.save\n format.html { redirect_to @backend_planet, notice: 'Planet was successfully created.' }\n format.json { render json: @backend_planet, status: :created, location: @backend_planet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @backend_planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(planets)\n @planets = planets\n #@age = rand(9999)\n end",
"def create(data)\n @planet_model.create(data)\n end",
"def planetaryWelcome(planet)\n\tif [:mercury, :venus, :earth, :mars, :jupiter, :saturn, :uranus, :neptune].include? planet\n\t\tputs \"Welcome to planet #{planet}!\"\n\telse\n\t\tputs \"#{planet} is not a planet!\"\n\t\tif [:moon].include? planet\n\t\t\tputs \"Come to the dark side, we have cake.\"\n\t\telsif [:pluto].include? planet\n\t\t\tputs \"Sorry dude.\"\n\t\tend\n\tend\nend",
"def cli_planet_details (solar_system)\n print\"Enter a planet name: \"\n planet_name = gets.chomp # ask them for the name of the planet they wish to learn about\n planet = solar_system.find_planet_by_name(planet_name)\n if planet.nil?\n puts \"This planet isn't in our system, if you want to add you it, chooe the option 3 below!\"\n else\n puts planet.summary\n end\nend",
"def initialize(planet_hash)\n @name = planet_hash[:name]\n @mass = planet_hash[:mass] #unit: (e+24 kg)\n @diameter = planet_hash[:diameter] #unit: (km)\n @number_of_moons = planet_hash[:number_of_moons]\n @distance_from_the_sun = planet_hash[:distance_from_the_sun] #unit: (e+6 km)\n @rate_of_solar_rotation = planet_hash[:rate_of_solar_rotation] #unit: (length of one day in hours)\n @orbital_period = planet_hash[:orbital_period] #unit : (length of year in earth days)\n end",
"def find_planet(planet_name) # input is a string, returns a Planet object\n planet_names.each_with_index do |planet, i|\n return @planets[i] if planet == planet_name.capitalize\n end\n puts \"#{planet_name.capitalize} is not in my solar system.\\n\\n\"\n return nil\n end",
"def initialize(planet_attributes)\n @name = planet_attributes[:name]\n @moons = planet_attributes[:moons]\n @year_length = planet_attributes[:year_length] # wave 1 enhancement\n @distance_from_sun = planet_attributes[:distance_from_sun] # also wave 1 extra\n @mass = planet_attributes[:mass]\n @diameter = planet_attributes[:diameter]\n @diety = planet_attributes[:diety]\n end",
"def gen_star(package_map)\n text = \"//#{package_map[\"name\"]}\nvar #{package_map[\"indexed_name\"]} = new Celestial({\n name: \\\"#{package_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{package_map[\"radius\"]+0.01}, 12, 12),\n material: new THREE.MeshBasicMaterial({color: 0xffdd22, map: star_texture}),\n light: new THREE.PointLight( 0xffddbb, 1, 0 ),\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01});\ncelestials[celestials.length] = #{package_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def user_planet_pick(solar_system)\n puts \"Which planet are you interested in learning about?\"\n your_planet = gets.chomp.capitalize\n puts \"Great, you want to learn about #{your_planet}.\"\n puts \"Here are planet details about #{solar_system.find_planet_by_name(your_planet).summary}\"\nend",
"def print_planet_data\n\n if validate_planet\n\n # print the moon info\n print \"#{@name} has #{@moons.length} moon(s) and has\"\n\n # rings information\n if @rings\n puts \" rings!\"\n else\n puts \" no rings.\"\n end\n\n # other data here\n puts \"#{@name} is #{@surface_temp} and is as wide as #{@diameter_in_earths} Earth(s)!\"\n puts \"#{@name}'s rate of solar rotation is #{@rate_of_solar_rotation} Earth days.\"\n puts \"It's #{@distance_from_the_sun_in_miles} miles from the sun!\"\n\n end\n end",
"def planet_details ()\n return planet_detail = \"\\n#{@name} Planet Information : \\nRadius (mi): #{@radius_mi}\\nDistance from Sun (mi): #{@distance_frm_sun}\\nNumber of moons: #{@num_moons}\\nNumber of suns: #{@num_moons}\\nNumber of days in year: #{@year_in_days}\\n\"\n end",
"def list_planets\n planet_list = \"Planets orbiting #{ @star_name }\\n\"\n @planets.length.times do |add|\n planet_list += \"#{ add + 1 }. #{ @planets[add].name }\\n\"\n end\n\n return planet_list\n end",
"def set_planet\n @planet = Planet.find_by(id: params[:id])\n end",
"def initialize(planet_hash)\n @name = planet_hash[:name]\n @moons = planet_hash[:moons]\n @diameter = planet_hash[:diameter]\n @position = planet_hash[:position]\n @type = planet_hash[:type]\n @distance = planet_hash[:distance_from_the_sun]\n @solar_revolution = planet_hash[:solar_revolution]\n end",
"def main \n\tsolar_system = SolarSystem.new('Sol')\n\n\tearth = Planet.new('Earth', 'blue-green', 5.972e24, 4.769e9, 'Only planet known to support life')\n\tsolar_system.add_planet(earth)\n\n\tvenus = Planet.new('Venus', 'White', 6.392e24, 2.982e9, 'Sister planet to Earth')\n\tsolar_system.add_planet(venus)\n\n\tputs \"What action would you like to take?\"\n\tuser_control = gets.chomp.downcase\n\t\n\t# Prompts user for options until they choose to exit\n\tuntil user_control == 'exit'\n\t\tcase user_control\n\t\twhen 'list planets'\n\t\t\tputs solar_system.list_planets\n\t\twhen 'planet details'\n\t\t\tdisplay(solar_system)\n\t\twhen 'add planet'\n\t\t\tuser_create_planet(solar_system)\n\t\twhen 'find distance'\n\t\t\tdisplay_distance_between(solar_system)\n\t\telse\n\t\t\tputs \"Please enter a valid option.\"\n\t\tend\n\t\t\n\t\tputs \"What action would you like to take next?\"\n\t\tuser_control = gets.chomp.downcase\n\tend\n\nend",
"def find_planet_by_name(planet_name)\n planet_instance = @planets.find {|planet| planet.name.downcase == planet_name.downcase}\n return planet_instance\n\n # what does this return? the planet name if there's such a match?\n # it returns the corresponding instance of Planet that has all the states\n # q: what should method do if there is no planet with the given name? error, tell them to type in another planet?\n # q : wht should your method do if there are multiple planets with the given name?\n end",
"def initialize(some_planets, name, solar_age)\n @planets = some_planets\n @name = name\n @solar_age = solar_age\n end",
"def find_planet_by_name(planet_name)\n raise(ArgumentError, \"not a planet\") unless planet_name.instance_of? String \n @planets.each do |planet|\n return planet if planet_name.upcase == planet.name.upcase\n end\n puts \"#{planet_name} is not a valid planet:(\" #difference between throw and raise an error? \n end",
"def users_planet\n\n puts \"Please enter the name of your planet.\"\n user_planet_name = gets.chomp\n\n puts \"Please enter its volume.\"\n user_planet_volume = gets.chomp\n\n puts \"Is your planet solid?\"\n user_planet_solid = gets.chomp\n\n puts \"Please enter its diameter.\"\n user_planet_diameter = gets.chomp\n\n puts \"Please enter the time it takes to orbit its sun.\"\n user_planet_orbit_time = gets.chomp\n\nend",
"def init\n\n=begin\n Positions in array @spec for factors:\n 0 orefactor\n 1 energyfactor\n 2 populationfactor\n 3 credtitfactor\n 4 crysstalfactor\n 5 lagerfactor\n 6 buildfactor\n 7 forschungfactor\n=end\n @spec = [1, 1, 1, 1, 1, 1, 1, 1]\n self.calc_spec\n\n if self.name.nil?\n #self.under_construction = 0\n\n if self.size.nil?\n self.size = Random.rand(@@MAX_SIZE-@@MIN_SIZE) + @@MIN_SIZE\n end\n self.ore = 20 if self.ore.nil?\n self.maxore = 100 if self.maxore.nil?\n self.maxcrystal = 1 if self.maxcrystal.nil?\n self.maxenergy = 200 if self.maxenergy.nil?\n self.crystal = 0 if self.crystal.nil?\n self.energy = 50 if self.energy.nil?\n self.population = self.size/20 if self.population.nil?\n self.maxpopulation = self.size/2 if self.maxpopulation.nil?\n\n #Creates random Planet name\n self.name = PlanetsHelper.namegen\n\n #Creates specialties for Planet\n unless self.special.nil? || self.special == 0\n self.special = Random.rand(7) + 1\n #Oreplanet\n if self.special == 1\n self.ore = 50\n @spec[0] = 1.3\n #Loveplanet \n elsif self.special == 2\n @spec[1] = 1.3\n #Creditplanet \n elsif self.special == 3\n @spec[3] = 1.3\n #Crystalplanet \n elsif self.special == 4\n self.size = @@MIN_SIZE + Random.rand(@@MIN_SIZE*2)\n self.population = self.size/10\n self.maxpopulation = self.size/2\n self.maxore = 75\n self.maxenergy = 175\n self.maxcrystal = 5\n @spec = [0.5, 0.5, 0.5, 0.5, 1, 1, 1,1]\n #Buildplanet\n elsif self.special == 5\n self.ore = 50\n self.energy = 100\n @spec[6] = 0.7\n #Lagerplanet \n elsif self.special == 6\n self.maxore = 200\n self.maxenergy = 400\n self.maxcrystal = 5\n @spec[5] = 1.3\n #Scienceplanet entfernt... fehlerhaft noch aktiv gewesen\n #elsif self.special == 7\n # @spec[7] = 1.3\n #Energieplanet \n else self.special == 7 #8\n self.energy = 100\n @spec[2] = 1.3\n end \n else\n \n self.size = (@@MAX_SIZE/2)\n self.ore = 20\n self.special = 0\n self.maxore = 100\n self.maxcrystal = 1\n self.maxenergy = 200\n self.crystal = 0\n self.energy = 50\n #self.population = 1000\n self.maxpopulation = 5000\n \n end\n @start_maxore = maxore\n @maxcrystal = maxcrystal\n @start_maxenergy = maxenergy\n end\n end",
"def return_planet_object(planet_name)\n planets_collection.each do |planet|\n if planet.name == planet_name\n return planet.planet_output\n #once we get a match\n end\n end\n end",
"def initialize(planets)\n @solar_system = planets\n end",
"def validate_planet\n if @planet_hash.key? @name\n return true\n elsif planet != @name\n puts \"Sorry, I don't know anything about planet #{@name}!\"\n return false\n end\n end",
"def initialize(planet_hash)\n @name = planet_hash[:name]\n @orbital = planet_hash[:orbital]\n @mass = planet_hash[:mass_in_earths]\n @moons = planet_hash[:moons]\n @distance_from_sun = planet_hash[:distance_from_sun]\n end",
"def create\n @planet_type = PlanetType.new(planet_type_params)\n\n respond_to do |format|\n if @planet_type.save\n format.html { redirect_to @planet_type, notice: 'Planet type was successfully created.' }\n format.json { render :show, status: :created, location: @planet_type }\n else\n format.html { render :new }\n format.json { render json: @planet_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def planet_params\n params.require(:planet).permit(:name, :life, :moons, :image, :star_id, :galaxy_id, :description, :category)\n end",
"def create\n @galaxy = Galaxy.find_by(params[:galaxy_id])\n @star = Star.find_by(id: params[:star_id])\n @planet = @star.planets.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to galaxy_star_path(@galaxy, @star), notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def planets; end",
"def annex_planet(options={})\n options.assert_valid_keys(:count)\n\n options.reverse_merge! :count => 1\n @objectives.push([\n Objective::AnnexPlanet,\n {:key => PLANET_KEY, :count => options[:count], :npc => true}\n ])\n end",
"def initialize(planet_attributes)\n @name = planet_attributes[:name]\n @age = planet_attributes[:age]\n @size = planet_attributes[:size]\n @visitor_count = planet_attributes[:visitor_count]\n @inhabitants = planet_attributes[:inhabitants]\n end",
"def verify_planet_choice(user_choice)\n until user_choice == \"earth\" || user_choice == \"jupiter\" || user_choice == \"mars\"\n puts \"That's not a valid planet on this list! Please type the planet name.\"\n user_choice = gets.chomp\n end\n return user_choice\n end",
"def initialize(name, color, mass_kg, distance_from_sun_km, fun_fact)\n @name = name\n @color = color\n @mass_kg = mass_kg\n @distance_from_sun_km = distance_from_sun_km\n @fun_fact = fun_fact\n @found_planet = \"\"\n\n # Add error checking to your constructor (W1.5)\n if @mass_kg < 0\n raise ArgumentError \"Mass kg must be greater than 0\"\n end\n if @distance_from_sun_km < 0\n raise ArgumentError \"Distance from the sun km must be greater than 0\"\n end\n end"
] | [
"0.78234327",
"0.7657574",
"0.7433642",
"0.7393319",
"0.7371366",
"0.71264064",
"0.70756966",
"0.7057372",
"0.70562917",
"0.70562917",
"0.70562917",
"0.70562917",
"0.70562917",
"0.7000872",
"0.69893163",
"0.6938458",
"0.6905905",
"0.68091875",
"0.67716867",
"0.67657614",
"0.6743436",
"0.6706929",
"0.66683453",
"0.66149354",
"0.66075563",
"0.6592037",
"0.65726584",
"0.65716654",
"0.6551298",
"0.6549869",
"0.6537492",
"0.65310824",
"0.65249825",
"0.6509173",
"0.6500254",
"0.6498767",
"0.64970803",
"0.6438496",
"0.6433064",
"0.6391956",
"0.63748205",
"0.63709617",
"0.630896",
"0.6304265",
"0.6256439",
"0.6221525",
"0.62113416",
"0.62015307",
"0.6174101",
"0.6149634",
"0.6142999",
"0.61005735",
"0.60993016",
"0.60971814",
"0.6090983",
"0.6090983",
"0.6088013",
"0.60732156",
"0.60559845",
"0.6041279",
"0.6030495",
"0.59930813",
"0.59916514",
"0.59896123",
"0.59896123",
"0.59655505",
"0.59467494",
"0.59423196",
"0.5935535",
"0.5927737",
"0.5917513",
"0.5913199",
"0.5912726",
"0.59100944",
"0.5841037",
"0.58208895",
"0.58048904",
"0.5795869",
"0.5793933",
"0.5777912",
"0.5769474",
"0.57667136",
"0.57661533",
"0.57640946",
"0.5745254",
"0.57412237",
"0.5710209",
"0.57062876",
"0.56847775",
"0.5683388",
"0.56820816",
"0.56530064",
"0.56491137",
"0.56485176",
"0.564246",
"0.5637451",
"0.56219965",
"0.56196004",
"0.5618176",
"0.5610784"
] | 0.79343444 | 0 |
Helper method to collect and validate user's choice | def valid_choice(range)
choice = gets.chomp.to_i
until (1..range).include?(choice)
print "Please enter a valid choice: "
choice = gets.chomp.to_i
end
return choice
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_choice\n @user_choice = gets.chomp\n end",
"def get_valid_user_choice ###\n print \"\\nWhat would you like to do next? \\n(Enter 'list planets', 'planet details', 'add planet', or 'exit'.) \"\n @user_choice = gets.chomp.downcase\n\n until @user_choice == \"list planets\" || @user_choice == \"exit\" || @user_choice == \"planet details\" || @user_choice == \"add planet\"\n puts \"Please enter a valid choice: list planets, planet details, add planet, or exit.\"\n @user_choice = gets.chomp.downcase\n end\n end",
"def validate_user_choice\n input = gets.chomp\n if input ==\"exit\"\n exit_screen\n elsif input == \"buy\"\n ticketing_screen\n elsif input.to_i == 1\n concert_screen\n elsif input.to_i == 2\n # if user doesn't want to buy a ticket yet, they can look for other upcoming bands and/or concerts by typing bands.\n bands_screen\n else\n unrecognized_input\n end\n end",
"def check_main_menu_choice(given_choice)\n if given_choice == \"First Time User, Want To Register\"\n choice = 1\n end\n if given_choice == \"Already A Registered User, Want To Login\"\n choice = 2\n end\n if given_choice == \"Do Not Wish To Register, Just Browsing\"\n choice = 3\n end\n if given_choice == \"Looking For Info About The App\"\n choice = 4\n end\n if given_choice == \"Nothing Really, Spare Me Your @?%#&?|%!\"\n choice = 5\n end\n choice\nend",
"def get_user_selection\r\n clear\r\n test_banner\r\n puts\r\n puts \"---------- User selection----------\\n\\n\"\r\n # First get the name to represent the user\r\n user_name = @prompt.ask(\"Hello, visitor! Can I have you name please?\\n\\n\") do |input|\r\n input.required true\r\n input.validate(/\\A\\w+\\Z/)\r\n input.modify :capitalize\r\n input.messages[:valid?] =\r\n 'My dear friend, only letters, numbers and underscore are allowed. Please try again.'\r\n end\r\n clear\r\n test_banner\r\n puts\r\n # Get the time attribute from the test model\r\n level_selections = [\r\n { name: 'Easy: 16s', value: lambda {\r\n @test.time_level[:Easy]\r\n } },\r\n { name: 'Normal: 12s', value: lambda {\r\n @test.time_level[:Normal]\r\n } },\r\n { name: 'Hard: 8s', value: lambda {\r\n @test.time_level[:Hard]\r\n } },\r\n { name: 'I want to change my name. Please let me go back', value: lambda {\r\n interface\r\n } }\r\n ]\r\n selection = @prompt.select(\r\n \"Please select one time mode for answering each question in a quiz.\\nIf you can not selection a option in the limited time\\nIt will be considered as false amswer\".colorize(:light_magenta), level_selections, help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always, per_page: 5\r\n )\r\n\r\n clear\r\n test_banner\r\n puts\r\n # Choose default or custom collections\r\n test_collections = [\r\n { name: 'Default collections', value: lambda {\r\n pick_collection('Default', user_name, selection)\r\n } },\r\n { name: 'Custom collections', value: lambda {\r\n pick_collection('Custom', user_name, selection)\r\n } },\r\n { name: 'I want to change the time setting. Please let me go back to main menu', value: lambda {\r\n interface\r\n } }\r\n ]\r\n test_collection = @prompt.select('Please select one group of collecctions', test_collections,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always, per_page: 3)\r\n end",
"def instructor_or_student\n user_type = PROMPT.select(\"Are you a Student or Instructor?\", \n [\"Student\",\"Instructor\"])\nend",
"def postprocess_user_choices\n if @user_choices[:ensure]\n @user_choices[:ensure] = @user_choices[:ensure].map{|string| string.to_sym }.to_set\n end\n \n if @user_choices[:files].empty? or @user_choices[:files].include?(Pathname('-'))\n @user_choices[:files] = [STDIN]\n end\n end",
"def checkUserInput\r\n #initialize mainmenu selection characters array\r\n @mainMenuCharSelection = [\"c\",\"l\",\"u\",\"d\",\"e\"];\r\n #check user input for input validation\r\n if(@mainMenuCharSelection.include? @userInput.downcase)\r\n case @userInput.downcase\r\n when \"c\"\r\n result = BackEndLogic.create(politicians);\r\n \r\n politicians << result;\r\n when \"l\"\r\n BackEndLogic.list(politicians);\r\n when \"u\"\r\n BackEndLogic.update(politicians);\r\n when \"d\"\r\n result = BackEndLogic.remove(politicians);\r\n when \"e\"\r\n @ismainMenuLoop = false;\r\n else\r\n puts \"entry unkown! Try again! \\n\\n\"\r\n end\r\n else\r\n puts \"Please enter a valid choice from the menu options! You chose (#{@userInput}) \\n\\n\";\r\n end\r\n end",
"def validate(choice)\n CHOICE_ABBR[choice]\nend",
"def get_valid_user_choice\r\n choice_ok = false\r\n choice = \"\"\r\n until choice_ok\r\n print \"> \"\r\n choice = gets.chomp\r\n choice_ok = verify_choice_ok(choice)\r\n puts \"Invalid choice.\" unless choice_ok\r\n end\r\n return choice\r\nend",
"def sanitize_choice(choice)\nif choice.include? ' '\nputs 'Please choose from the three option above....sans typos'\nexit\nelse\nuser_mashable = Mashable.new(choice)\nuser_mashable.get\nputs user_mashable.parsed_response\nend\nend",
"def verify_selection(user_input)\n VALID_SELECTIONS.include?(user_input)\nend",
"def get_user_selection\n guess_again = true\n until guess_again == false\n puts \"Please choose rock, paper, or scissors (or q to quit)\"\n @user_current_throw = gets.chomp\n case @user_current_throw.downcase\n when \"q\"\n puts \"Thanks for playing!\"\n exit\n when \"rock\"\n @user_current_throw = @rock\n guess_again = false\n when \"scissors\"\n @user_current_throw = @scissors\n guess_again = false\n when \"paper\"\n @user_current_throw = @paper\n guess_again = false\n else\n puts \"That is not a valid entry\"\n guess_again = true\n end\n end #end of until\n end",
"def record_users_choice input\n\n if input == \"p\"\n player_picked = \"Paper\"\n elsif input == \"r\"\n player_picked = \"Rock\"\n elsif input == \"s\"\n player_picked = \"Scissors\"\n end\nend",
"def validate_user_selection(input)\n VALID_CHOICES.each do |option, value|\n # test allows strings longer than valid keystrokes\n # requires start of input string is valid keystroke/strokes\n # strips leading or trailing spaces\n return option.to_s if input.downcase.strip.index(value.to_s) == 0\n end\n false\nend",
"def selection(input, user)\n case input\n when 1\n get_number_of_random_recipes(user)\n when 2\n recipe_hash = run_option_find_recipe_by_name\n run_sub_menu_option(user, recipe_hash)\n when 3\n run_option_create(user)\n when 4\n run_option_view_favs(user)\n end\n end",
"def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end",
"def choice\n @choice\n end",
"def choice\n @choice\n end",
"def admin_choice\n @choice = params[:choice]\n end",
"def pick_option\n input = get_input\n if input == '1'\n events_array = search_by_city\n display_events_by_city(events_array)\n save_event_or_main_menu(events_array)\n elsif input == '2'\n attractions_array = search_by_keyword\n display_by_keyword(attractions_array)\n save_event_or_main_menu(attractions_array)\n elsif input == '3'\n display_user_events\n elsif input == '4'\n delete_account\n elsif input == '5'\n space(1)\n puts \"#{$logged_in.username}, thanks for checking us out. See ya later!\"\n exit\n else\n space(1)\n invalid_input\n pick_option\n end\nend",
"def user_choose_rps\n\tputs \"Enter rock, paper or scissors:\"\n user = gets.chomp\n user\nend",
"def validate_choice\n return if errors.present?\n\n return if %i[not_required all_day].include? service_choice.to_sym\n\n validate_numbers\n validate_number_ranges\n return if errors.present?\n\n validate_time_sequence\n end",
"def validate_selection(input)\n print \"#{input} is not a valid choice, re-enter the number or ID > \"\n return gets.strip\nend",
"def checkUserInputForCreateMenu(arr)\r\n #initialize mainmenu selection characters array\r\n @mainMenuCharSelection = [\"p\",\"v\"];\r\n #check user input for input validation\r\n if(@mainMenuCharSelection.include? @userInput.downcase)\r\n case @userInput.downcase\r\n when \"p\"\r\n puts \"Name?\";\r\n\r\n checkExistingNames(arr);\r\n\r\n name = @userInput;\r\n\r\n @userInput = \"\";\r\n while(@userInput.downcase != \"d\" && @userInput.downcase != \"r\" )\r\n puts \"Party? (D)emocrat or (R)epublican\"\r\n @userInput = gets.chomp;\r\n end\r\n\r\n party = @userInput == \"d\" ? \"Democrat\" : \"Republican\";\r\n p = Politician.new(name,party,\"Politician\")\r\n \r\n @ismainMenuLoop = false;\r\n return p;\r\n when \"v\"\r\n puts \"Name?\"\r\n \r\n checkExistingNames(arr);\r\n\r\n name = @userInput;\r\n\r\n @userInput = \"\";\r\n compareArr = [\"l\",\"c\",\"t\",\"s\",\"n\"];\r\n while(!compareArr.include? @userInput.downcase)\r\n puts \"Politics?\\n(L)iberal, (C)onservative, (T)ea Party, (S)ocialist, or (N)eutral\"\r\n @userInput = gets.chomp;\r\n end\r\n\r\n politics = \"\";\r\n case @userInput.downcase\r\n when compareArr[0]\r\n politics = \"Liberal\";\r\n when compareArr[1]\r\n politics = \"Conservative\"\r\n when compareArr[2]\r\n politics = \"Tea Party\"\r\n when compareArr[3]\r\n politics = \"Socialist\"\r\n when compareArr[4]\r\n politics = \"Neutral\"\r\n else\r\n puts \"Wrong choice\"\r\n end\r\n p = Politician.new(name,politics,\"Voter\")\r\n \r\n @ismainMenuLoop = false;\r\n return p;\r\n else\r\n puts \"entry unkown! Try again! \\n\\n\"\r\n end\r\n else\r\n puts \"Please enter a valid choice from the menu options! You chose (#{@userInput}) \\n\\n\";\r\n end\r\n end",
"def user_selection(selection)\n case selection\n when \"1\"\n puts \"You have chosen to add more students\\n\".center(100)\n @students = input_students\n when \"2\"\n puts \"You have chosen to see our current student list\\n\".center(100)\n student_displayer\n when \"3\"\n \"You have save our current student list to a csv file\\n\".center(100)\n save_students\n when \"4\"\n \"You have chosen to load students from a csv file\\n\".center(100)\n load_students\n when \"9\"\n puts \"Okay bye\".center(100)\n exit \n else \n puts \"I do not recognise this input, please choose again\".center(100)\n end\nend",
"def main_selector\n print \"What would you like to do? Create, List, Update, or Vote: \"\n main_decision = gets.chomp.downcase\n main_decision = main_decision[0]\n case main_decision\n when \"c\"\n create_person_or_politician\n when \"l\"\n list_characters_created\n when \"u\"\n update_character\n when \"v\"\n vote\n else\n puts \"That is not a valid entry please try again!\"\n main_selector\n end\n end",
"def manage_account_menu\n choice = @prompt.select(\"Please choose from the following options:\") do |menu|\n menu.choice 'Change my name'\n menu.choice 'Change my password'\n menu.choice 'Delete my account'.blue\n menu.choice \"Back to Main Menu\"\n end\n\n if choice == \"Change my name\"\n change_name\n elsif choice == \"Change my password\"\n change_password\n elsif choice == \"Delete my account\".blue\n delete_account\n elsif choice == \"Back to Main Menu\"\n start_menu\n end\nend",
"def user_params\n params.require(:choice)\n end",
"def user_selection\n menu\n choice = gets.to_i\n case choice\n when 1\n create_contact\n when 2\n view_contacts\n when 3\n delete_contact\n when 4\n edit_contact\n when 5\n puts \"Adios Amigo!\"\n exit\n else\n puts \"Invalid Choice Try Again\"\n end\nend",
"def get_user_selection\n puts 'Choice (Press enter for first choice):'\n loop do\n choice = STDIN.gets.strip.to_i\n if !choice.nil? && possible_moves.each_index.to_a.include?(choice)\n return choice\n else\n puts \"Please select valid choice.\"\n end\n end\n end",
"def verify_planet_choice(user_choice)\n until user_choice == \"earth\" || user_choice == \"jupiter\" || user_choice == \"mars\"\n puts \"That's not a valid planet on this list! Please type the planet name.\"\n user_choice = gets.chomp\n end\n return user_choice\n end",
"def choice_check\n begin\n choice = gets.chop.upcase\n if choice != \"GET\" && choice != \"POST\" && choice != \"EXIT\"\n raise \"Wrong input!\"\n end\n rescue StandardError => e\n puts \"#{e} You can choose between GET, POST and EXIT\"\n retry\n else\n choice\n end \n end",
"def valid?(choice)\n @acceptable_choices.include? choice\n end",
"def valid_selection(*choices)\r\n while true\r\n selection = gets.chomp\r\n if choices.to_s.include?(selection)\r\n return selection.to_i\r\n end\r\n puts \"Invalid choice number, please re-enter\"\r\n end \r\n end",
"def situation_selection\n $prompt.select(\"Welcome to Ticket Master! What would you like to do?\") do |menu|\n menu.choice 'Sign up'\n menu.choice 'Login'\n menu.choice 'Terminate program'\n end\nend",
"def get_input(message, choices)\n print(message)\n response = gets.chomp.downcase\n while response.length < 1 || !choices.include?(response[0])\n print(\"Invalid selection. \" + message)\n response = gets.chomp.downcase\n end\n return response[0]\nend",
"def get_gender \n PROMPT.select(\"Enter your gender:\", %w(Male Female Other))\nend",
"def user_choice(input = nil)\n loop do\n input ||= gets.chomp.downcase\n break if %w[p i l].include?(input)\n puts \"invalid. (p)lay, (l)oad, or (i)nstructions\"\n input = nil\n end\n input\n end",
"def get_user_input\n puts \"\\n\\nMAIN MENU - please select from the following\"\n\n OPTIONS.each do |option|\n puts option.join(\" \")\n end\n \n print \"\\nWhat would you like to do? > \"\n choice = gets.strip.downcase\n return choice\nend",
"def check_validity(choice)\n valid_options = ['pick up', 'use', 'display inventory', 'move']\n @valid_choices.include?(choice.to_sym) || valid_options.include?(choice)\n end",
"def display_results(choice, computer_choice)\n index_user_choice = VALID_CHOICES.index(choice)\n if VALID_CHOICES[index_user_choice - 1] == computer_choice\n prompt(\"you won\")\n elsif choice == computer_choice\n prompt(\"its a tie\")\n else\n prompt(\"computer won!\")\n end\nend",
"def provide_user_option \r\n @user_choice = user_input \"\\nWhat would you like to do?\\nPress 1 to pick a file and play normally\\nPress 2 to play file in reverse\\nPress 3 if you'd like to exit\\n\"\r\nend",
"def user_selection\n menu\n choice = gets.to_i\n case choice\n when 1\n add_items\n when 2\n view_cart\n when 3\n remove_items\n when 4\n check_out\n when 5\n puts \"Thank you, come again!\"\n exit\n else\n puts \"Invalid Choice Try Again\"\n sleep(2)\n end\nend",
"def greet_and_selection\r\n @view.greeting\r\n exit = true\r\n while exit\r\n user_selection = @view.selection\r\n if(user_selection != 1 && user_selection != 2)\r\n @view.wrong_answer\r\n else\r\n exit = false\r\n end\r\n end\r\n return user_selection\r\n end",
"def process_user_choice(user_choice, path_name, lang_choice)\n Dir[path_name].each do |file_iterator|\n case user_choice\n when 1\n check_image_attributes(file_iterator, 1)\n when 2\n check_image_attributes(file_iterator, 2)\n when 3\n check_image_attributes(file_iterator, 3)\n else\n $flag = 2\n if lang_choice == 1\n puts 'Please provide proper choice'\n else\n puts 'Veuillez fournir le bon choix'\n end\n return -1\n end\n end\n end",
"def parse_choice(choice)\n new_choice = choice.split.join(\"_\")\n valid_choice = @valid_choices.select { |entry| entry == new_choice.to_sym }.first\n if choice.include?('move') && valid_move(choice)\n move(choice.split(' ').last.to_sym)\n elsif choice.include?('pick up')\n item = choice.split.select{ |item| item != 'pick' && item != 'up' }.join(' ')\n pick_up(item)\n elsif choice.include?('take')\n item = choice.split.select{ |item| item != 'take' }.join(' ')\n take(item)\n elsif choice.include?('use')\n item = choice.split.select{ |item| item != 'use' }.join(' ')\n use(item)\n elsif valid_choice != nil && check_validity(new_choice.to_sym)\n self.send valid_choice\n else\n puts \"That is not a valid choice, try again.\"\n end\n end",
"def category_results(db,options)\n spacer\n puts \"\\nChoose a catagory\"\n puts options\n choice = gets.chomp\n if options.include?(choice)\n choice\n else\n spacer\n puts \"\\n---- Thats not a choice ----\"\n category_results(db,options)\n end\nend",
"def validate_event_complete(_options = {})\n # 0: user has never saved this thus when baptized_at_home_parish will not show yes or no as selected\n # 1: user has saved a selection for baptized_at_home_parish\n # if baptized_at_home_parish == true then done\n # if baptized_at_home_parish == false then baptized_catholic will not show yes or no as selected\n # 2: User has chosen baptized_catholic(true or false)\n case show_empty_radio\n when 0\n errors.add(:base, I18n.t('messages.error.baptized_should_be_checked', home_parish: Visitor.home_parish))\n false\n when 1\n basic_valid = validate_basic_info\n church_info = validate_other_church_info\n return basic_valid && church_info if baptized_at_home_parish\n\n errors.add(:base, I18n.t('messages.error.baptized_catholic_should_be_checked'))\n\n false\n when 2\n basic_valid = validate_basic_info\n church_info = validate_other_church_info\n\n if baptized_catholic\n church_info && basic_valid\n else\n validate_profession_of_faith && church_info && basic_valid\n end\n else\n raise(I18n.t('messages.error.unknown_show_empty_radio', show_empty_radio: show_empty_radio))\n end\n end",
"def player_choice_check(player_choice)\n if player_choice == \"P\" || player_choice == \"R\" || player_choice == \"S\"\n return player_choice\n else\n puts \"Please select either P, R or S\"\n player_choice_check(player_choice = gets.chomp)\n end\n end",
"def account_choice\n action = Dialog::how_can_we_help_you\n case action\n when \"new account\"\n do_new_account\n account_choice\n when \"balance\"\n show_accounts\n account_choice\n when \"deposit\"\n show_accounts\n do_dep_and_with {do_deposit}\n account_choice\n when \"withdraw\"\n show_accounts\n do_dep_and_with {do_withdraw}\n account_choice\n when \"end\"\n Dialog::goodbye_cust\n else\n Dialog::wrong_entry\n account_choice\n end\n end",
"def select_game_type\n begin\n puts \"\\n#{@player}, would you like to play a new game, \"\n puts \"load and continue a previous game, \"\n puts \"change current player, or quit?\"\n puts \"(Enter 'N', 'L', 'C', or 'Q')\"\n choice = gets.chomp.strip.upcase\n valid_answer = %w[N L C Q]\n unless valid_answer.include?(choice)\n raise ArgumentError.new(\"Selection was not of the correct format.\")\n end\n rescue ArgumentError=>e\n puts \"Error: #{e.message}\"\n retry\n end\n return choice\n end",
"def select_object_type\n puts 'Select 1 for Organizations, 2 for Users, 3 for Tickets or Exit to quit program'\n user_response = gets.chomp\n while !['1', '2', '3', 'Exit'].include?(user_response)\n puts 'Incorrect input'\n puts 'Select 1 for Organizations, 2 for Users, 3 for Tickets'\n user_response = gets.chomp\n end\n if user_response == 'Exit'\n @running = false\n else\n @object = user_response\n end\n end",
"def display_main_menu_choice\n #The disabled choice will be displayed with a cross ✘ character next to it and followed by an explanation:\n menu_choices = [\n 'First Time User, Want To Register',\n 'Already A Registered User, Want To Login',\n # { name: 'Goro', disabled: '(injury)' },\n 'Do Not Wish To Register, Just Browsing',\n 'Looking For Info About The App',\n 'Nothing Really, Spare Me Your @?%#&?|%!'\n ]\n choice_msg = 'What Will It Be, We Offer A Great Many Choices!'\n # system \"say #{choice_msg}\"\n main_menu_choice = prompt.select('What Will It Be, We Offer A Great Many Choices!'.colorize(:color => :light_blue), menu_choices)\nend",
"def make_selection\n\tprint \"\\nPlease make a selection \"\n\tgets.chomp\nend",
"def test_valid_choice_true_2\n\t\tgame = SetGame.new\n\t\tuser_input = \"3\"\n\t\tassert_equal true, game.valid_choice?(user_input, 3)\n\tend",
"def ai_selection\n @acceptable_choices.sample\n end",
"def choice\n puts \"How do you want to play?:\"\n print \"Many Battles \"\n print \"- Choose Your Stats \"\n print \"- Move Battle(unavailable)\"\n puts \" \"\n print \"Enter your choice: \"\n choice = gets.chomp\n\n if choice == \"Many Battles\"\n system \"clear\"\n many_battles\n elsif choice == \"many battles\"\n system \"clear\"\n many_battles\n elsif choice == \"Many battles\"\n system \"clear\"\n many_battles\n elsif choice == \"many Battles\"\n system \"clear\"\n many_battles\n elsif choice == \"Choose Your Stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose your stats\"\n system \"clear\"\n user_input\n elsif choice == \"Choose your stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose Your stats\"\n system \"clear\"\n user_input\n elsif choice == \"choose your Stats\"\n system \"clear\"\n user_input\n elsif choice == \"Move Battle\"\n puts \"This Mode is unavailable\"\n elsif choice == \"move battle\"\n puts \"This Mode is unavailable\"\n else\n puts \"Type in one of the choices\"\n end\n end",
"def menu_select()\n puts \"Select an option:\"\n puts \"1. New User\"\n puts \"2. Existing User\"\n input = ''\n until input == '1' || input == '2'\n input = gets.chomp\n if input == '1'\n create_user()\n elsif input == '2'\n existing_user()\n else\n puts \"Please enter a valid option: 1 or 2\"\n end\n end \nend",
"def select_option\n print_menu\n @choice = gets.chomp\n perform_selection\n end",
"def meal_choice(choice = \"meat\")\n return choice #meal choice that was passed into it \nend",
"def choice(message, choices)\n default = default(choices)\n message = message + \" [\" + choices.split('').join('/') + \"] ? \"\n if non_interactive and default.nil?\n raise \"--yes fails because '#{choices}' has no default value for question '#{message}'\"\n elsif non_interactive\n puts message + default\n return default.downcase\n else\n value = ask(message, String) { |q| q.in = choices.downcase.split(\"\"); }\n return value.downcase\n end\n end",
"def printUsersChoiceOnScreen()\n $strAnswer = ($arrCorrectAnswers[$intQuestionOnScreen - 1].strip)\n if $strAnswer.length == 1\n case $arrUserAnswers[$intQuestionOnScreen - 1]\n when \"A\"\n $radioA.invoke()\n when \"B\"\n $radioB.invoke()\n when \"C\"\n $radioC.invoke()\n when \"D\"\n $radioD.invoke()\n end\n else\n case $arrUserAnswers[$intQuestionOnScreen - 1]\n when \"A\"\n checkInvoke(true, false, false, false)\n when \"B\"\n checkInvoke(false, true, false, false)\n when \"C\"\n checkInvoke(false, false, true, false)\n when \"D\"\n checkInvoke(false, false, false, true)\n when \"AB\"\n checkInvoke(true, true, false, false)\n when \"AC\"\n checkInvoke(true, false, true, false)\n when \"AD\"\n checkInvoke(true, false, false, true)\n when \"BC\"\n checkInvoke(false, true, true, false)\n when \"BD\"\n checkInvoke(false, true, false, true)\n when \"CD\"\n checkInvoke(false, false, true, true)\n when \"ABC\"\n checkInvoke(true, true, true, false)\n when \"ABD\"\n checkInvoke(true, true, false, true)\n when \"ACD\"\n checkInvoke(true, false, true, true)\n when \"BCD\"\n checkInvoke(false, true, true, true)\n when \"ABCD\"\n checkInvoke(true, true, true, true)\n end\n end\nend",
"def recipe_ask_for_options\n puts \"\"\n puts \"What would you like to do?\".colorize(:yellow)\n puts \"\\n- [1] Save recipe\\n- [2] See Conversion tool\\n- [3] Back to main menu\".colorize(:yellow)\n user_input = gets.chomp\n if @answers[1][1].include?(user_input)\n @recipe.save_recipe\n self.save_menu_options\n elsif @answers[1][2].include?(user_input)\n self.start_convert\n elsif @answers[1][3].include?(user_input)\n self.start_main_menu\n elsif user_input == \"end\"\n exit \n else\n puts \"Thats wasn't a valid input, type 1 to start program, type 2 to navigate to the conversion feature and type 3 to see help.\".colorize(:red)\n end\n end",
"def get_user_choice\n puts \"Do you want to be X or O?\"\n puts \"Type 'X' or 'O': \"\n # assign the choice to a variable\n @symbol = gets.chomp\n # call the method to then get the computers symbol for the game\n get_computer_choice\n end",
"def menu_choice\n user_input = gets.chomp\n case user_input\n when \"1\"\n # Call function to show all of the doctors by region\n\n # show_all_doctors_by_region\n\n show_all_article_by_with_authors\n return_to_menu\n when \"2\"\n # Call function to show all of the doctors by specialties\n show_all_article_titles_with_content\n return_to_menu\n when \"3\"\n # Call function to show all of the doctors a user has visited\n show_all_authors\n return_to_menu\n when \"4\"\n puts Rainbow(\"Here are all the authors to choose from:\\n\").white.bright\n show_all_authors\n puts Rainbow(\"\\nPlease provide an author name:\").white.bright\n author = gets.chomp\n find_article_titles_by_author(author)\n show_full_list_of_articles(author)\n return_to_menu\n when \"5\"\n show_latest_article\n return_to_menu\n when \"6\"\n quit\n else\n puts Rainbow(\"Invalid option. Please select a number between 1 and 6.\").white.bright\n menu\n menu_choice\n end\n end",
"def choice_option\n \"#{assigned_at.to_date.to_s} (#{user_name})\"\n end",
"def resolve_valid_choice(component)\n available_string = self.class.available_choices_for(component).join(\", \")\n choice = options[component]\n until valid_choice?(component, choice)\n say(\"Option for --#{component} '#{choice}' is not available.\", :red)\n choice = ask(\"Please enter a valid option for #{component} (#{available_string}):\")\n end\n choice\n end",
"def query_user(user_prompt = 'Please enter a string: ', input_type = 'string')\n user_input = nil\n print user_prompt\n loop do\n user_input = gets.chomp\n case input_type\n when 'yesno'\n user_input = 'y' if user_input == 'Y' #give user some slack\n user_input = 'n' if user_input == 'N'\n return user_input if valid_yesno?(user_input)\n print \"Regrettably, a binary choice (\\'y\\' or \\'n\\') is required: \"\n when 'char'\n return user_input if valid_char?(user_input)\n print \"Sorry, single standard characters only. Please try again: \"\n when 'string'\n return user_input if valid_string?(user_input)\n print \"Sorry, standard keyboard characters only. \\nPlease try again: \"\n when 'int'\n return user_input.to_i if valid_int?(user_input)\n print 'Sorry, an integer is required. Try again: '\n when 'float'\n return user_input.to_f if valid_float?(user_input)\n print 'Sorry, a float is required. Try again: '\n else\n abort('Application Error: Improper input_type provided to query_user')\n end #case\n end #do\nend",
"def give_choices\n puts \"\\nWhat would you like to do today?\n | 1 | Withdraw money\n | 2 | Deposit money\n | 3 | Check balance\n | 4 | Exit\"\n\n choice = gets.chomp.upcase\n\n case choice\n when \"1\", \"WITHDRAW\", \"WITHDRAW MONEY\"\n puts \"You chose withdraw. How much would you like to withdraw?\"\n withdraw_amount = gets.chomp.to_f\n @withdraw_amount = withdraw_amount\n withdraw(withdraw_amount)\n when \"2\", \"DEPOSIT\", \"DEPOSIT MONEY\"\n puts \"You chose deposit. How much would you like to deposit?\"\n deposit_amount = gets.chomp.to_f\n @deposit_amount = deposit_amount\n deposit(deposit_amount)\n when \"3\", \"CHECK BALANCE\", \"CHECK\"\n puts \"You chose to check your balance. Your current balance is #{@balance}.\"\n when \"4\", \"EXIT\"\n puts \"Thank you for choosing E-Corp Bank.\"\n else\n puts \"Error, invalid input. Please try again.\"\n give_choices\n end\n\n #Calls ask_again method\n ask_again\n end",
"def select_option\n return $prompt.select(\"What's your option?\",\n [\"Ladder\", \"Team's info\", \"Play a game!\", \"Training\", \"Exit\"])\n \nend",
"def register_choice\n end",
"def main_menu\n options = [\"View recipe book\", \"Search by ingredient\", \"Quit app\"]\n answer = @prompt.select(\"Choose an option:\".colorize(:color => :blue), (options))\n if answer == options[0]\n select_recipe_from_book(@user.view_recipe_book)\n elsif answer == options[1]\n find_recipe\n elsif answer == options[2]\n puts ''\n puts \"Thanks for using Feed. See you next time!\".colorize(:color => :blue)\n system exit\n end\nend",
"def get_user_choice\n # Show the available operations\n puts \"(+) - Addition\"\n puts \"(-) - Subtraction\"\n puts \"(*) - Multiplication\"\n puts \"(/) - Dividation\"\n puts \"(**) - Exponent\"\n puts \"(r) - squareRoots\"\n puts \"(q) - Quit\"\n\n print \"Enter your selection: \"\n gets.downcase.chomp # Implicit return\n end",
"def choose_user_input\n begin\n puts 'Please choose one of the following:'\n puts ' R ==> Rock'\n puts ' P ==> Paper'\n puts ' S ==> Scissors'\n user_input = gets.chomp.upcase\n end while !['R', 'P', 'S'].include?(user_input)\n user_input\nend",
"def prompt_action \n puts \"You have six options: list users, list channels, select user, select channel, display details, send message, or quit.\"\n puts \"\\n\"\n print \"Please enter your choice: \"\n return gets.chomp.downcase\nend",
"def get_selection\n # get input from user convert to int\n puts \"Select a value\"\n input = gets.strip\n # if input is not a valid integer it will go to rescue\n selection = Integer(input)\n # check if input is int, maybe check is a valid int ie if we four option in our menu the value 1,2,3,4\n if (selection >= 1 && selection <= @menu[:options].size)\n return selection\n else\n puts \"#{selection} need to be in between 1 and #{@menu[:options].size}, please try again\"\n self.get_selection\n end\n rescue ArgumentError\n #if a ArgumentError occurs above than ruby will come here instead of throwing error\n puts \"#{input} is not a integer please select a integer\"\n self.get_selection\n end",
"def choice\n puts \"Welcome to haiwet\"\n\n input = nil\n while input != \"exit\" do\n puts \"please enter the name of the service you want to see a list of\"\n puts \"1- courses\"\n puts \"2- products\"\n puts \"3- Other\"\n input = gets.strip.downcase\n if input == \"courses\"\n cours_list\n option_cour\n done\n elsif input == \"products\"\n products_list\n option_prod\n done\n elsif input == \"other\"\n site_list\n option_site\n done\n else\n puts \"Didn't you understand?\"\n end\n\n end\n\n end",
"def ask(generator)\n allowed_choices = valid_choices == '[ANY]' ? valid_choices : (valid_choices.split(',') + TropoController::COMMANDS.keys.flatten).join(',')\n generator.ask :name => name,\n :attempts => attempts,\n :choices => {:value => allowed_choices},\n :say => [{:event => 'nomatch', :value => invalid_message},\n {:value => question_text}]\n end",
"def user_recipe_choice\n puts \"\\nWhich recipe would you like to see?\\nPlease input the recipe number:\\n\"\n\n input = gets.strip\n if valid_recipe_choice(input)\n recipe_index = (input.to_i - 1)\n\n attributes = EverythingButTheKitchenSink::SpoonacularApi.recipe_info(recipe_index)\n recipe_object = EverythingButTheKitchenSink::Recipe.all[recipe_index]\n EverythingButTheKitchenSink::TransformData.get_time_and_url(attributes, recipe_object)\n recipe_object\n else\n user_recipe_choice\n end\n end",
"def first_opt\n prompt = TTY::Prompt.new\n\n puts \"\\n\"\n\n selector = prompt.select(\"What would you like to do?\") do |menu|\n menu.choice \"Study\"\n menu.choice \"Start quiz\"\n menu.choice \"Add a new Q&A\"\n menu.choice \"Exit\"\n end\n\n case selector\n when \"Study\"\n show_categories\n study(@category_input_push)\n when \"Start quiz\"\n\n show_categories\n quiz(@category_input_push)\n\n when \"Add a new Q&A\"\n another_qa_opt\n when \"Exit\"\n exit\n end\nend",
"def call_option(user_selected) \n\t case user_selected\n\t when 1 then add_new_contact\t\t\n\t when 2 then modify_existing_contact\n\t when 3 then display_one_contact\n\t when 4 then delete_contact\n\t when 5 then display_all_contacts\n\t when 6 then display_by_attribute\n\t when 7\n\t\t\tputs \"Current session ended, goodbye!\"\n\t\t\treturn\n\t\telse\n\t\t\tputs \"Invalid Option, try again.\"\n\t\t\treturn\n\t\tend\t\n\tend",
"def select_user(workspace)\n print \"Enter user id or name: \"\n choice = gets.chomp\n begin\n workspace.select_user(choice)\n rescue => exception\n puts \"Error: #{exception.message}\"\n end\nend",
"def make_role_choice(human_name)\n puts \"Hi there #{human_name}! Enter b to play as the codeBreaker or m to play as the codeMaker.\"\n choice = gets.chomp.to_s\n if %w[b m].include?(choice)\n create_players(choice, human_name)\n else make_role_choice(human_name)\n end\n end",
"def get_choice\n puts \"\\nThank you for using our Solar System Explorer! Here are your options:\n (A) Add a planet to the list\n (B) View a planet\n (C) Exit the program\"\n print \"\\nPlease select a letter: \"\n choice = gets.chomp.upcase\n choice\nend",
"def choice_select\n\tloop do\n\t\tloop do\n\t\t\tprint \"\\n\\t\\tEnter product Id: \"\n\t#get product id from user\n\t\t\t@choice=gets.to_i\n\t#check condition for choice\n\t\t\tbreak if @choice>0 and @choice<@count+1\n\t\t\tputs \"\\n\\n\\t\\tInvalid Id!!!...Enter Correct\"\n\t\tend\n\t\t\tstatement=@connection.prepare(\"select * from inline_products where p_id=? and card_no=?\")\n\t\t\tstatement.execute(@choice,@card_no)\n\t\t\tbreak if (recordset=statement.fetch).nil?\n\t\t\tputs \"\\n\\n\\t\\tYou already purchased this product....!!!\"\n\tend\n\t#call methods product details\n\t\tproduct_details(@choice)\n\tend",
"def get_user_choice\n # show the user the available options\n puts \"(+) - Addition\"\n puts \"(-) - Subtraction\"\n puts \"(*) - Multiplication\"\n puts \"(/) - Division\"\n puts \"(x) - Exponent\"\n puts \"(r) - Root\"\n puts \"(q) - Quit\"\n\n print \"Enter your selection: \"\n gets.downcase.chomp #implicit return\nend",
"def parseChoice(input)\n case input\n when \"r\", \"rock\"\n @playerChoice = \"rock\"\n when \"p\", \"paper\"\n @playerChoice = \"paper\"\n when \"s\", \"scissors\"\n @playerChoice = \"scissors\"\n else\n puts \"Please enter 'rock', 'paper', 'scissors', or their abbreviated versions (r,p,s)\"\n end\n end",
"def get_attachment_choice\n puts \"Which attachment plugin would you like to use? (please type the number only)\"\n puts \"\\t1. ActiveRecord\\n\\t2. Sequel\"\n choice = gets.chomp\n unless choice.to_i == 1 || choice.to_i == 2\n puts \"Please ensure you only type '1' or '2'\"\n get_attachment_choice\n end\n choice\nend",
"def choose\n puts \"Do you like programming? Yes or No please.\"\n choice = gets.chomp\n case choice.downcase #value being evaluated\n when \"yes\" #possible value\n puts \"That\\'s great!\"\n when \"no\" #possible value\n puts \"That\\'s too bad!\"\n when \"maybe\" #possible value\n puts \"Glad you\\'re giving it a chance!\"\n else #executed as a default\n puts \"I have no idea what that means\"\n end\nend",
"def interface\r\n clear\r\n menu_banner\r\n puts\r\n options = [\r\n { name: 'New Game', value: -> { get_user_selection } },\r\n { name: 'Custom quiz collections', value: -> { custom_collection } },\r\n { name: 'History', value: -> { history_select } },\r\n { name: 'Exit', value: lambda {\r\n clear\r\n exit_banner\r\n exit\r\n } }\r\n ]\r\n option = @prompt.select(\"Please select from the following options.\\n\\n\", options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always)\r\n end",
"def choose(choices, title)\n res = @dialog.menu(title, choices)\n\n raise CancelPressed.new unless res\n\n res\nend",
"def player_rps\n loop do\n prompt(\"Choose #{OPTIONS.join(', ')}: \")\n choice = gets.chomp.downcase\n break choice unless OPTIONS.include?(choice) == false\n end\nend",
"def get_user_input(user, enemies)\n option = gets.chomp.to_s\n while (option != \"a\" && option != \"b\" && option != \"1\" && option != \"0\")\n puts \"Option non valide\"\n option = gets.chomp.to_s\n end\n if option == \"a\"\n user.search_weapon\n elsif option == \"b\"\n user.search_health_pack\n elsif option == \"0\"\n user.attack(enemies[1])\n elsif option == \"1\"\n user.attack(enemies[0])\n end\nend",
"def student_choices(content)\n content.each do |key, value| \n if key =~ /choice_(.*)/\n text = content[key]\n is_selected = content[\"correct_#{$1}\"] == \"1\"\n yield text, is_selected\n end\n end\n end",
"def get_choices\n begin\n choices = case \n when @yaml['choices'] then @yaml['choices']\n when @yaml['eval'] then\n do_eval(@yaml['eval'])\n else \n c = t('helpers.label.' + @form['table'] + '.choices4_' + @yaml['name'] )\n c = 'Error' if c.match( 'translation missing' )\n c\n end\n # Convert string to Array\n choices.class == String ?\n choices.chomp.split(',').inject([]) {|r,v| r << (v.match(':') ? v.split(':') : v )} :\n choices\n rescue Exception => e \n Rails.logger.debug \"Error in select eval. #{e.message}\\n\"\n ['error'] # return empty array when error occures\n end\nend",
"def student_choice\n\t\tinput = nil\n\t\tuntil input == \"a\" || input == \"q\"\n\t\t\t\tputs \"Input \\\"a\\\" to add classes and \\\"q\\\" to quit.\"\n\t\t\t\tinput = gets.chomp.downcase\n\t\tend\n\t\tif input == \"q\"\n\t\t\tputs \"Thank you for using this computer!\"\n\t\t\tRegistration.new\n\t\telse\n\t\t\tdisplay_classes\n\t\tend\n\tend",
"def test_valid_choice_true_4\n\t\tgame = SetGame.new\n\t\tuser_input = \"8\"\n\t\tassert_equal true, game.valid_choice?(user_input, 8)\n\tend",
"def menu_choice\n puts \"Votre réponse :\"\n print \">\"\n user_answer = gets.chomp\n\n if(user_answer == \"a\")\n then @human_player.search_weapon\n end\n if(user_answer == \"s\")\n then @human_player.search_health_pack\n end\n if(user_answer == 0.to_s)\n then @human_player.attacks(@player1)\n end\n if(user_answer == 1.to_s)\n then @human_player.attacks(@player2)\n end\n if(user_answer == 2.to_s)\n then @human_player.attacks(@player3)\n end\n if(user_answer == 3.to_s)\n then @human_player.attacks(@player4)\n end\n kill_player\n end",
"def vote_or_random (list, user_list)\n system 'clear'\n # Create a new prompt\n voterandom = TTY::Prompt.new \n selection = voterandom.select(\"Would you like to vote or have the program randomly pick an option for you? \", %w(Vote Random))\n # Check which method to run based on valid user input\n if selection == \"Vote\" \n list_of_users(list, user_list)\n else\n random_winner(list)\n end\nend",
"def whos_your_enemy(enemy)\n\n # validate enemy response\n valid_options = [\"Riddler\", \"Penguin\", \"Joker\"]\n until valid_options.include?(enemy)\n # puts [\"Huh?\", \"Wha?\", \"Que?\", \"Como?\"].sample\n question = [\"Huh?\", \"Wha?\", \"Que?\", \"Como?\"].sample\n\n # puts \"Options: Joker, Penguin, Riddler\"\n options = \"Joker, Penguin, Riddler\"\n\n # enemy = gets.chomp.capitalize.strip\n enemy = ask_question question, options\n end\n\n # alternate validation strategy\n # loop do\n # puts \"Huh?\"\n # puts \"Options: Joker, Penguin, Riddler\"\n # enemy = gets.chomp.capitalize.strip\n #\n # if valid_options.include?(enemy)\n # break\n # end\n # end\n\n case enemy\n when \"Riddler\"\n say \"#{enemy}: Puzzle me this, Batman.\"\n when \"Joker\"\n say \"#{enemy}: Ha ha ha ha... ha ha.\"\n when \"Penguin\"\n say \"#{enemy}: Rweh rweh rweh... rweh...\"\n else\n say \"This should never happen.\"\n # ... if the validation is correct\n end\nend"
] | [
"0.7081809",
"0.70805854",
"0.69184625",
"0.68849957",
"0.68595177",
"0.67581433",
"0.67222863",
"0.67005074",
"0.66769475",
"0.66724885",
"0.66682655",
"0.666798",
"0.66641414",
"0.6626478",
"0.6576982",
"0.6561172",
"0.6539722",
"0.651585",
"0.6501375",
"0.64915645",
"0.6463872",
"0.6411616",
"0.64113873",
"0.6408873",
"0.6399327",
"0.63915294",
"0.6321329",
"0.6310296",
"0.6300433",
"0.6285518",
"0.62789565",
"0.6270528",
"0.6267901",
"0.62525815",
"0.623973",
"0.622668",
"0.6210767",
"0.61966985",
"0.6195439",
"0.6187084",
"0.61760473",
"0.61687446",
"0.6161716",
"0.6151802",
"0.61477405",
"0.6137748",
"0.61230946",
"0.6121706",
"0.612143",
"0.6119272",
"0.6117591",
"0.61139715",
"0.61128724",
"0.6102603",
"0.6102047",
"0.6097743",
"0.6096259",
"0.6084145",
"0.60728705",
"0.6067463",
"0.60649306",
"0.60643756",
"0.6057471",
"0.6055553",
"0.6054706",
"0.60445476",
"0.6041266",
"0.6033373",
"0.60245466",
"0.6023114",
"0.601517",
"0.6007657",
"0.6004954",
"0.5995045",
"0.59909827",
"0.5983199",
"0.5981126",
"0.59719795",
"0.5970906",
"0.5962117",
"0.5961709",
"0.5957152",
"0.59382814",
"0.59347326",
"0.59286517",
"0.5927667",
"0.5925638",
"0.5921654",
"0.59141934",
"0.59134936",
"0.5912001",
"0.5906425",
"0.59030956",
"0.5900962",
"0.58962774",
"0.58846676",
"0.5883277",
"0.5877603",
"0.58740294",
"0.5865461",
"0.58602965"
] | 0.0 | -1 |
Helper method to print out planet list | def print_list(solar_system)
solar_system.planet_list.each_index do |i|
print "#{i + 1}. #{solar_system.planet_list[i]} "
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_planets\n list = \"Planets orbiting #{@star_name}:\\n\"\n @planets.each do |planet|\n list += \"* #{planet.name}\\n\"\n end\n list += \"\\n\"\n return list\n end",
"def print_planets\n puts \"\\n#{@name} has #{@planets.length} planets and was formed #{@formation_year} years ago.\"\n puts \"\\nHere are the planets in the #{@name} solar system:\\n\\n\"\n @planets.each do |planet|\n puts \"#{planet.print_planet_data}\"\n end\n puts \"\\n\"\n end",
"def display_planet_list\n puts \"Here are the current planets in our solar system:\"\n @all_planets.each do |planet_info|\n puts planet_info.name\n end\n end",
"def list_planets\n planet_list = \"Planets orbiting #{@star_name}:\"\n @planets.each_with_index do |planet, index|\n planet_list += \"\\n#{index + 1}. #{planet.name}\"\n end\n return planet_list\n end",
"def list_planets\n i = 1\n planets_list = \"\"\n @planets.each do |planet|\n planets_list += \"#{i}. #{planet.name}\\n\"\n i += 1\n end\n return \"Planets orbiting #{@star_name}:\\n#{planets_list}\"\n end",
"def planet_list\n list = \"\"\n @planets.each_with_index do |planet, i|\n list += \" #{i+1}. #{planet.name}\\n\"\n end\n return list\n end",
"def list_planets\n planet_list = \"Planets orbiting #{ @star_name }\\n\"\n @planets.length.times do |add|\n planet_list += \"#{ add + 1 }. #{ @planets[add].name }\\n\"\n end\n\n return planet_list\n end",
"def list_planets\n planet_list = ''\n i = 0\n @planets.each do |planet|\n i += 1\n planet_list << \"#{i}. #{planet.name.capitalize}\\n\"\n end\n planet_list\n end",
"def planet_list\n puts \"\\n1: Mercury, 2: Venus, 3: Earth, 4: Secret Earth, 5: Mars, 6: Jupiter, 7: Saturn, 8: Uranus, 9: Neptune, 10: Pluto\".colorize(:yellow)\n puts \"\\n11: Exits our solar system (so you can start making your own solar systems and planets!)\".colorize(:yellow)\n puts \"\\n(At this time, you are unable to return to our solar system's information after exiting.)\".colorize(:yellow)\nend",
"def list_planets\n planet_string = \"Planets orbiting #{@star_name} \\n\"\n @planets.each_with_index do |planet, index|\n planet_string += \"#{index+1}. #{planet.name} \\n\"\n end\n return planet_string\n end",
"def list_planets\n list_planets = \"Planets orbiting #{star_name} \\n\"\n\n @planets.each_with_index do |planet, index|\n list_planets = \"#{list_planets}\" + \"#{index + 1}. #{planet.name}\\n\"\n end\n\n return list_planets\n end",
"def list_planets()\n\t\tplanets_list = @planets.each_with_index.map {|planet,index|\n\t\t\t\"#{index + 1}. #{planet.name}\"}\n\t\tplanets_list.unshift(\"Planets orbiting #{@star_name}:\\n\").to_s\n\t\t\n\t\treturn planets_list \n\tend",
"def all_planet_info\n list_string = \"\"\n @planets.each_with_index do |planet, i|\n list_string << \"#{i+1}.\\n#{planet.planet_info}\\n\"\n end\n return list_string\n end",
"def list_planets\n str = \"Planets orbiting #{@star_name}:\\n\"\n count = 0\n @planets.each do |planet|\n count += 1\n str += \"#{count.to_s}. #{planet.name}\\n\"\n end\n return str\n end",
"def list_all_planets\n puts \"The #{ @system } system has these #{ @all_planets.length } planets:\"\n @all_planets.each do |planet|\n puts \"#{@all_planets.index(planet)+1}. #{planet.name}\"\n end\n end",
"def list\n list = \"\"\n i = 0\n @planets.each do |planet|\n list << \"#{i+1}. #{planet}\\n\"\n i += 1\n end\n return list\n end",
"def list_of_planets()\n counter = 0\n planet_names = \"\"\n @planets.each do |planet|\n planet_names += \"\\n#{counter+1}. #{planet.planet_details}\"\n counter+=1\n end\n return planet_names\n end",
"def print_planet_info\n puts \"☛ Planet #{@name} takes #{@year_length} earth days to go around its star.✰\".bold\n puts \"\"\n puts \"◆ It is #{@distance_from_the_sun} kilometers away from the sun ☀️ and has a mass of #{@mass} kilogram.\".bold\n puts \"\"\n puts \"◆ It's diameter is #{@diameter} kilometer and it has these atmospheric components: #{@atmospheric_components}.\".bold\n puts \"\"\n end",
"def display_planet_details\n puts \"Name: #{@name}, Primary Export: #{@primary_export}, Year-Length: #{@year_length}\"\n end",
"def list_planets\n x = \"Planets orbitting #{@star_name}\\n\"\n z = \"\"\n z = z + x\n l = 1\n while l <= @planets.length\n y = \"#{l}. #{@planets[l-1].name}\\n\"\n z += y\n l += 1\n end\n return z\n end",
"def list_planets\n puts \"Planets orbiting #{star_name}:\"\n\n @planets.each_with_index do |planet, i|\n @list_of_planets << \"#{i+1}. #{planet.name}\"\n end\n return @list_of_planets\n end",
"def print_planet_data\n\n if validate_planet\n\n # print the moon info\n print \"#{@name} has #{@moons.length} moon(s) and has\"\n\n # rings information\n if @rings\n puts \" rings!\"\n else\n puts \" no rings.\"\n end\n\n # other data here\n puts \"#{@name} is #{@surface_temp} and is as wide as #{@diameter_in_earths} Earth(s)!\"\n puts \"#{@name}'s rate of solar rotation is #{@rate_of_solar_rotation} Earth days.\"\n puts \"It's #{@distance_from_the_sun_in_miles} miles from the sun!\"\n\n end\n end",
"def planet_list\n planet_array = []\n @planets.each_with_index do |planet, index|\n # **--->how to do without storing list in an array as a variable??\n # **--->prints whole array of hashes if not\n current_planet = \"#{index + 1}. #{planet.name}\"\n planet_array << current_planet\n end\n return planet_array\n end",
"def list_planets(format)\n planet_list = \"\"\n\n if format == :num\n @planets.each do |planet|\n num = @planets.index(planet)\n planet_list.concat(\"#{num + 1}. #{planet.name}\\n\")\n end\n elsif format == :comma\n @planets.each do |planet|\n planet_list.concat(planet.name + \", \")\n end\n return planet_list.strip.chop\n end\n return planet_list\n end",
"def prints_solarsystem_props\n puts \"I am the #{@name} solar system.\"\n puts \"I have #{@planet.length} planet(s), they are:\"\n @planet.each do |p|\n puts p.name\n end\n end",
"def list_planets\n list = \"\"\n @planets.each do |planet|\n list += \"#{@planets.index(planet) + 1}. #{planet}\\n\"\n end\n return list\n end",
"def each_planet_return\n return \"#{@name} is a planet in the solar system that is #{@distance_from_sun} million miles from the sun and has a year length of #{@planet_year} days.\\n\"\n end",
"def return_planets\n planet_list = \"\"\n @planets.each do |planet|\n planet_list << \"#{@planets.index(planet) + 1}. #{planet.name} \\n\"\n end\n return planet_list\n end",
"def show_library\n @name_pool = []\n @planet_names = \"\"\n @planets.length.times do |i|\n @planet_names += \"#{i + 1}. #{@planets[i].name}\\n\"\n @name_pool << @planets[i].name\n end\n return @planet_names\n end",
"def planet_info #(there's no parameter here)\n puts \"#{@name} has #{@orbital} days in one of its years, weighs #{@mass} earth, has #{@moons}, and is #{@distance_from_sun} million miles from the sun.\"\n end",
"def planet_details ()\n return planet_detail = \"\\n#{@name} Planet Information : \\nRadius (mi): #{@radius_mi}\\nDistance from Sun (mi): #{@distance_frm_sun}\\nNumber of moons: #{@num_moons}\\nNumber of suns: #{@num_moons}\\nNumber of days in year: #{@year_in_days}\\n\"\n end",
"def print_info\n puts \"#{ @name } is the #{ @position } planet from the sun.\\nIt is a #{ @type } planet that is #{ @diameter } miles wide.\\n#{ @name } has #{ @moons } moons.\"\n end",
"def planets_list\n @list = String.new\n @planets.each_with_index do |planet, i|\n @list += \"#{i+1}. #{planet.name}\\n\"\n end\n return @list\n end",
"def print_info\n puts \" Planet Summary\"\n puts \"=============================================================\"\n puts \"Planet Name: #{@name.capitalize}\"\n puts \"Mass: #{@mass} e+24 kg\"\n puts \"Diameter: #{@diameter} km\"\n puts \"Number of Moons: #{@number_of_moons}\"\n puts \"Average Distance From The Sun: #{@distance_from_the_sun} e+6 km\"\n puts \"Rate of Solar Rotation: #{@rate_of_solar_rotation} hours\"\n puts \"Orbital Period: #{@orbital_period} Earth days\\n\\n\"\n end",
"def show_menu\n planet_list = \"\"\n i = 1\n @solar_system.length.times do |n|\n planet_list << \"\\n#{i}. #{@solar_system[n].name}\"\n i += 1\n end\n return \"\\nPlanet List#{planet_list}\\nOther: Exit\\n\\n\"\n end",
"def planet_list\n return @planets\n end",
"def list_planet_names_in_solar(solar_obj)\n solar_obj.list_of_planets.each do |element|\n puts element.name\n end\nend",
"def return_planet_names\n planet_names = \"\"\n @solar_system.each do |planet_name|\n planet_names += planet_name.planets_name\n end\n return planet_names\n end",
"def show_planet(number)\n selected = @solar_system[number-1]\n\n # Calculate planet related ages\n age = 4.5e9/(selected.rotation_time/12.0)\n age = age.to_i.to_s\n age = age.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n\n # Calculate the closest neighboring planets\n # Collect names and distances of planets\n distance_and_name = []\n @solar_system.length.times do |i|\n planet_info = {}\n planet_info[:name] = @solar_system[i].name\n planet_info[:distance] = @solar_system[i].distance_from_the_sun\n distance_and_name << planet_info\n end\n # Get only the distances and sort them\n planet_distances = []\n @solar_system.each do |planet|\n planet_distances << planet.distance_from_the_sun\n end\n ordered_planets = planet_distances.sort\n number_index = ordered_planets.index(selected.distance_from_the_sun).to_i\n\n # Find the select planet's distance neighbors (2)\n if (number_index+1) == @solar_system.length\n neighbor1_distance = 0\n neighbor1_difference = 0\n else\n neighbor1_distance = ordered_planets[(number_index+1)]\n neighbor1_difference = (selected.distance_from_the_sun - neighbor1_distance).abs.round(2)\n end\n if (number_index-1) < 0\n neighbor2_distance = 0\n neighbor2_difference = 0\n else\n neighbor2_distance = ordered_planets[(number_index-1)]\n neighbor2_difference = (selected.distance_from_the_sun - neighbor2_distance).abs.round(2)\n end\n neighbor1_name = \"\"\n neighbor2_name = \"\"\n distance_and_name.each do |planet|\n if neighbor1_distance == planet[:distance]\n neighbor1_name << planet[:name]\n end\n if neighbor2_distance == planet[:distance]\n neighbor2_name << planet[:name]\n end\n end\n if neighbor1_distance == 0 && neighbor2_distance == 0\n true_neighbor = \"not to be found\"\n true_distance = \"both infinity and negative infinity\"\n elsif neighbor1_distance == 0 && neighbor2_distance > 0\n true_neighbor = neighbor2_name\n true_distance = neighbor2_difference\n elsif neighbor2_distance == 0 && neighbor1_distance > 0\n true_neighbor = neighbor1_name\n true_distance = neighbor1_difference\n else\n true_neighbor = \"#{neighbor2_name} and #{neighbor1_name}\"\n true_distance = \"#{neighbor2_difference} and #{neighbor1_difference}\"\n end\n\n # Text summary shown to user\n text = \"\\nThe planet \\[#{selected.name}\\] is #{selected.distance_from_the_sun} Astronomical Units from the sun.\n \\rThe closest neighboring planet(s) is/are #{true_neighbor}, which is/are #{true_distance} AU away.\n \\rIt orbits the sun once every #{selected.rotation_time} Earth months, or #{(selected.rotation_time/12.0).round(2)} Earth years.\n \\rSince our sun is 4.5 billion Earth years old, this planet's age is #{age}!\n \\r#{selected.name} also enjoys #{selected.moon_count} moon(s) orbitin' around it.\\n\"\n return text\n end",
"def list_planets\n counter = 0\n list = \"\"\n @planets.each do |planet|\n counter += 1\n list += \"#{counter}. #{planet.name.each_first_letters}\\n\"\n end\n\n list += \"#{counter + 1}. **CREATE NEW PLANET**\"\n return list\n end",
"def list_planet_names\n list_planet_names = []\n planets_collection.each do |planet_name|\n list_planet_names << planet_name.name\n end\n return list_planet_names\n end",
"def show_planets\n @planet_names = planets.keys{:name}\n end",
"def list_of_planets\n list = []\n @planets.length.times do |index|\n list << \"#{index+1}. #{@planets[index].name}\"\n end\n return list\n end",
"def get_planet_info\n \"#{@name} has a mass of #{@mass} kilograms, a mean diameter of \" +\n \"#{@diameter} kilometers, and #{@moons} moon(s). It is #{@sun_distance}\" +\n \" million kilometers from the sun and one planetary year on #{@name} is\" +\n \" equal to #{@planetary_year} Earth days. If you were to stand on the \" +\n \" surface of #{@name}, you would experience a gravitational force of \" +\n \"#{@gravity} meters per second squared and a mean temperature of \" +\n \"#{@temp} degrees Kelvin. That's approximately \" +\n \"#{kelvin_to_fahrenheit(@temp).to_i} degrees Fahrenheit! \"\n end",
"def show_info\n @planets.each do |planet|\n planet.show_details\n end\n end",
"def all_info(the_planet_i_care_about)\n return @planets.each do |each_planet_in_my_solar_system|\n if each_planet_in_my_solar_system.name == the_planet_i_care_about\n puts each_planet_in_my_solar_system.info\n end\n end\n end",
"def organized_planet_details\n detailed_summary = \"Here are your facts about #{name}:\"\n detailed_summary << \"\\nNumber of Moons: #{@moons}\\nYear Length: #{@year_length}\"\n detailed_summary << \"\\nDistance from its Star: #{@distance_from_sun} million miles\"\n detailed_summary << \"\\nMass: #{@mass} kg.\\nDiameter: #{@diameter} miles.\"\n detailed_summary << \"\\nDiety Namesake: #{@diety}\"\n detailed_summary << \"\\nWe hope you learned something new about #{@name}.\"\n return detailed_summary\n end",
"def names\n planet_names = []\n @planets.each do |planet|\n planet_names << planet.name\n end\n return planet_names\n end",
"def planets\n # go through my colonies\n self.colonies.map do |my_colony|\n # get the information about each planet the colony is on\n my_colony.planet\n end\n end",
"def print_backpack_list\n output = []\n output << \"Melinda, here's your packing list!\"\n output << \"Day: #{@attributes[:day_of_week]}, Weather: #{@attributes[:weather]}\"\n output << \"\"\n\n @items.each do |item|\n output << \"- #{item}\"\n end\n output.join(\"\\n\")\n end",
"def planet_information(some_planet)\n @planets.each do |planet|\n if some_planet.downcase == planet.name.downcase\n return planet.organized_planet_details\n end\n end\n end",
"def show_planets our_solar_system\n all_planets = our_solar_system.planets\n puts \"Choose which planet:\"\n all_planets.length.times do |index|\n puts \"#{index+1}: #{all_planets[index].name}\"\n end\n puts \"Which planet info you want\"\n planet_choice = gets.chomp.to_i\n if planet_choice >=1 && planet_choice <= all_planets.length\n # Display all the planet objects in array.\n puts all_planets[planet_choice - 1].print_planet_info\n # Local variable which is assigned the planet that is selected\n choosen_planet = all_planets[planet_choice -1]\n all_planets.length.times do |index|\n # Skips the selected planet\n if planet_choice - 1 != index\n # Output the distance from other planet.\n puts \"✹ The distance from #{all_planets[index].name} is #{choosen_planet.distance_from_the_planet(all_planets[index])} km.\".bold\n puts \"\"\n end\n end\n end\nend",
"def planet\n fetch('stargate.planets')\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 planet\n fetch('dune.planets')\n end",
"def showlist\n\t\t@people_list.each do |x|\n\t\t\tputs \"* #{capitalize(x.type)}, #{capitalize(x.name)}, #{capitalize(x.party)}\"\n\t\tend\n\tend",
"def return_solar_system_info\n solar_system_output = \"\"\n @planets_collection.each do |planet_object| # planet_object represents a new planet instance\n #add to planet_output string\n solar_system_output += planet_object.planet_output\n end\n return solar_system_output\n end",
"def get_list_of_planets\n planets = get_space_bodies.select{|body| body[\"isPlanet\"] == true}\n end",
"def show\r\n @positions.each do |p|\r\n\t puts p.inspect\r\n\tend\r\n end",
"def planet_details(solarsystem)\n puts \"which planet would you like to know more about?\"\n planet = gets.chomp.downcase\n solarsystem.planets.each do |planetlist|\n if planetlist.name.downcase == planet\n puts planetlist.summary\n else puts \"this planet is not in this solar system! try a different planet!\"\n end\n end\nend",
"def display_port\n @port.each do |x|\n puts \"Company: #{x.name}\"\n puts \"Shares: #{x.shares}\"\n puts \"Price: #{x.price}#{x.currency}\"\n puts \"To USD: $#{sprintf('%.2f', x.con)}\"\n puts \"Total: #{x.total}#{x.currency}\"\n puts\n end\n end",
"def print_list\n\t puts \"\"\n\t puts \"\"\n\t\tputs \"#{@list_name}\"\n\t\tprint \"-\" * 40\n\t\t@grocery_list.each {|k, v| puts \"#{k} #{v}\"}\n\t\tputs \"\"\n\t\tget_item\n\tend",
"def print_list\n if @tenant.first_name && @tenant.last_name\n return \"#{@address[:street_number]} #{@address[:street_name]}, #{@address[:suburb]}. #{@rent}/pw #{@status}. Tenant: #{@tenant.first_name} #{@tenant.last_name}. Landlord: #{@landlord.first_name} #{@landlord.last_name}\"\n else \n return \"#{@address[:street_number]} #{@address[:street_name]}, #{@address[:suburb]}. #{@rent}/pw #{@status}. Tenant: Not available. Landlord: #{@landlord.first_name} #{@landlord.last_name}\"\n end\n end",
"def portfolios_listing\n portfolios.each_index do |index|\n puts \"Portfolio (#{index}) : #{portfolios.to_s}\"\n end\n end",
"def info\n puts \"All stations:\"\n @stations.each.with_index(1) do |station|\n puts \"#{station.name}: \"\n station.show_trains(\"Cargo\")\n station.show_trains(\"Passenger\")\n end\n\n puts \"All routes:\"\n show_routes\n puts \"All trains:\"\n show_trains\n puts \"All wagons:\"\n show_wagons\n end",
"def summary\n return \"\\nThis planet is called #{@name}. It is #{@color} in color, #{@mass_kg} kilograms in weight, \n and #{@distance_from_sun_km} kilometers from the sun. A fun fact about this planet: #{@fun_fact}.\"\n end",
"def planet_choice_and_details(the_solar_system)\n puts \"What planet would you like to learn about? Please enter the name.\"\n puts the_solar_system.return_planets\n planet_name = gets.chomp\n decoration\n puts the_solar_system.planet_information(planet_name)\n end",
"def display_pets\n\t\tpets.join(\"\\n\")\n\tend",
"def solarsystem_list_return\n list = []\n @array_of_planets.each do |bodies|\n list << \"#{@array_of_planets.index(bodies) + 1}. #{bodies.name}\"\n end\n return list\n end",
"def display()\n\t\tmaze.each do|x| \n\t\t\tx.each {|j| print j}\n\t\t\tputs\n\t\tend\n\tend",
"def print_list; end",
"def view_all_tenants(tenants)\n puts `clear`\n puts \"View All Apartments\"\n puts\n printf(\" %10s %-30s %6s %10s \\n\",\"ID\",\"Name\",\"Age\",\"Apt ID\")\n tenants.each_entry{ |o| printf \" %10s %-30s %8d %10d \\n\",\n o.id,o.name,o.age,\n o.apartment_id }\n puts\n\nend",
"def return_planet\n terrraform_info = \"\"\n if @terraform_state\n terrraform_info = \"Additionally, it has been terraformed.\"\n else\n terrraform_info = \"Additionally, it has not been terraformed.\"\n end\n planet_info = \"#{@name} is a planet located in the #{@location} galaxy. It is a #{@temperature} planet, whose atmosphere is #{@atmosphere} to humans. #{terrraform_info}\"\n return planet_info\n end",
"def print\n @maze[:matrix].each do |line|\n puts line.join\n end\n end",
"def print\n unless success?\n return nil\n end\n nlen = \"Name\".length\n clen = \"Craft\".length\n @data['people'].each do |p|\n nlen = p['name'].length > nlen ? p['name'].length : nlen\n clen = p['craft'].length > clen ? p['craft'].length : clen\n end\n\n print_header(nlen, clen)\n @data['people'].each do |p|\n print_line(nlen, p['name'], clen, p['craft'])\n end\n end",
"def to_s\n\t\t@tam_alto.times do |i|\n\t\t\t@tam_ancho.times do |j|\n\t\t\t\tprint @plano[i][j].to_s + \" \"\n\t\t\tend\n\t\t\tprint \"\\n\"\n\t\tend\n\tend",
"def info\n <<~INFO\n ~~ Planet Particulars ~~\n Name: #{@name}\n Position: #{@position}\n Mass: #{@mass}\n Radius: #{@radius}\n Orbital Period (in days): #{@orbital_period}\n Solar System: #{@solar_system}\n INFO\n end",
"def print_list\n \t\tputs \"\\n----------------------------\"\n \t\tputs \"#{@date_created.month}/#{@date_created.day}/#{date_created.year}\"\n \t\tputs \"Your Grocery List:\\n\\n\" \t\t\n \t\tif @list.empty?\n \t\t\tputs \"The List Is Empty!\"\n \t\telse\n\n \t@list.each_with_index { |item, index| puts \"#{index+1}. #{item.qty} #{item.name}\" }\n end\n puts \"\\n----------------------------\"\n end",
"def print_stations_and_trains\n show_all_trains_on_stations_header\n return show_empty_message_on_stations if Station.all.empty?\n\n Station.all.each do |station|\n show_name_of_station_header(station)\n show_empty_message_on_stations unless station.trains.any?\n\n station.each_train do |train|\n puts train\n train.each_carriage { |carriage| show_formatted_item(carriage) }\n end\n end\n end",
"def show!\n puts 'Current Hosts:'\n @plataforms.each do |key, plataform|\n puts plataform.toString\n end\n end",
"def return_solar_system_info\n solar_system_output = \"\"\n @solar_system.each do |planet_object| # planet_object represents a new planet instance\n #add to planet_output string\n solar_system_output += planet_object.planet_output\n end\n return solar_system_output\n end",
"def show_list\n\t\tclear\n\t\tputs \"= LISTE DES INSTANCES #{name} =\".bleu\n\t\tputs \"\\n\\n\"\n\t\tlen_delim = defined?(LIST_ENTETE) ? LIST_ENTETE.length + 2 : 80\n\t\tdelim = (\"-\"*len_delim).bleu\n\t\tif defined?(LIST_ENTETE)\n\t\t\tputs delim\n\t\t\tputs LIST_ENTETE \n\t\tend\n\t\tputs delim\n\t\tall.each do |inst|\n\t\t\tputs \" #{inst.to_console}\"\n\t\tend\n\t\tputs delim\n\t\tputs \"\\n\\n\"\n\tend",
"def planetaryWelcome(planet)\n\tif [:mercury, :venus, :earth, :mars, :jupiter, :saturn, :uranus, :neptune].include? planet\n\t\tputs \"Welcome to planet #{planet}!\"\n\telse\n\t\tputs \"#{planet} is not a planet!\"\n\t\tif [:moon].include? planet\n\t\t\tputs \"Come to the dark side, we have cake.\"\n\t\telsif [:pluto].include? planet\n\t\t\tputs \"Sorry dude.\"\n\t\tend\n\tend\nend",
"def dump\n locs = sectors.inject({}) { |h,s| (h[s.location || nil] ||= []) << s; h }\n\n dump = \"galaxy {\\n\"\n locs.each do |loc, sectors|\n dump << \" region(#{loc.inspect}) {\\n\" if loc\n sectors.each do |sector|\n dump << \" sector(#{SpaceMerchant::Galaxy.sectors.index(sector) + 1}) {\\n\"\n sector.planets.each do |planet|\n dump << \" planet #{planet.name.inspect}\\n\"\n end\n sector.stations.each do |station|\n dump << \" station #{station.name.inspect}\\n\"\n end\n unless sector.links.empty?\n dump << \" neighbors \"\n dump << sector.links.map { |s| Galaxy.sectors.index(s) + 1 }.join(', ')\n dump << \"\\n\"\n end\n dump << \" }\\n\"\n end\n dump << \" }\\n\" if loc\n end\n dump << \"}\\n\"\n end",
"def prints\n tiros = @tiros\n tiros.each do |tiro_puntaje|\n puts \"Puntaje por tiro: #{tiro_puntaje}\"\n end\n end",
"def pick_a_planet\n display_planet = nil\n puts \"\\nPlease choose from the following list of planets.\"\n planet_names = []\n @planets.each do |planet| # gets the names of the planets that currently exist in solar system\n planet_names << planet.name\n end\n puts planet_names\n\n # get planet choice and validate\n print \"\\nWhich planet would you like to \\\"learn\\\" more about? \"\n planet_choice = gets.chomp.capitalize\n planet_choice = planet_choice.gsub(\" \", \"\")\n while !planet_names.include? planet_choice\n print \"Sorry, which planet? \"\n planet_choice = gets.chomp.capitalize\n end\n\n # print the planet info for the chosen planet\n @planets.each do |planet|\n if planet.name == planet_choice\n puts planet.print_planet_data\n end\n end\n\n continue_or_quit\n end",
"def attributes_of_planet(planet_of_choice)\n planet_attributes = \"\"\n @planets.each do |planet_info|\n if planet_info.name == planet_of_choice\n planet_attributes += \"#{planet_info.name}'s attributes:\"\n planet_attributes += \"\\nIt has a diameter of #{planet_info.diameter}.\"\n planet_attributes += \"\\nIts gravity is #{planet_info.gravity}.\"\n planet_attributes += \"\\nIt takes #{planet_info.year_length} to spin on Axis.\"\n planet_attributes += \"\\nIts distance from the sun is #{planet_info.distance_from_the_sun}.\\n\"\n end\n end\n return planet_attributes\n end",
"def show_teams\n puts(@teams.to_s);\n end",
"def pretty_in_print(list)\n puts \"---------------------------------------\"\n puts \"These are the items we are gonna buy\"\n list.each {|item, qty| puts \"#{qty} pieces of #{item}\" }\nend",
"def display ()\n @maze_table.each_with_index do |row, i|\n (0..row.size-1).each do |index|\n print \"+\" if row[index] == \"1\" && i % 2 == 0 && index % 2 == 0\n print \"-\" if row[index] == \"1\" && i % 2 == 0 && index % 2 == 1\n print \"|\" if row[index] == \"1\" && i % 2 == 1 \n print \" \" if row[index] == \"0\"\n end\n print \"\\n\"\n end\n end",
"def park_list\n NSWParks::Nsw_parks.all.each.with_index(1) {|a,i| puts \"#{i}. #{a.park_name}\"} # Start array index from 1 not 0\n end",
"def plant_list\n self.plant_types.order('name').map {|m| m.name}.to_sentence\n end",
"def print_all_players(print_title, players)\r\n puts\r\n puts(print_title)\r\n players.each do |player|\r\n puts(\"\\t >> #{player}\")\r\n end\r\n puts\r\nend",
"def display_features\n puts\n puts \"Features:\"\n @features.each { |feature| puts \" * #{feature}\"}\n puts\n end",
"def planet_attributes\n return \"name: #{name}\\nmass: #{@mass}\\ndays to orbit star: #{@year_length}\\ndiameter: #{@diameter}\\nnumber of moons: #{@number_of_moons}\\ndistance from sun: #{distance_from_sun} million miles\"\n end",
"def print_inventory\n @inventory.each do |couple|\n puts couple.first.name + \" (#{couple.second})\"\n end\n print \"\\n\"\n end",
"def print\n placeholder = @head\n list = \"\"\n while placeholder.next\n list += placeholder.data + \"\\n\"\n placeholder = placeholder.next\n end\n list += placeholder.data + \"\\n\" # the plus \"\\n\" added because of the way the spec is written.\n printf list\n end",
"def show\n\t\t\n\t\t#Show total items and prices\n\t\tputs \"\\nShopping list: \"\n @list_products.each {|key, val| print val, \" \", key, \" \",productsMarket[key], \"$\\n\"} \n\tend",
"def to_s\n\t\t@platos.each do |alimento|\n\t\t\tputs alimento.nombre\n\t\tend\n\tend",
"def summon_captain_planet(elements)\n p elements.map {|summon_elements| \"#{summon_elements}!\".capitalize}\nend"
] | [
"0.81896716",
"0.8164517",
"0.8155885",
"0.80787927",
"0.80470777",
"0.802067",
"0.8012752",
"0.79885644",
"0.7977885",
"0.79235756",
"0.7829433",
"0.78271127",
"0.77807397",
"0.7678786",
"0.76606923",
"0.76065415",
"0.7598233",
"0.7573457",
"0.7567897",
"0.7555762",
"0.7480284",
"0.7442314",
"0.73888993",
"0.7352477",
"0.72382",
"0.7228049",
"0.7203523",
"0.7191985",
"0.716798",
"0.71515465",
"0.713706",
"0.70980066",
"0.7087301",
"0.699073",
"0.6975674",
"0.6963505",
"0.69296527",
"0.67904544",
"0.6787315",
"0.67479455",
"0.6726693",
"0.67098975",
"0.6668888",
"0.6660565",
"0.66282743",
"0.6623735",
"0.66064835",
"0.6484502",
"0.64133984",
"0.63910604",
"0.6371726",
"0.6362791",
"0.6332799",
"0.6303154",
"0.6302525",
"0.6297888",
"0.6277978",
"0.62584525",
"0.62288475",
"0.6219153",
"0.6190238",
"0.6183599",
"0.61816543",
"0.6180628",
"0.6164923",
"0.6157765",
"0.6132929",
"0.613197",
"0.6127515",
"0.61068684",
"0.6083734",
"0.60822195",
"0.60779566",
"0.6042699",
"0.60230124",
"0.6010969",
"0.6009826",
"0.6009339",
"0.60015726",
"0.6000694",
"0.5984653",
"0.598147",
"0.5972529",
"0.59677744",
"0.5960318",
"0.5951151",
"0.5949536",
"0.594351",
"0.5927851",
"0.59193796",
"0.5915536",
"0.591048",
"0.5904533",
"0.5890282",
"0.5886943",
"0.58853",
"0.5883603",
"0.58807015",
"0.5870531",
"0.5867953"
] | 0.78889024 | 10 |
that has the number of digits specified as an argument. (The first Fibonacci number has index 1.) | def find_fibonacci_index_by_length_bk(digits_num)
fib_position = 1
first_fib = 1
second_fib = 1
decimal_position = decimal_base(digits_num)
loop do
break if first_fib >= decimal_position
first_fib, second_fib = second_fib, first_fib + second_fib
fib_position += 1
end
fib_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_fibonacci_index_by_length(digits)\n index = 1\n last_fib_number = 0\n fib_number = 1\n loop do\n break if fib_number >= 10 ** (digits - 1)\n\n fib_number += last_fib_number\n last_fib_number = fib_number - last_fib_number\n index += 1\n end\n\n index\nend",
"def find_fibonacci_index_by_length(num_digits)\n prev = 1\n curr = 1\n index = 2\n return 1 if num_digits == 1\n while curr.digits.size < num_digits\n # puts \"number: #{curr} size: #{curr.digits.size} num_digits: #{num_digits}\"\n new = curr + prev \n prev = curr\n curr = new\n index += 1\n end\n # puts \"We reached number #{curr} with a length of #{num_digits} at index #{index}\"\n index \nend",
"def find_fibonacci_index_by_length(num_digits)\n \n first = 1\n second = 1\n index = 2\n \n loop do \n index += 1\n next_num = first + second\n break if next_num.to_s.size >= num_digits\n \n first = second\n second = next_num\n end\n \n \n index\nend",
"def fibonacci_index_by_length(digits)\n first = 1\n second = 1\n counter = 2\n \n loop do\n counter += 1\n fib_number = first + second\n break if fib_number.to_s.size >= digits\n first = second\n second = fib_number\n end\n \n counter\nend",
"def fibonacci_digit_counter\n num1, num2, i = -1, 0, 1\n\n #Create a while loop and iterate over the digit value of i, convert i to a string then call the length method\n #on it to get the total number of digits there.\n while i.to_s.length < 1000\n num1 += 1\n #i is equal to num2 and num2 is equal to num2\n i, num2 = num2, num2 + i\n end\n #return num1\n num1\nend",
"def find_fibonacci_index_by_length(digits)\n sequence = [1, 1]\n loop do\n n = sequence[-1] + sequence[-2]\n sequence << n\n break if n.to_s.size == digits\n end\n sequence.size\nend",
"def find_fibonacci_index_by_length(digits)\n fibonacci_series = [1, 1]\n\n while fibonacci_series.last < 10 ** (digits - 1)\n fibonacci_series << fibonacci_series[-1] + fibonacci_series[-2]\n end\n fibonacci_series.size\nend",
"def find_fibonacci_index_by_length(digits)\n fibonacci_sequence = []\n fibonacci_sequence << 0\n\n previous_number = fibonacci_sequence.last\n current_number = 1\n\n loop do\n current_number += previous_number\n previous_number = fibonacci_sequence.last\n fibonacci_sequence << current_number\n break if current_number.to_s.size >= digits\n end\n\n fibonacci_sequence.size - 1\nend",
"def find_fibonacci_index_by_length(digits)\n target_number = 10 ** (digits - 1)\n recent_nums = [1,1]\n idx = 2\n\n while recent_nums[1] < target_number\n num = recent_nums.reduce(:+)\n recent_nums.push(num).shift\n idx += 1\n end\n\n idx\nend",
"def find_fibonacci_index_by_length (digits)\n\n series = []\n series[0] = 1\n series[1] = 1\n \n counter = 2\n\n loop do \n series << series[counter - 1] + series[counter - 2]\n last_digit_size = series.last.to_s.size\n counter += 1\n break if last_digit_size == digits\n end\n \n counter\nend",
"def find_fibonacci_index_by_length(num)\n first_num = 1\n second_num = 1\n count = 3\n loop do \n result = first_num + second_num\n break if result.to_s.size == num\n first_num, second_num = second_num, result\n count += 1\n end\n count\nend",
"def find_fibonacci_index_by_length(digs)\n fibmin1 = 8\n fibonacci = 13\n counter = 7\n while fibonacci.digits.length < digs\n fibonacci = fibonacci + fibmin1\n fibmin1 = fibonacci - fibmin1\n counter += 1\n end\n counter\nend",
"def find_fibonacci_index_by_length(num_digits)\n fib = [1, 1]\n until fib[-1].to_s.size == num_digits do #read: se dodeka...\n fib << (fib[-1] + fib[-2])\n end\n fib.index(fib[-1])+1\nend",
"def find_fibonacci_index_by_length(number_digits)\n first = 1\n second = 1\n index = 2\n\n loop do\n index += 1\n fibonacci = first + second\n break if fibonacci.to_s.size >= number_digits\n\n first = second\n second = fibonacci\n end\n\n index\nend",
"def find_fibonacci_index_by_length(number_digits)\n first = 1\n second = 1\n index = 2\n\n loop do\n index += 1\n fibonacci = first + second\n break if fibonacci.to_s.size >= number_digits\n\n first = second\n second = fibonacci\n end\n\n index\nend",
"def find_fibonacci_index_by_length(num)\n fib = [1, 1]\n until fib.last.digits.size == num\n fib << fib[-1] + fib[-2]\n end\n fib.size\nend",
"def find_fibonacci_index_by_length(number_digits)\n first = 1\n second = 1\n index = 2\n\n loop do\n index += 1\n fibonacci = first + second\n break if fibonacci.to_s.size >= number_digits\n\n first = second\n second = fibonacci\n end\n\n index\nend",
"def find_fibonacci_index_by_length(num)\n counter = 0\n prev_num = 1\n result = 0\n loop do\n new_num = prev_num + result\n prev_num = result\n result = new_num\n counter += 1\n break if result.to_s.length == num\n end\n counter\nend",
"def find_fibonacci_index_by_length_2(number_digits)\n first, second = 1\n index = 2\n\n loop do\n index += 1\n fibonacci = first + second\n break if fibonacci.digits.size >= number_digits\n first = second\n second = fibonacci\n end\n index\nend",
"def find_fibonacci_index_by_length(int)\nlimit = (10**int)/10\nindex = 2\nx = 1\ny = 1\n loop do\n z = x + y\n x = y\n y = z\n index += 1\n break if z > limit \n end\n index\nend",
"def find_fibonacci_index_by_length(num_of_digits)\n fibonacci = [1, 1]\n loop do\n fibonacci << fibonacci[-1] + fibonacci[-2]\n break if fibonacci.last.to_s.size == num_of_digits\n end\n\n fibonacci.index(fibonacci.last) + 1\nend",
"def find_fibonacci_index_by_length(num)\n count = 0\n idx = 2\n\n loop do\n break if count.to_s.size == num\n if idx <= 2\n count = 1\n elsif idx > 2\n count += 1\n end\n idx += 1\n count += 1\n end\n idx\nend",
"def fibonacci(limit)\n sequence = [0]\n if limit == 0\n puts \"Please enter a number above 0\"\n else\n pattern = 1\n (limit - 1).times do |index|\n sequence << pattern\n pattern = pattern + sequence[index]\n end\n puts \"The first #{limit.to_s} numbers in the Fibonacci Sequence are #{sequence}\"\n end\nend",
"def find_fibonacci_index_by_length(length)\n a, b = 1, 1\n index = 2\n\n until b.to_s.length >= length\n a, b = b , b + a\n index += 1\n end\n index\nend",
"def fibonacci_last(n)\n return 1 if n.between?(1, 2)\n prev_last_digits = [1, 1]\n \n 3.upto(n) do |_|\n prev_last_digits << prev_last_digits.sum % 10\n prev_last_digits.shift\n end\n \n prev_last_digits.last\nend",
"def find_fibonacci_index_by_length(num_size)\n fibonacci_numbers = [1, 1]\n counter = 2\n\n while fibonacci_numbers.last.digits.length < num_size\n fibonacci_numbers << (fibonacci_numbers[counter-1] + fibonacci_numbers[counter-2])\n counter += 1\n end\n\n fibonacci_numbers.length\nend",
"def nth_fib(x)\n arr = [0,1]\n count = 1\n while count < x\n next_val = arr[-1] + arr[-2]\n arr = [arr[-1], next_val]\n count += 1\n end\n puts next_val\n # puts \"The weird algorithm from Hackerank comes to: #{next_val % (10**8 + 7)}\"\n end",
"def fib_number(n)\n fib_array = (1..n).collect { |num| nth_fibonacci num }\n fib_array.join().to_i\nend",
"def find_fibonacci_index_by_length(integer)\n fib_nums = [1, 1]\n i = 2\n loop do\n fib_nums[i] = fib_nums[i - 1] + fib_nums[i - 2]\n break if fib_nums[i].digits.length >= integer\n i += 1\n end\n i + 1 \nend",
"def fibonacci_last(n)\n return 1 if n <= 2\n n1, n2 = [1, 1]\n 3.upto(n) { n1, n2 = [n2, n1 + n2] }\n n2.to_s.chars[-1].to_i\nend",
"def nthFibonacci (n)\r\n # Your code here\r\n a = 0\r\n b = 1\r\n n.times do\r\n temp = a\r\n a = b\r\n b = temp + b\r\n end\r\n return a\r\nend",
"def fibonacci_given(nth)\n return 1 if nth <= 2\n fibonacci_given(nth - 1) + fibonacci_given(nth - 2)\nend",
"def nthFibonacci (n)\n # Your code here \nend",
"def fibonacci(fib)\r\n \t#Set a variable to 0\r\n\tvalue1 = 0 \r\n\t#Set a variable to 1 (array must start with 0, 1...)\r\n\tvalue2 = 1\r\n\t\t#For the number of digits it will be, loop do this many times\r\n\t\tfib.times do \r\n\t\t\t#Create a temp to store value1\r\n \t\t\ttemp = value1\r\n \t\t\t#Make value1 equal value2\r\n \t\t\t#This will help when printing out 0,1,1.. in the beginning\r\n \t\t\tvalue1 = value2\r\n \t\t\t#Make value2 equal the sum of temp and value2\r\n \t\t\t#This will add the last numbers to get the next number\r\n \t\t\tvalue2 = temp + value2\r\n \t\t#End do loop\r\n\t\tend\r\n\t#Return the first value\r\n \tvalue1\r\n#End of method\r\nend",
"def digits_of_answer(digits)\n n = 0\n previous = 0\n i = 1\n\n\n\n while i.to_s.length < digits\n n += 1\n i, previous = previous, previous + i\n end\n\n (n-1)\nend",
"def nthFibonacci (n)\r\n num = n.to_i\r\n fibonacci_sequence = Array.new\r\n case num\r\n when 0 \r\n fibonacci_sequence << 0\r\n when 1\r\n fibonacci_sequence << [0,1]\r\n else\r\n fibonacci_sequence[0] = 0\r\n fibonacci_sequence[1] = 1\r\n i = 1\r\n while i < num\r\n i+= 1\r\n fibonacci_sequence[i] = fibonacci_sequence[i-1] + fibonacci_sequence[i-2] \r\n end\r\n end\r\n return fibonacci_sequence\r\nend",
"def fibonacci_last(nth)\n result = []\n nth.times do \n result.size < 2 ? result << 1 : result << result[-2] + result[-1]\n end\n result[-1].digits[0] # result.last.digits.first\nend",
"def nDigits n,a\n return 1000 if a == 10 && n == 1000 # incorrect test\n ((Math.log10(a)*n)+1).to_i\nend",
"def find_fibonacci_index_by_length(x)\n n1 = 1\n n2 = 1\n index = 2\n until (n1 + n2).to_s.size >= x\n fibonacci = n1 + n2\n n1 = n2\n n2 = fibonacci\n index += 1\n end\n index + 1\nend",
"def nthFibonacci(n)\r\n fibonacci = []\r\n a = 0 \r\n b = 1\r\n\r\n while n >= fibonacci.length\r\n fibonacci.push(a)\r\n fibonacci.push(b)\r\n a = a + b\r\n b = a + b\r\n end\r\n return fibonacci[n]\r\nend",
"def find_fibonacci_index_by_length(length)\n fibonacci_sequence(length).size\nend",
"def nth_fibonacci(n)\n return 0 if n == 1\n sequence = [1]\n (n - 2).times do\n current_number, last_number = sequence.last(2)\n sequence << current_number + (last_number || 0)\n end\n\n sequence.last\nend",
"def nthFibonacci (n)\n # Your code here\n fArr = []\n a = 0\n b = 1\n if n == 0\n fArr << 0\n elsif n == 1\n fArr << 0\n elsif n > 1\n fArr << 0\n while fArr.size < n+1 do\n fArr << b\n a,b = b,a+b\n end\n end\n return fArr[n]\nend",
"def fibonacci(n)\n fib = [1, 1]\n while fib.size < n\n fib << fib[-1] + fib[-2]\n end\n fib.last % 10\nend",
"def fibonacci(how_many_numbers)\n fibonacci_sequence = []\n count = 0\n while count < how_many_numbers\n if count == 0\n fibonacci_sequence << 0\n count += 1\n elsif count == 1\n fibonacci_sequence << 1\n count += 1\n else\n fibonacci_sequence << fibonacci_sequence[-1] + fibonacci_sequence[-2]\n count += 1\n end\n end\n fibonacci_sequence\nend",
"def nthFibonacci (n)\n \n if n == 0\n return 0\n end\n\n i = 0\n\n sequence = Array.new\n\n sequence.push(i)\n\n i += 1\n\n sequence.push(i)\n\n while i < n do\n sequence[i+1] = (sequence[-1]) + (sequence[-2])\n\n i += 1\n end\n\n sequence[-1]\nend",
"def fibo(n)\n if n <= 2\n fibo_num = 1\n else\n fibo_num = fibo(n-1) + fibo(n-2)\n end\n fibo_num\nend",
"def compute_number(digits)\n digits.length == 1 ? (digits.to_i) : (digits[-1].to_i + 10*compute_number(digits[0..-2]))\nend",
"def get_fibonacci(num)\n f = [0,1]\n for i in (2..num)\n f << (f[-1] + f[-2])\n end\n if num == 0\n f = 0\n end\n f[-1]\nend",
"def twenty\n sum_of_digits(factorial(100))\nend",
"def firstFibOfLength(limit)\n\tfl, fc = 1,1\n\tcount = 2\n\twhile(fc < limit)\n\t\tfl,fc,count = fc,fl+fc,count + 1\n\tend\n\tcount\nend",
"def fibonacci(n)\n if n.nil?\n raise ArgumentError.new(\"Invalid\")\n elsif n < 0\n raise ArgumentError.new(\"Invalid\")\n end\n\n return 0 if n == 0\n\n num_one = 0\n num_two = 1\n fib_n = 1\n\n count = n - 1\n\n count.times do\n fib_n = num_one + num_two\n num_one = num_two\n num_two = fib_n\n end\n\n return fib_n\nend",
"def fibonacci(n)\n n = fibonacci( n - 1 ) + fibonacci( n - 2 ) if n > 1\n n\nend",
"def nthFibonacci(n)\r\n if n == 1\r\n return 1\r\n\r\n elsif n == 2\r\n return 1\r\n\r\n else n > 2\r\n n = nthFibonacci(n-1) + nthFibonacci(n-2)\r\n end\r\nend",
"def nthFibonacciNumber ()\n f = [1, 1]\n puts \"Which fibonacci number do you want?\"\n n = gets.chomp\n\n # error checking baked in\n if n.to_i.to_s != n\n puts \"That is not an integer\"\n else\n while f.size < n.to_i\n length = f.length\n nextFib = f[length - 2] + f[length - 1]\n f.push(nextFib)\n end\n puts \"#{f[-1]} is the fibonacci number at position #{n}\"\n end\nend",
"def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def find_fibonacci_index_by_length(places)\n a = 1\n b = 1\n fib_sequence = []\n\n until fib_sequence.last.to_s.size == places\n fib_sequence << a\n a = b\n b += fib_sequence.last\n end\n fib_sequence.size\nend",
"def factorial_digits(n)\n return fact(n) if n <= 9\n fact(n % 10) + factorial_digits(n / 10)\nend",
"def fibonacci(n)\n if n == nil || n < 0\n raise ArgumentError\n elsif n == 0\n return 0\n elsif n == 1\n return 1\n end\n\n first = 0\n second = 1\n\n index = 1\n while index < n\n holder = first + second\n first = second\n second = holder\n index += 1\n end\n return holder\nend",
"def fibonacci(nth)\n return 1 if nth <= 2\n\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fibonacci(n)\n fibonacci_num = 0\n prior_num = 0\n current_num = 1\n\n if !n || n < 0\n raise ArgumentError\n elsif n == 0 || n == 1\n return n\n else \n (n-1).times do\n fibonacci_num = prior_num + current_num\n prior_num = current_num\n current_num = fibonacci_num\n end\n return current_num\n end\nend",
"def fibonacci(number)\r\n if number < 2\r\n number\r\n else\r\n fibonacci(number - 1) + fibonacci(number - 2)\r\n end\r\nend",
"def f(n)\n sum = (\"1\"*n).to_i # the last number of the sequence is n 1's\n # start with single digit if possible\n sum += n if n.to_s.length == 1\n # 2 digits next\n x = 2\n puts terms_of_n_with_length_x(n,x).inspect\n puts \"got here\"\n puts n-1\n (1..(n-1)).to_a.reverse.each do |x|\n puts x\n puts eat_2s(x)\n end\n return sum\nend",
"def fib (n)\n # return appropriate starter values if n is 0 or 1\n if n == 0 \n return 0\n elsif n == 1\n return 1\n end\n # set up initial constants\n prevNum = 0\n currNum = 1\n # Loop through fibonacci numbers, starting at index 2.\n 2.upto(n) do\n nextNum = prevNum + currNum\n prevNum = currNum\n currNum = nextNum\n end\n return currNum\nend",
"def fibonacci(number_output)\n fibonacci=[1] #default with only one number\n if number_output > 1\n fibonacci << 1 #second digit in fibonnacci sequence\n if number_output > 2\n #already has two numbers in array\n (number_output-2).times do |count|\n fibonacci << fibonacci[-1] + fibonacci[-2]\n end\n end\n end\n print fibonacci\nend",
"def find_fibonacci_index_by_length(num)\n fibonacci = [1, 1]\n loop do\n fibonacci << (fibonacci[-2] + fibonacci[-1])\n break if fibonacci[-1].to_s.length == num\n end\n fibonacci.size\nend",
"def last_n_digits(num, n)\r\n # your code goes here\r\n num % 10**n\r\nend",
"def fibonacci_last(nth)\n answer = fibonacci(nth)\n answer.to_s.chars[-1].to_i\nend",
"def fibonacci_last(n)\n x = 1\n y = 1\n z = 0\n (n-2).times do\n z = x + y\n x = y%10\n y = z%10\n end\n z % 10\nend",
"def fibonacci(nth)\n return 1 if nth < 3\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fibonacci_number(n)\n #define nth Fibonacci term\n fibonacci_lst=[0,1] #F1=1,F2=1\n for i in 2..n\n fibonacci_lst[i]=fibonacci_lst[i-1]+fibonacci_lst[i-2]\n end\n return fibonacci_lst[n]\nend",
"def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend",
"def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend",
"def find_fibonacci_index_by_length(num)\n fibonacci = [1,1]\n n = 2\n\n loop do\n break if fibonacci.last.to_s.length == num\n fibonacci << fibonacci[n - 1] + fibonacci[n - 2]\n n += 1\n end\n\n n\nend",
"def fibonacci_number(i)\n if i == 1 || i == 2\n 1\n else\n fibonacci_number(i - 1) + fibonacci_number(i - 2)\n end\nend",
"def fib(x)\n fibo_number = [0, 1]\n (x - 2).times do\n n = fibo_number[-1] + fibo_number[-2]\n fibo_number << n\n end\n puts fibo_number\nend",
"def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fibonacci_last2(num)\n num %= 60\n return 0 if num == 0\n last = 1\n pen_ultimate = 1\n 3.upto(num) do\n last, pen_ultimate = (pen_ultimate + last) % 10, last\n end\n last\nend",
"def fibonacci(n)\n raise ArgumentError if n == nil\n raise ArgumentError if n < 0\n\n i = 0\n k = 0\n m = 0\n j = 1\n\n until i > n\n k = k + m\n m = j\n j = k\n i += 1\n end\n\n return k\nend",
"def biggest_possible_digit_factorial\n digits = 1\n \n loop do \n digits += 1\n break if digits * factorial(9) < ('9' * digits).to_i\n end\n ('9' * digits).to_i\nend",
"def fib(n)\n arr = []\n for i in 0..n do\n if i == 0\n arr.push(0)\n elsif i == 1\n arr.push(1)\n else\n arr.push(arr[i-1] + arr[i-2])\n end\n end\n return arr.last.to_s.size\nend",
"def find_fibonacci_index_by_length(number)\n fibonacci = [1, 1]\n index = 2\n while fibonacci.last.to_s.size < number\n index += 1\n fibonacci[0], fibonacci[1] = fibonacci[1], fibonacci[0] + fibonacci[1]\n end\n index\nend",
"def nth_fibonacci(n) \n if n == 1\n return 0\n elsif n == 2\n return 1\n end\n return nth_fibonacci(n-1) + nth_fibonacci(n-2)\nend",
"def nthFibonacci (n)\r\n # Your code here\r\n f = [0, 1, 1, 2, 3, 5, 8]\r\n if n < 7\r\n return f[n]\r\n end\r\n\r\n t = 6\r\n fn = 8\r\n\r\n while t < n\r\n fn = (fn * PHI).round(0)\r\n t += 1\r\n end\r\n\r\n return fn\r\nend",
"def fibonacci_last(n)\n fibonacci(n).to_s[-1].to_i\nend",
"def nth_fibonacci(n)\n result = [0,1]\n\n for i in 1..n-1\n result[i+1] = result[i] + result[i-1]\n end\n\n return result[n]\nend",
"def fibonacci_num(num)\n return 0 if num == 0\n return 1 if num == 1\n return 1 if num == 2\n fib_num = (fibonacci_num(num - 1)) + (fibonacci_num(num - 2))\nend",
"def fibonacci(number)\n $counter += 1\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fibonacci(n)\n raise ArgumentError if n.nil?\n raise ArgumentError if n < 0\n\n number = 0\n succeeding = 1\n n.times do\n temp = succeeding\n succeeding += number\n number = temp\n\n end\n return number\nend",
"def fibo(num)\n \n print \"Fibonacci series is: \"\n\n if num == 0\n puts num\n return num\n end\n\n if num == 1\n puts \"0 1\"\n return num\n end\n\n i,j,cur = 0,1,1\n\n print \"0 1 \"\n while cur < num\n k = i\n i = j\n j = k + j\n print \"#{j} \"\n cur = cur + 1\n end\n\n return j\n\nend",
"def num_of_num(number)\n\tnumber_of_num=1\n\tnumber_size=number.to_s.size\n while number_size > 1 do\n number_of_num = number_of_num * \tnumber_size\n number_size = number_size - 1 \n end\n return number_of_num\nend",
"def iterative_fib(num)\r\n\treturn num if num < 2\r\n\tfib = [0, 1]\t\r\n\t(2..num).each do |digit|\r\n\t\tx = fib[digit - 1] + fib[digit - 2]\r\n\t\tfib << x\r\n\tend\r\n\treturn fib.last\r\nend",
"def find_fibonacci_index_by_length(num)\n fib_nums = [1, 1]\n\n loop do\n next_fib = fib_nums[-2] + fib_nums[-1]\n fib_nums.push(next_fib)\n return fib_nums.length if fib_nums[-1].to_s.length == num\n end\nend",
"def iterative_nth_fib(n)\n return 1 if n <= 2\n a = 1\n b = 1\n i = 3\n while i <= n\n new_a = b\n b = a + b\n a = new_a\n i += 1\n end\n b\nend"
] | [
"0.80817133",
"0.7976853",
"0.7937612",
"0.7924988",
"0.79147226",
"0.7909445",
"0.7904327",
"0.78173935",
"0.78128386",
"0.778339",
"0.77623636",
"0.77336115",
"0.76942456",
"0.76265967",
"0.76265967",
"0.76014495",
"0.7590078",
"0.75671375",
"0.75468105",
"0.7531966",
"0.7500568",
"0.7428807",
"0.7307704",
"0.72018564",
"0.7190321",
"0.7189279",
"0.71862084",
"0.7136434",
"0.7135867",
"0.71088004",
"0.70964897",
"0.70555735",
"0.70548934",
"0.70219725",
"0.7016406",
"0.7015647",
"0.69902575",
"0.69848853",
"0.6979375",
"0.6951441",
"0.6951075",
"0.6940769",
"0.6935793",
"0.6927249",
"0.69140804",
"0.69114095",
"0.6897449",
"0.68892497",
"0.6885697",
"0.6880012",
"0.6879636",
"0.68777704",
"0.68739766",
"0.68705845",
"0.6869816",
"0.68678874",
"0.68678874",
"0.68678874",
"0.68678874",
"0.685411",
"0.68508446",
"0.6849792",
"0.68429244",
"0.68394107",
"0.6830256",
"0.68293065",
"0.6825595",
"0.68242896",
"0.68192685",
"0.6818861",
"0.6816441",
"0.6813936",
"0.6810834",
"0.680833",
"0.6805627",
"0.6805627",
"0.68048644",
"0.6797726",
"0.67906785",
"0.67846084",
"0.67846084",
"0.67846084",
"0.67846084",
"0.6784233",
"0.6782638",
"0.67815375",
"0.6779555",
"0.67746496",
"0.6773606",
"0.67705405",
"0.67621815",
"0.6753856",
"0.6751962",
"0.6749022",
"0.6745673",
"0.67425686",
"0.67416316",
"0.6736309",
"0.6731131",
"0.6722192"
] | 0.752822 | 20 |
def decimal_base(n) ten_to_position = 1 loop do n = 1 break if n == 0 ten_to_position = 10 end ten_to_position end | def decimal_base(n)
10**(n-1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toBase(n, base)\n return n.to_s(base) if base > 0\n return '0' if n.zero?\n\n digits = []\n while n != 0\n n, remainder = n.divmod(base)\n if remainder < 0\n n += 1\n remainder -= base\n end\n digits << remainder\n end\n digits.join.reverse\nend",
"def super_digit(n)\n while n >= 10\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend",
"def super_digit(n)\n while n > 9\n n = n % 10 + super_digit(n / 10)\n end\n return n\nend",
"def super_digit(n)\n # base case\n return n if n/10 == 0\n \n # recursive case\n return super_digit(n/10 + n%10)\nend",
"def super_digit(n)\n n < 10 ? n : super_digit(n / 10 + n % 10)\nend",
"def convert_base(number, base)\n \n exponents = []\n n = 0 # Exponent / number position\n\n # Find the appropriate exponent size larger than the number \n while number != 0\n # puts \"Current top number: #{number}\"\n # puts \"Current exponent value: #{n}\"\n running_total = 0\n if number < base ** n\n # puts \"Base ** n: #{base ** n}\" \n # puts \"If loop current number: #{number}\"\n running_total += base ** (n-1)\n # puts \"If loop running_total: #{running_total}\"\n number = number - running_total\n # puts \"If loop number after subtraction: #{number}\"\n if exponents[n-1].nil? then exponents[n-1] = 1 else exponents[n-1] += 1 end\n n = 0\n else\n n += 1\n end\n end\n\n exponents.inspect\n\nend",
"def super_digit(n)\n return n if n/10 == 0\n \n sum = n % 10\n while n/10 != 0\n n = n/10\n sum += n % 10\n end\n return super_digit(sum)\nend",
"def super_digit(n)\n return n if n < 10\n\n sum_digits = 0\n until n == 0\n sum_digits += n % 10\n n /= 10\n end\n\n super_digit(sum_digits)\nend",
"def super_digit(n)\n return n if n <= 9\n \n until n < 10\n sum = 0\n sum += (n % 10)\n sum += (n / 10)\n n = sum\n end\n\n return sum\nend",
"def dec_to_base7(decimal)\r\n result = []\r\n until decimal == 0\r\n result.push(decimal % 7)\r\n decimal = decimal / 7\r\n end\r\n return result.reverse.join.to_i\r\nend",
"def base_converter(num, b)\n\n return num.to_s if [0, 1].include?(num)\n\n digits = %w(0123456789abcdef)\n base_converter(num/b, b) + digits[num % b]\n\nend",
"def decimal(digits, base)\n e = digits.size - 1\n v = 0\n digits.each do |n|\n v += n.to_i * base**e\n e -= 1\n end\n v\n end",
"def digital_root(n)\n n < 10 ? n : digital_root(n / 10 + n % 10)\nend",
"def s(n)\n ((9*n-1)*(10**n)+1)/9\nend",
"def super_digit(n)\n if 10 > n\n return n\n end\n\n last_digit = n % 10\n sum = n / 10 + last_digit \n \n return super_digit(sum)\nend",
"def base_converter(num, b)\n return num.to_s if [0,1].include?(num)\n\n digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)\n base_converter(num/b, b) + digits[num % b]\nend",
"def persistence(n)\n n < 10 ? 0 : 1 + persistence(n.digits.reduce(&:*))\nend",
"def super_digit(n)\n sum = 0\n while n >= 10 do\n sum += n % 10\n n /= 10\n end\n sum += n\n return sum < 10 ? sum : super_digit(sum)\nend",
"def get_first_digit n \n n / 10**length(n) \nend",
"def super_digit(n)\n return n if n < 10\n\n sum = 0 \n\n while n > 0\n digit = n % 10\n n /= 10\n sum += digit\n end\n\n super_digit(sum)\n\nend",
"def base_converter(num, b)\n return \"\" if num == 0\n digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)\n\n base_converter(num/b, b) + digits[num%b]\n end",
"def last_n_digits(num, n)\r\n # your code goes here\r\n num % 10**n\r\nend",
"def super_digit(n)\n sum = 0\n\n if n < 10\n return sum + n\n else\n until n < 10\n sum += (n % 10)\n n /= 10\n end\n\n sum += n\n end\n\n return super_digit(n = sum)\nend",
"def super_digit(n)\n return n if n / 10 == 0\n return super_digit(digit_helper(n))\nend",
"def super_digit(n)\n sum = 0;\n\n while n > 0 || sum > 9\n if n == 0\n n = sum\n sum = 0\n end\n sum += n % 10\n n /= 10\n end\n return sum\nend",
"def champernowne(n)\n # Find which base-10 'power' n belongs to.\n # (if it is ones, tens, hundreds, thousands, etc)\n power = 0\n 0.step do |d|\n if 9*(d+1) * 10**(d) >= n\n power = d\n break\n end\n end\n return n if power == 0\n digits = power + 1\n # Get all the numbers that we've passed through before reaching n.\n bounds = (0..(power-1)).map { |d| 9*(d+1) * 10**(d) }\n passed_indices = bounds.reduce(0, :+) # In the case where n is in [1, 9], bounds defaults to 0.\n normalized_position = n - passed_indices\n number = (10**power + (normalized_position - 1) / (digits)).to_s\n # This variable holds the index of the digit to be returned.\n normalized_index = normalized_position % digits\n return (normalized_index == 0 ? number[-1] : number[normalized_index-1]).to_i\nend",
"def round_1_sig_fig n \n get_first_digit(n) * 10**length(n)\nend",
"def super_digit(n)\n return n if n < 10 \n return super_digit(n.to_s.chars.map(&:to_i).sum)\nend",
"def super_digit(n)\n return n if n < 10 \n \n sum = 0\n until n == 0\n sum += n % 10\n n /= 10\n end\n \n return super_digit(sum) # I had n.digits.sum here earlier, but since #digits creates a new array, I thought this solution would be less expensive\nend",
"def place_to_num(place, base = 10)\n place > 1 ? base**(place - 1) : 1\n end",
"def base2to10(binary)\n base_ten = 0\n binary.split(\"\").reverse.map {|digit| digit.to_i}.each_with_index {|digit, index| base_ten += digit * (2**index)}\n return base_ten\nend",
"def digital_root(n)\n return n < 1 ? 0 : (n - 1) % 9 + 1\nend",
"def from_base(base=10)\n n = 0\n chars.reverse_each.with_index do |c, power|\n value = BASE_DIGITS[c]\n n += (base**power) * value\n end\n n\n end",
"def digital_root(n)\r\n while n > 9\r\n n = n.digits.inject(:+)\r\n end\r\n n\r\nend",
"def to_i(base=10) end",
"def smallest_n_digit_number(n)\n 10 ** (n-1)\nend",
"def base10_to_base2(num)\n base2_ary = []\n\n MAX_POWER_OF_TWO.downto(0).each do |pow|\n if 2 ** pow <= num\n base2_ary << num / 2 ** pow\n num = num % 2 ** pow\n else\n base2_ary << 0\n end\n end\n\n base2_ary.join('').to_i\nend",
"def super_digit(n)\n return n.abs if n.abs < 10\n\n sum = recursive_digit_helper(n)\n\n return super_digit(sum)\nend",
"def base_conversion(value, base)\n #if value < 0\n # @negative, value = true, value.abs\n #end\n i = value.abs\n\n a = []\n while i > 0\n i, r = i.divmod(base)\n a << r\n end\n\n a << 0 if a.empty?\n\n a.reverse\n end",
"def super_digit(n, sum=0) \n return sum + n if n / 10 == 0\n return super_digit(super_digit(n/10, sum+(n%10)))\nend",
"def super_digit(n)\n return n if n / 10 < 1\n \n string = n.to_s.split(\"\")\n sum = 0\n \n string.each do |num|\n sum += num.to_i\n end\n \n return super_digit(sum)\nend",
"def super_digit(n)\n return n if n < 10\n sum = n.to_s.chars.map(&:to_i).sum\n return super_digit(sum)\nend",
"def nDigits n,a\n return 1000 if a == 10 && n == 1000 # incorrect test\n ((Math.log10(a)*n)+1).to_i\nend",
"def to_base(a, b)\n return [a] if a == 1 or a == 2\n maxlen = Math.log(a + 1, b).ceil\n base_nums = Array.new maxlen, 0\n while a > 0\n c = Math.log(a, b).floor\n rm = b ** c\n a -= rm\n i = maxlen - c - 1\n base_nums[i] += 1\n end\n base_nums\nend",
"def kidmod10(base); end",
"def recursiveBaseExpansionOf(base, n, a)\n if n != 0\n q = (n/base).floor\n recursiveBaseExpansionOf(base, q, a << n - (q * base))\n else \n return a\n end\n end",
"def super_digit(n)\n return n if n < 10\n sum = super_digit_helper(n, 0)\n super_digit(sum)\nend",
"def superDigit(n, k)\n target = n.split('').map(&:to_i).sum * k\n\n until target < 10\n target = target.digits.sum\n end\n\n target\nend",
"def digital_root(n)\n until n < 10 do\n j = n\n n = 0\n until j < 1 do\n n += j % 10\n j /= 10\n end\n end\n return n\nend",
"def super_digit(n)\n return n if n < 10\n super_digit(n.digits.sum)\nend",
"def super_digit(n)\n return n if n < 10\n super_digit(n.digits.sum)\nend",
"def super_digit(n)\n raise ArgumentError if n < 0\n return n if n < 10\n super_digit(sum_of_digits(n))\nend",
"def digital_root(num)\n until num < 10\n num = num.to_s.split(\"\")\n formatted = []\n num.each do |n|\n formatted << n.to_i\n end\n\n num = formatted.inject(:+)\n end\n num\nend",
"def super_digit(n)\n return n if n < 10\n return super_digit(n.digits.sum)\nend",
"def represent(number, in_base:)\n digits = \"\"\n\n while number > 0\n digits = CHARS[number % in_base] + digits\n number = number / in_base\n end\n\n digits\n end",
"def digital_root(n)\n p '--- Jan-09-2017 problem2 --- '\n n = n.to_s.chars.map(&:to_i).reduce(:+) until n < 10\n n\nend",
"def decimalExpansionOf(n)\n i = 0\n expansion = 0\n while i < n.count\n expansion += (n[i] * 2 ** i)\n i+= 1\n end\n return expansion\n end",
"def base2to10(binary)\n #split to single digits\n digits = binary.split('').map{|str| str.to_i}.reverse\n #loop through multiply by 2 raised to index and add to result\n result = 0\n digits.each_with_index do |num, i|\n result += (num *(2**i))\n end\n result\nend",
"def persistence(n)\n count = 0\n while n > 9 do\n n = n.digits.inject(:*)\n count += 1\n end\n count\nend",
"def zeros(n)\n if n <= 3\n return 0\n end\n total = 1\n while n > 1\n total *= n\n n -= 1\n end\n result = 0\n while true\n if total % 10 != 0\n return result\n else\n total /= 10\n result += 1\n end\n end\n end",
"def number_base_repeat(base)\n\t(self- (self % base)) / base\nend",
"def super_digit(n)\n\n return n if n < 10\n super_digit(n.digits.sum)\n\nend",
"def super_digit(n)\n #has to be a single digit \n if n < 10 \n return n\n else \n return super_digit(n.digits.sum)\n end \n \n \nend",
"def last_digit(int)\r\n # your code goes here\r\n # in decimal math, last digit is the modulo when divided the number by 10\r\n\r\n int % 10\r\nend",
"def super_digit(n)\n return n if n < 10\n\n return super_digit(n.digits.sum)\nend",
"def convert( number, base )\n if(number < base)\n return @digits[number]\n else\n return convert( number / base, base ) + @digits[ number % base ]\n end\n end",
"def digital_root(n)\n num = 0\n n.to_s.split(\"\").each {|x| num += x.to_i}\n num.to_i > 9 ? digital_root(num.to_i) : num.to_i\nend",
"def binary_to_base_n(binaryarr, base)\n val = 0\n pow = 0\n while !binaryarr.empty?\n val += binaryarr.pop * 2**pow\n pow += 1\n end\n t = []\n num_to_digit_array(val, base).each do |dig|\n if dig > 9\n t << (('a'..'z').to_a[dig-10])\n else\n t << (dig)\n end\n end\n t.join\nend",
"def refined_super_digit(n, k)\n sum = 0\n until n == 0\n sum += n % 10\n n /= 10\n end\n\n n = sum * k\n return super_digit(n)\nend",
"def sumdig_r(n)\n return n if n < 10\n (n%10) + sumdig_r(n/10)\nend",
"def super_digit(n)\n if n >= 0 && n < 10 \n return n\n end\n digits_of_n = n.digits\n sum_digits = digits_of_n.sum\n\n return super_digit(sum_digits)\nend",
"def super_digit(n)\n return n if n < 10\n count = add_digits(n)\n return super_digit(count)\n\nend",
"def digital_root(n)\n arr = n.to_s.split('')\n if arr.length != 1\n tot = arr.inject(0){|sum,x| sum.to_i + x.to_i }\n while (tot >= 10)\n tot = tot.to_s.split('').inject(0){|sum,x| sum.to_i + x.to_i }\n end\n else \n return arr[0].to_i\n end\n return tot\n end",
"def base2to10(str_num)\n str = str_num.dup.reverse\n total = 0\n\n str.each_char.with_index do |char, idx|\n total += (char.to_i * (2 ** idx))\n end\n total\nend",
"def value_of(digits, in_base:)\n number = 0\n\n digits.to_s.chars.each do |digit|\n number = in_base * number + CHARS.index(digit)\n end\n\n number\n end",
"def super_digit(n)\n num_array = n.to_s.chars.map(&:to_i)\n sum = num_array.sum\n if sum <9\n return sum\n else \n return super_digit(sum)\n end\n \nend",
"def factorial(n)\n base = 1\n n.downto(1) { |val| base *= val }\n return base\nend",
"def decimal_to_binary(number)\n if number == 0\n 0\n else\n number % 2 + 10 * decimal_to_binary(number/2)\n end \nend",
"def digital_root(n)\n return n if n < 10\n \n n_arr = n.to_s.chars\n num = n_arr.first.to_i\n new_num = n_arr[1..-1].join.to_i\n digital_root(num + digital_root(new_num))\nend",
"def compute_number(digits)\n digits.length == 1 ? (digits.to_i) : (digits[-1].to_i + 10*compute_number(digits[0..-2]))\nend",
"def find_the_digit number\n if number / 1000\n thousands = number / 1000\n number = number - thousands*1000\n puts \"thousands: #{thousands}\"\n end\n if number / 100\n hundreds = number / 100\n number = number - hundreds*100\n puts \"hundreds: #{hundreds}\"\n end\n if number / 10\n tens = number / 10\n number = number - tens*10\n puts \"tens: #{tens}\"\n end\n if number / 1\n ones = number / 1\n puts \"ones: #{ones}\"\n end\nend",
"def super_digit(n)\n string_n = n.to_s\n return n if string_n.size == 1\n\n i = 1\n sum = string_n[0].to_i\n while i < string_n.size\n sum += string_n[i].to_i\n i += 1\n end\n return super_digit(sum)\n end",
"def digital_root_best(n)\r\n n < 10 ? n : digital_root_best(n/10 + n%10)\r\nend",
"def last_n_digits(num, n)\n # your code goes here\n if n == 1\n return num % 10\n else\n \treturn num % 100\n end\nend",
"def s(n)\n n.to_s.gsub(/\\d/) { |d| d.to_i**2 }.to_i\nend",
"def super_digit(n)\n n_array = n.to_s.split('').map {|i| i.to_i}\n return n if n_array.length == 1\n return super_digit(n_array.sum)\nend",
"def super_digit(n)\n string_n = n.to_s\n return n if string_n.size == 1\n\n i = 1\n sum = string_n[0].to_i\n while i < string_n.size\n sum += string_n[i].to_i\n i += 1\n end\n return super_digit(sum)\nend",
"def digital_root(number)\n return number if number < 10\n\n digital_root((number / 10) + (number % 10))\nend",
"def substracts_from_next_ten(input)\n output = 10 - input % 10\n output = 0 if output == 10\n output\n end",
"def super_digit(n)\n new_num = 0\n numbers = n.to_s.split(\"\")\n if numbers.length <= 1\n return n\n end\n numbers.each do |i|\n new_num += i.to_i\n end\n return super_digit(new_num)\nend",
"def power_of_n(number, power)\n array = [number] * power\n base_number = 1\n array.each do |num|\n base_number = multiply(base_number, num)\n end\n base_number\nend",
"def refined_super_digit(n, k)\n return n if k == 1 && n/10 == 0\n sum = 0\n sum += super_digit(n) * k\n return super_digit(sum)\nend",
"def comb n\n #if integer has more than 1 digit \n if n >= 10\n #if the first digit is less than the second digit of the integer\n if get_first_digit(n) < get_first_digit(drop1(n))\n #switch first and second digits, continue combing\n (round_1_sig_fig(drop1(n)) * 10) + comb( (round_1_sig_fig(n) / 10) + drop1(drop1(n)) )\n else\n #digits are in correct positions, contiune combing\n round_1_sig_fig(n) + comb(drop1(n))\n end\n else\n #last digit reached, comb finshed.\n n\n end\n\nend",
"def rec_cycle_length(n)\n decimals = []\n remainder = 1\n remainders = []\n continue = true\n while continue do\n remainders << remainder\n remainder = (remainder * 10 % n)\n if remainders.include? remainder\n continue = false\n end\n end\n remainders.length - remainders.find_index(remainder)\nend",
"def digital_root(num)\n return num if num < 10\n digital_root((num % 10) + (num / 10))\nend",
"def digital_root(n)\n n < 10 ? n : digital_root(n.digits.sum)\nend",
"def format_int(n)\n return - 2**31 if n < -2**31\n return 2**31 - 1 if n > 2**31 - 1\n n\nend",
"def bound_0_to_10(num)\n if num >= 10\n return 10\n elsif num < 0\n return 0\n else\n return num\n end\n end",
"def digital_root(num)\n array = []\n\n until num == 0\n array << num % 10\n num = num / 10\n end\n result = array.inject(:+)\n\n if result > 9\n digital_root(result)\n else\n result\n end\nend",
"def leading_zeroes(max_num_length)\n 101.times do |i|\n num_of_zeroes = max_num_length - i.digits.length\n puts \"0\" * num_of_zeroes + i.to_s\n end\nend"
] | [
"0.74928284",
"0.7391296",
"0.73467326",
"0.7299868",
"0.72959495",
"0.7256317",
"0.72488725",
"0.7213806",
"0.71847534",
"0.7150823",
"0.7109661",
"0.7091952",
"0.7083971",
"0.705517",
"0.7028662",
"0.7022338",
"0.70145804",
"0.700829",
"0.6998789",
"0.6951361",
"0.6947307",
"0.692563",
"0.69053507",
"0.68976283",
"0.68693036",
"0.68691546",
"0.68684816",
"0.68494624",
"0.6838654",
"0.68334717",
"0.6811052",
"0.6796944",
"0.6791819",
"0.67897314",
"0.67842066",
"0.6772928",
"0.67614466",
"0.67611235",
"0.67512554",
"0.67309433",
"0.67268616",
"0.6726609",
"0.67260045",
"0.6722949",
"0.6722906",
"0.67116237",
"0.6706741",
"0.66983205",
"0.6682734",
"0.6660329",
"0.6660329",
"0.6649004",
"0.66445875",
"0.6637187",
"0.6627339",
"0.66214263",
"0.6617722",
"0.66098535",
"0.6597584",
"0.6590124",
"0.6585297",
"0.65799004",
"0.6547719",
"0.65456223",
"0.6543877",
"0.65389836",
"0.6528083",
"0.65274125",
"0.64835626",
"0.64760154",
"0.6474627",
"0.6463301",
"0.64629096",
"0.64567494",
"0.6450507",
"0.64497703",
"0.6449025",
"0.6441109",
"0.6417953",
"0.63966346",
"0.63876957",
"0.6379352",
"0.63766426",
"0.6372441",
"0.63719445",
"0.6369295",
"0.6368817",
"0.63662106",
"0.6361866",
"0.63524854",
"0.63496995",
"0.634196",
"0.6327797",
"0.6322383",
"0.6318856",
"0.6311711",
"0.63067544",
"0.6301026",
"0.63002855",
"0.629715"
] | 0.8483405 | 0 |
2835 pixels per meter is basically 72dpi | def initialize(width, height)
@width, @height = width, height
@pixels = Array.new(@height) { Array.new(@width) { "00" } }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dpi\n {:x=>dpi_x,:y=>dpi_y}\n end",
"def i2p(inches)\n (inches * @target_dpi).to_i\n end",
"def dpi_y\n self.class.dpm_to_dpi(dpm_y)\n end",
"def zoom\n `#@native.devicePixelRatio`\n end",
"def image_dpi id\n image = get_image(id)\n raise \"Surprising non-symetrical dpi\" if image.x_resolution != image.y_resolution \n [image.x_resolution, image.y_resolution] \n end",
"def max_resolution; end",
"def dpi_x\n self.class.dpm_to_dpi(dpm_x)\n end",
"def to_pixel_per_meter(**options) = convert_to('pixel-per-meter', **options)",
"def screen_y\n return 464\n end",
"def pixels(height, width)\r\n\tpixels = height * width\r\n\tputs \"Your resolution displays #{pixels} pixels.\"\r\nend",
"def resolution\n if width >= 3800 || height >= 2100 # close to 3860 x 2160\n \"HQ\"\n elsif width >= 1900 || height >= 1000 # close to 1920 x 1080\n \"1080p\"\n elsif width >= 1200 || height >= 700 # close to 1280 x 720\n \"720p\"\n else\n \"SD\"\n end\n end",
"def cm2pts(x)\n (x / 2.54) * 72\n end",
"def pixel_width\n @sensor_width / @width_in_pixels\n end",
"def height\n (self.width.to_f * (9.to_f/16.to_f)).to_i\n end",
"def largura_em_pixels\n if self.posicao == HORIZONTAL\n (self.largura.to_f / 100.to_f) * MULTIPLICADOR_PIXELS\n else\n (self.comprimento.to_f / 100.to_f) * MULTIPLICADOR_PIXELS\n end\n end",
"def pixelwidth\n end",
"def pixel_height\n @sensor_height / @height_in_pixels\n end",
"def display_height\n (display_width.to_f / width.to_f) * height\n end",
"def display_height\n (display_width.to_f / width.to_f) * height\n end",
"def display_height\n (display_width.to_f / width.to_f) * height\n end",
"def pixelheight\n end",
"def zoom_unit\n [@native_screen_width, @native_screen_height]\n end",
"def mm2pts(x)\n (x / 25.4) * 72\n end",
"def pixel_size; size.x * size.y; end",
"def pixel\n return ($game_system == nil ? 1 : 2 ** $game_system.pixel_rate)\n end",
"def gear_inches\n ratio * wheel.diameter\n end",
"def gear_inches\n ratio * wheel.diameter\n end",
"def gear_inches\n ratio * wheel.diameter\n end",
"def gear_inches\n\tratio * diameter\nend",
"def magnification\n 1300\n end",
"def windows_width\n Graphics.width / 2 + 10 # + 64\n end",
"def px_to_length(view)\n\n view.pixels_to_model 1, @scale_origin\n\n end",
"def base_height; 24; end",
"def base_height; 24; end",
"def pixel_per_meter? = unit == 'pixel-per-meter'",
"def large_image_width\n 850\n end",
"def resolution\n Vector2.new w, h\n end",
"def gauge_area_width\n return 220\n end",
"def pixels; end",
"def pixelSize()\n GoogleMap.getPixelSize(@zoom)\n end",
"def g_width \n Config.ground_width\n end",
"def find_ppi(width, height)\n sc = screen_config(width, height)\n return sc ? sc[:ppi] : nil\n end",
"def resolution_mode\n {width: Highgui.get_property(@capture_handler, :width),\n height: Highgui.get_property(@capture_handler, :height)}\n end",
"def mm2pixel(mm1_value)\n return mm1_value * mm_unit;\n end",
"def gear_inches\n\tratio * (rim + (tire * 2))\nend",
"def medium_width\n width * medium_height / height\n end",
"def get_tiff_dpi(file_path)\n out, err = tty_command.run(\n mediainfo_command,\n \"--Inform=Image;\\%Density_X\\% \\%Density_Unit\\%\",\n file_path\n )\n\n if out =~ /\\A(\\d+(\\.?\\d+)?) dpi/\n return $1.to_f\n else\n Rails.logger.warn(\"#{self.class}: Could not find dpi for Asset #{asset.friendlier_id}, assuming #{GUESS_ASSUME_SOURCE_DPI}\")\n return GUESS_ASSUME_SOURCE_DPI\n end\n end",
"def coord_time(i)\n i.to_f / 24 * @width\nend",
"def convert_inches_to_cm length\n in_to_cm = 2.54\n length * in_to_cm\nend",
"def convert_inches_to_cm length\n in_to_cm = 2.54\n length * in_to_cm\nend",
"def convert_inches_to_cm length\n in_to_cm = 2.54\n length * in_to_cm\nend",
"def in2pts(x)\n x * 72\n end",
"def size\n \n return case \n when pixels <= (16*16)\n :tiny\n when pixels <= (32*32)\n :small\n when pixels <= (64*64)\n :icon\n when pixels <= (4200..6200)\n :default\n when pixels <= (128*128)\n :medium\n when pixels <= (256*256)\n :large\n when pixels <= (512*512)\n :huge\n else\n :silly\n end\n \n end",
"def pixels\n \n return width.to_i * height.to_i\n \n end",
"def pixels_to_meters(px, py, zoom)\n res = resolution(zoom)\n mx = px * res - @origin_shift\n my = py * res - @origin_shift\n [mx, my]\n end",
"def calc_generator_size(val1= chp_salable_elec, val2 = 364 * 24)\n\t\t(val1 / val2).round 3\n\tend",
"def gear_inches\n ratio * diameter\nend",
"def hidratosIR\n\t\t((valorEnergeticoKJ.to_f*260)/8400).round(2)\n\tend",
"def window_width\n Graphics.width / 2\n end",
"def calculate_coordinate(size_in_inches)\n return size_in_inches * 144\n end",
"def set_ratio\n @ratio = $program.width.to_f / $program.height\n end",
"def gear_inches\n ratio * wheel.diameter\nend",
"def calculate_ppi(img)\n ppi = 0\n if params[:arrowPixelLength] && params[:renderWidth] && params[:calibrateLength] && params[:calibrateUnit]\n ppi = @lifesize.calc_image_ppi_with_arrow(params[:arrowPixelLength].to_f, img.length_in_inches, img.width, params[:renderWidth].to_i)\n else\n ppi = params[:ppi]\n end\n logger.info \"server calculated ppi: #{ppi}, ppi from client: #{params[:ppi]}\"\n ppi\n end",
"def dpi_str(dpi)\n DPI_TO_NAME_MAP[dpi.to_i] || \"xxxhdpi\"\n end",
"def screen_tile_y\n Graphics.height / TILE_HEIGHT\n end",
"def yres\n get \"yres\"\n end",
"def resolution(zoom)\n @initial_resolution / (2**zoom)\n end",
"def fullwidth\n return self.bitmap.width.to_f * self.zoom_x\n end",
"def window_width() Graphics.width - 128 end",
"def percent_or_pixel(number)\n number.to_f.zero? ? \"1px\" : \"#{number}%\"\n end",
"def irhidratos\n vag=(hcarbono * 100) / 260\n vag.round(2)\n end",
"def ir_hidratos \n\t\t@hidratos_ir = hidratos\n\t\t@ir_hidratos = (@hidratos_ir/260.to_f)*100\n\t\t@ir_hidratos.round(1)\n\tend",
"def radius\n \twidth / 2\n end",
"def window_height\n fitting_height(11)\n end",
"def window_height\n fitting_height(11)\n end",
"def window_height\n fitting_height(11)\n end",
"def display_size\n # (1.9 ** @magnitude) / 3.0 + 2.5\n (2.15 ** @magnitude) / 3.6 + 2.5\n end",
"def my_width \n 0.75\n end",
"def setup\n \n size 640, 360\n \nend",
"def pixel_x; @x / PIXEL_WIDTH; end",
"def pixel_x; @x / PIXEL_WIDTH; end",
"def aspect_ratio\n if self.native_width && self.native_height\n return self.native_width/self.native_height.to_f\n else\n return 1.324 # Derived from the default values, above\n end\n end",
"def zoom_2\n return 1.0\n end",
"def fullheight\n return self.bitmap.height.to_f * self.zoom_y\n end",
"def scale_factor(point, view)\n\n px_to_length(view)/view.pixels_to_model(1, point)\n\n end",
"def min_shutter_speed; end",
"def p2i(pixels)\n case pixels\n when Fixnum\n return (pixels * @target_dpi)\n when BPoint\n return BPoint.new(pixels.x * @target_dpi, pixels.y * @target_dpi)\n else \n raise \"p2i argument error\"\n end\n end",
"def light_pen_y\n @cr[7]\n end",
"def size\n $stdout.winsize.reverse rescue [80,25]\n end",
"def image_width\n end",
"def test_png_size_determined_correctly\n assert_equal [120, 175], @page.get_png_size(@test_png)\n end",
"def gear_inches\n ratio * Wheel.new(rim, tire).diameter\n end",
"def to_dot_per_inch(**options) = convert_to('dot-per-inch', **options)",
"def base_width; 24 + SKC_Settings::WIDTH; end",
"def aspect_ratio; (@x/@y).abs; end",
"def calculate_diagram_width max, current\n return 0 if current <= 0\n (current.to_f/max.to_f * 1000).to_i / 10.0\n end",
"def gradians\n self * Math::PI / 200.0\n end",
"def sizeY()\n return @device.sizeY() ;\n end",
"def get_doc_scale w, h\n page_w, page_h = @current_page.size\n\n scale_x = w / page_w \n scale_y = h / page_h\n\n if scale_x > scale_y\n scale_y\n else\n scale_x\n end\n end",
"def screen_settings\n @glines, @gcols = `stty size`.split.map(&:to_i)\n # @glines = `tput lines`.to_i\n # @gcols = `tput cols`.to_i\n @grows = @glines - 3\n # @pagesize = 60\n # @gviscols = 3\n @pagesize = @grows * @gviscols\nend",
"def meters_to_pixels(mx, my, zoom)\n res = resolution(zoom)\n px = (mx + @origin_shift) / res\n py = (my + @origin_shift) / res\n [px, py]\n end"
] | [
"0.7078284",
"0.6549018",
"0.6362042",
"0.63123435",
"0.6292032",
"0.62706035",
"0.6225801",
"0.62146026",
"0.6120312",
"0.6119724",
"0.6097993",
"0.59607846",
"0.59418887",
"0.5921663",
"0.5875648",
"0.58702224",
"0.5837363",
"0.5796204",
"0.5796204",
"0.5796204",
"0.5753857",
"0.57531905",
"0.574203",
"0.5733176",
"0.57014656",
"0.56224555",
"0.56224555",
"0.56224555",
"0.5604824",
"0.56004864",
"0.55900395",
"0.55898994",
"0.5575481",
"0.5575481",
"0.5568053",
"0.555529",
"0.5553613",
"0.5548517",
"0.5531177",
"0.5486782",
"0.54712003",
"0.54512703",
"0.54505825",
"0.54143685",
"0.54130214",
"0.54059875",
"0.53893274",
"0.5382791",
"0.53626823",
"0.53626823",
"0.53626823",
"0.5350556",
"0.5347788",
"0.53464466",
"0.5331089",
"0.5322483",
"0.5321697",
"0.53194124",
"0.5306993",
"0.53062195",
"0.52906877",
"0.52895725",
"0.52649844",
"0.5262972",
"0.523085",
"0.52215123",
"0.5215684",
"0.5198534",
"0.519124",
"0.5190461",
"0.5178467",
"0.51765484",
"0.517214",
"0.5171434",
"0.5171434",
"0.5171434",
"0.51702434",
"0.51660794",
"0.5164922",
"0.5159916",
"0.5159916",
"0.5153519",
"0.5151994",
"0.51468575",
"0.51331884",
"0.513299",
"0.5132109",
"0.5115825",
"0.5114288",
"0.5112078",
"0.5099583",
"0.5092417",
"0.5082335",
"0.50779617",
"0.5075616",
"0.50733316",
"0.50700015",
"0.5064784",
"0.5056006",
"0.5047963",
"0.5046588"
] | 0.0 | -1 |
Note: the 'right' pattern to use is actually "Vl<2v2V2l<2V2", but that only works on 1.9.3 | def write_dib_header(file)
file << [DIB_HEADER_SIZE, @width, @height, 1, BITS_PER_PIXEL,
0, pixel_array_size, PIXELS_PER_METER, PIXELS_PER_METER,
0, 0].pack("V3v2V6")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tr_s(p0, p1) end",
"def tag_pattern\n @tag_pattern || 'v%s'\n end",
"def difftype() [1, \"s\"] end",
"def test_verse_range_and_separated_verse\n text = 'Ruth 2,1-3.11'\n t1, t2 = text.split(dot)\n assert_parsed_ast_for_text [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)], text\n end",
"def test_verse_range_and_separated_verse\n text = 'Ruth 2,1-3.11'\n t1, t2 = text.split(dot)\n assert_formated_text_for_ast text, [pass(text: t1, b1: :Ruth, c1: 2, v1: 1, b2: :Ruth, c2: 2, v2: 3), dot, pass(text: t2, b1: :Ruth, c1: 2, v1: 11, b2: :Ruth, c2: 2, v2: 11)]\n end",
"def _V(data) ; end",
"def tr_s!(p0, p1) end",
"def V(*args)\n end",
"def test_a_vertical_pipe_means_or\n grays = /(James|Dana|Summer) Gray/\n assert_equal 'James Gray', \"James Gray\"[grays]\n assert_equal 'Summer', \"Summer Gray\"[grays, 1]\n assert_equal nil, \"Jim Gray\"[grays, 1]\n end",
"def tr(p0, p1) end",
"def ver(v, typ)\n v.gsub!(/ (?:^.+ \\sAS\\s (.+$))? | \\s+() | ^v() /nix, \"\\\\1\")\n case typ\n when :deb\n v.gsub!(/[-@](dev|patch).*$/, \"~~\")\n v.gsub!(/[-@](alpha|beta|RC|stable).*$/, \"~\")\n when :rpm\n v.gsub!(/[-@](dev|patch|alpha|beta|RC|stable).*$/, \"\")\n else\n v.gsub!(/@/, \"-\")\n end\n return v\n end",
"def test_multiple_string_number_2\r\n # x2-g8 < x2-y7 < x2-y08 < x8-y8\r\n assert_equal ['x02-g8', 'x2-y7', 'x02-y08', 'x8-y8'], ['x02-y08', 'x8-y8', 'x2-y7', 'x02-g8'].natural_sort, \"TODO Not implemented\"\r\n end",
"def |( other )\n\t\treturn Regexp.new( \"(?:%s|%s)\" % [self.to_s, other.to_s] )\n\tend",
"def s2v(str)\n #Variables\n if str =~ /\\$[{]?\\w+[}]?/\n str.gsub(/\\$[{]?(\\w+)[}]?/) do |t|\n str = str.sub(t,lookupvar($1).to_s)\n end\n end\n #Functions\n if str =~ /%[{]?[a-zA-Z0-9!\"'\\(\\)\\*\\+,-\\.\\/:;<=>\\?@\\[\\\\\\]\\^_\\\\|~]+[\\}]?/\n str.gsub(/%[{]?([a-zA-Z0-9!\"'\\(\\)\\*\\+,-\\.\\/:;<=>\\?@\\[\\\\\\]\\^_\\\\|~]+)[\\}]?/) do |t|\n str = str.sub(t,eval(\"function_#{$1}\").to_s)\n end\n end\n return str\n end",
"def prepare_pattern(pattern)\n pattern.scan(/(\\<[^\\>]+\\>[^\\<]?)/).flatten.map { |x| TagPattern.new(x) }.reverse\n end",
"def reduce_vtab(_production, _range, _tokens, _children)\n Regex::Character.new('\\v')\n end",
"def two_word_name; end",
"def older_version v1, v2\n v1 = v1.split('.').map{|s|s.to_i}.extend(Comparable)\n v2 = v2.split('.').map{|s|s.to_i}.extend(Comparable)\n return v1 < v2\n end",
"def convert_u2!(comment=nil)\n v = get_u2\n out_with_comment! \"<u2>#{v}</u2>\", comment\n end",
"def tag(string); end",
"def literal_string(v)\n \"N#{super}\"\n end",
"def nested_anon_pattern \n /#<(#<.*>):(.*)>/\n end",
"def two_vowels_two_letters(first_l, second_l, vowels)\n vowel1 = vowels[0]\n vowel2 = vowels[1]\n\n return place_above(second_l, vowel2) && place_below(first_l, vowel1)\n end",
"def lcs(s1, s2); end",
"def test_standard_to_semver_with_v\n value_ = ::Versionomy.parse('v1.2.3')\n value2_ = value_.convert(:semver)\n assert_equal([1, 2, 3, ''], value2_.values_array)\n value_ = ::Versionomy.parse('V 1.2.3')\n value2_ = value_.convert(:semver)\n assert_equal([1, 2, 3, ''], value2_.values_array)\n end",
"def gen_match_code(context, vname)\n\n if type != nil\n # Element with a named datatype\n\n if type == 'xsd:string'\n return \"#{PREFIX_PARSE_PR}string(#{vname}[offset]), offset + 1\"\n elsif type == 'xsd:anyURI'\n return \"#{PREFIX_PARSE_PR}string(#{vname}[offset]), offset + 1\"\n else\n return \"#{XSD::PREFIX_PARSE_CT}#{type}(#{vname}[offset]), offset + 1\" # assumes only complexTypes\n end\n\n elsif ! complexType.empty?\n # Element with an anonymous complexType\n\n the_ct = complexType[0]\n return \"#{XSD::PREFIX_PARSE_CT}#{the_ct.internal_name}(#{vname}[offset]), offset + 1\" # assumes only complexTypes\n\n elsif ref != nil\n raise # TODO\n\n else\n raise \"internal error\"\n end\n end",
"def version_tag(text); end",
"def double_angle_string_literal!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 45)\n\n type = DOUBLE_ANGLE_STRING_LITERAL\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 500:4: '<<' ( . )* '>>'\n match(\"<<\")\n # at line 500:9: ( . )*\n loop do #loop 8\n alt_8 = 2\n look_8_0 = @input.peek(1)\n\n if (look_8_0 == ?>) \n look_8_1 = @input.peek(2)\n\n if (look_8_1 == ?>) \n alt_8 = 2\n elsif (look_8_1.between?(0x0000, ?=) || look_8_1.between?(??, 0xFFFF)) \n alt_8 = 1\n\n end\n elsif (look_8_0.between?(0x0000, ?=) || look_8_0.between?(??, 0xFFFF)) \n alt_8 = 1\n\n end\n case alt_8\n when 1\n # at line 500:9: .\n match_any\n\n else\n break #loop 8\n end\n end\n match(\">>\")\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__, 45)\n\n end",
"def test_compare_string_overlap_defs\n v1 = Vertex.new(\"speech\", 2, 1, 0, 0, 1, \"NN\")\n v2 = Vertex.new(\"delivering\", 2, 1, 0, 0, 1, \"VB\")\n assert_equal(1, instance.compare_strings(v1, v2, speller))#no POS is considered for hypernyms and hyponyms\n end",
"def parse_one_constraint!(ret, versions_string)\n rest_string = nil\n if match = versions_string.match(ConstraintRegex1)\n ret << { version: normalize_to_three_parts(match[2]), constraint: match[1] }\n rest_string = match[3] unless match[3].empty?\n elsif match = versions_string.match(ConstraintRegex2)\n ret << { version: normalize_to_three_parts(match[1]), constraint: '>=' }\n ret << { version: normalize_to_three_parts(match[1].to_i + 1), constraint: '<' }\n else\n fail Error.new(\"error parsing version constraints string: #{versions_string})\")\n end\n rest_string\n end",
"def nested(s)\n # this is a wrapper method\n return nested_2(s, 0, (s.length - 1) )\nend",
"def tag_key(v)\n v.to_s.downcase. # make lowercase\n gsub(/_/, ' '). # convert all underscores to spaces so we can elide\n gsub(/'/, ''). # elide apostrophes\n gsub(/\\W/, ' '). # change all non-word chars to spaces\n gsub(/\\s+/, '_'). # change multiple whitespace to single underscore\n gsub(/_+$/, ''). # remove trailing underscores\n gsub(/^_+/, ''). # remove leading underscores\n strip\n end",
"def overload_tag(text); end",
"def version_prefix\n '/v2'\n end",
"def underlying_matcher; end",
"def underlying_matcher; end",
"def compile_vexpression\n out = expect :number, :identifier,\n :istring, :lparen,\n :sstring, :operator,\n :keyword,\n :regex,\n :newline,\n :istring_begin,\n :iheredoc_begin,\n :plus, :minus,\n :lbrace => :object,\n :lbrack => :array,\n :arrow => :function,\n [\n :preunop, :unop\n ] => :unop,\n [\n :heredoc_ref, :iheredoc_ref\n ] => :href,\n [\n :heredoc, :iheredoc\n ] => :heredoc\n\n value_expect(out)\n end",
"def v1_older_v2(v1=\"0.0.0_0\", v2=\"0.0.0_0\")\n v1_n = version_split(v1)\n v2_n = version_split(v2)\n i = 0\n while ( v1_n[i] && v2_n[i] ) do\n if v1_n[i] < v2_n[i]\n return true\n elsif v1_n[i] > v2_n[i]\n return false\n end\n i+=1\n end\n # versions equal case\n return false\n end",
"def compare_version(v1, v2)\r\n v1 = v1.split('.')\r\n v2 = v2.split('.')\r\n longest = v1.length > v2.length ? v1 : v2\r\n (0...(longest.length)).each do |idx|\r\n one = v1[idx] || '0'\r\n two = v2[idx] || '0'\r\n return -1 if two.to_i > one.to_i\r\n return 1 if one.to_i > two.to_i\r\n end\r\n 0\r\nend",
"def normalize_version_strings(first_string, second_string)\n if first_string.nil? || second_string.nil? || first_string.empty? || second_string.empty?\n return first_string, second_string\n end\n first_groups = first_string.split(\".\").length\n second_groups = second_string.split(\".\").length\n if first_groups != second_groups\n if first_groups > second_groups\n ((1..first_groups-second_groups).to_a).each do |digit|\n second_string += \".0\"\n end\n end\n if first_groups < second_groups\n ((1..second_groups-first_groups).to_a).each do |digit|\n first_string += \".0\"\n end\n end\n end\n return first_string, second_string\nend",
"def as_replacements; end",
"def as_replacements; end",
"def as_replacements; end",
"def submatcher; end",
"def submatcher; end",
"def test_format_tag\n version = VMLib::Version.new 'foo', 1, 2, 3, 'rc.1', 'sha.5114f85'\n\n # Make sure all fields are included in the tag\n assert_equal 'v1.2.3-rc.1+sha.5114f85', version.tag\n\n # Changing the build should reflect in the tag\n version.build = 'sha.0012312'\n assert_equal 'v1.2.3-rc.1+sha.0012312', version.tag\n\n # Removing the build should reflect in the tag\n version.build = ''\n assert_equal 'v1.2.3-rc.1', version.tag\n\n # Changing the prerelease should reflect in the tag\n version.prerelease = 'alpha.02'\n assert_equal 'v1.2.3-a.2', version.tag\n\n # Removing the prerelease should reflect in the tag\n version.prerelease = ''\n assert_equal 'v1.2.3', version.tag\n\n # Having a build metadata and no prerelease should reflect in the tag\n version.build = 'sha.12ab32d'\n assert_equal 'v1.2.3+sha.12ab32d', version.tag\n end",
"def longexpr\n end",
"def expected\n Regexp.new('\\A' << super.gsub('%', '.*').tr('_', '.') << '\\z')\n end",
"def method_delta_line es, method_name\n es.select {|e| e.method_name == method_name }\n .map(&:method_length)\n .each_cons(2)\n .map {|c,n| [\"^\",\"-\",\"v\"][(c <=> n) + 1] }\n .join\nend",
"def lex_en_leading_dot=(_arg0); end",
"def lex_en_leading_dot=(_arg0); end",
"def lex_en_leading_dot=(_arg0); end",
"def format_vector(vec)\n timeset = vec.timeset ? \"#{vec.timeset.name}\" : ''\n pin_vals = vec.pin_vals ? \"#{vec.pin_vals};\".gsub(' ', '') : ''\n sig_name = tester.ordered_pins_name || 'ALL'\n if sig_name.nil?\n Origen.log.warn \"WARN: SigName must be defined for STIL format. Use pin_pattern_order(*pins, name: <sigName>). Default to 'ALL'\"\n sig_name = 'ALL'\n end\n if vec.repeat > 1\n microcode = \"Loop #{vec.repeat} {\\n\"\n else\n microcode = vec.microcode ? vec.microcode : ''\n end\n if vec.pin_vals && ($_testers_enable_vector_comments || vector_comments)\n comment = \"// V:#{vec.number} C:#{vec.cycle} #{vec.inline_comment}\"\n else\n comment = vec.inline_comment.empty? ? '' : \"Ann {*// #{vec.inline_comment}*}\"\n end\n\n microcode_post = vec.repeat > 1 ? \"\\n}\" : ''\n \"#{microcode} V { \\\"#{sig_name}\\\" = #{pin_vals} }#{comment}#{microcode_post}\"\n end",
"def filter_sort_tables(v)\n a = v.split(\".\")\n if a.length == 1\n return a[0]\n end\n a[-2]= a[-2].pluralize\n a[-2,2].join(\".\")\n end",
"def from_right; end",
"def from_right; end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def lex_en_interp_string; end",
"def expand_name?(vstring)\n /%<\\S+>/ =~ vstring\n end",
"def do_v(s); s[:direction] = 'down'; end",
"def simple_tag_type_pluralizer(s)\n case s\n when /o\\Z/ then s.sub(/o\\Z/, \"es\")\n when /y\\Z/ then s.sub(/y\\Z/, \"ies\")\n when /ss\\Z/ then s.sub(/ss\\Z/, \"sses\")\n else\n \"#{s}s\"\n end\n end",
"def parse(virtual); end",
"def even_splitters(string)\r\n\r\nend",
"def multiple_vowels_two_letters(first_l, second_l, vowels)\n # Place the first vowel below the available first letter\n success = place_below(first_l, vowels[0])\n if (!success)\n return false\n end\n\n # Add placeholders with vowels attached after the first letter\n prev_placeholder = nil\n for i in 1...(vowels.length - 1)\n if (!prev_placeholder || i % 2 == 1)\n # Make a new placeholder\n next_index = !prev_placeholder ? first_l.index + 0.5 : (prev_placeholder.index + second_l.index) / 2\n prev_placeholder = Letter.new(\"sp\", true, next_index)\n @edigaul_letters[next_index] = prev_placeholder\n\n success = place_above(prev_placeholder, vowels[i])\n if (!success)\n return false\n end\n else\n success = place_below(prev_placeholder, vowels[i])\n if (!success)\n return false\n end\n end\n end\n\n # Add the last vowel\n if (prev_placeholder.vowel_available(BOTTOM))\n return one_vowel_two_letters(prev_placeholder, second_l, vowels[-1])\n else\n return place_above(second_l, vowels[-1])\n end\n end",
"def test_string_comparison\n value1_ = ::Versionomy.create([1, 9, 2, 'a2'], :semver)\n value2_ = ::Versionomy.create([1, 9, 2, 'b1'], :semver)\n assert(value2_ > value1_)\n end",
"def mixed_pairs\nend",
"def two_sort(s)\n s.min.chars.join('***')\nend",
"def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend",
"def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend",
"def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend",
"def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend",
"def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend",
"def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend",
"def literalize(name); end",
"def test_standard_to_rubygems_with_v\n value_ = ::Versionomy.parse('v1.2b3')\n value2_ = value_.convert(:rubygems)\n assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)\n value_ = ::Versionomy.parse('V 1.2b3')\n value2_ = value_.convert(:rubygems)\n assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)\n end",
"def double_metaphone(str); end",
"def ConvertSplits( l, r )\n if( l == r )\n return ?A.ord + l\n else\n s = $splitPositions[ l ][ r ]\n iL = $gcds[ l ][ l + s ] / $gcds[ l ][ r ]\n iR = $gcds[ l + s + 1 ][ r ] / $gcds[ l ][ r ]\n\n # Don't display 1 to reduce confusion\n if( iL == 1 )\n iL = \"\"\n end\n if( iR == 1 )\n iR = \"\"\n end\n\n return \"(#{iL}\" << ConvertSplits( l, l + s ) << \")(#{iR}\" << ConvertSplits( l + s + 1, r ) << \")\"\n end\nend",
"def two_sort(s)\n s.min.chars.join(\"***\")\nend",
"def replace(p0) end",
"def replace(p0) end",
"def replace(p0) end",
"def bothV\n [outV, inV]\n end",
"def one_vowel_two_letters(first_l, second_l, vowel)\n if (second_l.uptail)\n # First, if second_l is an uptail, place the vowel above second_l\n return place_above(second_l, vowel)\n elsif (first_l.uptail)\n # Second, if first_l is an uptail, place the vowel below first_l\n return place_below(first_l, vowel)\n else\n # Finally, both must be downtails, place the vowel above second_l\n return place_above(second_l, vowel)\n end\n end",
"def diff2; end",
"def solution(s)\n # write your code in Ruby 2.2\n r = Reformat.new(s)\n r.reformat\nend",
"def Vector2d(*args)\n Vector2d.parse(*args)\nend",
"def vls(filter=/./)\n VersionLS.print_vls(filter)\n end",
"def lex_en_interp_backslash_delimited; end",
"def lex_en_interp_backslash_delimited; end",
"def lex_en_interp_backslash_delimited; end",
"def string_replacements\nend",
"def lex_en_regexp_modifiers; end",
"def lex_en_regexp_modifiers; end",
"def lex_en_regexp_modifiers; end",
"def compare_docstring_tags(d1, d2); end",
"def test_parse_set_collating_sequence\n root = RP.parse('[a[.span-ll.]h]', :any)\n exp = root[0]\n\n assert_equal '[.span-ll.]', exp[1].to_s\n end",
"def to_vui(ary,ofs)\n b0=ary[ofs]\n return [b0,1] if b0 <128\n b0&=0x7f\n b1=ary[ofs+1]\n return [b0+(b1<<7),2] if b1<128\n b1&=0x7f\n b2=ary[ofs+2]\n return [b0+(b1<<7)+(b2<<14),3] if b2<128\n b2&=0x7f \n b3=ary[ofs+3]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21),4] if b3<128\n b3&=0x7f \n b4=ary[ofs+4]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28),5]\n throw \"error\"\nend\n# buf to varlong\ndef to_vul(ary,ofs)\n b0=ary[ofs]\n return [b0,1] if b0 <128\n b0&=0x7f\n b1=ary[ofs+1]\n return [b0+(b1<<7),2] if b1<128\n b1&=0x7f\n b2=ary[ofs+2]\n return [b0+(b1<<7)+(b2<<14),3] if b2<128\n b2&=0x7f \n b3=ary[ofs+3]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21),4] if b3<128\n b3&=0x7f \n b4=ary[ofs+4]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28),5]\n b4&=0x7f\n b5=ary[ofs+5]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35),6]\n b5&=0x7f\n b6=ary[ofs+6]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42),7]\n b6&=0x7f\n b7=ary[ofs+7]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49),8]\n b7&=0x7f\n b8=ary[ofs+8]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49)+(b8<<56),9]\n b8&=0x7f\n b9=ary[ofs+9]\n return [b0+(b1<<7)+(b2<<14)+(b3<<21)+(b4<<28)+(b5<<35)+(b6<<42)+(b7<<49)+(b8<<56)+(b9<<63),10]\n throw \"error\"\nend\n\ndef to_l(ary,ofs)\n return ary[ofs+7]+(ary[ofs+6]<<8)+(ary[ofs+5]<<16)+(ary[ofs+4]<<24)+(ary[ofs+3]<<32)+(ary[ofs+2]<<40)+(ary[ofs+1]<<48)+(ary[ofs]<<56)\nend\n\n\ndef bm2ary(bm)\n out=[0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]\n out[0]=1 if bm & 1 == 1\n out[1]=1 if bm & 2 == 2\n out[2]=1 if bm & 4 == 4\n out[3]=1 if bm & 8 == 8\n out[4]=1 if bm & 16 == 16\n out[5]=1 if bm & 32 == 32\n out[6]=1 if bm & 64 == 64\n out[7]=1 if bm & 128 == 128\n out[8]=1 if bm & 256 == 256\n out[9]=1 if bm & 512 == 512\n out[10]=1 if bm & 1024 == 1024\n out[11]=1 if bm & 2048 == 2048\n out[12]=1 if bm & 4096 == 4096\n out[13]=1 if bm & 8192 == 8192\n out[14]=1 if bm & 16384 == 16384\n out[15]=1 if bm & 32768 == 32768\n return out\nend\n\n\n# long \ndef i32_to_bitary(v)\n out=[]\n 32.times do |i|\n out[31-i]=v&1\n v=v>>1\n end\n return out\nend\n\ndef bitary_to_i(ba)\n out=0\n v=1\n ba.size.times do |i|\n out+=v if ba[ba.size-1-i]==1 \n v=v<<1\n end\n return out\nend\n\n# [25215072,806882310],[25215072,806882310],[25215072,806882310], ...\n#\n# 9 bits * 256 = 2304 bits, 36 longs\n# irb(main):002:0> printf(\"%b\",25215072)\n# 1100000001100000001100000\n# 110000000 110000000 1100000\n# 000011000 000011000 000011000\n\n# [[25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215328,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215073,-2145907706],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [25215072,806882310],[25215072,806882310],[25215072,806882310],[25215072,806882310],\n# [0,806882310]]\n\n#\n# 19200, 11488\n# {\"x\":1200,\"z\":718,\"groundUp\":true,\"bitMap\":15,\"heightmaps\":{\"type\":\"compound\",\"name\":\"\",\"value\":{\"MOTION_BLOCKING\":{\"type\":\"longArray\",\"value\":[[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[1,-117670337]]},\"WORLD_SURFACE\":{\"type\":\"longArray\",\"value\":[[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[264758257,-117670337],[1,-117670337]]}}}\n\n# MSB - LSB\n# 0 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee fffffffff ggggggggg hhhhhhhhh iiiiiiiii\n# \ndef la2hm(la)\n outhm=[]\n ba=[]\n la.each do |pair|\n ba0=i32_to_bitary(pair[0])\n ba1=i32_to_bitary(pair[1])\n ba63=ba0[1..-1]+ba1 # 9*7\n slices=[]\n ba63.each_slice(9) do |slice|\n slices.push(slice)\n end\n slices.reverse.each do |slice|\n outhm.push(bitary_to_i(slice))\n end\n end\n return outhm\nend\n\n# ul:uint64_t\ndef ul2blocks(ul,bit_depth)\n \n if bit_depth==4 then\n # 1ULに16個入ってる\n s0=(ul>>48)&0xffff\n s1=(ul>>32)&0xffff\n s2=(ul>>16)&0xffff\n s3=ul&0xffff\n return [\n (s0>>12)&0xf,(s0>>8)&0xf,(s0>>4)&0xf,s0&0xf,\n (s1>>12)&0xf,(s1>>8)&0xf,(s1>>4)&0xf,s1&0xf,\n (s2>>12)&0xf,(s2>>8)&0xf,(s2>>4)&0xf,s2&0xf,\n (s3>>12)&0xf,(s3>>8)&0xf,(s3>>4)&0xf,s3&0xf\n ]\n elsif bit_depth==5 then\n # 1ULに12個はいっててMSBが0000\n return [\n (ul>>55)&0x1f,(ul>>50)&0x1f,(ul>>45)&0x1f,(ul>>40)&0x1f,(ul>>35)&0x1f,\n (ul>>30)&0x1f,(ul>>25)&0x1f,(ul>>20)&0x1f,(ul>>15)&0x1f,(ul>>10)&0x1f,\n (ul>>5)&0x1f,(ul&0x1f)\n ]\n elsif bit_depth==6 then\n # 1ULに10個 MSBは0000\n return [\n (ul>>54)&0x3f,(ul>>48)&0x3f,(ul>>42)&0x3f,(ul>>36)&0x3f,(ul>>30)&0x3f,\n (ul>>24)&0x3f,(ul>>18)&0x3f,(ul>>12)&0x3f,(ul>>6)&0x3f,ul&0x3f\n ]\n elsif bit_depth==7 then\n # 1ULに9個 MSBは0\n return [\n (ul>>56)&0x7f,(ul>>49)&0x7f,(ul>>42)&0x7f,(ul>>35)&0x7f,(ul>>28)&0x7f,\n (ul>>21)&0x7f,(ul>>14)&0x7f,(ul>>7)&0x7f,ul&0x7f\n ]\n elsif bit_depth==8 then\n # 1ULに8個\n return [\n (ul>>56)&0xff,(ul>>48)&0xff,(ul>>40)&0xff,(ul>>32)&0xff,(ul>>24)&0xff,\n (ul>>16)&0xff,(ul>>8)&0xff,ul&0xff\n ]\n elsif bit_depth==9 then\n # 1ULに7個\n return [\n (ul>>54)&0x1ff,(ul>>45)&0x1ff,(ul>>36)&0x1ff,(ul>>27)&0x1ff,(ul>>18)&0x1ff,\n (ul>>9)&0x1ff,ul&0x1ff\n ]\n elsif bit_depth==10 then\n # 1ULに6個, MSBは0000\n return [\n (ul>>50)&0x3ff,(ul>>40)&0x3ff,(ul>>30)&0x3ff,(ul>>20)&0x3ff,(ul>>10)&0x3ff,\n ul&0x3ff\n ]\n else\n throw \"bit depth not supported\"\n end\n\nend\n\n#\n#\n#\n\na=JSON.parse(File.open(\"pkt6.txt\").read())\n\nprint \"x:\", a[\"x\"], \" z:\", a[\"z\"], \" gu:\", a[\"groundUp\"], \"\\n\"\nbitmap = a[\"bitMap\"]\nbit_ary = bm2ary(bitmap)\nsection_num = bit_ary.count(1)\nprint \"bit_ary:\", bit_ary.join(\",\"),\" section_num:\",section_num, \"\\n\"\nouthm=la2hm(a[\"heightmaps\"][\"value\"][\"MOTION_BLOCKING\"][\"value\"])\nouthm.each_slice(16) do |row| print \"hm:\", row, \"\\n\" end\n\ndata=a[\"chunkData\"][\"data\"]\nprint \"ary size:\",data.size,\"\\n\"\n\n# [5, 234, 4, 14, [ 0, 33, 1, 2, vi(174, 30), 6, vi(154, 26), 70, vi(186, 61), 14, vi(243, 15), vi(255, 15), vi(226, 65), vi(157, 65), vi(128, 2), 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 1\n\n# java -cp server_1.16.5.jar net.minecraft.data.Main --all\n\nblocks=JSON.parse(File.open(\"blocks_1.16.5.json\").read())\n$id2key={}\nblocks.keys.each do |key|\n blocks[key][\"states\"].each do |state|\n $id2key[state[\"id\"]]=key\n end\nend\n\ndef readChunkArray(data,secnum)\n ofs=0\n\n secnum.times do |si|\n print \"reading section #{si}\\n\"\n\n block_num=to_s16(data,ofs)\n print \"#{ofs} block num:\",block_num,\"\\n\"\n ofs+=2\n\n bit_depth=data[ofs]\n print \"#{ofs} bit_depth:\",bit_depth,\"\\n\"\n ofs+=1\n \n palette_len,inc = to_vui(data,ofs)\n print \"#{ofs} palette_len:\",palette_len,\", inc:\",inc,\"\\n\"\n ofs+=inc\n\n palette_len.times do |i|\n ui,inc=to_vui(data,ofs)\n print \"#{ofs} palette[#{i}]:\",ui,\" key:\",$id2key[ui], \", inc:\",inc,\"\\n\"\n ofs+=inc\n end\n\n # 4bitのときは256 (64x256/4=4096)\n # 5bitのときは342 (64x342/4=5472)だいぶオーバーしてる。 https://wiki.vg/Protocolによると頭の4ビットは0だと。\n # 60ビットだけが使われるので、 long1個あたりでは 12ブロック。よって、342*12=4104.\n # 6bitのときは410. long1個あたりでは10ブロック。よって4100\n # ルールは一応わかったかな。\n data_array_len_long,inc = to_vui(data,ofs) \n print \"#{ofs} data_array_len_long:\",data_array_len_long,\", inc:\",inc,\"\\n\"\n ofs+=inc\n\n blocks=[]\n data_array_len_long.times do |i|\n ul=to_l(data,ofs) # sprintf(\"%016x\",ul)\n blocks+=ul2blocks(ul,bit_depth)\n ofs+=8\n end\n blocks=blocks.slice(0,4096)\n print \"#{ofs} blocks:\", blocks.size, \" \", blocks, \"\\n\"\n end\n print \"final ofs:\",ofs, \"\\n\"\n throw \"bug!!\" if ofs != data.size\nend\n\nreadChunkArray(data,section_num)\n \n#print data\n\n\n",
"def str2; end",
"def str2; end",
"def start_re=(_); end"
] | [
"0.57544446",
"0.5624163",
"0.5485726",
"0.53944135",
"0.5366539",
"0.5281899",
"0.527217",
"0.5216387",
"0.5179667",
"0.5121564",
"0.5022791",
"0.50056535",
"0.49941632",
"0.49561542",
"0.4916982",
"0.49066222",
"0.4893566",
"0.48844594",
"0.48839042",
"0.48837075",
"0.48604843",
"0.48549497",
"0.485019",
"0.4839441",
"0.4834987",
"0.4827521",
"0.48255593",
"0.4820636",
"0.47994897",
"0.479776",
"0.47961804",
"0.4795647",
"0.47925287",
"0.4785222",
"0.47717035",
"0.47717035",
"0.47700596",
"0.47604892",
"0.47585258",
"0.47573534",
"0.47500956",
"0.47500956",
"0.47500956",
"0.47427666",
"0.47427666",
"0.472707",
"0.47139993",
"0.4693025",
"0.4684336",
"0.46769518",
"0.46769518",
"0.46769518",
"0.46756667",
"0.4667086",
"0.466526",
"0.466526",
"0.46606907",
"0.46606907",
"0.46606907",
"0.4657737",
"0.4657392",
"0.46514806",
"0.46503937",
"0.46469378",
"0.46461326",
"0.46328953",
"0.46216622",
"0.46197832",
"0.46152663",
"0.46144423",
"0.46144423",
"0.46144423",
"0.46144423",
"0.46144423",
"0.46143365",
"0.46078876",
"0.45970368",
"0.45928958",
"0.45927438",
"0.45926395",
"0.45926395",
"0.45910877",
"0.45861176",
"0.45841458",
"0.45822024",
"0.45810553",
"0.45759585",
"0.45743376",
"0.4564406",
"0.4564406",
"0.4564406",
"0.45618734",
"0.45575905",
"0.45575905",
"0.45575905",
"0.45568824",
"0.45552754",
"0.45481905",
"0.4544184",
"0.4544184",
"0.45411855"
] | 0.0 | -1 |
The attributes of a PhidgetStepper | def attributes
super.merge({
:inputs => inputs.size,
:steppers => steppers.size,
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_steps\n self.steps\n end",
"def attrs\n @attrs\n end",
"def attr_info; end",
"def attributes\n instance_values\n end",
"def attributes\n data[:attributes]\n end",
"def attributes\n instance_values\n end",
"def attributes\n end",
"def attributes\n @attrs\n end",
"def attributes\n end",
"def permitted_attributes_for_step(step)\n []\n end",
"def attrs\n @attrs\n end",
"def attributes\n %i[val div]\n end",
"def attrs\n @options[:attrs]\n end",
"def data_attributes\n end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attrs\n self.class.attrs\n end",
"def attributes\n @_attributes\n end",
"def attributes\n @attributes\n end",
"def permitted_params(step)\n case step.to_sym\n when :informations\n [general_fields_attributes: [:id, :value]]\n when :parameters\n [input_parameters_attributes: [:id, :input_type, :_destroy]]\n when :parameters_details\n field_attributes_base = [:id, :value]\n fields = []\n (1..7).each do\n fields = field_attributes_base + [fields_attributes: fields]\n end\n [input_parameters_attributes: [:id, fields_attributes: fields]]\n when :upload\n [:zip_file, method_fields_attributes: [:id, :value]]\n end\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @_attributes\n end",
"def attribs\n\t\t@attributes\n\tend",
"def step_params\n params.require(:step).permit(:name, :step_url, :html, :collection_id, :next_step_id, :only_customer, :is_custom)\n end",
"def attributes\n self.class.class_variable_get(:@@attributes)\n end",
"def attributes\n\t\treturn attributes_of @current_node\n\tend",
"def attributes\n @attributes\n end",
"def attributes\n ATTRIBUTES\n end",
"def attributes\n self.class::ATTRIBUTES\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n model_attributes(@@setters_list)\n end",
"def attributes\n @context[:attributes]\n end",
"def attributes\n @params\n end",
"def attr_to_step(attr)\n @attrs_to_steps ||=\n PARAMS.each_with_object({}) do |kv, params_to_steps|\n step, params = *kv\n params.each do |param|\n case param\n when Symbol\n params_to_steps[param] = step\n when Hash\n param.keys.each do |array_param|\n params_to_steps[array_param] = step\n end\n end\n end\n end\n @attrs_to_steps.fetch(attr)\n end",
"def init_phidget\n Phidgets::Log.enable(:verbose, nil)\n @sc = Phidgets::Stepper.new\n log_info(\"Waiting for PhidgetStepper to attach...\")\n\n # Get some info from the phidget\n # register callbacks\n\n @sc.on_attach do |device, obj|\n log_info(\"Device attributes: #{device.attributes} attached\")\n @device = device\n\n @vars['Attached'].value = 'true'\n @vars['# Steppers'].value = @device.steppers.size\n @vars['Name'].value = @device.name\n @vars['Serial No'].value = @device.serial_number\n @vars['Version'].value = @device.version\n\n @acc_steps = Array.new\n @acc_mins = Array.new\n @acc_maxs = Array.new\n @velocity_mins = Array.new\n @velocity_maxs = Array.new\n\n for i in 0..(@device.steppers.size - 1 )\n\t@acc_mins[i] = @device.steppers[i].acceleration_min\n\t@acc_maxs[i] = @device.steppers[i].acceleration_max\n\n\t@velocity_mins[i] = @device.steppers[i].velocity_min\n\t@velocity_maxs[i] = @device.steppers[i].velocity_max\n\n\t# Manual says sets a default value for acceleration. \n # Otherwise it could be anything\n\t@device.steppers[i].acceleration = @acc_maxs[i]\n\t# 1 acceleration step since our joystick goes from 0 to 100\n\t@acc_steps[i] = (@acc_maxs[i] - @acc_mins[i]) / 100\n\t@device.steppers[i].current_position = 0\n end\n\n @device.steppers[0].velocity_limit = @device.steppers[0].velocity_max\n @device.steppers[0].acceleration = @acc_maxs[0]\n\n # Need to update the slider scales now that we can query limits\n motor_selected\n end\n\n @sc.on_detach do |device, obj|\n log_info(\"#{device.attributes.inspect} detached\")\n @device = nil\n end\n\n @sc.on_error do |device, obj|\n log_error(\"Error #{code}: #{description}\")\n end\n\n @sc.on_position_change do |device, stepper, position, obj|\n @vars['actual_position'].value = position\n end\n end",
"def attr_to_step(attr)\n @attrs_to_steps ||=\n PARAMS.each_with_object({}) do |kv, params_to_steps|\n step, params = *kv\n params.each do |param|\n case param\n when Symbol\n params_to_steps[param] = step\n when Hash\n param.each_key do |array_param|\n params_to_steps[array_param] = step\n end\n end\n end\n end\n @attrs_to_steps.fetch(attr)\n end",
"def attributes(*args)\n hash = super\n if @instance_options[:detailed] == true\n hash[:checklists] = checklists\n hash[:current_timer] = current_timer\n end\n hash\n end",
"def attributes\n @@attributes\n end",
"def attributes\n self.class.attributes + numeric_attrs\n end",
"def values_for_properties; end",
"def attr; end",
"def attributes\n @attrs.keys\n end",
"def attributes\n map { |direction| direction.attribute }\n end",
"def exposed_attributes\n [ :id, :student_id, :curriculum_id, :accuracy, :baseline, :trial_days_actual, :trial_days_total,\n :description, :is_completed, :baseline_date, :due_date\n ]\n end",
"def properties\n self.values\n end",
"def get_attributes\n\t\t\t@@attributes\n\t\tend",
"def attributes\n node[1]\n end",
"def step_params\n params.require(:step).permit(:recipe_id, :number, :description, :timer)\n end",
"def attributes\n ATTRIBUTE_NAMES\n end",
"def attributes\n @data.keys\n end",
"def parameters\n attributes.fetch(:parameters)\n end",
"def arguments\n self.class.dry_initializer.attributes(self)\n end",
"def step_size\n self['Step'] || 0\n end",
"def wizard_value(step_name)\n step_name\n end",
"def props()\n @props\n end",
"def instance_attributes; end",
"def attributes\n self.class.attributes\n end",
"def step_params\n params.require(:step).permit(:number, :description, :locator, :skip, :testcase_id, :actionValue)\n end",
"def next_review_attrs\n {:unit_id => unit_id, :user_id => user_id, :interval => next_interval, :scheduled_at => next_scheduled_at}\n end",
"def attributes\n @enabled\n end",
"def trial_until\n @attributes[:trial_until]\n end",
"def values\n @attrs.values\n end",
"def attributes\r\n self.class.attributes\r\n end",
"def required_attributes\n self.class::REQUIRED_ATTRIBUTES\n end",
"def attributes\n {\"name\"=> @name, \"component\" => self.component}\n end",
"def attributes\n self.class.attributes\n end",
"def attributes\n self.class.attributes\n end",
"def user_flow_attributes\n return @user_flow_attributes\n end",
"def step_params\n params.require(:step).permit(:user_id, :assignment_id, :title, :url, :justification, :parent_id, :lft, :rgt, :favorite, :document, :screenshot)\n end",
"def attributes\n scraper.attributes.keys + uri_response_attributes + [:feed]\n end",
"def options\n attributes.fetch(:options)\n end",
"def print_attribute(*) end",
"def step_points\n points.select { |point| point.kind == \"Step\" }\n end",
"def attributes\n @list.map(&:attributes)\n end",
"def attributes\n @attributes ||= {}\n @attributes\n end",
"def attributes\n @build['attributes']\n end",
"def steps\n @steps ||= 0\n end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attribute; end",
"def attributes\n Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]\n end"
] | [
"0.59020156",
"0.5777914",
"0.5753583",
"0.57328516",
"0.57256657",
"0.57071215",
"0.57026625",
"0.5694358",
"0.5684938",
"0.5680471",
"0.5680448",
"0.56314987",
"0.56223154",
"0.5595958",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.55880994",
"0.5553351",
"0.5549634",
"0.553405",
"0.5507057",
"0.5501962",
"0.5501962",
"0.5501962",
"0.5501769",
"0.54984045",
"0.5496427",
"0.54958576",
"0.54879975",
"0.54729533",
"0.54706305",
"0.5454158",
"0.54245603",
"0.54245603",
"0.54245603",
"0.54245603",
"0.54245603",
"0.54245603",
"0.5419059",
"0.5413973",
"0.54039186",
"0.5399237",
"0.5396083",
"0.53838426",
"0.5373962",
"0.537298",
"0.53592175",
"0.535544",
"0.53546154",
"0.53480345",
"0.53182423",
"0.5312474",
"0.53108877",
"0.53047824",
"0.5280428",
"0.5259157",
"0.525791",
"0.52464956",
"0.5235045",
"0.5225906",
"0.5224357",
"0.5200752",
"0.5190983",
"0.5184231",
"0.5180952",
"0.5160018",
"0.5159688",
"0.5155929",
"0.51491165",
"0.5138216",
"0.51343256",
"0.5121258",
"0.5113212",
"0.5113212",
"0.5108526",
"0.510511",
"0.51036185",
"0.5094673",
"0.5091897",
"0.5084974",
"0.5079172",
"0.50779694",
"0.50738585",
"0.5065608",
"0.50549954",
"0.50549954",
"0.50549954",
"0.50549954",
"0.50549954",
"0.50549954",
"0.50549954",
"0.50463104"
] | 0.54992485 | 33 |
Displays data for the digital input | def inspect
"#<#{self.class} @index=#{index}, @state=#{state}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n if @input.devolucion\n @es_devolucion = \"Devolución\"\n else\n @es_devolucion = [\"Remito: \",@input.remito].join\n end\n end",
"def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend",
"def d(data)\n data.send :display \n \"\\n\".send :display\nend",
"def display\r\n end",
"def data()\n\t\tputs(\"Please enter the name of the employee\")\n\t\t@name = gets\n\t\tputs(\"Now the age\")\n\t\t@age = gets\n\t\tputs(\"Finally his social number\")\n\t\t@social_n = gets\n\tend",
"def render_edit\n @txt_disk_usage = `df`\n @txt_memory_usage = `free -m`\n\n # Get temperature\n begin\n @temperature = `cat /sys/class/thermal/thermal_zone0/temp`\n @temperature = @temperature.to_i / 1000.0\n @temperature = \"#{@temperature} Cº\"\n rescue\n Log.log_last_exception\n @temperature = '??? Cº'\n end\n\n # Available input devices:\n begin\n devs_dir = '/dev/input/by-id'\n if Dir.exists?(devs_dir)\n @input_devices = Dir\n .entries( devs_dir )\n .select { |d| !File.directory?(d) }\n else\n @input_devices = []\n end\n rescue\n Log.log_last_exception\n @input_devices = []\n end\n\n render 'edit'\n end",
"def display_character_blah\n \n puts \"Name: #{name}\"\n puts \"Bio: #{description}\"\n end",
"def display_input\n\t\n\t\tputs \"2-lettered tiles:\"\n\t\t(@@two_tiles).each { |t| \n\t\t\tprint \"#{t.letters} \" \n\t\t}\n\t\t\n\t\tputs \"\\n3-lettered tiles:\"\n\t\t(@@three_tiles).each { |t| \n\t\t\tprint \"#{t.letters} \" \n\t\t}\n\t\t\n\t\tputs \"\\n4-lettered tiles:\"\n\t\t(@@four_tiles).each { |t| \n\t\t\tprint \"#{t.letters} \" \n\t\t}\n\t\t\n\tend",
"def display_data_universe\n\n end",
"def display\n puts \"Title: #{@title}\"\n puts \"Author: #{@author}\"\n puts \"Price: #{@price}\"\n end",
"def display input\n\tputs \"#\"*40\n\tputs input\n\nend",
"def displayinvalidinputerror\r\n\t\t\t@output.puts('Invalid input.')\r\n\t\tend",
"def show\n data, format = [], []\n \n update(:elapsed, (Time.now - @start_time).to_i)\n \n sorted = @data.sort { |a,b| a[1][:order]<=>b[1][:order] }\n sorted.each do |item|\n format << \"#{item[0].to_s.capitalize}: #{item[1][:format]}\"\n data << item[1][:value] \n end\n \n $stdout.printf(format.join(' | ') + \"\\r\", *data)\n $stdout.flush\n end",
"def output(data)\n msg @presenter.format(data)\n end",
"def printData()\n puts @data\n end",
"def show_info()\n\t\tputs \"ID: #{@@id}\"\n\t\tputs \"Name: #{@car_name}\"\n\t\tputs \"Make: #{@@make}\"\n\t\tputs \"Cost: #{calc_total_cost} INR\"\n\t\tputs\n\t\tputs \"Review: #{@review}\"\n\t\tputs \"Rating: #{@rating} stars\"\n\tend",
"def output(data)\n msg @presenter.format(data)\n end",
"def display_entry\n\t\tputs user.username + \" \" + date.to_s\n\t\tputs text\n\tend",
"def output(data); end",
"def show \r\n end",
"def display_character_info(input)\n #binding.pry \n api = Api.new\n character = api.create_character (input)\n character.display_character_blah\n end",
"def show() end",
"def show() end",
"def show() end",
"def display_show_interface\n Show.display_all_shows_lite\n puts \"There are #{Show.all.size} shows. Enter the number of the show you'd like to display\"\n usr_input = get_usr_input.to_i\n if usr_input <= Show.all.size\n disp_horiz_line\n Show.display_show(usr_input)\n disp_horiz_line\n end\n end",
"def show\n @versions = @arduino.versions\n @sensors = @arduino.sensors\n end",
"def show\n\t\tputs @gender+\" - \"+@blood_type+\" - \"+@weight+\" - \"+@infected\n\tend",
"def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end",
"def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end",
"def display\n\t\tputs \" #{cells[0]} | #{cells[1]} | #{cells[2]} \"\n\t\tputs \"-----------\"\n\t\tputs \" #{cells[3]} | #{cells[4]} | #{cells[5]} \"\n\t\tputs \"-----------\"\n\t\tputs \" #{cells[6]} | #{cells[7]} | #{cells[8]} \"\n\tend",
"def handle\n display\n end",
"def mostrar_datos\n\tputs \"Los datos de #{@nombre} son: \" <<\n\t\"\\nY: \" << get_Y.to_s <<\n\t\"\\nK: \" << get_K.to_s << \"\\n---------------------\\n\"\n\n\tend",
"def show()\n puts \"\\n for Addition press :1 \"\n puts \"\\n for Subtraction press :2 \"\n puts \"\\n for Multiplication press :3 \"\n puts \"\\n for Division press :4 \"\n end",
"def show?; read?; end",
"def display\n if command\n write_green \"\\t#{hname}\"\n command && write_cyan(\"\\t vite-faits #{command}\")\n end\n # TODO Quand on pourra sortir une version HTML, on pourra mettre\n # un lien vers le mode d'emploi.\n # manuel && puts(\"\\t Ancre manuel : ##{manuel}\")\n end",
"def print_data\n\n # Print customer information.\n box_height = 0.166667\n y = 8.9\n self.vms_text_box(\"Attn: <strong>PIERRE PAROZ</strong>\", 0.5, y, 3.5, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"AMEMIC\", 4.5, y, 3.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Date: <strong>12/13/18</strong>\", 4.5, y, 3.5, box_height, 10, :normal, :right, :center)\n y -= box_height\n self.vms_text_box(\"AMERICAN MICRO PRODUCTS, INC.\", 0.5, y, 3.5, box_height, 10, :bold, :left, :center)\n y -= box_height\n self.vms_text_box(\"4288 ARMSTRONG BLVD\", 0.5, y, 3.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Phone:\", 4.5, y, 0.75, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"(513) 732-2674\", 5.15, y, 3.5, box_height, 10, :bold, :left, :center)\n y -= box_height\n self.vms_text_box(\"BATAVIA, OH 45103-1600\", 0.5, y, 3.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Fax:\", 4.5, y, 0.75, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"(513) 732-3535\", 5.15, y, 1.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Ext\", 6.4, y, 0.5, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"032\", 6.7, y, 1, box_height, 10, :bold, :left, :center)\n y -= (box_height + 0.25)\n\n # Draw quotation box.\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n self.vms_text_box(\"VMS Quote # <strong>71295</strong>\", 0.35, y, 3.8, 0.4, 12, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Your Request # <strong>Q02I7446</strong>\", 4.35, y, 3.8, 0.4, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.4\n fill_color('cccccc')\n fill_rectangle([0.25.in, y.in], 8.in, 0.25.in)\n stroke_rectangle([0.25.in, y.in], 2.in, 0.25.in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, 0.25.in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, 0.25.in)\n self.vms_text_box(\"Part Number\", 0.25, y, 2, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"Part Description & Process Specification\", 2.25, y, 4.5, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"EAU\", 6.75, y, 1.5, 0.25, 10, :bold, :center, :center)\n quotation_lines = 9\n y -= 0.25\n stroke_rectangle([0.25.in, y.in], 2.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, (quotation_lines * _p(10)).in)\n self.vms_text_box(\"627591\\n \\n \\n \\n \\n \\n \", 0.35, y, 1.8, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"POLE PIECE\\n\\n12L14 STEEL X 12.3MM OD X 7MM ID\\n& 1.90MM THRU HOLE X 13.9MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.35, y, 4.3, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"500,000 PCS\\n \\n \\n \\n \\n \\n \", 6.85, y, 1.3, quotation_lines * _p(10), 10, :normal, :center, :center)\n y -= quotation_lines * _p(10)\n remarks_lines = 4\n stroke_rectangle([0.25.in, y.in], 8.in, (remarks_lines * _p(10)).in)\n self.vms_text_box(\"<em>Remarks:</em>\\nPLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\", 0.35, y, 7.8, remarks_lines * _p(10), 10, :normal, :left, :center)\n y -= remarks_lines * _p(10)\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n self.vms_text_box(\"Price: <strong>$0.028/each</strong>\", 0.35, y, 3.8, 0.32, 10, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Minimum Lot Charge: <strong>$250.00</strong>\", 4.35, y, 3.8, 0.32, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.57\n\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n self.vms_text_box(\"VMS Quote # <strong>71296</strong>\", 0.35, y, 3.8, 0.4, 12, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Your Request # <strong>Q02I7447</strong>\", 4.35, y, 3.8, 0.4, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.4\n fill_color('cccccc')\n fill_rectangle([0.25.in, y.in], 8.in, 0.25.in)\n stroke_rectangle([0.25.in, y.in], 2.in, 0.25.in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, 0.25.in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, 0.25.in)\n self.vms_text_box(\"Part Number\", 0.25, y, 2, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"Part Description & Process Specification\", 2.25, y, 4.5, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"EAU\", 6.75, y, 1.5, 0.25, 10, :bold, :center, :center)\n quotation_lines = 9\n y -= 0.25\n stroke_rectangle([0.25.in, y.in], 2.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, (quotation_lines * _p(10)).in)\n self.vms_text_box(\"627599\\n \\n \\n \\n \\n \\n \", 0.35, y, 1.8, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"ARMATURE\\n\\n12L14 STEEL X 12.3MM & 10.3MM &\\n4.5MM & 1.90MM OD X 50.05MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.35, y, 4.3, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"500,000 PCS\\n \\n \\n \\n \\n \\n \", 6.85, y, 1.3, quotation_lines * _p(10), 10, :normal, :center, :center)\n y -= quotation_lines * _p(10)\n remarks_lines = 4\n stroke_rectangle([0.25.in, y.in], 8.in, (remarks_lines * _p(10)).in)\n self.vms_text_box(\"<em>Remarks:</em>\\nPLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\", 0.35, y, 7.8, remarks_lines * _p(10), 10, :normal, :left, :center)\n y -= remarks_lines * _p(10)\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n self.vms_text_box(\"Price: <strong>$0.091/each</strong>\", 0.35, y, 3.8, 0.32, 10, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Minimum Lot Charge: <strong>$250.00</strong>\", 4.35, y, 3.8, 0.32, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.57\n\n return\n\n # Print data table.\n self.vms_text_box(\"LN\", 0.25, 7.95, 0.5, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\"627591\\nQuote # <strong>71295</strong>\", 0.8, 7.95, 1.9, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"POLE PIECE\\n\\n12L14 STEEL X 12.3MM OD X 7MM ID\\n& 1.90MM THRU HOLE X 13.9MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.8, 7.95, 3.15, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"500,000 PCS\", 6.05, 7.95, 1.15, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\".028\\n$/EACH\\n\\n<em>MINIMUM</em>:\\n$250.00\", 7.3, 7.95, 0.9, 8 * _p(10), 10, :normal, :center, :top)\n fill_color('eeeeee')\n fill_rectangle([0.5.in, 6.75.in], 7.5.in, (8 * _p(10)).in)\n stroke_rectangle([0.5.in, 6.75.in], 7.5.in, (8 * _p(10)).in)\n self.vms_text_box(\"PLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\\n\\nYOUR REQUEST NUMBER <strong>Q0217446</strong>\\n\\nPLEASE REFER TO OUR QUOTATION NUMBER <strong>71295</strong> ON ALL CORRESPONDENCE OR ORDERS\", 0.5, 6.75, 7.5, 8 * _p(10), 10, :normal, :center, :center)\n self.vms_text_box(\"LN\", 0.25, 5.5, 0.5, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\"627599\\nQuote # <strong>71296</strong>\", 0.8, 5.5, 1.9, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"ARMATURE\\n\\n12L14 STEEL X 12.3MM & 10.3MM &\\n4.5MM & 1.9MM OD X 50.05MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.8, 5.5, 3.15, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"500,000 PCS\", 6.05, 5.5, 1.15, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\".091\\n$/EACH\\n\\n<em>MINIMUM</em>:\\n$250.00\", 7.3, 5.5, 0.9, 8 * _p(10), 10, :normal, :center, :top)\n fill_color('eeeeee')\n fill_rectangle([0.5.in, 4.3.in], 7.5.in, (8 * _p(10)).in)\n stroke_rectangle([0.5.in, 4.3.in], 7.5.in, (8 * _p(10)).in)\n self.vms_text_box(\"PLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\\n\\nYOUR REQUEST NUMBER <strong>Q0217447</strong>\\n\\nPLEASE REFER TO OUR QUOTATION NUMBER <strong>71296</strong> ON ALL CORRESPONDENCE OR ORDERS\", 0.5, 4.3, 7.5, 8 * _p(10), 10, :normal, :center, :center)\n\n\n \n end",
"def display_info\n \n puts \"\\nPlayer Name: #{self.name}\"\n puts \"Current Rank: #{self.rank}\"\n puts \"Position: #{self.position}\"\n puts \"School/Club: #{self.schoolclub}\"\n # binding.pry\n #if there is no class_year, nothing is displayed\n puts \"Year: #{self.class_year}\"\n #\n puts \"Height/Weight: #{self.height}, #{self.weight} \"\n puts \"Age: #{self.age}\"\n puts \"Last rank: #{self.last_rank}\"\n puts \"Scouting Report: #{self.blurb}\"\n puts \"------------------------------------\"\n end",
"def show_info\n\t\tputs \"Your start station: #{starting_point}\"\n\t\tputs \"Your destination: #{ending_point}\"\n\t\tputs \"Travel time: ___\"\n\t\tputs \"Price: ____\"\n\tend",
"def show\n\n if @fixed_asset.serial_number? && CONFIG[:NETBOX][:ENABLED]\n fa_serial = @fixed_asset.serial_number\n @nb_device = NetboxClientRuby.dcim.devices.find_by(serial: fa_serial)\n logger.debug \"data from netbox: #{@nb_device}\"\n else\n end\n end",
"def display\n # Don't no why i thought i would need that. or if i need this.\n end",
"def show\n\t\t end",
"def displayCard()\n puts \" Value: #{@value}\"\n puts \" Suit: #{@suit}\"\n end",
"def show\n puts \"ID = #{@id}\"\n puts \"Node name = #{@name}\"\n puts \"Require's input = #{@require_input}\"\n puts \"Type = #{@type}\"\n puts \"Points at => #{@points_at.pretty_inspect}\"\n end",
"def display\n system 'clear'\n @line_width = 60\n display_header\n display_board\n display_shield_row\n display_legend\n end",
"def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end",
"def output\n puts \"Name: #{@name}\"\n puts \"Email: #{@email}\"\n puts \"Phone: #{@phone}\"\n puts \"Title: #{@title}\"\n end",
"def show_information_card\n puts \"------------------------------\"\n puts \"Name: #{@name}\"\n puts \"Address: #{@address}\"\n puts \"Email: #{@email}\"\n puts \"Random Fact: #{@random_fact}\"\n puts \"-----------------------------\"\n end",
"def DisplayResults(data)\n\t\n\tputs \"Street Address: #{data[0]}\"\n\tputs \"Last Year Assessed Value: $#{data[1]}\"\n\tputs \"Current Assessed Value: $#{data[2]}\"\n\tputs \"Exemption: $25,000\"\n\tputs \"Taxable Value: $#{data[2]-25000}\"\n\tputs \"Tax Rate (per $1,000): $10.03\"\n\tputs \"Due: $#{data[3]}\"\nend",
"def display_details()\n\t\tputs \"------------------------------\"\n\t\tputs \"User Details\"\n\t\tputs \"#{@first_name} #{@surname} aged '#{@age}'\"\n\t\tputs \"------------------------------\"\n\tend",
"def stdinput\n @input\n end",
"def print\n\t\t\tputs \"F: \" + toFahrenheit(@degrees, @scale).to_s + \" C: \" + toCelsius(@degrees, @scale).to_s + \" K: \" + toKelvin(@degrees, @scale).to_s\n\t\tend",
"def display_character_info(input)\n api = Api.new(query)\n api.create_character \n end",
"def show_values\n puts \"Name: \" + @heating_name\n puts \" Area: \" + @heating_area.to_s\n puts \" Temperature: \" + @heating_temperature.to_s\n puts \"Radiator: \" + @num_radiator.to_s\n puts \" Ground: \" + @num_ground.to_s\n puts \" Num: \" + @num.to_s\n end",
"def show_input\n puts \"====================================\"\n puts \"What show would you like to explore?\"\n puts \"====================================\"\n puts \"\"\n input = gets.strip\n list = show_search(input)\n system(\"clear\")\n if list.keys.size < 1\n puts \"I'm sorry, there doesn't seem to be a show with that title.\"\n sleep(1)\n repeat_prompt\n else \n list.keys.each.with_index(1) {|k,i| puts \"#{i}) #{k}\"}\n end\n puts \"What production would you like to learn more about?\"\n puts \"\"\n input = gets.strip.to_i\n if input.between?(1,list.keys.size)\n Scraper.new('show', list[list.keys[input-1]])\n else\n system(\"clear\")\n puts \"I'm not sure what you want.\"\n sleep(1)\n system(\"clear\")\n repeat_prompt\n end\n system(\"clear\")\n Production.all.last.print\n repeat_prompt\n end",
"def display\n puts \" 0 1 2 3 4 5 6 7 \"\n puts \"#{format}\"\n end",
"def print\r\n\t\t\tputs \"F: \" + toFahrenheit(@degrees, @scale).to_s + \" C: \" + toCelsius(@degrees, @scale).to_s + \" K: \" + toKelvin(@degrees, @scale).to_s\r\n\t\tend",
"def show ; end",
"def display\n puts @o\n puts @a\n puts @b\n puts @c\n puts @d\n puts @e\n puts @f\n puts @g\n puts @h\n puts @i\n puts \" \"\n end",
"def show\n @history_index = @history.length\n self.text = \"\"\n self.visible = true\n self.active = true\n Input.text_input = true if $MKXP\n end",
"def show_details\n print @name.upcase + \": #{@name} has #{@moons} moons and a diameter of #{@diameter} miles.\"\n print \"It is #{@color} in color and associated with the #{@zodiac} zodiac sign.\"\n puts \"#{@name} is #{@distance} miles from the sun and has a solar rotation of #{@rotation} earth days!\"\n end",
"def display\n tp self\n end",
"def show\n @data.each do | row |\n row.each do | cell |\n if cell.infected?\n print \"%3s\" % cell.virus.generation\n else\n print \" #{cell.content} \"\n end\n end\n puts\n end\n end",
"def show\n IRuby.display(self)\n end",
"def display\n encoded_asterisks, encoded_text = cmd('?FL', /^FL([0-9A-F]{2})([0-9A-F]{28})$/)\n return nil unless encoded_asterisks && encoded_text\n\n str = case encoded_asterisks\n when '00' then ' '\n when '01' then ' *'\n when '02' then '* '\n when '03' then '**'\n else; ''\n end\n\n return str + encoded_text.unpack('a2' * 14).map { |c| c.to_i(16).chr }.join\n end",
"def display_instrutions\n\n\tConsole_Screen.cls #clear the display area\n\tputs \"\\t\\t\\tInstructions: \\n\\n\" #display a heading\n\n\t#display the game's instrutions\n\tputs %Q{ This test consists of a series of 10 typing challenges. The challenge sentences are presented one at a time. To respond correctly, you must retype each sentence exactly as shown and press the Enter key. You receive an A if you get 9 or 10 right, a B if you get 8 right, a C if you get 7, a D if you get 6 and F for anything 5 or below. Happy gaming. \\n\\n\\n\\n\\n\\n Press Enter to continue.\\n\\n}\n\n\tConsole_Screen.pause\nend",
"def display\n puts self\n end",
"def hidden_input(label = '>>', n = 0)\n printi label + whites, n\n STDIN.noecho(&:gets).strip.chomp\n end",
"def display\n\t\t\"\"\n\tend",
"def data=(value)\n @main.text = value.to_s\n end",
"def keyboards_tech_demo\n outputs.labels << [460, row_to_px(0), \"Current game time: #{state.tick_count}\", small_font]\n outputs.labels << [460, row_to_px(2), \"Keyboard input: inputs.keyboard.key_up.h\", small_font]\n outputs.labels << [460, row_to_px(3), \"Press \\\"h\\\" on the keyboard.\", small_font]\n\n if inputs.keyboard.key_up.h # if \"h\" key_up event occurs\n state.h_pressed_at = state.tick_count # frame it occurred is stored\n end\n\n # h_pressed_at is initially set to false, and changes once the user presses the \"h\" key.\n state.h_pressed_at ||= false\n\n if state.h_pressed_at # if h is pressed (pressed_at has a frame number and is no longer false)\n outputs.labels << [460, row_to_px(4), \"\\\"h\\\" was pressed at time: #{state.h_pressed_at}\", small_font]\n else # otherwise, label says \"h\" was never pressed\n outputs.labels << [460, row_to_px(4), \"\\\"h\\\" has never been pressed.\", small_font]\n end\n\n # border around keyboard input demo section\n outputs.borders << [455, row_to_px(5), 360, row_to_px(2).shift_up(5) - row_to_px(5)]\n end",
"def display_app_header\n\t\t\n\t\t\t#specifying font to be used\n\t\t\ttext_font @font, 25\n\t\t\t#setting title to dipslay\n\t\t\ttext \"SerialDuino v1a - StephanAG 2012\", 10 ,25\n\t\t\t\n\t\t\t#display intro paragraph\n\t\t\ttext_font @font, 13\n\t\t\ttext @intro_data, 10 ,45\n\t\tend",
"def display\n puts \" #{@cells[0]} \" + \"|\" + \" #{@cells[1]} \" + \"|\" + \" #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} \" + \"|\" + \" #{@cells[4]} \" + \"|\" + \" #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} \" + \"|\" + \" #{@cells[7]} \" + \"|\" + \" #{@cells[8]} \"\n end",
"def print_label\n puts \"#{@nombre_etiqueta}\"\n puts \"\\nValor energetico o nutriente | por 100g o 100ml de producto \"\n puts \"--------------------------------|--------------------------------\"\n puts \"valor energetico |\" + \" #{energetic_value_KJ}\" + \" KJ/\" + \"#{energetic_value_Kcal}\" + \" Kcal\"\n puts \"Camtidad de grasas |\" + \" #{@grasa}g\"\n puts \"Camtidad de grasas saturadas |\" + \" #{@grasa_saturada}g\"\n puts \"Camtidad de hidratos de carbono |\" + \" #{@hid_carbono}g\"\n puts \"Camtidad de azucares |\" + \" #{@azucares}g\"\n puts \"Camtidad de proteinas |\" + \" #{@proteinas}g\"\n puts \"Camtidad de sal |\" + \" #{@sal}g\"\n @nombre_etiqueta\n end",
"def getAndShow\n\tputs \"Enter your name\"\n\tname = gets()\n\tputs \"Enter your Age\"\n\tage = gets()\n\tputs \"Your name is #{name}\"\n\tputs \"Your Age is #{age}\"\nend",
"def show_data(param)\n\tparam.each do |k,v|\n\t\tputs \"#{k} : #{v}\"\n\tend\nend",
"def read_input\n end",
"def display\n\t\t\"SUITE: #{@suite}, RANK: #{@rank}, VALUE: #{@value}\"\n\tend",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n puts \"******* show *******\"\n end",
"def display_post\n\t\tputs \" \"\n\t\tputs \"#{@title} #{@date}\"\n\t\tputs \"----------------\"\n\t\tputs @content\n\t\tputs \"----------------\"\n\t\tputs \" \"\n\tend",
"def display\n puts \" #{@cells[0]} | #{@cells[1]} | #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} | #{@cells[4]} | #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} | #{@cells[7]} | #{@cells[8]} \"\n end",
"def display\n puts \" #{@cells[0]} | #{@cells[1]} | #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} | #{@cells[4]} | #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} | #{@cells[7]} | #{@cells[8]} \"\n end",
"def render\n @input = \"\"\n until @done\n question = render_question\n @prompt.print(question)\n @prompt.print(render_error) if @failure\n if paginated? && !@done\n @prompt.print(render_page_help)\n end\n @prompt.read_keypress\n question_lines = question.split($INPUT_RECORD_SEPARATOR, -1)\n @prompt.print(refresh(question_lines_count(question_lines)))\n end\n @prompt.print(render_question) unless @quiet\n answer\n end",
"def print_values\n print \"\\nRegister A: #{@register_a}\\tRegister B: #{@register_b}\\n\"\n print \"Zero Bit: #{@zero_bit}\\tOverflow Bit: #{@overflow}\\n\"\n print \"Program Counter: #{@pc}\\n\"\n print \"Memory: #{@memory}\\n\"\n end",
"def display_details()\r\n\t\tprintf(\"\\n**************************************************\")\r\n\t\tprintf(\"\\n***** MONTHLY PAY SLIP DETAILS *****\")\r\n\t\tprintf(\"\\n**************************************************\")\r\n\t\tprintf(\"\\nEmployee Name : %s\",@name)\r\n\t\t# Amounts are depicted with 2 decimal places.\r\n\t\tprintf(\"\\nGross Monthly Salary : $ %.2f\",@grossMonthlyIncome)\r\n\t\tprintf(\"\\nMonthly Tax : $ %.2f\",@monthlyIncomeTax)\r\n\t\tprintf(\"\\nNet Monthly Salary : $ %.2f\",@netMonthlyIncome)\r\n\t\tprintf(\"\\n**************************************************\")\r\n end",
"def display\r\n puts \" #{cells[0]} | #{cells[1]} | #{cells[2]} \"\r\n puts \"-----------\"\r\n puts \" #{cells[3]} | #{cells[4]} | #{cells[5]} \"\r\n puts \"-----------\"\r\n puts \" #{cells[6]} | #{cells[7]} | #{cells[8]} \"\r\n end",
"def draw_info\n def ppair(a,b)\n @scr.puts '<message>' + a + (' ' * (18-a.length-b.to_s.length)) + '<value>' + b.to_s\n end\n # game info\n @scr.x = @scr.y = 0\n @scr.puts '<info>' + @game.player.name\n ppair _('Year'), @game.year.abs.to_s + _(' B.C.')\n @scr.puts\n # selected unit\n if (u = @driver.focused)\n @scr.puts '<info>' + u.military.name\n if u.skills.empty?\n @scr.puts _('No skills')\n else\n u.skills.each { |sk| @scr.puts sk.name }\n end\n ppair _('Moves left'), u.moves_left\n end\n end",
"def text_input; end",
"def display!(data)\n self[:full_text] = (self[:symbol] || self[:name]) + self[:ends] + core_display(data) + self[:ends]\n self\n end",
"def main\n\t#limpiar pantalla\t\n\tputs \"\\e[H\\e[2J\"\n\tputs \"====================================\"\n\tprint \"== Introducir perimetro: \"\n\tSTDOUT.flush\n\tperi = gets.chomp\n\tperi = peri.to_r\n\n\tcal = Perimetro.new(peri)\n\tprint \"== Radio: \" \n\tputs cal.calperimetro\n\t\n\t#pulsar una tabla\n\tputs \"\"\n\tputs \"== Para continuar pulse una tecla... \"\n\tSTDOUT.flush\n\tgets.chomp\nend",
"def display_instructions\r\n \r\n Console_Screen.cls #Clear the display area\r\n puts \"INSTRUCTIONS:\\n\\n\" #Display a heading\r\n\r\n #Display the game's instructions\r\n puts \"10 multiple choice questions! can you get them right?\" \r\n puts \"To answer a question type its corresponding letter!\"\r\n puts \"for example you want to enter answer A, so press a/A then Enter key.\"\r\n puts \" Your grade will be presented at the end but 5 or more wrong answers and you fail! \\n\\n\\n\"\r\n puts \"Each question is worth one point!\\n\\n\\n\\n\\n\\n\\n\\n\\n\"\r\n \r\n puts \"if your ready hit any key\"\r\n\tputs (\"\\n\" * 5)\r\n\t \r\n\t\r\n\tanswer = STDIN.gets \r\n\tanswer.chop! \r\n\t\r\n\tif answer == \"i\" \r\n\t\r\n\tputs \"10 out of 10 is a true fan 9 is a fan and 8 is a semi fan 7 is a FF new fan \"\r\n\tputs \"lower than that is failure.\" \r\n\r\n Console_Screen.pause #Pause the game\r\n end \r\n\r\n end",
"def displayInfo(text)\n puts \"( - ) #{text}\"\n end",
"def display\n puts\n puts \"* Class: #{self.class_name} *\"\n puts\n puts \"Description: #{self.description}\"\n puts\n puts \"Spellcasting: #{spellcasting}\"\n puts\n puts \"-----------------------------\"\n end"
] | [
"0.6648387",
"0.6565481",
"0.6255316",
"0.62418574",
"0.6169812",
"0.6112287",
"0.6083041",
"0.60418856",
"0.5982994",
"0.5953679",
"0.58847886",
"0.5870912",
"0.5865864",
"0.58593875",
"0.5847815",
"0.5846593",
"0.5845567",
"0.57900524",
"0.57850885",
"0.5766434",
"0.57642287",
"0.57556474",
"0.57556474",
"0.57556474",
"0.57467896",
"0.5745107",
"0.57433283",
"0.5735063",
"0.5735063",
"0.57278776",
"0.5725187",
"0.5723114",
"0.57071173",
"0.56958824",
"0.56956357",
"0.56942314",
"0.5690258",
"0.5686892",
"0.56747663",
"0.5669715",
"0.5668403",
"0.56508064",
"0.5642017",
"0.56419784",
"0.5640452",
"0.562755",
"0.5626913",
"0.5622038",
"0.5621047",
"0.5601449",
"0.5598619",
"0.5596494",
"0.5593047",
"0.55928296",
"0.55921537",
"0.557329",
"0.55716217",
"0.5571293",
"0.5570405",
"0.5569956",
"0.55676925",
"0.55570215",
"0.5540461",
"0.55394775",
"0.5536283",
"0.5530909",
"0.55195755",
"0.5512735",
"0.55109835",
"0.5508693",
"0.5507998",
"0.54935676",
"0.5488939",
"0.548762",
"0.5481859",
"0.5481607",
"0.54761386",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5469262",
"0.5465245",
"0.5463191",
"0.5462872",
"0.5462872",
"0.54618865",
"0.54589194",
"0.5456301",
"0.5447868",
"0.5446617",
"0.54346836",
"0.5427484",
"0.5413898",
"0.5410373",
"0.54100496",
"0.54074913"
] | 0.0 | -1 |
Displays data for the stepper | def inspect
"#<#{self.class} @index=#{index}, @acceleration_min=#{acceleration_min}, @acceleration_max=#{acceleration_max}, @current_min=#{current_min}, @current_max=#{current_max}, @engaged=#{engaged}, @position_min=#{position_min}, @position_max=#{position_max}, @velocity_min=#{velocity_min}, @velocity_max=#{velocity_max}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\t#@step = user_information\n end",
"def do_next\n update_screen(get_step_content(@step + 1, @editor.value, @output.value))\n end",
"def show\n case step\n when :parameters\n # Create an initial input parameter if there is none\n @algorithm.input_parameters.build if @algorithm.input_parameters.empty?\n when :parameters_details\n # Possibly skip a step if there are no parameters used\n if @algorithm.input_parameters.empty?\n if @algorithm.upload?\n jump_to :parameters\n else\n flash[:notice] = \"Skipped step 3 due to no input parameters set\"\n skip_step\n end\n end\n end\n # Update the step of the algorithm.\n @algorithm.update_attribute(:status, step.to_sym) if steps.include?(step)\n render_wizard\n end",
"def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend",
"def print\n @steps = @experiment.steps\n \n # renders the print template without the normal layout\n render :layout => false;\n end",
"def show\n @step = @script.steps.build\n end",
"def show\n \"$#{total} #{@state[0]} #{@state[1]} #{@state[2]} #{@state[3]} #{@state[4]}\"\n end",
"def opinion_wizard_stepper(current_step)\n content_tag :ol, class: \"wizard__steps\" do\n %(\n #{opinion_wizard_stepper_step(:step_1, current_step)}\n #{opinion_wizard_stepper_step(:step_2, current_step)}\n #{opinion_wizard_stepper_step(:step_3, current_step)}\n #{opinion_wizard_stepper_step(:step_4, current_step)}\n ).html_safe\n end\n end",
"def showData\n $page = $page +\n \"<dl>\\n\" +\n \" <dt>name\\n\" +\n \" <dd>\" + $name + \"\\n\" +\n \" <dt>organization\\n\" +\n \" <dd>\" + $organization + \"\\n\" +\n \" <dt>email\\n\" +\n \" <dd>\" + $email + \"\\n\" +\n \" <dt>source\\n\" +\n \" <dd>\" + $source + \"\\n\" +\n \" <dt>use\\n\" +\n \" <dd>\" + $use + \"\\n\" +\n \" <dt>notification\\n\" +\n \" <dd>\" + $notification + \"\\n\" +\n \"</dl>\\n\"\nend",
"def show\n @payment = EwayPayment.new\n @maunal = Manual.find(params[:id])\n \n if @manual[:filled] && !@manual.paid?\n @manual.current_step = \"payment\"\n end\n \n if params[:step]\n @manual.current_step = params[:step]\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @manual }\n end\n end",
"def display\n tp self\n end",
"def show\n calculate_progress\n ##complete_goal\n end",
"def show\n data, format = [], []\n \n update(:elapsed, (Time.now - @start_time).to_i)\n \n sorted = @data.sort { |a,b| a[1][:order]<=>b[1][:order] }\n sorted.each do |item|\n format << \"#{item[0].to_s.capitalize}: #{item[1][:format]}\"\n data << item[1][:value] \n end\n \n $stdout.printf(format.join(' | ') + \"\\r\", *data)\n $stdout.flush\n end",
"def show\n # TODO put computation here for displaying alternate values?\n end",
"def show\n @steptwos = Steptwo.where(stepone_id: @stepone.id)\n render_dummy\n end",
"def show\n case step\n when :verify_mobile\n skip_step if current_user.mobile_verified?\n # TODO: Remove this once SMS provider has been added\n @otp = Redis.current&.get(current_user.id)\n when :enter_address\n skip_step if current_user.address_entered?\n @address = Address.find_or_initialize_by(user: current_user, address_type: :permanent)\n when :upload_docs\n skip_step if current_user.docs_uploaded?\n @user_document = UserDocument.find_or_initialize_by(user: current_user)\n end\n render_wizard\n end",
"def display_data_universe\n\n end",
"def show \r\n end",
"def show\n @steps = @tutorial.steps\n @step = @tutorial.steps.build\n end",
"def display\r\n end",
"def show\n @moving_items = @moving.moving_items\n @total_volume = @moving_items.inject(0) { |total, item| total + (item.volume * item.quantity) }\n remember_moving @moving # Remember moving id for later use.\n\n # @moving_item = MovingItem.new # For new form\n # @suggestions = @moving.autocomplete_suggestions # For AutoComplete\n\n @dataForBarChart = data_for_bar_chart(@moving_items)\n @dataForPieChart = data_for_pie_chart(@moving_items)\n end",
"def index\n @steps = @guide.steps\n end",
"def display\n system 'clear'\n @line_width = 60\n display_header\n display_board\n display_shield_row\n display_legend\n end",
"def showData\n $page = $page +\n \"<dl>\\n\" +\n \" <dt>events\\n\" +\n \" <dd>\" + $events + \"\\n\" +\n \"</dl>\\n\"\nend",
"def show\n @chart_data0 = make_chart_data(@progress.company_name,0)\n @chart_data1 = make_chart_data(@progress.company_name,1)\n @chart_data2 = make_chart_data(@progress.company_name,2)\n end",
"def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end",
"def render_step_result_header(step)\n puts string_with_padding(\"Step #{step}\", 8).white.on_black\n end",
"def to_variable_step\n @data.map { |i,v| \"#{i}\\t#{v.to_s(5)}\" }.join(\"\\n\")\n end",
"def time_period_v1_screen\n @heading = 'Time period = 1 / frequency'\n background('images/waves_large.png')\n\n # Time period v1 screen header\n ScreenHeader.new(self, '/title_screen/waves_screen', @@font, @heading)\n\n # Time period v1 screen content\n flow(:height => 640, :width => 1080, :scroll => true) do\n # Left margin offset\n stack(:height => 640, :width => 80) do\n end\n # Content column\n stack(:height => 640, :width => 1000) do\n ScreenLabel.new(self, @@font, @heading, 'Frequency')\n flow do\n @frequency = ScreenEditLine.new(self, @@font, @heading)\n @frequency_unit = para(strong(' Hz'))\n @frequency_unit.style(@@screen_unit_text_styles)\n end\n\n @calculate = button('Calculate')\n\n @result_display = flow\n\n @error_display = flow\n\n @calculate.click do\n @result_display.clear do\n @result = Joules.time_period_v1(@frequency.text.to_f)\n @time_period_v1 = para(@result.to_s)\n @time_period_v1_unit = para(' s')\n @time_period_v1.style(@@screen_result_text_styles)\n @time_period_v1_unit.style(@@screen_result_text_styles)\n end\n end\n end\n end\n end",
"def show\n \t@step = Step.find(params[:id])\n \t\n \trespond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @step }\n end\n end",
"def handle\n display\n end",
"def show\n\t\t end",
"def d(data)\n data.send :display \n \"\\n\".send :display\nend",
"def view_flight_info\n\n self.current_person.flights.each do |flight|\n puts \"----------------------------------------\"\n puts \"Flight ID : #{flight.id}\"\n puts \"Airline : #{flight.airline}\"\n puts \"Origin : #{flight.origin}\"\n puts \"Destination: #{flight.destination}\"\n puts \"Departure Time: #{flight.departure_time}\"\n puts \"Arrival Time: #{flight.arrival_time}\"\n puts \"Duration: #{flight.duration}\"\n puts \"\"\n puts \"----------------------------------------\"\n\n end\n return_to_menu\n end",
"def display_details()\n\t\tputs \"------------------------------\"\n\t\tputs \"User Details\"\n\t\tputs \"#{@first_name} #{@surname} aged '#{@age}'\"\n\t\tputs \"------------------------------\"\n\tend",
"def show_info\n\t\tputs \"Your start station: #{starting_point}\"\n\t\tputs \"Your destination: #{ending_point}\"\n\t\tputs \"Travel time: ___\"\n\t\tputs \"Price: ____\"\n\tend",
"def show_state\n\t\tputs \"#{@name} a #{@life_points} points de vie.\"\n\tend",
"def getsteps\n\t\t@hide_menu = true\n\n puts \"In Steps\"\n recId = params['query'].inspect\n #this is the link to the API\n url = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/\" + recId[1..-2] + \"/analyzedInstructions?stepBreakdown=true\"\n stepss = Unirest.get url,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n allSteps = stepss.body\n\n recSteps = Hash.new\n\n counter = 1\n #this is how the recipe information is formatted\n allSteps.each do |key|\n key.each do |key2,steps|\n if(key2.eql? \"steps\")\n steps.each do |step|\n step.each do |key3, lastStep|\n if(key3.eql? \"step\")\n recSteps[counter] = lastStep\n counter += 1\n #this gives each step a number, for ease of use\n end\n end\n end\n end\n end\n end\n puts recSteps\n\n @recipeData = recSteps\n render template: \"recipes/data3\"\n end",
"def display_exemple\n @array.each_with_index do |element, index|\n \tif index < @array.count-1 \n \t\tputs \"(data : #{element.value}) --> #{element.next_node.value}\"\n \telse\n \t\tputs \"(data : #{element.value}) --> #{element.next_node}\"\n \tend\n end\n end",
"def energy_efficiency_screen\n @heading = 'Energy efficiency = (useful energy output / energy input) x 100'\n background('images/energy_work_power_large.png')\n\n # Energy efficiency screen header\n ScreenHeader.new(self, '/title_screen/energy_work_power_screen', @@font, @heading)\n\n # Energy efficiency screen content\n flow(:height => 640, :width => 1080, :scroll => true) do\n # Left margin offset\n stack(:height => 640, :width => 80) do\n end\n # Content column\n stack(:height => 640, :width => 1000) do\n ScreenLabel.new(self, @@font, @heading, 'Useful energy output')\n flow do\n @useful_energy_output = ScreenEditLine.new(self, @@font, @heading)\n @useful_energy_output_unit = para(strong(' J'))\n @useful_energy_output_unit.style(@@screen_unit_text_styles)\n end\n\n ScreenLabel.new(self, @@font, @heading, 'Energy input')\n flow do\n @energy_input = ScreenEditLine.new(self, @@font, @heading)\n @energy_input_unit = para(strong(' J'))\n @energy_input_unit.style(@@screen_unit_text_styles)\n end\n\n @calculate = button('Calculate')\n\n @result_display = flow\n\n @error_display = flow\n\n @calculate.click do\n @result_display.clear do\n @result = Joules.energy_efficiency(@useful_energy_output.text.to_f,\n @energy_input.text.to_f)\n @energy_efficiency = para(@result.to_s)\n @energy_efficiency_unit = para(' %')\n @energy_efficiency.style(@@screen_result_text_styles)\n @energy_efficiency_unit.style(@@screen_result_text_styles)\n end\n end\n end\n end\n end",
"def index\n @next_steps = NextStep.all\n end",
"def show_state\n \tputs \"#{@name} a #{life_points} points de vie\"\n end",
"def display\n puts \" #{@cells[0]} \" + \"|\" + \" #{@cells[1]} \" + \"|\" + \" #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} \" + \"|\" + \" #{@cells[4]} \" + \"|\" + \" #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} \" + \"|\" + \" #{@cells[7]} \" + \"|\" + \" #{@cells[8]} \"\n end",
"def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end",
"def display_details()\n puts \"Numele persoanei: #@nume\"\n puts \"Prenumele persoanei: #@prenume\"\n end",
"def display\n\t\tputs \" #{cells[0]} | #{cells[1]} | #{cells[2]} \"\n\t\tputs \"-----------\"\n\t\tputs \" #{cells[3]} | #{cells[4]} | #{cells[5]} \"\n\t\tputs \"-----------\"\n\t\tputs \" #{cells[6]} | #{cells[7]} | #{cells[8]} \"\n\tend",
"def display\n puts self\n end",
"def opinion_wizard_stepper_step(step, current_step)\n return if step == :step_4 && type_of == :collaborative_drafts\n\n attributes = { class: opinion_wizard_step_classes(step, current_step).to_s }\n step_title = opinion_wizard_step_name(step)\n if step.to_s.split(\"_\").last.to_i == opinion_wizard_step_number(current_step)\n current_step_title = opinion_wizard_step_name(\"current_step\")\n step_title = content_tag(:span, \"#{current_step_title}: \", class: \"show-for-sr\") + step_title\n attributes[\"aria-current\"] = \"step\"\n end\n\n content_tag(:li, step_title, attributes)\n end",
"def print_output_head(index)\n puts \"\\nPrinting dataset for %.2f\" %\n (@meta_data.domain_z.lower + (index * @meta_data.domain_z.step))\n puts \"\\n\"\n end",
"def printout()\n user_training_rows = @user_training.user_training_rows\n .includes(:exercise, :training_step_type)\n .sort_by_part_order\n .all\n if user_training_rows.size < 1\n flash[:error] = I18n.t(:no_detail_to_process)\n redirect_to( user_trainings_path() ) and return\n end\n title = I18n.t('trainings.show_title').gsub( \"{TRAINING_TITLE}\", @user_training.description )\n\n # == OPTIONS setup + RENDERING phase ==\n base_filename = \"#{I18n.t('trainings.training')}_#{@user_training.description}\"\n filename = create_unique_filename( base_filename ) + '.pdf'\n options = {\n report_title: title,\n meta_info_subject: 'training model printout',\n meta_info_keywords: \"Goggles, #{base_filename}\",\n header_row: TrainingDecorator.decorate( @user_training ),\n detail_rows: TrainingRowDecorator.decorate_collection( user_training_rows )\n }\n send_data( # == Render layout & send data:\n TrainingPrintoutLayout.render( options ),\n type: 'application/pdf',\n filename: filename\n )\n end",
"def show_state\n\t\tputs \"#{self.name} a #{self.life_points} points de vie et une arme de niveau #{self.weapon_level}.\"\n\tend",
"def render\n super\n args.outputs.primitives << [\n # Layout\n {x: 330, y: 335, w: 556, h: 308, r: 100, g: 100, b: 100}.solid,\n @exit,\n {x: 860, y: 625, text: 'X', r: 175, g: 175, b: 175}.label,\n { x: 340, y: 370, text: \"Money: $#{state.money}\", size_enum: 5, alignment_enum: align(:left) }.label,\n { x: 500, y: 66, text: 'Take a Break', size_enum: 10, r: 250, g: 250, b: 250 }.label\n ]\n args.outputs.primitives << items.map(&:render)\n end",
"def summary\n # do extra setup for new returns to clear wizard cache _before_ setup_step is called\n # so we don't populate @ variables with old data!\n if params[:new]\n Rails.logger.debug('Starting new SLfT return')\n wizard_end\n end\n\n setup_step\n\n # Need to save on the summary to make sure that we have a new return if one was created\n wizard_save(@slft_return)\n\n # manage the buttons AFTER wizard_save so we don't save the validation errors\n return if manage_draft(@slft_return) || manage_calculate(@slft_return)\n end",
"def display\n puts \" #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} \"\n puts \"-----------\"\n puts \" #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} \"\n puts \"-----------\"\n puts \" #{self.cells[6]} | #{self.cells[7]} | #{self.cells[8]} \"\n end",
"def frequency_v1_screen\n @heading = 'Frequency = wave speed / wavelength'\n background('images/waves_large.png')\n\n # Frequency v1 screen header\n ScreenHeader.new(self, '/title_screen/waves_screen', @@font, @heading)\n\n # Frequency v1 screen content\n flow(:height => 640, :width => 1080, :scroll => true) do\n # Left margin offset\n stack(:height => 640, :width => 80) do\n end\n # Content column\n stack(:height => 640, :width => 1000) do\n ScreenLabel.new(self, @@font, @heading, 'Wave speed')\n flow do\n @wave_speed = ScreenEditLine.new(self, @@font, @heading)\n @wave_speed_unit = para(strong(' ms'), strong(sup('-1')))\n @wave_speed_unit.style(@@screen_unit_text_styles)\n end\n\n ScreenLabel.new(self, @@font, @heading, 'Wavelength')\n flow do\n @wavelength = ScreenEditLine.new(self, @@font, @heading)\n @wavelength_unit = para(strong(' m'))\n @wavelength_unit.style(@@screen_unit_text_styles)\n end\n\n @calculate = button('Calculate')\n\n @result_display = flow\n\n @error_display = flow\n\n @calculate.click do\n @result_display.clear do\n @result = Joules.frequency_v1(@wave_speed.text.to_f,\n @wavelength.text.to_f)\n @frequency_v1 = para(@result.to_s)\n @frequency_v1_unit = para(' Hz')\n @frequency_v1.style(@@screen_result_text_styles)\n @frequency_v1_unit.style(@@screen_result_text_styles)\n end\n end\n end\n end\n end",
"def display_cohort_info\n puts '=========================================='\n puts @name\n puts \"Start Phase 0: #{@p0_start_date}\"\n puts \"Start Immersive: #{immersive_start_date}\"\n puts \"Graduate: #{graduation_date}\"\n puts \"Enrollment: #{self.num_of_students}\"\n puts \"Current Phase: #{currently_in_phase}\"\n end",
"def show_state\n puts \"#{@name} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end",
"def display\n port_total\n display_port\n overall_total\n end",
"def show\n @next_step = NextStep.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @next_step }\n end\n end",
"def show\n @step = @guide.steps.find(params[:id])\n end",
"def show_state \n puts \"#{@name} a #{@life_points} points de vie.\"\n end",
"def show_state\n puts \"#{@name} a #{@life_points} points de vie\"\n end",
"def display\n current = @head\n full_list = []\n while current.next != nil\n full_list += [current.data.to_s]\n current = current.next\n end\n full_list += [current.data.to_s]\n puts full_list.join(\"->\")\n end",
"def show\n @truck = Truck.new\n @marcas = @truck.get_marcas() \n @modelos = @truck.get_modelos() \n @tipo_unidad = @truck.get_tipos()\n @config = @truck.get_config()\n @clase = @truck.get_clase()\n @color = @truck.get_color()\n end",
"def output(data)\n msg @presenter.format(data)\n end",
"def show_state\n puts \"#{@names} a #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\n end",
"def show_state\n puts \"#{@name} a #{@life_points} points de vie.\"\n end",
"def show() end",
"def show() end",
"def show() end",
"def new_show\n # def show\n\n # Clear the session on the first step, otherwise, load the Student\n if step == steps[0]\n reset_session\n @student = Student.create\n session[:student_id] = @student.id\n else\n @student = Student.find(session[:student_id])\n end\n\n # Render student gender pronouns\n if STUDENT_GENDER_PRONOUN_STEPS.include?(step)\n @student_gender_pronoun = genderToPronoun(@student.gender) # He/She\n @student_gender_possessive_pronoun = genderToPossessivePronoun(@student.gender) # His/Hers\n @student_gender_objective_pronoun = genderToObjectivePronoun(@student.gender) # Him/Her\n @student_gender_possessive_adjective = genderToPossessiveAdjective(@student.gender) # His/Her\n end\n\n render_wizard\n end",
"def display\n puts \" #{@cells[0]} | #{@cells[1]} | #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} | #{@cells[4]} | #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} | #{@cells[7]} | #{@cells[8]} \"\n end",
"def display\n puts \" #{@cells[0]} | #{@cells[1]} | #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} | #{@cells[4]} | #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} | #{@cells[7]} | #{@cells[8]} \"\n end",
"def printData()\n puts @data\n end",
"def opinion_wizard_current_step_of(step)\n current_step_num = opinion_wizard_step_number(step)\n see_steps = content_tag(:span, class: \"hide-for-large\") do\n concat \" (\"\n concat content_tag :a, t(:\"decidim.opinions.opinions.wizard_steps.see_steps\"), \"data-toggle\": \"steps\"\n concat \")\"\n end\n content_tag :span, class: \"text-small\" do\n concat t(:\"decidim.opinions.opinions.wizard_steps.step_of\", current_step_num: current_step_num, total_steps: total_steps)\n concat see_steps\n end\n end",
"def display\n\t\tdisplay_headers\n\t\t@rows.each do |row|\n\t\t\tdisplay_row(row)\n\t\tend\n\tend",
"def output(data)\n msg @presenter.format(data)\n end",
"def update(step, t, e, acceptance, improvement)\n elapsed = Time.now - self.start\n if step == 0\n puts(' Temperature Energy Accept Improve Elapsed Remaining')\n puts(\"\\r%12.2f %12.2f %s \" % [t, e, time_string(elapsed).to_s] )\n else\n remain = (self.steps - step) * (elapsed.to_f / step)\n puts(\"\\r%12.2f %12.2f %7.2f%% %7.2f%% %s %s\" % [t, e, 100.0 * acceptance, 100.0 * improvement, time_string(elapsed), time_string(remain)])\n end\n end",
"def power_of_lens_screen\n @heading = 'Power of lens = 1 / focal length'\n background('images/waves_large.png')\n\n # Power of lens screen header\n ScreenHeader.new(self, '/title_screen/waves_screen', @@font, @heading)\n\n # Power of lens screen content\n flow(:height => 640, :width => 1080, :scroll => true) do\n # Left margin offset\n stack(:height => 640, :width => 80) do\n end\n # Content column\n stack(:height => 640, :width => 1000) do\n ScreenLabel.new(self, @@font, @heading, 'Focal length')\n flow do\n @focal_length = ScreenEditLine.new(self, @@font, @heading)\n @focal_length_unit = para(strong(' m'))\n @focal_length_unit.style(@@screen_unit_text_styles)\n end\n\n @calculate = button('Calculate')\n\n @result_display = flow\n\n @error_display = flow\n\n @calculate.click do\n @result_display.clear do\n @result = Joules.power_of_lens(@focal_length.text.to_f)\n @power_of_lens = para(@result.to_s)\n @power_of_lens_unit = para(' D')\n @power_of_lens.style(@@screen_result_text_styles)\n @power_of_lens_unit.style(@@screen_result_text_styles)\n end\n end\n end\n end\n end",
"def display\n\t\t\"SUITE: #{@suite}, RANK: #{@rank}, VALUE: #{@value}\"\n\tend",
"def index\n @step_fours = StepFour.all\n end",
"def print_data\n\n # Print customer information.\n box_height = 0.166667\n y = 8.9\n self.vms_text_box(\"Attn: <strong>PIERRE PAROZ</strong>\", 0.5, y, 3.5, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"AMEMIC\", 4.5, y, 3.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Date: <strong>12/13/18</strong>\", 4.5, y, 3.5, box_height, 10, :normal, :right, :center)\n y -= box_height\n self.vms_text_box(\"AMERICAN MICRO PRODUCTS, INC.\", 0.5, y, 3.5, box_height, 10, :bold, :left, :center)\n y -= box_height\n self.vms_text_box(\"4288 ARMSTRONG BLVD\", 0.5, y, 3.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Phone:\", 4.5, y, 0.75, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"(513) 732-2674\", 5.15, y, 3.5, box_height, 10, :bold, :left, :center)\n y -= box_height\n self.vms_text_box(\"BATAVIA, OH 45103-1600\", 0.5, y, 3.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Fax:\", 4.5, y, 0.75, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"(513) 732-3535\", 5.15, y, 1.5, box_height, 10, :bold, :left, :center)\n self.vms_text_box(\"Ext\", 6.4, y, 0.5, box_height, 10, :normal, :left, :center)\n self.vms_text_box(\"032\", 6.7, y, 1, box_height, 10, :bold, :left, :center)\n y -= (box_height + 0.25)\n\n # Draw quotation box.\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n self.vms_text_box(\"VMS Quote # <strong>71295</strong>\", 0.35, y, 3.8, 0.4, 12, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Your Request # <strong>Q02I7446</strong>\", 4.35, y, 3.8, 0.4, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.4\n fill_color('cccccc')\n fill_rectangle([0.25.in, y.in], 8.in, 0.25.in)\n stroke_rectangle([0.25.in, y.in], 2.in, 0.25.in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, 0.25.in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, 0.25.in)\n self.vms_text_box(\"Part Number\", 0.25, y, 2, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"Part Description & Process Specification\", 2.25, y, 4.5, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"EAU\", 6.75, y, 1.5, 0.25, 10, :bold, :center, :center)\n quotation_lines = 9\n y -= 0.25\n stroke_rectangle([0.25.in, y.in], 2.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, (quotation_lines * _p(10)).in)\n self.vms_text_box(\"627591\\n \\n \\n \\n \\n \\n \", 0.35, y, 1.8, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"POLE PIECE\\n\\n12L14 STEEL X 12.3MM OD X 7MM ID\\n& 1.90MM THRU HOLE X 13.9MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.35, y, 4.3, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"500,000 PCS\\n \\n \\n \\n \\n \\n \", 6.85, y, 1.3, quotation_lines * _p(10), 10, :normal, :center, :center)\n y -= quotation_lines * _p(10)\n remarks_lines = 4\n stroke_rectangle([0.25.in, y.in], 8.in, (remarks_lines * _p(10)).in)\n self.vms_text_box(\"<em>Remarks:</em>\\nPLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\", 0.35, y, 7.8, remarks_lines * _p(10), 10, :normal, :left, :center)\n y -= remarks_lines * _p(10)\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n self.vms_text_box(\"Price: <strong>$0.028/each</strong>\", 0.35, y, 3.8, 0.32, 10, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Minimum Lot Charge: <strong>$250.00</strong>\", 4.35, y, 3.8, 0.32, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.57\n\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.4.in)\n self.vms_text_box(\"VMS Quote # <strong>71296</strong>\", 0.35, y, 3.8, 0.4, 12, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Your Request # <strong>Q02I7447</strong>\", 4.35, y, 3.8, 0.4, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.4\n fill_color('cccccc')\n fill_rectangle([0.25.in, y.in], 8.in, 0.25.in)\n stroke_rectangle([0.25.in, y.in], 2.in, 0.25.in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, 0.25.in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, 0.25.in)\n self.vms_text_box(\"Part Number\", 0.25, y, 2, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"Part Description & Process Specification\", 2.25, y, 4.5, 0.25, 10, :bold, :center, :center)\n self.vms_text_box(\"EAU\", 6.75, y, 1.5, 0.25, 10, :bold, :center, :center)\n quotation_lines = 9\n y -= 0.25\n stroke_rectangle([0.25.in, y.in], 2.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([2.25.in, y.in], 4.5.in, (quotation_lines * _p(10)).in)\n stroke_rectangle([6.75.in, y.in], 1.5.in, (quotation_lines * _p(10)).in)\n self.vms_text_box(\"627599\\n \\n \\n \\n \\n \\n \", 0.35, y, 1.8, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"ARMATURE\\n\\n12L14 STEEL X 12.3MM & 10.3MM &\\n4.5MM & 1.90MM OD X 50.05MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.35, y, 4.3, quotation_lines * _p(10), 10, :normal, :left, :center)\n self.vms_text_box(\"500,000 PCS\\n \\n \\n \\n \\n \\n \", 6.85, y, 1.3, quotation_lines * _p(10), 10, :normal, :center, :center)\n y -= quotation_lines * _p(10)\n remarks_lines = 4\n stroke_rectangle([0.25.in, y.in], 8.in, (remarks_lines * _p(10)).in)\n self.vms_text_box(\"<em>Remarks:</em>\\nPLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\", 0.35, y, 7.8, remarks_lines * _p(10), 10, :normal, :left, :center)\n y -= remarks_lines * _p(10)\n fill_color('000000')\n fill_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n stroke_rectangle([0.25.in, y.in], 8.in, 0.32.in)\n self.vms_text_box(\"Price: <strong>$0.091/each</strong>\", 0.35, y, 3.8, 0.32, 10, :normal, :left, :center, nil, 'ffffff')\n self.vms_text_box(\"Minimum Lot Charge: <strong>$250.00</strong>\", 4.35, y, 3.8, 0.32, 10, :normal, :right, :center, nil, 'ffffff')\n y -= 0.57\n\n return\n\n # Print data table.\n self.vms_text_box(\"LN\", 0.25, 7.95, 0.5, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\"627591\\nQuote # <strong>71295</strong>\", 0.8, 7.95, 1.9, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"POLE PIECE\\n\\n12L14 STEEL X 12.3MM OD X 7MM ID\\n& 1.90MM THRU HOLE X 13.9MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.8, 7.95, 3.15, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"500,000 PCS\", 6.05, 7.95, 1.15, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\".028\\n$/EACH\\n\\n<em>MINIMUM</em>:\\n$250.00\", 7.3, 7.95, 0.9, 8 * _p(10), 10, :normal, :center, :top)\n fill_color('eeeeee')\n fill_rectangle([0.5.in, 6.75.in], 7.5.in, (8 * _p(10)).in)\n stroke_rectangle([0.5.in, 6.75.in], 7.5.in, (8 * _p(10)).in)\n self.vms_text_box(\"PLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\\n\\nYOUR REQUEST NUMBER <strong>Q0217446</strong>\\n\\nPLEASE REFER TO OUR QUOTATION NUMBER <strong>71295</strong> ON ALL CORRESPONDENCE OR ORDERS\", 0.5, 6.75, 7.5, 8 * _p(10), 10, :normal, :center, :center)\n self.vms_text_box(\"LN\", 0.25, 5.5, 0.5, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\"627599\\nQuote # <strong>71296</strong>\", 0.8, 5.5, 1.9, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"ARMATURE\\n\\n12L14 STEEL X 12.3MM & 10.3MM &\\n4.5MM & 1.9MM OD X 50.05MM LONG\\n\\nZINC-NICKEL (.0003\\\" MINIMUM) &\\nCLEAR TRIVALENT CHROMATE\", 2.8, 5.5, 3.15, 8 * _p(10), 10, :normal, :left, :top)\n self.vms_text_box(\"500,000 PCS\", 6.05, 5.5, 1.15, 8 * _p(10), 10, :normal, :center, :top)\n self.vms_text_box(\".091\\n$/EACH\\n\\n<em>MINIMUM</em>:\\n$250.00\", 7.3, 5.5, 0.9, 8 * _p(10), 10, :normal, :center, :top)\n fill_color('eeeeee')\n fill_rectangle([0.5.in, 4.3.in], 7.5.in, (8 * _p(10)).in)\n stroke_rectangle([0.5.in, 4.3.in], 7.5.in, (8 * _p(10)).in)\n self.vms_text_box(\"PLEASE NOTE: FORD WSA-M1P87-A1 IS OBSOLETE.\\nUSING FORD WSS-M1P87-B1 FOR PURPOSE OF THIS QUOTATION.\\n\\nYOUR REQUEST NUMBER <strong>Q0217447</strong>\\n\\nPLEASE REFER TO OUR QUOTATION NUMBER <strong>71296</strong> ON ALL CORRESPONDENCE OR ORDERS\", 0.5, 4.3, 7.5, 8 * _p(10), 10, :normal, :center, :center)\n\n\n \n end",
"def show\n render_wizard\n end",
"def index\n @steps = Step.all\n end",
"def index\n @steps = Step.all\n end",
"def index\n @steps = Step.all\n end",
"def index\n @steps = Step.all\n end",
"def display\n puts \"Title: #{@title}\"\n puts \"Author: #{@author}\"\n puts \"Price: #{@price}\"\n end",
"def show_state\r\n puts \"#{@name} à #{@life_points} points de vie\"\r\n end",
"def show_state \n puts \"#{@name} à #{@life_points} points de vie\"\n end",
"def show_state\n puts \"#{self.name} a #{self.life_points} points de vie.\"\n end",
"def frequency_v2_screen\n @heading = 'Frequency = 1 / time period'\n background('images/waves_large.png')\n\n # Frequency v2 screen header\n ScreenHeader.new(self, '/title_screen/waves_screen', @@font, @heading)\n\n # Frequency v2 screen content\n flow(:height => 640, :width => 1080, :scroll => true) do\n # Left margin offset\n stack(:height => 640, :width => 80) do\n end\n # Content column\n stack(:height => 640, :width => 1000) do\n ScreenLabel.new(self, @@font, @heading, 'Time period')\n flow do\n @time_period = ScreenEditLine.new(self, @@font, @heading)\n @time_period_unit = para(strong(' s'))\n @time_period_unit.style(@@screen_unit_text_styles)\n end\n\n @calculate = button('Calculate')\n\n @result_display = flow\n\n @error_display = flow\n\n @calculate.click do\n @result_display.clear do\n @result = Joules.frequency_v2(@time_period.text.to_f)\n @frequency_v2 = para(@result.to_s)\n @frequency_v2_unit = para(' Hz')\n @frequency_v2.style(@@screen_result_text_styles)\n @frequency_v2_unit.style(@@screen_result_text_styles)\n end\n end\n end\n end\n end",
"def display_each\n puts \" * #{self.experience} experience at #{self.company_name}\"\n end",
"def print_report(step)\n puts \"STEP #{step}\"\n i = 0\n @list.each do |pattern|\n i = i.next\n puts \"PATTERN #{i}\"\n j = 0\n pattern.each do |item|\n j = j.next\n puts \"#{j} - #{item}\"\n end\n end\n puts \"\\n\"\n end",
"def index\n @steps = Step.all\n end",
"def display_info\n \n puts \"\\nPlayer Name: #{self.name}\"\n puts \"Current Rank: #{self.rank}\"\n puts \"Position: #{self.position}\"\n puts \"School/Club: #{self.schoolclub}\"\n # binding.pry\n #if there is no class_year, nothing is displayed\n puts \"Year: #{self.class_year}\"\n #\n puts \"Height/Weight: #{self.height}, #{self.weight} \"\n puts \"Age: #{self.age}\"\n puts \"Last rank: #{self.last_rank}\"\n puts \"Scouting Report: #{self.blurb}\"\n puts \"------------------------------------\"\n end",
"def show_state \n puts \"#{@name} a #{@life_points} points de vie et une arme au niveau #{@weapon_level}.\"\n end",
"def show_state\r\n puts \"#{@name} à #{@life_points} points de vie et une arme de niveau #{@weapon_level}\"\r\n end",
"def display\r\n puts \" #{cells[0]} | #{cells[1]} | #{cells[2]} \"\r\n puts \"-----------\"\r\n puts \" #{cells[3]} | #{cells[4]} | #{cells[5]} \"\r\n puts \"-----------\"\r\n puts \" #{cells[6]} | #{cells[7]} | #{cells[8]} \"\r\n end",
"def show_state\n puts \"#{@name} a #{@life_points} de PV\"\n end",
"def show\n \n end"
] | [
"0.64014983",
"0.6322269",
"0.61051285",
"0.61007094",
"0.60106134",
"0.60051566",
"0.5974355",
"0.5900076",
"0.5835587",
"0.5776174",
"0.57733434",
"0.5734561",
"0.5703235",
"0.56873846",
"0.56829464",
"0.5676335",
"0.5670373",
"0.5670327",
"0.5655762",
"0.5652419",
"0.56070286",
"0.55924356",
"0.55921793",
"0.5585446",
"0.558368",
"0.55686027",
"0.5542964",
"0.5539014",
"0.5532928",
"0.55059576",
"0.5502569",
"0.5471054",
"0.5470032",
"0.5460394",
"0.5459519",
"0.5450204",
"0.54466003",
"0.5433455",
"0.5433398",
"0.5431176",
"0.54311615",
"0.5430016",
"0.54280734",
"0.5426861",
"0.5426861",
"0.54257965",
"0.5423296",
"0.54087144",
"0.5407864",
"0.53996354",
"0.53983307",
"0.5387803",
"0.53870535",
"0.5385392",
"0.53837174",
"0.53809494",
"0.5380754",
"0.5378933",
"0.5374784",
"0.5372365",
"0.53716433",
"0.5370987",
"0.5368955",
"0.5364604",
"0.5358609",
"0.535713",
"0.5353174",
"0.53510404",
"0.53510404",
"0.53510404",
"0.53500706",
"0.53387564",
"0.53387564",
"0.5338085",
"0.53369236",
"0.533575",
"0.5334212",
"0.53333294",
"0.53250617",
"0.531771",
"0.53133714",
"0.53080875",
"0.5304877",
"0.5303396",
"0.5303396",
"0.5303396",
"0.5303396",
"0.5302513",
"0.529266",
"0.5292126",
"0.5287785",
"0.52875525",
"0.5286906",
"0.5286398",
"0.52860785",
"0.52834386",
"0.52785385",
"0.52739227",
"0.5264168",
"0.5264046",
"0.52624625"
] | 0.0 | -1 |
Sets the acceleration of a stepper, in (micro)steps per second squared, or raises an error. | def acceleration=(new_acceleration)
Klass.setAcceleration(@handle, @index, new_acceleration.to_f)
new_acceleration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accelerate (rateOfAcceleration)\n @speed = @speed + rateOfAcceleration\n end",
"def accel\n @speed += 7\n end",
"def accelerate\n @speed = @speed + @accelerator\n end",
"def acceleration(state_object, t)\n k = 10\n b = 1\n (- k * state_object.position) - (b * state_object.velocity)\nend",
"def accelerate(speed_wanted)\n @speed = speed_wanted\n puts \"The #{@color} #{@model} accelerated to #{@speed} mph.\"\n end",
"def accel=(value)\n MSPhysics::Newton::Hinge.set_accel(@address, value)\n end",
"def accelerate(time) \n @velocity += time * @acceleration;\n @velocity = @max_speed if @velocity > @max_speed\n end",
"def increase_speed(delta=10)\n @speed += delta\n end",
"def acceleration(state_object, t)\n k = 10\n b = 1\n (- k * state_object.x) - (b * state_object.v)\nend",
"def accelerate(mph)\n @speed += mph\n puts \"You accelerate the car by #{mph} miles per hour\"\n end",
"def accelerate strength = 1.0\n self.speed += self.rotation_vector * strength/SUBSTEPS\n end",
"def accelerate\n self.current_speed += 1 \n end",
"def set_speed(input_speed)\n @speed = input_speed * MULTIPLIER\n end",
"def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end",
"def pedal_faster accel\n #Increment speed by the value of the argument\n @speedometer += accel\n #Display updated speed\n speed\n end",
"def speedIncrease(value)\n self.speedSet = self.speedGet + value\n end",
"def step_acceleration(time, state)\n\t\t\n#\t\tpp state\n\n\t\tt1, t1p = state[0]\n\t\tt2, t2p = state[1]\n\t\tf = state[2][0]\n\n\t\t# modulo the positions\n#\t\tt1 = begin m = t1 % (2.0 * PI); m > PI ? -(PI - m) : m end\n#\t\tt2 = begin m = t2 % (2.0 * PI); m > PI ? -(PI - m) : m end\n\n\t\t# bind velocities\n\t\tt1p = (t1p < T1P_MIN) ? T1P_MIN : ((t1p > T1P_MAX) ? T1P_MAX : t1p)\n\t\tt2p = (t2p < T2P_MIN) ? T2P_MIN : ((t2p > T2P_MAX) ? T2P_MAX : t2p)\n\n\t\t# f\n#\t\tassert{ inputs.include?('F') }\n#\t\tf = inputs['F']\n#\t\tassert{ [0.0, -1.0, 1.0].include?(f) }\n\t\t\n\t\t# tau\n\t\ttau = f * TORQUE \n\n\t\t# phi 2\n\t\tphi2 = M2 * LC2 * G * cos(t1 + t2 - PI / 2.0)\n\n\t\t# phi 1\n\t\tphi1 = -M2 * L1 * LC2 * (t2p ** 2.0) * sin(t2) - 2.0 * M2 * L1 * LC2 * t2p * t1p * sin(t2) + (M1 * LC1 + M2 * L1) * G * cos(t1 - PI / 2.0) + phi2\n\n\t\t# d2\n\t\td2 = M2 * (LC2 ** 2.0 + L1 * LC2 * cos(t2)) + I2\n\n\t\t# d1\n\t\td1 = M1 * (LC1 ** 2.0) + M2 * ((L1 ** 2.0) + (LC2 ** 2.0) + 2.0 * L1 * LC2 * cos(t2)) + I1 + I2\n\n\t\t# t2pp\n\t\tt2pp = (tau + (d2 / d1) * phi1 - phi2) / (M2 * (LC2 ** 2.0) + I2 - (d2 ** 2.0) / d1)\n\n\t\t# t1pp\n\t\tt1pp = (d2 * t2pp + phi1) / -d1\n\n#\t\t$stderr << \"debug acceleration t1pp #{t1pp}, t2pp #{t2pp}\\n\"\n\t\tmask = 1_000_000_000_000_000\n\t\tt1pp = (t1pp * mask).to_i / mask.to_f\n\t\tt2pp = (t2pp * mask).to_i / mask.to_f\n#\t\tt1pp = (t1pp * 10_000).to_i / 10_000.0\n#\t\tt2pp = (t2pp * 10_000).to_i / 10_000.0\n\n\t\n\t\t[t1pp, t2pp, 0.0]\n\tend",
"def accelerate\n @speed += 1\n end",
"def set_Speed(value)\n set_input(\"Speed\", value)\n end",
"def set_Speed(value)\n set_input(\"Speed\", value)\n end",
"def setSpeed(value)\r\n @speed = value\r\n end",
"def set_velocity action = :increment\n if action == :increment and @velocity <= 3\n @velocity += 1\n\n elsif action == :decrement and @velocity > 1\n @velocity -= 1\n end\n end",
"def gravity=(acceleration)\n acceleration = acceleration.to_f\n Sketchup.active_model.set_attribute('MSPhysics', 'Gravity', acceleration)\n sim = MSPhysics::Simulation.instance\n sim.world.set_gravity(0, 0, acceleration) if sim\n end",
"def speed_set _value\n send_cmd(\"speed_set #{_value}\")\n end",
"def apply_force(force:)\n f = force / @mass\n @acceleration += f\n end",
"def apply_force(force:)\n f = force / @mass\n @acceleration += f\n end",
"def apply_force(force:)\n f = force / @mass\n @acceleration += f\n end",
"def accelerate_to(speed) \r\n\t\tputs \"You #{speed > @speed ? \"sped up\" : \"slowed down\"} to #{speed}mph.\"\r\n\t\t@speed = speed;\r\n\tend",
"def update_timestep=(timestep)\n timestep = AMS.clamp(timestep.to_f, 1/1200.0, 1/30.0)\n Sketchup.active_model.set_attribute('MSPhysics', 'Update Timestep', timestep)\n sim = MSPhysics::Simulation.instance\n sim.update_timestep = timestep if sim\n end",
"def update\n # Update velocity\n @velocity.add(@acceleration)\n # Limit speed\n @velocity.limit(@maxspeed)\n @location.add(@velocity)\n # Reset accelerationelertion to 0 each cycle\n @acceleration.mult(0)\n end",
"def pedal_faster\n @speedometer = @speedometer + 10\n end",
"def accelerate\n if !@parkingbrake\n @speed += 10\n end\n end",
"def actual_hardware_acceleration\n super\n end",
"def jet_accelerate\n @speed = get_speed * 2\n end",
"def accelerate(increment, seconds)\n fail 'Engine Off Error' unless engine_on\n\n seconds.times do\n break if speed >= top_speed\n @speed += increment\n end\n end",
"def speed=(value)\n\t\t\t@speed = value\n\t\tend",
"def test_accel\n assert_equal(@test_car.accel(20).speed, 20)\n assert_equal(@test_car.accel(10).speed, 20+10)\n assert_equal(@test_car.accel(0).speed, 20+10+0)\n assert_raise(RangeError) {@test_car.accel(-1)}\n end",
"def update_accel\n user_controlling = false\n if user_controlling\n x, y = 0,0\n x -= 1 if @keys.include?( :left )\n x += 1 if @keys.include?( :right )\n y -= 1 if @keys.include?( :up ) # up is down in screen coordinates\n y += 1 if @keys.include?( :down )\n x *= @accel\n y *= @accel\n # Scale to the acceleration rate. This is a bit unrealistic, since\n # it doesn't consider magnitude of x and y combined (diagonal).\n @ax, @ay = x, y\n else\n @ax, @ay = @accel, @accel\n end\n end",
"def set_accelerometer\n @accelerometer = Accelerometer.find(params[:id])\n end",
"def raiseTemp( step ) \n if step < 0.0 then lowerTemp( -1.0 * step )\n else\n @value += step\n end \n self\n end",
"def increase_steps\r\n @steps = [@steps + 1, 9999999].min\r\n end",
"def sliderSetSpeed _obj, _args\n \"_obj sliderSetSpeed _args;\" \n end",
"def update()\n # Update velocity\n @velocity.add(@acceleration)\n # Limit speed\n @velocity.limit(@maxspeed)\n @location.add(@velocity)\n # Reset accelertion to 0 each cycle\n @acceleration.mult(0)\n end",
"def update(step, t, e, acceptance, improvement)\n elapsed = Time.now - self.start\n if step == 0\n puts(' Temperature Energy Accept Improve Elapsed Remaining')\n puts(\"\\r%12.2f %12.2f %s \" % [t, e, time_string(elapsed).to_s] )\n else\n remain = (self.steps - step) * (elapsed.to_f / step)\n puts(\"\\r%12.2f %12.2f %7.2f%% %7.2f%% %s %s\" % [t, e, 100.0 * acceptance, 100.0 * improvement, time_string(elapsed), time_string(remain)])\n end\n end",
"def set_quantity(qty) #should be quantity=(), but then calling from child doesn't work?\n @stall_current *= qty / @quantity\n @stall_torque *= qty / @quantity\n @max_power *= qty / @quantity\n @quantity = qty\n end",
"def accelerate\n @velocity_x += Gosu.offset_x(@angle, ACCELERATION)\n @velocity_y += Gosu.offset_y(@angle, ACCELERATION)\n end",
"def update\n @velocity.add(@acceleration)\n @location.add(@velocity)\n @acceleration.mult(0)\n @lifespan -= 2.0\n end",
"def update\n @velocity.add(@acceleration)\n @location.add(@velocity)\n @acceleration.mult(0)\n @lifespan -= 2.0\n end",
"def speed_up(number)\n @current_speed += number\n puts \"You push the gas and accelerate #{number} mph.\"\n end",
"def accelerate\n @shape.body.apply_force((@shape.body.a.radians_to_vec2 * (20000.0)), CP::Vec2.new(0.0, 0.0))\n end",
"def set_update_timestep(timestep)\n timestep = AMS.clamp(timestep.to_f, 1/1200.0, 1/30.0)\n Sketchup.active_model.set_attribute('MSPhysics', 'Update Timestep', timestep)\n sim = MSPhysics::Simulation.instance\n sim.set_update_timestep(timestep) if sim\n return timestep\n end",
"def setWaypointSpeed _obj, _args\n \"_obj setWaypointSpeed _args;\" \n end",
"def set_Force(value)\n set_input(\"Force\", value)\n end",
"def speedup(amount)\n @speed += amount\n end",
"def accelForward\n @vel_y -= @VELOCITY\n end",
"def set_Energy(value)\n set_input(\"Energy\", value)\n end",
"def pedal_faster increase_by\n @speed = @speed + increase_by\n end",
"def set_speed(speed)\n %x{#{echo()} speed_set #{speed} > #{fifo()}} if running?\n end",
"def update\n @vel.add(@acc)\n @loc.add(@vel)\n # Multiplying by 0 sets the all the components to 0\n @acc.mult(0)\n\n @osc.update(@vel.mag/10)\n end",
"def up_speed(arg)\n @speed += arg\n end",
"def error=(e)\n if e.is_a?(Hash) \n value = e[:value]\n exact = e[:exact]\n else\n value = e\n exact = true\n end\n \n @error = exact ? value : (value - @output)\n @gradient = @output * (1 - @output) * @error\n @error\n end",
"def cur_acceleration\n MSPhysics::Newton::CurvySlider.get_cur_acceleration(@address)\n end",
"def cur_acceleration\n MSPhysics::Newton::CurvySlider.get_cur_acceleration(@address)\n end",
"def control input\n error = @set_point - input\n @integral = @integral + error * @sample_rate\n @derivative = (error - @previous_error) / @sample_rate\n\n output =\n @proportional_gain * error +\n @integral_gain * @integral +\n @derivative_gain * @derivative\n\n @previous_error = error\n\n output\n end",
"def accelerometerX; end",
"def set_accel\n @accel = Accel.find(params[:id])\n end",
"def set_accelerometer\n @accelerometer = Accelerometer.find(params[:id])\n end",
"def spped number\n @velocity +=number\n puts \"You accelerator to #{@velocity}\"\n end",
"def accelBackward\n @vel_y += @VELOCITY\n end",
"def lowerTemp( step )\n if step < 0.0 then raiseTemp( -1.0 * step )\n else\n val = @value - step\n if isValid( val, @unit ) then\n @value = val\n end \n end \n self\n end",
"def speed=(new_speed)\n if @speed.nil? || new_speed != @speed\n @speed = new_speed\n brick.execute(_speed(new_speed))\n end\n end",
"def error=(val)\n @error = val\n self.state = 'error'\n end",
"def takeoff_avarage_acceleration(takeoff_distance,takeoff_time)\n takeoff_avarage_acceleration = (2*takeoff_distance)/(takeoff_time*takeoff_time)\n return takeoff_avarage_acceleration \nend",
"def set(left_value, right_value)\n @left.analog_speed = left_value\n @right.analog_speed = right_value\n end",
"def pt_step _value, _force=0\n send_cmd(\"pt_step #{_value} #{_force}\")\n end",
"def ease duration, *definitions\n ease_extended Kernel.tick_count,\n duration,\n GTK::Easing.initial_value(*definitions),\n GTK::Easing.final_value(*definitions),\n *definitions\n end",
"def slot_front_nvme3link_speed=(slot_front_nvme3link_speed)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"Auto\", \"Disabled\", \"GEN1\", \"GEN2\", \"GEN3\", \"GEN4\"])\n unless validator.valid?(slot_front_nvme3link_speed)\n fail ArgumentError, \"invalid value for \\\"slot_front_nvme3link_speed\\\", must be one of #{validator.allowable_values}.\"\n end\n @slot_front_nvme3link_speed = slot_front_nvme3link_speed\n end",
"def run\n @speed = 5\n end",
"def step\n @x = @x + @vx\n @y = @y + @vy\n self\n end",
"def set_FuelEfficiency(value)\n set_input(\"FuelEfficiency\", value)\n end",
"def set_FuelEfficiency(value)\n set_input(\"FuelEfficiency\", value)\n end",
"def update\n @vel += acc\n @loc += vel\n # Multiplying by 0 sets the all the components to 0\n @acc *= 0\n\n @osc.update(vel.mag / 10)\n end",
"def speed_ramping=(new_state)\n tmp = new_state ? 1 : 0\n Klass.setSpeedRampingOn(@handle, @index, tmp)\n new_state\n end",
"def accelLeft\n @vel_x -= @VELOCITY\n end",
"def start\n @speed = 10\n end",
"def _ease(t, st, ch, d=1.0)\r\n ch + st\r\n end",
"def centripetal_acceleration_v2(angular_velocity, radius)\n return (angular_velocity ** 2.0) * radius\n end",
"def setSpeedMode _obj, _args\n \"_obj setSpeedMode _args;\" \n end",
"def frames_per_second=(a); motion.frames_per_second = a; end",
"def setup\n size(800, 200)\n smooth\n @angle = 0\n @velocity = 0\n @acceleration = 0.0001\nend",
"def speedFactor\n Integer((@energy + @health) / (MAX_HEALTH + MAX_ENERGY)) * 10\n end",
"def current=(new_value)\n value = (new_value)%steps\n @dirty = @current != value\n @current = value\n end",
"def speed_incr _value\n send_cmd(\"speed_incr #{_value}\")\n end",
"def joystick_event(e, px, py, dx, dy)\n if @device.nil?\n log_info(\"Device not attached yet\")\n return\n end\n\n case e\n when Joystick::POSITION\n\n log_info(\"New position: #{px}, #{py}\")\n\n @device.steppers[0].acceleration = @acc_maxs[0]\n\n # Set motor(s) target\n if (px > 0)\n\t@device.steppers[0].target_position = @max_x\n\t@vars['target_position'].value = @device.steppers[0].target_position\n\t@device.steppers[0].engaged = true\n elsif (px < 0)\n\t@device.steppers[0].target_position = -@max_x\n\t@vars['target_position'].value = @device.steppers[0].target_position\n\t@device.steppers[0].engaged = true\n else\n\t@device.steppers[0].engaged = false\n end\n\n when Joystick::DELTA\n\n # Raise/lower motor(s) acceleration\n # Need to know if we have reversed the direction...\n puts \"@device.steppers[0].acceleration: #{@device.steppers[0].acceleration}\"\n puts \"dx: #{dx}\"\n puts \"@acc_steps[0]: #{@acc_steps[0] }\"\n\n new_dx = @device.steppers[0].acceleration + dx * @acc_steps[0] \n if(new_dx < 0)\n\tnew_dx = new_dx.abs\n\t@device.steppers[0].target_position = - @device.steppers[0].target_position\n end\n\n @device.steppers[0].acceleration = @acc_maxs[0]\n\n when Joystick::RELEASE\n\n log_info(\"Release: #{px}, #{py}\")\n\n # Stop the motor\n @device.steppers[0].engaged = false\n @device.steppers[1].engaged = false\n\n # set acceleration to min \n @device.steppers[0].acceleration = (@device.steppers[0].acceleration_min) * 2\n @device.steppers[1].acceleration = (@device.steppers[1].acceleration_min) * 2\n else\n log_error(\"Unknown joystick event at: #{px}, #{py}\")\n # Stop the motor?\n @device.steppers[0].engaged = false\n @device.steppers[1].engaged = false\n end\n\n end",
"def accelerate\r\n @velx += Gosu.offset_x(@angle,ACCELERATION)\r\n @vely += Gosu.offset_y(@angle,ACCELERATION)\r\n end",
"def quadratic_setter\n self.quadratic_coefficient = set_quadratic_coefficient\n self.schedule_type = type_for(self.schedule_type)\n end",
"def change_speed\n @statistics[:speed_changes] += 1\n # pick a coordination to change speed for\n @changed_coord = @coordinations.rand\n @previous_speed = @current_speed[@changed_coord]\n @current_speed[@changed_coord] = @previous_speed + SPEED_CHANGE_OPTIONS.rand\n delta_eval(@changed_coord)\n end",
"def accel_params\n params.require(:accel).permit(:accelx, :accely, :accelz, :rota, :rotb, :rotg, :timestamp, :lat, :lng, :accuracy, :heading, :speed)\n end",
"def accelerate\n\tputs \"Stepping on the gas\"\n\tputs \"Speeding up\"\nend"
] | [
"0.6187451",
"0.61048514",
"0.60582536",
"0.60556734",
"0.6005321",
"0.5939681",
"0.59366953",
"0.58714765",
"0.5864271",
"0.5863374",
"0.5802886",
"0.58006376",
"0.57577443",
"0.5673338",
"0.5644646",
"0.5620917",
"0.5570925",
"0.555828",
"0.55382943",
"0.55382943",
"0.55065477",
"0.5279983",
"0.52414954",
"0.52284205",
"0.5214222",
"0.5214222",
"0.5214222",
"0.5213994",
"0.521059",
"0.5206829",
"0.5204414",
"0.5176215",
"0.5156709",
"0.5156234",
"0.51324856",
"0.5129635",
"0.51269984",
"0.51140773",
"0.5058768",
"0.50586224",
"0.5058407",
"0.50581783",
"0.505452",
"0.5036022",
"0.50267214",
"0.5010486",
"0.49169812",
"0.49169812",
"0.49142817",
"0.49042356",
"0.48957875",
"0.48696756",
"0.4864147",
"0.48559064",
"0.48495468",
"0.48436582",
"0.4839923",
"0.48172653",
"0.48049414",
"0.47981167",
"0.4785833",
"0.4782663",
"0.4782663",
"0.47766197",
"0.4771185",
"0.47681904",
"0.47592568",
"0.47584608",
"0.47526586",
"0.47515208",
"0.46963325",
"0.4690548",
"0.46773914",
"0.46757162",
"0.46713066",
"0.4640314",
"0.46357763",
"0.46345806",
"0.46338928",
"0.4622367",
"0.4622367",
"0.46157986",
"0.4613076",
"0.46060485",
"0.4597432",
"0.4597197",
"0.45872545",
"0.45800784",
"0.45721075",
"0.45666423",
"0.45581",
"0.4557728",
"0.45550528",
"0.45539144",
"0.45487612",
"0.45357436",
"0.453444",
"0.4532071",
"0.45256785"
] | 0.6707642 | 1 |
Sets the stepper's current usage limit, in Amps, or raises an error. | def current_limit=(new_current_limit)
Klass.setCurrentLimit(@handle, @index, new_current_limit.to_f)
new_current_limit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_limit(amount)\r\n fail \"no valid limit\" if !amount.nil? && amount<0\r\n\r\n self.limit=amount\r\n end",
"def setValue(value)\n @current = value\n self.limitCurrentValue\n end",
"def set_limit\n @limit = 250\n end",
"def velocity_limit=(new_velocity_limit)\n Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)\n\t new_velocity_limit\n end",
"def set_limit(opts)\n opts = check_params(opts,[:limits])\n super(opts)\n end",
"def velocity_limit=(new_velocity_limit)\n Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)\n new_velocity_limit\n end",
"def limit(_limit)\n @limit = _limit\n self\n end",
"def quota=(value)\n @quota = value\n end",
"def set_LimitPerType(value)\n set_input(\"LimitPerType\", value)\n end",
"def capacity= value\n\t\t\t\tdifference = value - @capacity\n\t\t\t\t\n\t\t\t\t# An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that causes any flow-control window to exceed the maximum size as a connection error of type FLOW_CONTROL_ERROR.\n\t\t\t\tif (@available + difference) > MAXIMUM_ALLOWED_WINDOW_SIZE\n\t\t\t\t\traise FlowControlError, \"Changing window size by #{difference} caused overflow: #{@available + difference} > #{MAXIMUM_ALLOWED_WINDOW_SIZE}!\"\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t@available += difference\n\t\t\t\t@capacity = value\n\t\t\tend",
"def limit=(x); @opts['limit'] = x; end",
"def set_limit(n)\n @limit = n\n end",
"def set(watt:)\n if watt.eql? current_watt\n logger.info \"Current powerlimit is already at #{current}\"\n return\n end\n\n result = NvidiaSmi.run('-i', @index, '-pl', watt)\n logger.info(result)\n\n unless current_watt.eql? watt\n raise VerificationError, \"Powerlimit could not be set to #{watt} W. Current: #{current}\"\n end\n end",
"def limit(limit = nil)\n set_option(:limit, limit)\n end",
"def limit limit\n unless limit.is_a? Fixnum\n raise ArgumentError, 'Limit must be an integer'\n end\n @options[:limit] = limit.to_s\n self\n end",
"def limit(amount)\n self.parameters[:limit] = amount\n self\n end",
"def limit(val)\n @params[:retmax] = val\n self\n end",
"def limit_exceeded(amount = 1)\n self if exceeded?(amount)\n end",
"def limit(number)\n @options[:limit] = number\n self\n end",
"def limit(value)\n update_query(:limit => value)\n end",
"def limit(value)\n update_query(:limit => value)\n end",
"def limit(value)\n using(limit: value)\n end",
"def call limit\n notify_writeable limit\n end",
"def limit(value)\n\t\t\tparam(\"limit\", value)\n\t\tend",
"def limit=(kBps)\n raise \"Requires Integer KBps value\" if not kBps.is_a?(Integer)\n self.class.get(\"/action/set/download/limit/#{kBps}\").to_i\n end",
"def set_Maximum(value)\n set_input(\"Maximum\", value)\n end",
"def limit_to(n)\n self.limit = n\n self\n end",
"def set_amps_min x\n if x<10\n x=10\n end\n @@amps=x\n end",
"def set_capacity\n self.capacity ||= 100\n end",
"def quota\n quota = @experience / 2 + 50\n # Quota starts at 0. 0/2+50=50,\n # so the above line acts as base quota,\n # and also updating 'current' quota.\n end",
"def set_connection_limit(opts)\n opts = check_params(opts,[:limits])\n super(opts)\n end",
"def set_connection_limit(opts)\n opts = check_params(opts,[:limits])\n super(opts)\n end",
"def set_connection_limit(opts)\n opts = check_params(opts,[:limits])\n super(opts)\n end",
"def redirection_limit= limit\n @agent.redirection_limit = limit\n end",
"def set_ConsumptionAmount(value)\n set_input(\"ConsumptionAmount\", value)\n end",
"def set_ConsumptionAmount(value)\n set_input(\"ConsumptionAmount\", value)\n end",
"def limit!(limit = nil)\n mutate(:limit, limit)\n end",
"def change_limit(choose_file)\n prompt = TTY::Prompt.new\n per = prompt.select(\"Choose a periods limit would you like to change?\", choose_file, cycle: true)\n # accessing the right file\n json = read_json(\"periods/#{per}.json\")\n puts Rainbow(\"Current limit is $#{json['limit']}\").whitesmoke\n new_limit = prompt.ask(\"Enter new limit: $\") do |q|\n q.convert(:float, \"Error, enter numeric value\")\n q.validate(/^[+]?([.]\\d+|\\d+[.]?\\d*)$/, \"Invalid input, enter positive number.\")\n end\n # setting the new limit\n json['limit'] = new_limit\n write_json(json, \"periods/#{per}\", \"Limit changed to $#{new_limit}\")\nend",
"def usage=(value)\n @usage = value\n end",
"def used\n limit - remaining\n end",
"def limit\n self.class.get(\"/get/speedlimit\").to_i\n end",
"def redirection_limit=(limit); end",
"def session_uplimit(limit = nil)\n args = generate_speed_args(\"speed-limit-up-enabled\", \"speed-limit-up\", limit)\n remote_request(\"session-set\", args)\n end",
"def limit lim, off = nil\n @limit = ( lim || @limit ).to_i\n @offset = ( off || @offset ).to_i\n end",
"def update!(**args)\n @billing_cycle_count_limit = args[:billing_cycle_count_limit] if args.key?(:billing_cycle_count_limit)\n end",
"def set_attempts_amount\n max_number <= 10 ? 2 : 10\nend",
"def limit(value)\n merge(pilimit: value.to_s)\n end",
"def limit(value)\n merge(mpdlimit: value.to_s)\n end",
"def quota\n @quota = 50 + @exp/2\n \n end",
"def update!(**args)\n @total_required_quota = args[:total_required_quota] if args.key?(:total_required_quota)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def limit\n @options[:limit]\n end",
"def maximum_advance=(value)\n @maximum_advance = value\n end",
"def limit(value)\n merge(pslimit: value.to_s)\n end",
"def limit(value)\n merge(pslimit: value.to_s)\n end",
"def set_psi_max x\n if x>100\n x=100\n end\n @@psi = x\n end",
"def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end",
"def limits(limit,bust)\n @limit = limit\n @bust = bust\n end",
"def set(item, max)\n @item = item\n @max = max\n @number = 1\n refresh\n end",
"def limit(value)\n merge(smlimit: value.to_s)\n end",
"def set number=0.0\n\t\t@progress_bar.fraction = @prog = number\n\tend",
"def limit(value)\n merge(agulimit: value.to_s)\n end",
"def limit(action, value)\n limits = config.limits(action.to_sym)\n TrafficJam::Limit.new(action, value, **limits)\n end"
] | [
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.66565466",
"0.6459897",
"0.6316616",
"0.60501736",
"0.60484725",
"0.60362464",
"0.5942688",
"0.5919475",
"0.5886353",
"0.5872155",
"0.5851425",
"0.57956547",
"0.5771944",
"0.57701164",
"0.5611447",
"0.5604905",
"0.55785805",
"0.55651504",
"0.55647254",
"0.556226",
"0.55549586",
"0.5551102",
"0.55295223",
"0.54825443",
"0.5480103",
"0.54285324",
"0.5423186",
"0.5376882",
"0.5375655",
"0.5367237",
"0.5363834",
"0.5356083",
"0.5356083",
"0.5356083",
"0.5348306",
"0.534543",
"0.534543",
"0.5334179",
"0.5331997",
"0.53203833",
"0.52969897",
"0.52927923",
"0.5286841",
"0.52815443",
"0.525832",
"0.5256751",
"0.525003",
"0.524646",
"0.5246286",
"0.523397",
"0.52274096",
"0.5227401",
"0.5227401",
"0.5227401",
"0.5227401",
"0.5227401",
"0.5227401",
"0.5227401",
"0.5227401",
"0.5227401",
"0.52205384",
"0.5205042",
"0.5201682",
"0.5201682",
"0.5198805",
"0.5196549",
"0.51927274",
"0.5191526",
"0.51847786",
"0.5182211",
"0.51748544",
"0.51652306"
] | 0.6615679 | 29 |
Sets the current position of a stepper, in (micro)steps, or raises an error. | def current_position=(new_current_position)
Klass.setCurrentPosition(@handle, @index, new_current_position.to_i)
new_current_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current=(new_value)\n value = (new_value)%steps\n @dirty = @current != value\n @current = value\n end",
"def progressSetPosition _obj, _args\n \"_obj progressSetPosition _args;\" \n end",
"def set_invalid_steps(steps)\n self.invalid_steps = steps\n end",
"def pt_step _value, _force=0\n send_cmd(\"pt_step #{_value} #{_force}\")\n end",
"def setpoint\n @setpoint\n end",
"def steps=(new_value)\n @steps = new_value\n end",
"def move_prev\n self.step -= 1\n 'prev'\n end",
"def before_step(step)\n @current_step = step\n end",
"def position=(new_position)\n Klass.setPosition(@handle, @index, new_position.to_f)\n new_position\n end",
"def update_position!(next_move)\n table.x = next_move[:x]\n table.y = next_move[:y]\n end",
"def pt_up_step _value, _force=0\n send_cmd(\"pt_up_step #{_value} #{_force}\")\n end",
"def step\n halt if should_halt?\n stop_elevator or move_elevator\n end",
"def setCurrentWaypoint _obj, _args\n \"_obj setCurrentWaypoint _args;\" \n end",
"def position=(point); end",
"def change_position(position)\n @old_position = @position = position\n end",
"def target_position=(new_target_position)\n Klass.setTargetPosition(@handle, @index, new_target_position.to_i)\n\t new_target_position\n end",
"def move\n position_after_move = @position.new_coordinates_for_step_size(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n #ignore the command if robot is being out off tabletop\n if(@table_top.has_within_bounds?(position_after_move))\n @position = @position.new_coordinates_for(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n end\n end",
"def seek(position)\n current.position = position if position\n\n self\n end",
"def position=(new_position)\n Klass.setPosition(@handle, @index, new_position.to_i)\n new_position\n end",
"def set_position\n if params[:new_position].present? and params[:old_position].present?\n Top.update_position(params[:new_position], params[:old_position])\n head :ok\n else\n head :bad_request\n end\n end",
"def pos=(pos)\n if self.pos > pos\n @previous_line_number = @start_line_number\n @previous_pos = 0\n end\n super\n end",
"def next_position\n\n # change the direction when the number of a half spin\n # has been walked. Also increase the number of steps\n # in the next turn accordingly.\n if @steps_of_half_spin == 0\n @max_steps_in_dir += 1\n @steps_of_half_spin = 2 * @max_steps_in_dir\n @move_right_or_up = !@move_right_or_up\n @steps = 0\n end\n @steps_of_half_spin -= 1\n\n if @move_right_or_up\n if @steps < @max_steps_in_dir\n @x += 1\n @steps += 1\n else\n # up\n @y += 1\n end\n Pos2.new(@x, @y)\n else\n if @steps < @max_steps_in_dir\n # left\n @x -= 1\n @steps += 1\n else\n # down\n @y -= 1\n end\n Pos2.new(@x, @y)\n end\n end",
"def step\n move_if_needed; return self\n end",
"def advance_step\n @step += 1\n @scheduling.step\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def move(number)\n @position += number\n if @position < 32\n puts \"You moved #{number} steps forward\"\n end\n sleep(1)\n landed_on_which_panel(@position)\n end",
"def pos=(pos)\n @pos = pos\n end",
"def set_current_position!\n matrix[\n position[:y]\n ][\n position[:x]\n ] = DIRECTION_ARROWS[direction]\n end",
"def update_step(step, linear)\n if linear\n self.step_flow = step_flows.find_by(current_step: step)\n self.step_status.mirror_step_flow(self.step_flow)\n self.save\n else\n self.step_status.current_step = step\n end\n self.step_status.save\n self.save\n end",
"def set_point_position(index, position)\n MSPhysics::Newton::CurvySlider.set_point_position(@address, index, position)\n end",
"def set_point_position(index, position)\n MSPhysics::Newton::CurvySlider.set_point_position(@address, index, position)\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def jmp(pos=0)\n @pos = pos\n end",
"def step\n @x = @x + @vx\n @y = @y + @vy\n self\n end",
"def setPos _obj, _args\n \"_obj setPos _args;\" \n end",
"def set_next_step\n @next_step = NextStep.find(params[:id])\n end",
"def assign_current_step\n resource.current_step = step.to_sym\n end",
"def seek(new_position)\n end",
"def move(direction)\n @old = @pos\n @pos += direction\n end",
"def pos=(val)\n @pos = val\n\n end",
"def []=(position, mark)\n raise ArgumentError, \"Position already taken #{position}\" unless valid_position? position\n @state[position - 1] = mark\n end",
"def increase_steps\r\n @steps = [@steps + 1, 9999999].min\r\n end",
"def set_step\n @step = @trip.steps.find_by_id params[:id]\n end",
"def new_position(angle, step)\r\n radians = Math::PI*(angle/180.0)\r\n @position[0] = @position[0] + step*Math.cos(radians)\r\n @position[1] = @position[1] + step*Math.sin(radians)\r\n\r\n @position\r\n end",
"def step(steps, force = false)\n #This is a stub, used for indexing\n end",
"def sliderSetPosition _obj, _args\n \"_obj sliderSetPosition _args;\" \n end",
"def update(point)\n\t\t# move relative to the initial point\n\t\t\n\t\t@destination = @start + movement_delta(point)\n\tend",
"def setWaypointPosition _obj, _args\n \"_obj setWaypointPosition _args;\" \n end",
"def step\n @next_step = @next_step.call\n return self\n end",
"def step\n raise NotImplementedError, \"solver subclasses must implement #step\"\n end",
"def move\n\n\t\t# check landmarks and error variation inputs\n\t\tif !in_range || @error < 0\n\t\t\tstr = check_inputs(\"Move\")\n\t\t\treturn str\n\t\tend\n\n\t\t# traverse points array from 1 to 30\n\t\t@points.each_with_index do |point, index|\n\n\t\t\t# assign 1 if sensor reads current point as included in error variation\n\t\t\tif readSensor(index)\n\t\t\t\tpoint = 1\n\t\t\t\t@points[index] = point\n\t\t\tend\n\t\tend\n\tend",
"def forward(steps)\n move(steps)\n end",
"def send_to_correct_step\n if Member::States.include? step\n original_state = @member.state\n set_state previous_step\n if !@member.valid?\n member_step = wizard_steps.index(original_state) || 0\n jump_to wizard_steps[member_step.next]\n end\n end\n end",
"def set_position!\n return if position.present?\n\n self.position = self.class.count\n end",
"def step\n if (location = path.shift)\n if(move_to(*location))\n save!\n return self\n else\n update_attribute(:path, [])\n end\n elsif active_command\n if active_command.location == self.location\n return active_command.perform\n else\n #TODO: Path can't be found\n update_attribute(:path, find_path_to(active_command.x, active_command.y))\n end\n end\n\n nil\n end",
"def setPosition _obj, _args\n \"_obj setPosition _args;\" \n end",
"def seek(position, unit = TimeUnit::MS)\n position = 0 if position < 0\n FMOD.invoke(:Channel_SetPosition, self, position, unit)\n self\n end",
"def set_cursor_position locator, position\r\n command 'setCursorPosition', locator, position\r\n end",
"def Pager_SetPos(hwnd, iPos) send_pager_message(hwnd, :SETPOS, lparam: iPos) end",
"def xy=(value); self.state = { :xy => value }; end",
"def position_setpoint=(value)\n write_attribute('position_sp', value)\n end",
"def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end",
"def setUnitPos _obj, _args\n \"_obj setUnitPos _args;\" \n end",
"def set_step\n @step = @recipe_item.steps.find(params[:id])\n end",
"def execute\n if @robot.placed?\n new_position = @robot.current_position.go_to(@robot.current_position.direction)\n\n @robot.current_position = new_position if @table.position_is_valid?(new_position)\n end\n end",
"def setEditPosition(new_position)\n if new_position < 0\n CDK.Beep\n elsif new_position == 0\n @field_edit = new_position\n elsif self.validEditPosition(new_position)\n @field_edit = new_position\n else\n CDK.Beep\n end\n end",
"def move\n move_by get_incremental_position_for_velocity if (any_velocity?)\n decrease_velocity\n @has_increased_velocity_for = {\n x: false,\n y: false\n }\n @velocity_deltatime.update\n end",
"def setup_state_machine\n @line_number = 1\n reset_reading\n end",
"def short_assessment_next_step(arg_next_step)\n self.current_step = arg_next_step\n end",
"def advance_position\n case @direction\n when :up\n new_position = [@position[0], @position[1] - 1]\n determine_heading(new_position)\n @position = new_position\n when :down\n new_position = [@position[0], @position[1] + 1]\n determine_heading(new_position)\n @position = new_position\n when :left\n new_position = [@position[0] - 1, @position[1]]\n determine_heading(new_position)\n @position = new_position\n when :right\n new_position = [@position[0] + 1, @position[1]]\n determine_heading(new_position)\n @position = new_position\n end\n @position\n end",
"def move(steps)\n @instructions << Instruction.new(:move, steps)\n self\n end",
"def setValue(value)\n @current = value\n self.limitCurrentValue\n end",
"def move_to (x, y)\n @x, @y = x, y\n end",
"def position=(value)\n @position = value\n end",
"def position=(value)\n @position = value\n end",
"def progression=(progression)\n\n if !progression.nil? && progression > 1\n fail ArgumentError, \"invalid value for 'progression', must be smaller than or equal to 1.\"\n end\n\n if !progression.nil? && progression < 0\n fail ArgumentError, \"invalid value for 'progression', must be greater than or equal to 0.\"\n end\n\n @progression = progression\n end",
"def move_straight(step, x)\n comp(:position).add!(x * step)\n on_move\n end",
"def pos=(val)\n #setter method for position \n row, col = val\n @pos = val\n\n end",
"def set_quantity(qty) #should be quantity=(), but then calling from child doesn't work?\n @stall_current *= qty / @quantity\n @stall_torque *= qty / @quantity\n @max_power *= qty / @quantity\n @quantity = qty\n end",
"def setposition(x,y)\n\t\t@x = x\n\t\t@y = y\n\tend",
"def setup_move\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n mx = @map_char.real_x + @acts[1]\n my = @map_char.real_y + @acts[2]\n goto(mx, my, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def set_object_position(obj, value)\n obj.x = value\n end",
"def set_position\n if @player_correct[-1] == true\n @player_pos << (@player_pos[-1]) - 5\n else\n @player_pos << @player_pos[-1]\n end\n if @computer_correct[-1] == true\n @computer_pos << (@computer_pos[-1]) - 5\n else\n @computer_pos << @computer_pos[-1]\n end\n end",
"def set_object_position(obj, value)\n obj.x = value if obj\n end",
"def move(new_position)\n yield(new_position, self) if block_given?\n self.position = new_position\n self.moved = true\n nil\n end",
"def set_loc(x, y)\n @curr_x = x\n @curr_y = y\n end",
"def ctrlSetPosition _obj, _args\n \"_obj ctrlSetPosition _args;\" \n end",
"def setup_move\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n stop_all_movements\n goto(@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0)\n end",
"def go(pt)\n self.xy = pt\n track.last << xy if pen_down?\n end",
"def move_ahead\n @posx, @posy = coords_ahead\n activate\n end",
"def move\r\n return if not @selected_obj\r\n @state = STATE_MOVING\r\n @obj = @selected_obj\r\n @offset = @obj.center_offset\r\n find_end_points\r\n vec = @end_pt - @start_pt\r\n vec.length = vec.length/2\r\n @pt_to_move = @start_pt + vec\r\n @start_input_point = Sketchup::InputPoint.new(@pt_to_move)\r\nend",
"def setVehiclePosition _obj, _args\n \"_obj setVehiclePosition _args;\" \n end"
] | [
"0.5806139",
"0.56053126",
"0.55437475",
"0.5539134",
"0.55381596",
"0.5532316",
"0.55119836",
"0.54062337",
"0.5401332",
"0.5385979",
"0.53545046",
"0.5323149",
"0.5322548",
"0.5318022",
"0.5297276",
"0.52906615",
"0.52874625",
"0.52843904",
"0.5279208",
"0.5277352",
"0.5270568",
"0.5259079",
"0.52370584",
"0.52270144",
"0.5223654",
"0.52134424",
"0.5203621",
"0.51936066",
"0.5176957",
"0.5176797",
"0.5176797",
"0.51520675",
"0.51520675",
"0.51520675",
"0.51520675",
"0.51520675",
"0.51520675",
"0.51520675",
"0.51520675",
"0.51520675",
"0.5133336",
"0.51081175",
"0.51052916",
"0.5104411",
"0.51042485",
"0.50922805",
"0.5086783",
"0.5071328",
"0.5057932",
"0.5056668",
"0.5047329",
"0.5042368",
"0.5030254",
"0.5025152",
"0.5021488",
"0.5020535",
"0.50148386",
"0.5001689",
"0.50003105",
"0.49893737",
"0.49769348",
"0.4976567",
"0.49760228",
"0.49726647",
"0.49726415",
"0.4968049",
"0.4965144",
"0.49639276",
"0.49567968",
"0.49398246",
"0.4938352",
"0.49364945",
"0.49320337",
"0.49312198",
"0.49283332",
"0.49275967",
"0.49202678",
"0.49182674",
"0.4910712",
"0.4896313",
"0.4890832",
"0.48901743",
"0.48901743",
"0.48877335",
"0.48842248",
"0.48841473",
"0.48764426",
"0.48737112",
"0.487088",
"0.4848439",
"0.48442134",
"0.48422596",
"0.48419505",
"0.48396248",
"0.48376128",
"0.48354605",
"0.48326612",
"0.4827948",
"0.48271805",
"0.482526"
] | 0.5665552 | 1 |
Returns the engaged state of the stepper. | def engaged
ptr = ::FFI::MemoryPointer.new(:int)
Klass.getEngaged(@handle, @index, ptr)
(ptr.get_int(0) == 0) ? false : true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state\n @current_state\n end",
"def current_step\n\t\t@current_step || steps.first\t\n\tend",
"def current_step \n @current_step || steps.first\n end",
"def current_step\r\n\t @current_step || steps.first\r\n\tend",
"def current_step\n @current_step || steps.first\n end",
"def current_step\n @current_step || steps.first\n end",
"def current_state\n if self.steps.where(state: 'reproved').exists?\n 'reproved'\n elsif self.steps.pluck(:state).uniq == ['approved']\n 'approved'\n else\n 'waiting'\n end\n end",
"def state\n @state\n end",
"def state\n @gameState.state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n @state\n end",
"def fulfillment_status\n self.current_state\n end",
"def state\n @state\n end",
"def state\n @@states[@state]\n end",
"def state\n @state.first\n end",
"def currentStepIndex\n @current_step_index\n end",
"def state\n @game.state\n end",
"def current_step\n @current_step = wizard_steps.index(step) + 1\n @current_steps = wizard_steps.count\n @current_percentage = @current_step * 100 / @current_steps\n end",
"def opinion_wizard_current_step_of(step)\n current_step_num = opinion_wizard_step_number(step)\n see_steps = content_tag(:span, class: \"hide-for-large\") do\n concat \" (\"\n concat content_tag :a, t(:\"decidim.opinions.opinions.wizard_steps.see_steps\"), \"data-toggle\": \"steps\"\n concat \")\"\n end\n content_tag :span, class: \"text-small\" do\n concat t(:\"decidim.opinions.opinions.wizard_steps.step_of\", current_step_num: current_step_num, total_steps: total_steps)\n concat see_steps\n end\n end",
"def state\n states.first\n end",
"def state\n object.human_state_name\n end",
"def state\n self.well_info.state\n end",
"def state\n data.state\n end",
"def state\n data.state\n end",
"def current_state\n events.first\n end",
"def peek_current_state\n peek_state.last || @current_state\n end",
"def state\n @__state\n end",
"def friendly_state\r\n return '' if current_state == 'unstarted'\r\n return 'in progress' if current_state == 'started'\r\n current_state\r\n end",
"def current_state\n\t # Started and not finished\n\t if running? \n\t\tif respond_to?(\"state_machine\")\n # state_machine.status # => String\n # state_machine.status_name # => Symbol\n\t\t return state_machine.status_name\n\t\telse\n\t\t return :running\n\t\tend\n\t end\n\t\n\t # True, when task has never been started\n\t if pending? \n\t\treturn :pending \n elsif failed_to_start? \n\t\treturn :failed_to_start\n elsif starting?\n\t return :starting\n\t # True, when terminal event is pending\n elsif finishing? \n\t return :finishing\n\t # Terminated with success or failure\n elsif success? \n\t return :succeeded\n elsif failed? \n\t return :failed \n\t end\n\tend",
"def current_state\n find_state(@current_state_name)\n # TODO: add caching, i.e. with `@current_state ||= ...`\n end",
"def state\n object.state_code\n end",
"def enter_state\n puts \"Entering #{self.class}\"\n execution_state = EXECUTION_STATE[:active]\n end",
"def state\n @state.last\n end",
"def state\n @state.last\n end",
"def game_state\n end",
"def get_state\n return self.state == 't' || self.state == true\n end",
"def get_game_state\n @game_state\n end",
"def checked_state\n state\n end",
"def is_current_step?(step)\n current_step == step\n end",
"def next_step\n self.step_flow.next_step if can_increment_step\n end",
"def state\n if (interpreter = @interpreter)\n @interpreter.state\n else\n nil\n end\n end",
"def step_status(nav_step)\n return :active if active?(nav_step)\n return :visited if visited?(nav_step)\n # in case steps change, if the step or active step can't be found in what\n # is currently the list of steps don't barf\n return :disabled if disabled?(nav_step)\n end",
"def state\n status.state name\n end",
"def state()\n info[:state]\n end",
"def engaged=(new_state)\n tmp = new_state ? 1 : 0\n Klass.setEngaged(@handle, @index, tmp)\n new_state\n end",
"def engaged=(new_state)\n tmp = new_state ? 1 : 0\n Klass.setEngaged(@handle, @index, tmp)\n new_state\n end",
"def previous_step\n self.step_flow.previous_step if can_decrement_step\n end",
"def state\n data[:state]\n end",
"def state\n State.instance\n end",
"def current_step\n return (workflow - chosen_categories.collect(&:workflow_id) - session[:skipped_steps].to_a).first\n end",
"def state\n end",
"def lex_state_\n @lex_state\n end",
"def current_state\r\n self.send(self.class.state_column).to_sym\r\n end",
"def step_return\n input(model.step_return)\n end",
"def enter_state\n end",
"def state\n info[:state]\n end",
"def make_step\n @result\n end",
"def token_recognition_state()\n return engine.token_recognition_state()\n end",
"def current_state\n Display.hangman(@lives)\n puts @hints.join('.')\n Display.errors(@incorrect)\n end",
"def gamestate\n\t\t@game_state\n\tend",
"def current_state\n current = StateTransition.where(record_id: id, record_type: self.class.to_s, current: true).order(id: :desc).limit(1).first\n if current\n current.to_state.to_sym\n else\n self.initial_state.to_sym\n end\n end",
"def current_state_number\n 1\n end",
"def current_state_t(new_state=nil)\n self.current_state_s(new_state).t\n end",
"def state\n self[:ST]\n end",
"def getPreviousState()\n\t\t\treturn @_previous_state\n\t\tend",
"def current_state_s\n self.current_state.to_s.humanize.downcase\n end",
"def current_state_s\n self.current_state.to_s.humanize.downcase\n end",
"def calculation\n wizard_step(nil) { { next_step: :calculate_next_step, cache_index: LbttController } }\n end",
"def current?(step_name)\n current = case\n when HYDRANT_STEPS.first?(step_name)\n last_completed_step.first.empty?\n when HYDRANT_STEPS.exists?(step_name)\n previous_step = HYDRANT_STEPS.previous(step_name)\n (last_completed_step.first == previous_step.step)\n else\n false\n end\n\n current\n end",
"def wizard_value(step_name)\n step_name\n end",
"def steps\n step_flows.collect(&:current_step)\n end",
"def complete_state_name()\n return engine.complete_state_name()\n end",
"def state_obj; @_hegemon_states[@_hegemon_state]; end",
"def state\n @actions << :state\n self.class.mocked_states.shift\n end",
"def state\n @state ||= getStateData()\n end",
"def next_step\n\t\t# choose the next step based on the lowest absolute delta\n\t\tnext_step = [ delta_right_top, delta_right_mid, delta_right_bot ].min_by { |i| i[1].abs }\n\n\t\t# increase tot_elavation with the delta between current and next step\n\t\t@tot_elavation += next_step[1].abs\n\n\t\treturn next_step[0]\n\tend",
"def state\n \n session[ flow_session_name ].fetch( state_session_name )\n \n end",
"def passing\n state(\"passing\")\n end",
"def get_state(key)\n computation.get_state(key)\n end",
"def state_string()\n ss = 'UNKNOWN'\n case @state\n when STARTING\n ss = 'STARTING'\n when STOPPED\n ss = 'STOPPED'\n when RUNNING\n ss = 'RUNNING'\n when CLOSING\n ss = 'CLOSING'\n when BLOCKED\n ss = 'BLOCKED'\n when STEP\n ss = 'STEP'\n end\n ss\n end",
"def main_state\n if start_step?\n return \"START\"\n elsif finish_step? && finished?\n return \"FINISH\"\n elsif state == \"ACTION\" && !params_hash[\"manual\"]\n return \"PROCESS\"\n elsif state == \"WAITFOR\"\n return \"PROCESS\"\n else\n return state\n end\n end",
"def read_state\n end",
"def final_state\n aasm.states.last.name\n end",
"def step\n unless halt?\n next_states = exec_blocks(get_blocks)\n \n if next_states.empty?\n @halt = true\n else\n @cur_state = next_states.pop\n end\n \n return next_states, @tape\n end\n end",
"def next_step\n if !self.steps.where(state: 'reproved').exists?\n self.steps.order(:order).find_by(state: 'waiting')\n end\n end",
"def nextState(machine)\n\t\tif machine.halted\n\t\t\treturn nil\n\t\tend\n\n\t\t@transitions.each{ |t|\n\t\t\tif t.match machine\n\t\t\t\treturn t.do machine\n\t\t\tend\n\t\t}\n\t\tmachine.halted = true\n\t\treturn nil\n\tend",
"def state\n data['State']\n end",
"def next_state(curr_state = nil, **)\n transitions(curr_state).first.presence\n end",
"def get_state\n return @driver.execute_script('''var a = window.ThreesGame.__class__.state\n return a[0]''')\n end",
"def steps_remaining\n @total_steps - @step\n end",
"def form_steps\n self.steps\n end",
"def step\n @next_step = @next_step.call\n return self\n end"
] | [
"0.6736628",
"0.65314066",
"0.648196",
"0.6467491",
"0.64334285",
"0.6423051",
"0.62574077",
"0.624839",
"0.6177428",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.617205",
"0.6163447",
"0.6140183",
"0.6139224",
"0.61274743",
"0.61258596",
"0.6072926",
"0.60550183",
"0.6042842",
"0.6039487",
"0.6023176",
"0.59234715",
"0.59010684",
"0.58751386",
"0.58751386",
"0.5871478",
"0.58655846",
"0.58590466",
"0.5840332",
"0.5833943",
"0.5826465",
"0.5802102",
"0.5791575",
"0.57911825",
"0.57911825",
"0.5788098",
"0.57774425",
"0.57645047",
"0.57598627",
"0.5748901",
"0.57368594",
"0.5732545",
"0.5723399",
"0.5720414",
"0.57192373",
"0.5706902",
"0.5706902",
"0.57056224",
"0.56987333",
"0.56877613",
"0.56868756",
"0.5676081",
"0.56726307",
"0.5667664",
"0.5666511",
"0.5648311",
"0.5639265",
"0.56367004",
"0.56362367",
"0.56347495",
"0.5627189",
"0.5618847",
"0.5614945",
"0.5596847",
"0.55924684",
"0.5589849",
"0.5588917",
"0.5588917",
"0.55807716",
"0.55691296",
"0.55608356",
"0.55482584",
"0.55385715",
"0.5517727",
"0.55023617",
"0.5493123",
"0.5482962",
"0.5478909",
"0.5454419",
"0.54541945",
"0.5440078",
"0.54294604",
"0.5418844",
"0.54163486",
"0.5413547",
"0.540968",
"0.54093117",
"0.5402677",
"0.5401314",
"0.53982484",
"0.5371766",
"0.5371664",
"0.53677684"
] | 0.0 | -1 |
Sets the engaged state of the Phidget. | def engaged=(new_state)
tmp = new_state ? 1 : 0
Klass.setEngaged(@handle, @index, tmp)
new_state
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_state(state)\n self.state = state\n self.save\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def set_State(value)\n set_input(\"State\", value)\n end",
"def state=(new_state)\n @state = new_state\n refresh\n end",
"def set_state(is_on)\n @client.set_state(is_on)\n end",
"def set_state(state)\n @state = state\n self[:action] = state\n @health = @health.clamp(0, 100)\n trigger 'change'\n send_status_notification unless dead?\n save\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def state=(value)\n @state = value\n end",
"def set_published_state; end",
"def state= new_state\n @state = new_state\n end",
"def set_door_state(state)\r\n\t\t@state = state\r\n\tend",
"def set_state(key, value)\n proxy.setState(key, value)\n end",
"def pause=(state)\n @paused = state\n end",
"def set_PostState(value)\n set_input(\"PostState\", value)\n end",
"def state=(new_state)\n self.hmd_states.build(state: new_state)\n self.current_state = new_state.to_sym\n end",
"def state=(value)\n @children['state'][:value] = value\n end",
"def enter_state\n end",
"def enabled=(new_state)\n tmp = new_state ? 1 : 0\n Klass.setEnabled(@handle, @index, tmp)\n new_state\n end",
"def enabled=(new_state)\n tmp = new_state ? 1 : 0\n Klass.setEnabled(@handle, @index, tmp)\n new_state\n end",
"def state=(arg)\n resource.state = arg\n end",
"def set_published_state\n self.published = payload[\"isLivingLegend\"]\n end",
"def current_state=(new_state)\n self[:current_state] = FFILib::ReaderStateQuery.pack_state new_state\n end",
"def assign_state(state)\n @state = state\n end",
"def set(state)\n case state\n when false then @mplab_pin.set_low\n when true then @mplab_pin.set_high\n when Numeric then @mplab_pin.set_analog(state)\n else raise ArgumentError, \"Invalid pin state: #{state.inspect}.\"\n end\n end",
"def state=(state)\n if not STATES.include? state\n raise PreconditionError, \"Invalid game victory state.\"\n end\n super\n changed(true)\n notify_observers U_COMPLETED, state, self.currentPlayer\n if not self.state == state\n raise PostconditionError, \"State not set correctly.\"\n end\n self.state\n end",
"def back_light=(new_state)\n\t try_set_screen\n\t tmp = new_state ? 1 : 0\n\t Klass.setBacklight(@handle, tmp)\n new_state\n end",
"def setFocusActive(bool)\n @focusActive = bool\n end",
"def state=(s)\n @state = s\n end",
"def state=(state)\n @state = state\n @delegate.save_scene\n end",
"def active=(active)\n @active = active\n @cEnemyGraphic.active = active\n end",
"def hold=(hold)\n if hold\n set(\"drmaa_js_state\", \"drmaa_hold\") \n else\n set(\"drmaa_js_state\", \"drmaa_active\") \n end\n end",
"def set\r\n assert_exists\r\n assert_enabled\r\n #highlight(:set)\r\n set_clear_item(true)\r\n #highlight(:clear)\r\n end",
"def toggle_state\n state\n end",
"def set_state(key, value)\n computation.set_state(key, value)\n end",
"def publishing_state=(value)\n @publishing_state = value\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def event_state=(new_state)\n self[:event_state] = FFILib::ReaderStateQuery.pack_state new_state\n end",
"def toggle_state\n puts \"******* toggle_state *******\"\n end",
"def setState(state)\n\t\t\traise \"undefined state.\\n\" if state.nil?\n\t\t\traise \"#{state} is not a Statemap.State.\\n\" unless state.is_a?(Statemap::State)\n\t\t\t@_state = state\n\t\t\tif @_debug_flag then\n\t\t\t\t@_debug_stream.puts \"ENTER STATE : %s\\n\" % @_state.getName\n\t\t\tend\n\t\tend",
"def put_on_seatbelt\n self.seatbelt_on = true\n end",
"def set_game_state s=''\n @state = s\n end",
"def mark_free(state = 0)\n self.state = state\n self.save\n end",
"def on_state(state, &block)\n end",
"def set_active\n @active = true\n end",
"def set( setThis )\r\n assert_exists\r\n assert_enabled\r\n assert_not_readonly\r\n \r\n highlight(:set)\r\n @o.scrollIntoView\r\n @o.focus\r\n @o.select()\r\n @o.fireEvent(\"onSelect\")\r\n @o.value = \"\"\r\n @o.fireEvent(\"onKeyPress\")\r\n doKeyPress( setThis )\r\n highlight(:clear)\r\n @o.fireEvent(\"onChange\")\r\n @o.fireEvent(\"onBlur\")\r\n end",
"def put_on_seatbelt\n self.seatbelt_on = true\n end",
"def set_state(key, val)\n @state[key] = val\n self\n end",
"def set_initial_state!\n\t\t\t\tdefaults = {\n\t\t\t\t}\n\t\t\t\topts = read_initial_state\n\t\t\t\topts = defaults.merge(opts)\n\t\t\t\topts[:dealer] = opts[:button_seat]\n\t\t\t\tinitialize_from_opts(opts)\n\t\t\t\tstart_hand\n\t\t\tend",
"def active=(value)\n super\n self.reset_cursor_blinking\n update_cursor\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def set_state\n @state = State.find(params[:id])\n end",
"def starts_as(initial_state)\n @current_state = initial_state\n self\n end",
"def set_initial_state state\n $LOGGER.info \"Setting up the initial state of the game.\"\n @state = state\n calculate_shadows @player_name\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def set_state(is_on)\n state = { :on => is_on }\n payload = { :state => state }\n client.publish(state_topic, payload.to_json, true, 1)\n state\n end",
"def set_state(state)\n stop if state == :error and [:initializing, :ready, :running_sm].include? resource_status\n record.set_state(state)\n end",
"def set_power_state(state)\n response = @client.rest_put(@data['uri'] + '/powerState', 'body' => { powerState: state })\n @client.response_handler(response)\n end",
"def boiler_state=(boiler_state); end",
"def enter_state\n puts \"Entering #{self.class}\"\n execution_state = EXECUTION_STATE[:active]\n end",
"def set_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def set_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def set_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def set_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end",
"def set_enabled_state(opts)\n opts = check_params(opts,[:states])\n super(opts)\n end"
] | [
"0.61920553",
"0.61920553",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.6154074",
"0.60919803",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.60879356",
"0.6069289",
"0.5995986",
"0.5988838",
"0.58908737",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.5863558",
"0.57935804",
"0.5769107",
"0.576553",
"0.56931853",
"0.56662405",
"0.56314737",
"0.56211674",
"0.55980104",
"0.5566035",
"0.556241",
"0.556241",
"0.5552418",
"0.554737",
"0.5537292",
"0.55289984",
"0.55046755",
"0.54958886",
"0.54894173",
"0.5481061",
"0.5463001",
"0.54530054",
"0.54115015",
"0.5386695",
"0.5378805",
"0.5353756",
"0.5346779",
"0.5331",
"0.52994806",
"0.52994806",
"0.52994806",
"0.52994806",
"0.52994806",
"0.52994806",
"0.52994806",
"0.52994806",
"0.5284469",
"0.52707237",
"0.5270059",
"0.5269354",
"0.5260637",
"0.5247413",
"0.5237346",
"0.52363896",
"0.5231969",
"0.52274525",
"0.5222232",
"0.52218163",
"0.5220357",
"0.5217009",
"0.5217009",
"0.52164435",
"0.52158016",
"0.52153474",
"0.52153474",
"0.52153474",
"0.52153474",
"0.52153474",
"0.52153474",
"0.5213051",
"0.52011585",
"0.51998013",
"0.5195051",
"0.51876664",
"0.51814014",
"0.51814014",
"0.51814014",
"0.51814014",
"0.51814014"
] | 0.7006594 | 1 |
Sets the target position of a stepper, in (micro)steps, or raises an error. | def target_position=(new_target_position)
Klass.setTargetPosition(@handle, @index, new_target_position.to_i)
new_target_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 setpoint_to_target\n @setpoint = @freq_target\n end",
"def setup_target_move\n return unless PONY::ERRNO::check_sequence(current_act)\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n current_action_targets.each do |target|\n target.goto(*args)\n end\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 target=(new_value)\n @target = new_value unless const_defined?(:Target)\n end",
"def set_invalid_steps(steps)\n self.invalid_steps = steps\n end",
"def set_move_target cf=current_file\n ff = expand_path(cf)\n return unless File.directory? ff\n\n @move_target = ff\n message \"Move target set to #{cf}.\"\nend",
"def move\n position_after_move = @position.new_coordinates_for_step_size(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n #ignore the command if robot is being out off tabletop\n if(@table_top.has_within_bounds?(position_after_move))\n @position = @position.new_coordinates_for(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n end\n end",
"def seek(target)\n #A vector pointing from the location to the target\n desired = PVector.sub(target, @location)\n # Scale to maximum speed\n desired.setMag(@maxspeed)\n\n # Steering = Desired minus velocity\n steer = PVector.sub(desired, @velocity)\n steer.limit(@maxforce) # Limit to maximum steering force\n apply_force(steer)\n end",
"def steps=(new_value)\n @steps = new_value\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 setup_move\n return TSBS.error(@acts[0], 4, @used_sequence) if @acts.size < 5\n stop_all_movements\n goto(@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0)\n end",
"def pt_step _value, _force=0\n send_cmd(\"pt_step #{_value} #{_force}\")\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 progressSetPosition _obj, _args\n \"_obj progressSetPosition _args;\" \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 set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def set_Target(value)\n set_input(\"Target\", value)\n end",
"def setup_move\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n mx = @map_char.real_x + @acts[1]\n my = @map_char.real_y + @acts[2]\n goto(mx, my, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def target=(value)\n @target = value\n end",
"def setpoint\n @setpoint\n end",
"def seek(target)\n # A vector pointing from the location to the target\n desired = target - location\n # Normalize desired and scale to the maximum speed\n desired.normalize!\n desired *= MAX_SPEED\n # Steering = Desired minus velocity\n steer = desired - @velocity\n # Limit to a maximum steering force\n steer.set_mag(MAX_FORCE) { steer.mag > MAX_FORCE }\n steer\n end",
"def move_prev\n self.step -= 1\n 'prev'\n end",
"def setCurrentWaypoint _obj, _args\n \"_obj setCurrentWaypoint _args;\" \n end",
"def setup_target_slide\n return unless PONY::ERRNO::check_sequence(current_act)\n args = [@acts[1], @acts[2], @acts[3], @acts[4], @acts[5] || 0]\n current_action_targets.each do |target|\n target.slide(*args)\n end\n end",
"def move_to (x, y)\n @x, @y = x, y\n end",
"def pt_up_step _value, _force=0\n send_cmd(\"pt_up_step #{_value} #{_force}\")\n end",
"def target_positions=(positions)\n @target_need_refresh = true\n @reselect_targets = true\n set_targets([])\n @target_positions = positions\n end",
"def target=(target)\n @target = target\n end",
"def setup_target_reset\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n target.reset_pos(@acts[1], @acts[2])\n end\n end",
"def step\n halt if should_halt?\n stop_elevator or move_elevator\n end",
"def setUnitPos _obj, _args\n \"_obj setUnitPos _args;\" \n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def position=(new_position)\n Klass.setPosition(@handle, @index, new_position.to_f)\n new_position\n end",
"def set_next_step\n @next_step = NextStep.find(params[:id])\n end",
"def target_idx=(target_idx)\n if (target_idx)\n # Make sure the target index is valid\n if (target_idx >= exploit.targets.length)\n raise Rex::ArgumentError, \"Invalid target index.\", caller\n end\n end\n\n # Set the active target\n @target_idx = target_idx\n end",
"def jmp(pos=0)\n @pos = pos\n end",
"def setWaypointPosition _obj, _args\n \"_obj setWaypointPosition _args;\" \n end",
"def update_position!(next_move)\n table.x = next_move[:x]\n table.y = next_move[:y]\n end",
"def position=(point); end",
"def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end",
"def current=(new_value)\n value = (new_value)%steps\n @dirty = @current != value\n @current = value\n end",
"def seek(target)\n desired = PVector.sub(target, @location) # A vector pointing from the location to the target\n # Scale to maximum speed\n desired.normalize()\n desired.mult(@maxspeed)\n\n # Above two lines of code below could be condensed with new PVector setMag() method\n # Not using this method until Processing.js catches up\n # desired.setMag(@maxspeed);\n\n # Steering = Desired minus Velocity\n steer = PVector.sub(desired, @velocity)\n steer.limit(@maxforce) # Limit to maximum steering force\n return steer\n end",
"def robot_move\n state_execute do |robot|\n robot.move\n end\n end",
"def move_to(xx, yy)\n @x = xx\n @y = yy\n normalize\n end",
"def sliderSetPosition _obj, _args\n \"_obj sliderSetPosition _args;\" \n end",
"def move \n\n # If we've reached the end of our path, not much to do\n if @path_step >= @path.length\n return\n end\n\n # So, just set the destination to the next step on the path and let the base\n # ship movement handle it\n @dest_x = @path[@path_step][0]\n @dest_y = @path[@path_step][1]\n super\n\n # Now just check to see if we've reached the target - if so, move on to the next\n # step on the path\n if ( @x == @path[@path_step][0] ) && ( @y == @path[@path_step][1] )\n @path_step += 1\n end\n\n end",
"def target=(target)\n @target = target\n @ori_target = target\n end",
"def move_to(x, y, speed = 2)\n @new_x = x\n @new_y = y\n @speed = speed\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def set_step\n @step = Step.find(params[:id])\n end",
"def speed_set _value\n send_cmd(\"speed_set #{_value}\")\n end",
"def setTarget(lagrange: 0, mayer: 0)\n @lagrange = OCProblemChecker.convert_to_symbolic(lagrange, :lagrange, :setTarget)\n @mayer = OCProblemChecker.convert_to_symbolic(mayer, :mayer, :setTarget)\n OCProblemChecker.check_target(self)\n end",
"def setup_change_target\n return unless PONY::ERRNO::check_sequence(current_act)\n setup_target(@acts[1])\n end",
"def setPos _obj, _args\n \"_obj setPos _args;\" \n end",
"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 step\n move_if_needed; return self\n end",
"def move(number)\n @position += number\n if @position < 32\n puts \"You moved #{number} steps forward\"\n end\n sleep(1)\n landed_on_which_panel(@position)\n end",
"def set_direction(d)\r\n @direction = d if !@direction_fix && d != 0\r\n @stop_count = 0\r\n end",
"def position=(new_position)\n Klass.setPosition(@handle, @index, new_position.to_i)\n new_position\n end",
"def current_position=(new_current_position)\n Klass.setCurrentPosition(@handle, @index, new_current_position.to_i)\n\t new_current_position\n end",
"def goto(xpos, ypos, dur, jump)\n @point.goto(xpos,ypos,dur,jump)\n @dur = dur\n @jump = jump\n end",
"def set_position\n if params[:new_position].present? and params[:old_position].present?\n Top.update_position(params[:new_position], params[:old_position])\n head :ok\n else\n head :bad_request\n end\n end",
"def follow(target)\n @camera_target = target\n end",
"def move_to(x, y); end",
"def move_to(x, y)\n @x, @y = x, y\n @gui.move_to(x, y)\n self\n end",
"def setPosition _obj, _args\n \"_obj setPosition _args;\" \n end",
"def set_step\n @step = @trip.steps.find_by_id params[:id]\n end",
"def change_position(position)\n @old_position = @position = position\n end",
"def move(steps)\n @instructions << Instruction.new(:move, steps)\n self\n end",
"def move\r\n return if not @selected_obj\r\n @state = STATE_MOVING\r\n @obj = @selected_obj\r\n @offset = @obj.center_offset\r\n find_end_points\r\n vec = @end_pt - @start_pt\r\n vec.length = vec.length/2\r\n @pt_to_move = @start_pt + vec\r\n @start_input_point = Sketchup::InputPoint.new(@pt_to_move)\r\nend",
"def send_to_correct_step\n if Member::States.include? step\n original_state = @member.state\n set_state previous_step\n if !@member.valid?\n member_step = wizard_steps.index(original_state) || 0\n jump_to wizard_steps[member_step.next]\n end\n end\n end",
"def touch_move_scene(point)\n if @truly_selected\n @truly_selected.move(point - @current_point)\n @current_point = point\n end\n end",
"def move_steps()\n\n # check end stops\n\n if @board.pins[@pin_min].value == 1 and @steps < 0\n @nr_steps = 0\n @pos = @min\n puts \"end stop min #{@name} reached\"\n end\n\n if @board.pins[@pin_max].value == 1 and @steps > 0\n @nr_steps = 0\n @pos = @max\n puts \"end stop max #{@name} reached\"\n end\n\n # check minimum and maximum position\n\n if (@pos <= @min and @steps < 0) or (@pos >= @max and @steps > 0)\n @nr_steps = 0\n puts \"end position reached #{@name}\"\n end\n\n # send the step pulses to the motor drivers\n\n if @nr_steps > 0\n set_pulse_on_pin(@pin_stp)\n\n @pos += 1.0 / @steps_per_unit * (@steps<=>0.0)\n @nr_steps -= 1\n\n return false\n else\n return true\n end\n\n end",
"def reset_pos(dur = 30, jump = 0)\n goto(@ori_x, @ori_y, dur, jump)\n end",
"def reset_pos(dur = 30, jump = 0)\n goto(@ori_x, @ori_y, dur, jump)\n end",
"def update(point)\n\t\t# move relative to the initial point\n\t\t\n\t\t@destination = @start + movement_delta(point)\n\tend",
"def setVehiclePosition _obj, _args\n \"_obj setVehiclePosition _args;\" \n end",
"def move_instant\n # FIXME: cannot be in target directory and do auto update\n # should we have a key for specifying move_target ?\n\n # for the mo, lets not move if nothing selected\n if @selected_files.empty?\n target = readline \"Set Move target #{@move_target}:\"\n target = Dir.pwd if target == '.'\n target = File.expand_path(target)\n @move_target = target\n message \"Move target is #{@move_target}. Select files and press this key.\"\n return\n end\n\n # files selected. Use earlier target if there, else ask\n # XXX how do we change it once set\n target = @move_target\n if target.nil? || target == ''\n count = @selected_files.count\n target = readline \"Move #{count} files to :\"\n return unless target\n end\n target = File.expand_path(target)\n unless File.directory? target\n perror \"#{target} not a directory.\"\n return\n end\n\n files = @selected_files\n ccount = 0\n files.each do |f|\n FileUtils.mv f, target\n @log.info \"2.#{f} moved to #{target}.\"\n ccount += 1\n rescue StandardError => exc\n @log.warn 'Case 2:'\n @log.warn \"Target is #{target}, file was #{f}\"\n @log.warn exc.to_s\n perror exc.to_s\n end\n @move_target = target\n clean_selected_files\n message \"#{ccount} files moved to #{target}.\"\n refresh\nend",
"def step_property _property, _value=0, _direction=0\n send_cmd(\"step_property #{_property} #{_value} #{_direction}\")\n end",
"def move\n\n\t\t# check landmarks and error variation inputs\n\t\tif !in_range || @error < 0\n\t\t\tstr = check_inputs(\"Move\")\n\t\t\treturn str\n\t\tend\n\n\t\t# traverse points array from 1 to 30\n\t\t@points.each_with_index do |point, index|\n\n\t\t\t# assign 1 if sensor reads current point as included in error variation\n\t\t\tif readSensor(index)\n\t\t\t\tpoint = 1\n\t\t\t\t@points[index] = point\n\t\t\tend\n\t\tend\n\tend",
"def before_step(step)\n @current_step = step\n end",
"def move_to(x, y)\n object.x = x\n object.y = y\n end",
"def set_point_position(index, position)\n MSPhysics::Newton::CurvySlider.set_point_position(@address, index, position)\n end",
"def set_point_position(index, position)\n MSPhysics::Newton::CurvySlider.set_point_position(@address, index, position)\n end",
"def ctrlSetPosition _obj, _args\n \"_obj ctrlSetPosition _args;\" \n end"
] | [
"0.62203336",
"0.5957737",
"0.587027",
"0.5716573",
"0.55401325",
"0.5535329",
"0.5513744",
"0.5488356",
"0.54202664",
"0.53962225",
"0.5392546",
"0.5384767",
"0.5373468",
"0.53674364",
"0.53669",
"0.53264296",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.53110605",
"0.5290357",
"0.5282491",
"0.52573675",
"0.52561355",
"0.5221632",
"0.5219839",
"0.5216639",
"0.5211371",
"0.52066106",
"0.52051854",
"0.5200313",
"0.51789784",
"0.51699305",
"0.5131854",
"0.5124627",
"0.51215094",
"0.5112731",
"0.51097864",
"0.5101738",
"0.50978947",
"0.50853735",
"0.5081165",
"0.50794065",
"0.5079338",
"0.50759107",
"0.50755805",
"0.50526863",
"0.5047817",
"0.5037272",
"0.5025633",
"0.50252396",
"0.5023411",
"0.5023411",
"0.5023411",
"0.5023411",
"0.5023411",
"0.5023411",
"0.5023411",
"0.5023411",
"0.5023411",
"0.50137484",
"0.5013597",
"0.50130355",
"0.5011604",
"0.501152",
"0.50113857",
"0.49989858",
"0.49945664",
"0.4993742",
"0.49722883",
"0.49703735",
"0.49684712",
"0.49630585",
"0.49594033",
"0.49388626",
"0.49368104",
"0.4932429",
"0.49256516",
"0.4919184",
"0.4917839",
"0.49109793",
"0.49089777",
"0.48949692",
"0.48929992",
"0.48929992",
"0.4889195",
"0.48873144",
"0.48821232",
"0.48762822",
"0.4874892",
"0.48686406",
"0.4857884",
"0.48534372",
"0.48534372",
"0.48515677"
] | 0.6607499 | 0 |
Sets the velocity limit of a stepper, in (micro)steps per second, or raises an error. | def velocity_limit=(new_velocity_limit)
Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)
new_velocity_limit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def velocity_limit=(new_velocity_limit)\n Klass.setVelocityLimit(@handle, @index, new_velocity_limit.to_f)\n new_velocity_limit\n end",
"def set_velocity action = :increment\n if action == :increment and @velocity <= 3\n @velocity += 1\n\n elsif action == :decrement and @velocity > 1\n @velocity -= 1\n end\n end",
"def set_speed(new_speed:)\n if new_speed > 30\n new_speed = 30\n elsif new_speed < 0\n new_speed = 0\n end\n @curr_speed = new_speed \n end",
"def setSpeed(value)\r\n @speed = value\r\n end",
"def set_Speed(value)\n set_input(\"Speed\", value)\n end",
"def set_Speed(value)\n set_input(\"Speed\", value)\n end",
"def velocity(val = nil)\n val.nil? ? @state.velocity : @state.velocity = val\n end",
"def sliderSetSpeed _obj, _args\n \"_obj sliderSetSpeed _args;\" \n end",
"def set_speed(input_speed)\n @speed = input_speed * MULTIPLIER\n end",
"def setVelocity _obj, _args\n \"_obj setVelocity _args;\" \n end",
"def speed_set _value\n send_cmd(\"speed_set #{_value}\")\n end",
"def speed=(value)\n\t\t\t@speed = value\n\t\tend",
"def vel=(v)\n self.mo = Vector[mo[0], *(mo[0]*v.normalize)]\n end",
"def velocity=(arg)\n @view__.velocity = arg.is_a?(Vector) ? arg.getInternal__ : arg\n arg\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_Limit(value)\n set_input(\"Limit\", value)\n end",
"def set_velocity\n @chart = policy_scope(Chart).find(params[:id])\n authorize @chart\n @velocity = @chart.velocity\n end",
"def reset_max_velocity\n @max_velocity = @max_velocity_original.dup\n end",
"def chooseVelocity\n # Are we waiting in the queue to enter the lane proper? If so, we\n # will ignore the normal rules.\n return if inQueue\n\n # If we aren't fixed, we shouldn't choose a velocity.\n return unless isFixed\n\n @nextSpeed = @driver.velocity(self)\n\n if @exitTo.force <= @bodyStart + @nextSpeed.fps_i\n @nextSpeed = Velocity.FPS(@exitTo.force - @bodyStart)\n end\n\n # Improvement: Add a parameter to a lane that indicates if a car can go\n # past the end safely\n if @currentLane.length < @bodyEnd\n @nextSpeed = Velocity::Zero\n end\n\n @nextSpeed\n end",
"def max_angular_velocity; end",
"def set_speed_threshold!(speed)\n speed = speed.to_i\n\n if(speed != 0 && speed < 20)\n raise ArgumentError, \"speed must be >= 20 or 0 to disable\"\n end\n\n if(speed % 5 != 0)\n raise ArgumentError, \"speed must be in 5 mph increments\"\n end\n\n !!self.send!(\"+XT:3004,#{speed}\")\n end",
"def setWaypointSpeed _obj, _args\n \"_obj setWaypointSpeed _args;\" \n end",
"def vx=(n)\n @view__.velocity = @view__.velocity.tap {|v| v.x = n}\n n\n end",
"def set_limit(amount)\r\n fail \"no valid limit\" if !amount.nil? && amount<0\r\n\r\n self.limit=amount\r\n end",
"def update\n # Update velocity\n @velocity.add(@acceleration)\n # Limit speed\n @velocity.limit(@maxspeed)\n @location.add(@velocity)\n # Reset accelerationelertion to 0 each cycle\n @acceleration.mult(0)\n end",
"def update_timestep=(timestep)\n timestep = AMS.clamp(timestep.to_f, 1/1200.0, 1/30.0)\n Sketchup.active_model.set_attribute('MSPhysics', 'Update Timestep', timestep)\n sim = MSPhysics::Simulation.instance\n sim.update_timestep = timestep if sim\n end",
"def change_entity_velocity entity; end",
"def current_limit=(new_current_limit)\n Klass.setCurrentLimit(@handle, @index, new_current_limit.to_f)\n\t new_current_limit\n end",
"def slow\n if @speed < 5\n @speed = 0.0\n else\n @speed = @speed - 5\n end\n end",
"def seek(target)\n desired = PVector.sub(target, @location) # A vector pointing from the location to the target\n # Scale to maximum speed\n desired.normalize()\n desired.mult(@maxspeed)\n\n # Above two lines of code below could be condensed with new PVector setMag() method\n # Not using this method until Processing.js catches up\n # desired.setMag(@maxspeed);\n\n # Steering = Desired minus Velocity\n steer = PVector.sub(desired, @velocity)\n steer.limit(@maxforce) # Limit to maximum steering force\n return steer\n end",
"def seek(target)\n #A vector pointing from the location to the target\n desired = PVector.sub(target, @location)\n # Scale to maximum speed\n desired.setMag(@maxspeed)\n\n # Steering = Desired minus velocity\n steer = PVector.sub(desired, @velocity)\n steer.limit(@maxforce) # Limit to maximum steering force\n apply_force(steer)\n end",
"def set_shooting_velocity\n @shooting_velocity = policy_scope(ShootingVelocity).find(params[:id])\n end",
"def update()\n # Update velocity\n @velocity.add(@acceleration)\n # Limit speed\n @velocity.limit(@maxspeed)\n @location.add(@velocity)\n # Reset accelertion to 0 each cycle\n @acceleration.mult(0)\n end",
"def message_speed=(value)\n @message_speed = value.clamp(1, 999)\n end",
"def setValue(value)\n @current = value\n self.limitCurrentValue\n end",
"def slow\n if @speed < 5.0\n @speed = 0.0\n else\n @speed = @speed - 5.0\n end\n end",
"def set_psi x\n if x>200\n x=200\n elsif x<0\n x=0\n end\n @@psi = x\n end",
"def set_psi_max x\n if x>100\n x=100\n end\n @@psi = x\n end",
"def update_vel_axis( v, a, dt )\n # Apply slowdown if not accelerating.\n if a == 0\n if v > 0\n v -= @slowdown * dt\n v = 0 if v < 0\n elsif v < 0\n v += @slowdown * dt\n v = 0 if v > 0\n end\n end\n # Apply acceleration\n v += a * dt\n # Clamp speed so it doesn't go too fast.\n v = @max_speed if v > @max_speed\n v = -@max_speed if v < -@max_speed\n return v\n end",
"def set_speed(speed)\n %x{#{echo()} speed_set #{speed} > #{fifo()}} if running?\n end",
"def set_update_timestep(timestep)\n timestep = AMS.clamp(timestep.to_f, 1/1200.0, 1/30.0)\n Sketchup.active_model.set_attribute('MSPhysics', 'Update Timestep', timestep)\n sim = MSPhysics::Simulation.instance\n sim.set_update_timestep(timestep) if sim\n return timestep\n end",
"def velocity= o\n dx, dy = o.x, o.y\n self.m = Math.sqrt(dx*dx + dy*dy)\n self.a = Math.atan2(dy, dx) * R2D\n end",
"def set_limit\n @limit = 250\n end",
"def velocity\n @velocity ||= (127 * @intensity).round\n end",
"def seek(target)\n # A vector pointing from the location to the target\n desired = target - location\n # Normalize desired and scale to the maximum speed\n desired.normalize!\n desired *= MAX_SPEED\n # Steering = Desired minus velocity\n steer = desired - @velocity\n # Limit to a maximum steering force\n steer.set_mag(MAX_FORCE) { steer.mag > MAX_FORCE }\n steer\n end",
"def accelerate(time) \n @velocity += time * @acceleration;\n @velocity = @max_speed if @velocity > @max_speed\n end",
"def init_speed\n @init_velocity.length\n end",
"def spped number\n @velocity +=number\n puts \"You accelerator to #{@velocity}\"\n end",
"def increase_speed(delta=10)\n @speed += delta\n end",
"def speed=(new_speed)\n if @speed.nil? || new_speed != @speed\n @speed = new_speed\n brick.execute(_speed(new_speed))\n end\n end",
"def map_time_limit=(new_value)\n super new_value && new_value.to_f\n end",
"def length=(value)\n if value.respond_to?(:to_f)\n @length = (self.unit * value.to_f).round\n else\n raise TypeError, \"Can't set a Duration's length to a #{value.class.name} object.\"\n end\n end",
"def length=(value)\n if value.respond_to?(:to_f)\n @length = (self.unit * value.to_f).round\n else\n raise TypeError, \"Can't set a Duration's length to a #{value.class.name} object.\"\n end\n end",
"def stop_tones=(value)\n @stop_tones = value\n end",
"def slow\n if @speed < 1.25\n @speed = 0.0\n else\n @speed = @speed - 1.25\n end\n end",
"def set_VideoDuration(value)\n set_input(\"VideoDuration\", value)\n end",
"def set_timeout(value)\n if value.nil?\n @timeout = 2\n else\n return skip_resource 'timeout is not numeric' unless value.to_s =~ /^\\d+$/\n @timeout = value\n end\n end",
"def set_servo_parameters(min_us, max_us, degrees, velocity_max)\n\t Klass.setServoParameters(@handle, @index, min_us, max_us, degrees, velocity_max)\n\t true\n\tend",
"def timeout=(new_timeout)\n if new_timeout && new_timeout.to_f < 0\n raise ArgumentError, \"Timeout must be a positive number\"\n end\n @timeout = new_timeout.to_f\n end",
"def slow\n if @speed < 7\n @speed = 0.0\n else\n @speed = @speed - 7\n end\n end",
"def set_Force(value)\n set_input(\"Force\", value)\n end",
"def set_value(value)\r\n raise ProgressBarError, \"Value must be a Numeric type\" \\\r\n unless value.is_a?(Numeric)\r\n raise ProgressBarError, \"Value must be between 0 and 100\" \\\r\n if (value < 0.0) || (value > 100.0)\r\n @value = value/100.0\r\n @value = 1.0 if @value > 1.0\r\n end",
"def delay=(sec)\n raise ArgumentError, 'Delay sec can not be a negative number.' if sec.to_f < 0\n @delay = sec.to_f\n end",
"def set_LimitPerType(value)\n set_input(\"LimitPerType\", value)\n end",
"def unitsPerSecond=(v)\n @unitsPerSecond = v.to_f\n end",
"def set_options(opt)\n @speed = opt[:speed] || 115200\n @model = opt[:model] || :reprap\n\n # 0 - Blocking indefinitely, -1 nonblocking.\n @blocking = 0\n end",
"def maxVelocity\n return @lastSpeed + @maxAccel if @lastSpeed < @maxCompare\n @maxVelocity\n end",
"def vy=(n)\n @view__.velocity = @view__.velocity.tap {|v| v.y = n}\n n\n end",
"def setSpeedMode _obj, _args\n \"_obj setSpeedMode _args;\" \n end",
"def vmotion=(value)\n Puppet.debug \"Updating vmotion status flag of specified portgroup.\"\n begin\n setupvmotion\n rescue Exception => e\n fail \"Unable to configure the vMotion on a port group because the following exception occurred: -\\n #{e.message}\"\n end\n end",
"def set_voltage(voltage)\n send_request(FUNCTION_SET_VOLTAGE, [voltage], 'S', 0, '')\n end",
"def limit=(x); @opts['limit'] = x; end",
"def run\n @speed = 5\n end"
] | [
"0.7112307",
"0.6255239",
"0.6249731",
"0.6048269",
"0.59822744",
"0.59822744",
"0.5972854",
"0.589134",
"0.57726794",
"0.5745471",
"0.5715279",
"0.57056004",
"0.5559399",
"0.5486125",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.5467187",
"0.546337",
"0.54388404",
"0.53966874",
"0.5367857",
"0.53617287",
"0.5348411",
"0.53250134",
"0.5283875",
"0.5277663",
"0.5268524",
"0.523771",
"0.5204832",
"0.5180878",
"0.5175472",
"0.51718444",
"0.51678437",
"0.51675725",
"0.5164751",
"0.5164296",
"0.5118875",
"0.51162595",
"0.5110508",
"0.51061577",
"0.50916153",
"0.50808024",
"0.507844",
"0.506791",
"0.50344944",
"0.5019942",
"0.49984762",
"0.49950337",
"0.49866986",
"0.49743176",
"0.49709588",
"0.49632463",
"0.49554348",
"0.49554348",
"0.49547544",
"0.4947703",
"0.49453607",
"0.4945261",
"0.4928448",
"0.4913436",
"0.48982877",
"0.48884478",
"0.48731548",
"0.4870217",
"0.4864241",
"0.48518407",
"0.48462373",
"0.4843247",
"0.4837711",
"0.48300865",
"0.48195243",
"0.48177734",
"0.48147377",
"0.48107874"
] | 0.72637236 | 0 |
Create a NxN grid of points on a face of the cube. Note that this will generate (N+1)(N+1) points. Each point is projected on the sphere and stored in an array. Note that all these are points on the unit sphere, and so their distance to the origin is 1, and so each point can be used as its own normal. | def grid(face, n)
dx = 2.0/n
dy = 2.0/n
a = Array.new
n += 1
n.times do |j|
y = -1.0 + j*dy
n.times do |i|
x = -1.0 + i*dx
lon, lat = QuadSphere::CSC.inverse(face, x, y)
sx = Math::cos(lat) * Math::cos(lon)
sy = Math::cos(lat) * Math::sin(lon)
sz = Math::sin(lat)
a << [sx,sy,sz]
end
end
a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_points(u_count, v_count)\n points = []\n v_count.times do |iv|\n row = []\n u_count.times do |iu|\n u = map1d(iu, (0..u_count), U_RANGE)\n v = map1d(iv, (0..v_count), V_RANGE)\n # default scale: 50, param: Array.new(12, 1) and mesh_distortion: 0\n row << superformula(u: u, v: v)\n end\n points << row\n end\n points\nend",
"def generate_grid\n grid = []\n @y.times do\n row = []\n @x.times do\n row << nil\n end\n grid << row\n end\n grid\n end",
"def grid(n, m)\n arr = Array.new(n) { Array.new(m, :N) }\n arr\nend",
"def vertices\n [\n pos,\n Vertex.new(pos.x, pos.y + dims.y, pos.z),\n Vertex.new(pos.x + dims.x, pos.y + dims.y, pos.z),\n Vertex.new(pos.x + dims.x, pos.y, pos.z),\n Vertex.new(pos.x, pos.y, pos.z + dims.z),\n Vertex.new(pos.x, pos.y + dims.y, pos.z + dims.z),\n Vertex.new(pos.x + dims.x, pos.y, pos.z + dims.z),\n Vertex.new(pos.x + dims.x, pos.y + dims.y, pos.z + dims.z)\n ]\n end",
"def grid(n, m)\n Array.new(n) { Array.new(n) } # If you attempted to write this as Array.new(n, Array.new(m)) the contents would be repeated for each array rather\nend",
"def generate_coordinates\n coordinates = []\n (0..@column_count - 1).to_a.each do |i|\n (0..@row_count - 1).to_a.each do |j|\n coordinates << {x: i, y: j, z: 0}\n end\n end\n coordinates\n end",
"def generate_grid x = @x, y = @y\n new_grid = []\n\n y.times { new_grid << [] }\n new_grid.each do |array|\n x.times do\n array << []\n end\n end\n end",
"def new_cube(n)\r\n return n*n*n,70;\r\nend",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def three_row_grid\n grid = []\n grid << [\n Cell.new(:alive, 0, 0),\n Cell.new(:alive, 0, 1),\n Cell.new(:dead, 0, 2)\n ]\n grid << [\n Cell.new(:alive, 1, 0),\n Cell.new(:dead, 1, 1),\n Cell.new(:dead, 1, 2)\n ]\n grid << [\n Cell.new(:dead, 2, 0),\n Cell.new(:dead, 2, 1),\n Cell.new(:dead, 2, 2)\n ]\n grid\nend",
"def grid\n Matrix.build(@row_count, @column_count) { Cell.new }.to_a\n end",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def grid\n \t\t\tfinal, y = Array.new, 0\n \t\t\t@@axis.fetch(:y).times do\n \t\t\t\tfinal[y], x = Array.new, 0\n \t\t\t\t@@axis.fetch(:x).times do\n \t\t\t\t\tfinal[y][x] = init_coord(x, y)\n \t\t\t\t\tx += 1\n \t\t\t\tend\n \t\t\t\ty += 1\n\t\t\tend\n\t\t\tfinal.reverse\n\t\tend",
"def create_grid\n spaces = create_spaces\n assign_spaces_to_rows.map do |row|\n row.each.with_index do |coordinates, index|\n row[index] = {coordinates => spaces[coordinates]}\n end\n end\n end",
"def make_grid(*points)\n self.convert_values()\n printed = \"\"\n if (@clear)\n system ('clear')\n end\n x_points = Array.new\n y_points = Array.new\n # Divide points\n (0..points.length - 1).each do |position|\n if (position % 2 == 0)\n x_points.push(points[position].to_i)\n else\n y_points.push(points[position].to_i)\n end\n end\n # Start loop\n (0..@y_size.to_i).each do |current_y|\n (0..@x_size.to_i).each do |current_x|\n # Setup\n print_fill = true\n relative_x = current_x - @x_offset\n relative_y = @y_offset - current_y\n point_amount = x_points.length - 1\n # Check point\n (0..point_amount.to_i).each do |position_point|\n if (x_points[position_point] == relative_x)\n if (y_points[position_point] == relative_y)\n printed << @point.to_s\n print_fill = false\n end\n end\n end\n # Fill\n if (print_fill)\n if (@x_offset == current_x)\n printed << \"|\"\n elsif (@y_offset == current_y)\n printed << \"-\"\n else\n printed << @blank_space.to_s\n end\n end\n if (y_offset == current_y && current_x != @x_size)\n printed << \"-\"\n else\n printed << \" \"\n end\n end\n printed << \"\\n\"\n end\n print printed\n return printed\n end",
"def row_cube(y, z)\n Cube.new(0 * cell_width, y * cell_height, z * cell_depth,\n cell_width * columns, cell_height, cell_depth)\n end",
"def initiate_grid\n new_grid = []\n @width.times do |x|\n new_grid[x] = []\n @height.times do |y|\n new_grid[x][y] = 0\n end\n end\n new_grid\n end",
"def col_cube(x, z)\n Cube.new(x * cell_width, 0 * cell_height, z * cell_depth,\n cell_width, cell_height * rows, cell_depth)\n end",
"def cell_cube(*args)\n MACL::Cube.new(*cell_a(*args))\n end",
"def gridit(xd, yd, zd, nx, ny)\n nd = equal_length(xd, yd, zd)\n inquiry [{ double: nx }, { double: ny }, { double: nx * ny }] do |px, py, pz|\n super(nd, xd, yd, zd, nx, ny, px, py, pz)\n end\n end",
"def vertices\n [\n @origin,\n { x: x_max, y: y_min, z: z_min },\n { x: x_min, y: y_max, z: z_min },\n { x: x_min, y: y_min, z: z_max },\n { x: x_max, y: y_max, z: z_min },\n { x: x_max, y: y_min, z: z_max },\n { x: x_min, y: y_max, z: z_max },\n { x: x_max, y: y_max, z: z_max }\n ]\n end",
"def three_by_three_boxes\n @boxes ||= [0,1,2].repeated_permutation(2).map do |box_coord|\n box_row, box_col = *box_coord\n col_offset = box_col * 3\n row(box_row * 3)[col_offset...(col_offset+3)] +\n row(box_row * 3 + 1)[col_offset...(col_offset+3)] +\n row(box_row * 3 + 2)[col_offset...(col_offset+3)]\n end\n end",
"def create_boxes(num)\n box_vertices = polygon_vertices(NUM_SIDES, EDGE_SIZE)\n box_image = polygon_image(box_vertices)\n boxes = []\n num.times do\n body = CP::Body.new(1, CP::moment_for_poly(1.0, box_vertices, CP::Vec2.new(0, 0))) # mass, moment of inertia\n body.p = CP::Vec2.new(rand(WIDTH), rand(40) - 50)\n shape = CP::Shape::Poly.new(body, box_vertices, CP::Vec2.new(0, 0))\n shape.e = 0.0\n shape.u = 0.4\n boxes << Box.new(box_image, body)\n @space.add_body(body)\n @space.add_shape(shape) \n end\n return boxes\n end",
"def grid(cols, rows, col_size=1, row_size=1)\n (0..cols*rows).map do |i|\n x = col_size * (i % cols)\n y = row_size * i.div(cols)\n yield x, y\n end\n end",
"def initialize(size = 3)\n @size = size\n @grid = Array.new(size) { Array.new(size) }\n end",
"def grid(cols, rows, col_size=1, row_size=1)\n (0...cols*rows).map do |i|\n x = col_size * (i % cols)\n y = row_size * i.div(cols)\n yield x, y\n end\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def create_boxes(num)\n box_vertices = polygon_vertices(NUM_SIDES, EDGE_SIZE)\n box_image = polygon_image(box_vertices)\n boxes = []\n num.times do\n body = CP::Body.new(1, CP::moment_for_poly(1.0, box_vertices, CP::Vec2.new(0, 0))) # mass, moment of inertia\n body.p = CP::Vec2.new(rand(SCREEN_WIDTH), rand(40) - 50)\n shape = CP::Shape::Poly.new(body, box_vertices, CP::Vec2.new(0, 0))\n shape.e = 0.0\n shape.u = 0.4\n boxes << AObject.new(box_image, body)\n @space.add_body(body)\n @space.add_shape(shape) \n end\n return boxes\n end",
"def createcells(xstart,xend, ystart,yend, stepOverinuse, aface)\r\n countx = 0\r\n xmax = ymax = 0\r\n x = xstart\r\n while (x <= xend) do\r\n y = ystart\r\n county = 0\r\n while (y <= yend) do\r\n #note: using half stepover on the X axis, gets the ends of the zigs closer to the border\r\n xc = ((x-xstart) / (stepOverinuse/2) + 0.002).round # x cell index\r\n yc = ((y-ystart) / stepOverinuse + 0.002).round # y cell index\r\n pt = Geom::Point3d.new(x, y,0)\r\n res = aface.classify_point(pt)\r\n \r\n case res\r\n when Sketchup::Face::PointUnknown #(indicates an error),\r\n puts \"unknown\" if (@debug)\r\n when Sketchup::Face::PointInside #(point is on the face, not in a hole),\r\n @cells[[xc,yc]] = true\r\n when Sketchup::Face::PointOnVertex #(point touches a vertex),\r\n #cells[[xc,yc]] = true\r\n when Sketchup::Face::PointOnEdge #(point is on an edge),\r\n #cells[[xc,yc]] = true\r\n when Sketchup::Face::PointOutside #(point outside the face or in a hole),\r\n #puts \"outside\" if (@debug)\r\n when Sketchup::Face::PointNotOnPlane #(point off the face's plane).\r\n puts \"notonplane\" if (@debug)\r\n end\r\n \r\n xmax = (xmax < xc) ? xc : xmax\r\n ymax = (ymax < yc) ? yc : ymax\r\n y += stepOverinuse\r\n county += 1\r\n if (county > 5000) #really for debugging but prevents runaway loops\r\n puts \"county high break\"\r\n break\r\n end\r\n end # while y\r\n x += (stepOverinuse / 2.0)\r\n countx += 1\r\n if (countx > 5000)\r\n puts \"countx high break\"\r\n break\r\n end\r\n end # while x\r\n @cellxmax = xmax\r\n @cellymax = ymax\r\n end",
"def gen_cells args = {}\n\t\t\tx = args[:x] || 0\n\t\t\ty = args[:y] || 0\n\t\t\tw = args[:w] || 32\n\t\t\th = args[:h] || 32\n\n\t\t\tcell_count = {\n\t\t\t\tx: (current_room.w.to_f / w.to_f).floor,\n\t\t\t\ty: (current_room.h.to_f / h.to_f).floor\n\t\t\t}\n\n\t\t\treturn cell_count[:y].times.map do |row|\n\t\t\t\tnext cell_count[:x].times.map do |col|\n\t\t\t\t\tnext Cell.new(\n\t\t\t\t\t\tx: (w * col),\n\t\t\t\t\t\ty: (h * row),\n\t\t\t\t\t\tw: w, h: h,\n\t\t\t\t\t\tindex: { x: col, y: row },\n\t\t\t\t\t\tsolid: false\n\t\t\t\t\t)\n\t\t\t\tend\n\t\t\tend .flatten\n\t\tend",
"def _get_square_starting_points()\n square_starting_points = []\n row_index = 0\n column_index = 0\n 3.times do\n 3.times do\n square_starting_points << [row_index, column_index]\n column_index += 3\n end\n row_index += 3\n column_index = 0\n end\n square_starting_points\n end",
"def mesh_vertices\r\n # private ?\r\n d = TT::Instance.definition( @instance )\r\n transformation = @instance.model.edit_transform\r\n points = mesh_points( final_subdivs, transformation )\r\n vertices = raw_mesh_vertices()\r\n\r\n # <debug>\r\n unless points.size == vertices.size\r\n Console.log( 'mesh_vertices' )\r\n Console.log( \"> Points: #{points.size}\" )\r\n Console.log( \"> Vertices: #{vertices.size}\" )\r\n end\r\n # </debug>\r\n\r\n patch_vertices = []\r\n for point in points\r\n vertex = vertices.find { |v| v.position == point } # (!) Optimize\r\n patch_vertices << vertex\r\n vertices.delete( vertex )\r\n end\r\n patch_vertices\r\n end",
"def fill_face( entities, points )\r\n if points.size == 4 && !TT::Geom3d.planar_points?( points )\r\n face1 = entities.add_face( points[0], points[1], points[2] )\r\n face2 = entities.add_face( points[0], points[2], points[3] )\r\n edge = ( face1.edges & face2.edges )[0]\r\n QuadFace.set_divider_props( edge )\r\n [ face1, face2 ]\r\n else\r\n entities.add_face( points )\r\n end\r\n end",
"def lay_cube(x, y)\n Cube.new(x * cell_width, y * cell_height, 0 * cell_depth,\n cell_width, cell_height, cell_depth * layers)\n end",
"def cells_grid_1by1\n [\n [\n MazeMagic::Maze::Edge.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::Edge.instance\n ],\n [\n MazeMagic::Maze::VerticalWall.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::VerticalWall.instance\n ]\n ]\n end",
"def cubes(array)\n array.map { |number| number ** 3 }\nend",
"def create_position_array()\n array_2D = []\n array_1D = []\n\n (0...@row).each_with_index do |value, row_index|\n (0...@col).each_with_index { |value, col_index| array_1D.append(value+(row_index*@col)) }\n array_2D.append(array_1D)\n array_1D = []\n end\n\n return array_2D\n end",
"def window_to_sphere_space(window_point)\n\n radius = 1.0\n\n # window point( x=[0..width], y=[0..height])\n # fix the z and w for matrix math\n window_point.z = 0.0\n window_point.w = 1.0\n\n # point( x=[-1.0..1.0], y=[-1.0..1.0])\n sphere_point = @conversion_matrix[:window_to_sphere] * window_point\n\n sphere_point.z = sphere_point.w = 0.0\n\n x_y_magnitude = sphere_point.x**2 + sphere_point.y**2\n\n if (x_y_magnitude > 1.0)\n # Point is mapped outside of the sphere space... (length > radius squared)\n # Put x, y inside the sphere but leave z=0.0\n sphere_point.normalize\n else\n\n # Return a vector to a point mapped inside the sphere\n #\n # Sphere:\n # pX^2 + pY^2 + pZ^2 = r^2,\n # pZ^2 = r^2 - (pX^2 + pY^2)\n # pZ = sqrt(r^2 - (pX^2 + pY^2))\n #\n sphere_point.z = Math.sqrt((radius * radius) - x_y_magnitude)\n end\n\n return sphere_point\n end",
"def createcellsX(xstart,xend, ystart,yend, stepOverinuse, aface)\r\n county = 0\r\n xmax = ymax = 0\r\n y = ystart\r\n while (y <= yend) do\r\n x = xstart\r\n countx = 0\r\n while (x <= xend) do\r\n #note: using half stepover on the X axis, gets the ends of the zigs closer to the border\r\n xc = ((x-xstart) / (stepOverinuse) + 0.002).round # x cell index\r\n yc = ((y-ystart) / (stepOverinuse/2) + 0.002).round # y cell index\r\n pt = Geom::Point3d.new(x, y,0)\r\n res = aface.classify_point(pt)\r\n \r\n case res\r\n when Sketchup::Face::PointUnknown #(indicates an error),\r\n puts \"unknown\" if (@debug)\r\n when Sketchup::Face::PointInside #(point is on the face, not in a hole),\r\n @cells[[xc,yc]] = true\r\n when Sketchup::Face::PointOnVertex #(point touches a vertex),\r\n #cells[[xc,yc]] = true\r\n when Sketchup::Face::PointOnEdge #(point is on an edge),\r\n #cells[[xc,yc]] = true\r\n when Sketchup::Face::PointOutside #(point outside the face or in a hole),\r\n #puts \"outside\" if (@debug)\r\n when Sketchup::Face::PointNotOnPlane #(point off the face's plane).\r\n puts \"notonplane\" if (@debug)\r\n end\r\n \r\n xmax = (xmax < xc) ? xc : xmax\r\n ymax = (ymax < yc) ? yc : ymax\r\n x += stepOverinuse\r\n countx += 1\r\n if (countx > 5000) #really for debugging but prevents runaway loops\r\n puts \"countx high break\"\r\n break\r\n end\r\n end # while x\r\n y += (stepOverinuse / 2.0)\r\n county += 1\r\n if (county > 5000)\r\n puts \"county high break\"\r\n break\r\n end\r\n end # while y\r\n @cellxmax = xmax\r\n @cellymax = ymax\r\n end",
"def carve_walls_from_point(x, y, grid)\n \nend",
"def cubes(array)\narray.map {|number| number ** 3}\n\n\nend",
"def to_face_cube\n fc = FaceCube.new\n\n CORNERS.length.times do |i|\n j = corner_permutation[i]\n ori = corner_orientation[i]\n\n CORNER_SIZE.times do |n|\n ord = Facelet.for(i, (n + ori) % 3, type: :corner).ord\n fc.colors[ord] = FaceCube::CORNER_COLORS[j][n]\n end\n end\n\n EDGES.length.times do |i|\n j = edge_permutation[i]\n ori = edge_orientation[i]\n EDGE_SIZE.times do |n|\n ord = Facelet.for(i, (n + ori) % 2, type: :edge).ord\n fc.colors[ord] = FaceCube::EDGE_COLORS[j][n]\n end\n end\n\n fc\n end",
"def render\n # Every cell is an individual quad\n # using the propane grid convenience function instead of a nested loop\n grid(z.size - 1, z[0].size - 1) do |x, y|\n # one quad at a time\n # each quad's color is determined by the height value at each vertex\n # (clean this part up)\n no_stroke\n push_matrix\n begin_shape(PConstant::QUADS)\n translate(x * scl - w * 0.5, y * scl - h * 0.5, 0)\n fill(z[x][y] + 127, 220)\n vertex(0, 0, z[x][y])\n fill(z[x + 1][y] + 127, 220)\n vertex(scl, 0, z[x + 1][y])\n fill(z[x + 1][y + 1] + 127, 220)\n vertex(scl, scl, z[x + 1][y + 1])\n fill(z[x][y + 1] + 127, 220)\n vertex(0, scl, z[x][y + 1])\n end_shape\n pop_matrix\n end\n end",
"def randomn\n size = self.size\n case type = self.typecode\n when COMPLEX; type=FLOAT\n when SCOMPLEX; type=SFLOAT\n when FLOAT\n when SFLOAT\n else\n raise TypeError, \"NArray type must be (S)FLOAT or (S)COMPLEX.\"\n end\n rr = NArray.new(type,size)\n xx = NArray.new(type,size)\n i = 0\n while i < size\n n = size-i\n m = ((n+Math::sqrt(n))*1.27).to_i\n x = NArray.new(type,m).random!(1) * 2 - 1\n y = NArray.new(type,m).random!(1) * 2 - 1\n r = x**2 + y**2\n idx = (r<1).where\n idx = idx[0...n] if idx.size > n\n if idx.size>0\n\trr[i] = r[idx]\n\txx[i] = x[idx]\n\ti += idx.size\n end\n end\n # Box-Muller transform\n rr = ( xx * NMath::sqrt( -2 * NMath::log(rr) / rr ) )\n # finish\n rr.reshape!(*self.shape) if self.rank > 1\n rr = rr.to_type(self.typecode) if type!=self.typecode\n if RUBY_VERSION < \"1.8.0\"\n self.type.refer(rr)\n else\n self.class.refer(rr)\n end\n end",
"def create_particles\n 200.times do\n @particle = Particle.new(@window, self)\n @particle_array.push(@particle)\n end\n 100.times do\n @particle = Particle.new(@window, self)\n @particle_array_2.push(@particle)\n end\n end",
"def pile_of_cubes(m)\n n = 1\n n^3\n n^3 + (n+1)^3\n n^3 + (n+1)^3 + (n+2)^3\n\n\n # check m against 1^3\n # check m against 1^3 + 2^3\n # check m against 1^3 + 2^3 + 3^3...\n\n\nend",
"def mesh_points( subdivs, transformation )\r\n points = []\r\n for patch in @patches\r\n points.concat( patch.mesh_points( subdivs, transformation ).to_a )\r\n end\r\n points = TT::Point3d.extend_all( points ) # So that .uniq! works\r\n points.uniq!\r\n points\r\n end",
"def generate_grid(grid_size)\n Array.new(grid_size) { ('A'..'Z').to_a.sample } # random grid of letter\n end",
"def cubes(arr)\n p cubies = arr.map {|n| n ** 3}\nend",
"def grid3d(*)\n super\n end",
"def cubes(array)\n array.map { |number| number ** 3}\n # Return array\nend",
"def initialize(size)\n @grid = Array.new(size) {Array.new(size, :N)}\n @size = size * size\n end",
"def gridpoints\n gridpoints = {'l' => @ngauss, 'e' => @negrid, 's' => @nspec}\n if @grid_option == \"single\"\n gridpoints.absorb({'x'=>1, 'y'=>1})\n else\n gridpoints.absorb({'x' => (@ntheta0 or (2.0 * (@nx - 1.0) / 3.0 + 1.0).floor), 'y' => (@naky or ((@ny - 1.0) / 3.0 + 1.0).floor)})\n end\n return gridpoints\nend",
"def generate_grid(grid_size)\n # TODO: generate random grid of letters, allows duplicate of letters\n # 1. Create new array of 9 elements\n # 2. In the range A to Z for each element of the array, take a sample\n # (so by default, it allows duplicates)\n grid = Array.new(grid_size) { (\"A\"..\"Z\").to_a.sample }\n return grid\n end",
"def coordinates\n [rand(50), rand(90)]\n end",
"def vertices\n VertexList.new(1, nil, [@centre])\n end",
"def generate_points(num_points, width, height)\n points = [[width / 2, height / 2]]\n count = 0\n while points.length < num_points\n raise(\"sanity check failed\") if count > num_points * 2\n count += 1\n next_p = next_point(points.sample)\n if next_p[0].between?(0, width - 1) and next_p[1].between?(0, height - 1)\n points << next_p unless points.include?(next_p)\n else\n # debug\n puts \"#{next_p.inspect} out of bounds\"\n end\n end\n points\nend",
"def box(n)\n result = []\n 3.times do |i|\n row = (n.to_i / 3) * 3 + i\n # puts \"row: #{n} -> #{row}\"\n 3.times do |j|\n col = (n % 3) * 3 + j\n # puts \" col: #{n} -> #{col}\"\n result << @lines[row][col]\n end\n end\n result\n end",
"def calc_vertices\n @worksheet.position_object( @params[:start_col],\n @params[:start_row],\n @params[:x_offset],\n @params[:y_offset],\n @params[:width],\n @params[:height]\n )\n end",
"def vertices\n vertices = []\n\n vertices << [(@origin[0] + @l/2.0), (@origin[1] + @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] + @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] - @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] - @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] - @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] - @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] + @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] + @h/2.0), (@origin[2] + @w/2.0)]\n\n vertices\n end",
"def vertices\n result = [[@origin_x, @origin_y, @origin_z]]\n dimensions = [@length, @width, @height]\n \n dimensions.each_with_index do |dimension, index|\n temp = result[0].dup\n temp[index] += dimension\n result << temp\n (index...dimensions.length).each do |index2|\n next if index == index2\n temp2 = temp.dup\n temp2[index2] += dimensions[index2]\n result << temp2\n end\n end\n result << [@origin_x + @length, @origin_y + @width, @origin_z + @height]\n result\n end",
"def generate_surrounding_spaces(x, y)\n surround_array = []\n# Loop over 3x3 grid\n for i in x-1..x+1\n for j in y-1..y+1\n # Exclude the center square and ones not on the grid\n if ((i==x) && (j==y)) || !is_on_grid(i,j)\n next\n end\n surround_array.push([j, i])\n end\n end\n\n return surround_array\nend",
"def generate_grid\n (0...10).map { ('A'..'Z').to_a[rand(26)] }\n end",
"def encircle( points,\n x_start = Point.new( *([0]*points[0].size) ),\n max_iter = 100 )\n x = x_start\n y, g = nil, nil\n\n for k in 1..max_iter do\n y, g = evaluate( x, points )\n x = x - g/k\n end\n\n return Circle.new(x, Math.sqrt(y))\nend",
"def hflip\n g = Grid.new\n self.each do |point,v|\n g[Point.new( @width - point.x - 1, point.y )] = v \n end\n g\n end",
"def generate_grid(grid_size)\n # TODO: generate random grid of letters\n alphabet = (\"A\"..\"Z\").to_a\n grid = []\n grid_size.times { grid.push(alphabet[rand(1...alphabet.length)]) }\n grid\n end",
"def volume_of_cube(n)\n return n * n * n\nend",
"def set_points(count,size)\n if count > size\n raise \"Whow there!\"\n end\n points = []\n x = (0..size-1).to_a.shuffle\n y = (0..size-1).to_a.shuffle\n begin\n points.push([x.shift,y.shift])\n end until points.size == count\n points\nend",
"def create_grid_from_size(size_arr)\n rows = size_arr[0]\n columns = size_arr[1]\n Array.new(rows) { Array.new(columns) }\n end",
"def create_starting_positions\n\t\t[Point.new(BOARD_WIDTH/4, BOARD_HEIGHT/4),\n \t\tPoint.new(3 * BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4),\n\t\tPoint.new(3 * BOARD_WIDTH/4, BOARD_HEIGHT/4),\n\t\tPoint.new(BOARD_WIDTH/4, 3 * BOARD_HEIGHT/4)]\n\tend",
"def points_partion_array(member_counts)\n division = (0...member_counts).map {|i| points / member_counts }\n (0...points%member_counts).each {|i| division[0] += 1}\n division\n end",
"def triangulate(vertices)\n\t\tedges = []\n tris = []\n # sort by X coord\n vertices = vertices.sort_by {|p|p.x}\n # center/radius cache used by circum_circle\n cc_cache = {}\n\n # Set up the supertriangle\n # This is a triangle which encompasses all the sample points.\n # The supertriangle coordinates are added to the end of the\n # vertex list. The supertriangle is the first triangle in\n # the triangle list.\n number_of_vertices = vertices.size\n\t\tbounding_p1, bounding_p2, bounding_p3 = get_bounding_vertices(vertices)\n\t\tvertices << bounding_p1 << bounding_p2 << bounding_p3\n\t\ttris << ITRIANGLE.new(number_of_vertices, number_of_vertices+1, number_of_vertices+2)\n\n # Include each point one at a time into the existing mesh\n vertices.each_with_index { |current_point, i|\n edges.clear\n # Set up the edge buffer.\n # If the point (xp,yp) lies inside the circumcircle then the\n # three edges of that triangle are added to the edge buffer\n # and that triangle is removed.\n j = 0\n\t\t\ttris_size = tris.size\n\t\t\twhile j < tris_size\n\t\t\t\tcurrent_triangle = tris[j]\n if !current_triangle.complete\n p1 = vertices[current_triangle.p1]\n p2 = vertices[current_triangle.p2]\n p3 = vertices[current_triangle.p3]\n inside,xc,yc,r = circum_circle(current_point, p1, p2, p3, cc_cache)\n if (xc + r) < current_point.x\n current_triangle.complete = true\n end\n if inside\n\t\t\t\t\t\tedges << IEDGE.new(current_triangle.p1, current_triangle.p2)\n edges << IEDGE.new(current_triangle.p2, current_triangle.p3)\n edges << IEDGE.new(current_triangle.p3, current_triangle.p1)\n tris.delete_at(j)\n\t\t\t\t\t\ttris_size -= 1\n j -= 1\n end\n end\n j += 1\n end #while j\n\t\t\t\n\t\t\twhile !edges.empty?\n\t\t\t\tedge = edges.shift\n\t\t\t\trejected = edges.reject! {|e| e == edge}\n\t\t\t\ttris << ITRIANGLE.new(edge.p1, edge.p2, i) if rejected.nil? \n\t\t \tend\n \n } #each i\n \n\t\t# Remove supertriangle vertices\n\t\t3.times do \n\t\t\tvertices.pop\n\t\tend\n\t\tnumber_of_vertices = vertices.size\n\n # Remove triangles with supertriangle vertices\n # These are triangles which have a vertex number greater than number_of_vertices\n\t\ttris.delete_if {|tri| tri.p1 >= number_of_vertices || tri.p2 >= number_of_vertices || tri.p3 >= number_of_vertices}\n\n [ vertices, tris ]\n end",
"def generate_coords\n coords = [0,0]\n coords[0] = rand(9)\n coords[1] = rand(9)\n coords\n end",
"def center\n a, b, c, d = @points\n\n Geom::Point3d.new(\n (a.x + b.x + c.x + d.x) / 4,\n (a.y + b.y + c.y + d.y) / 4,\n (a.z + b.z + c.z + d.z) / 4\n )\n end",
"def fill_temp_grid\n temp_width = @width + 2\n temp_height = @height + 2\n\n temp_width.times do |x|\n @temp_grid[x] = []\n temp_height.times do |y|\n @temp_grid[x][y] = 0\n end\n end\n end",
"def generate\n for i in 0..$dimensions[0]-1\n for j in 0..$dimensions[1]-1\n for k in 0..$d-1\n item=populate k\n if item!=0 \n $grid[[i,j,k]]=item\n end\n end\n end\n end\nend",
"def makeLiving(points)\n points.map do |p|\n getCell(p[0],p[1]).spawn\n end\n end",
"def generateManySpheres numSpheres\n rnd = java.util.Random.new\n gameSurface = getGameSurface\n\n bubbles = []\n numSpheres.times do\n c = Color.rgb rnd.nextInt(255), rnd.nextInt(255), rnd.nextInt(255)\n b = Atom.new rnd.nextInt(15) + 5, c\n circle = b.getAsCircle\n # random 0 to 2 + (.0 to 1) * random (1 or -1)\n b.vX = (rnd.nextInt(2) + rnd.nextDouble) * (rnd.nextBoolean ? 1 : -1)\n b.vY = (rnd.nextInt(2) + rnd.nextDouble) * (rnd.nextBoolean ? 1 : -1)\n\n # random x between 0 to width of scene\n newX = rnd.nextInt gameSurface.getWidth\n\n # check for the right of the width newX is greater than width\n # minus radius times 2(width of sprite)\n if newX > gameSurface.get_width - (circle.getRadius * 2)\n newX = gameSurface.get_width - (circle.getRadius * 2)\n end\n\n # check for the bottom of screen the height newY is greater than height\n # minus radius times 2(height of sprite)\n newY = rnd.nextInt gameSurface.get_height\n if newY > gameSurface.get_height - (circle.getRadius * 2)\n newY = gameSurface.get_height - (circle.getRadius * 2)\n end\n\n circle.setTranslateX newX\n circle.setTranslateY newY\n circle.setVisible true\n circle.set_id \"atom-#{b.object_id}\"\n\n # add to actors in play (sprite objects)\n getSpriteManager.addSprites b\n\n # add sprites\n getSceneNodes.getChildren.add 0, b.node\n end\n end",
"def fox_the_cubes(*vals)\n foxed_cubes = vals.map { |v| FoxedCube.new(v) }\n @game.instance_variable_set(:@cubes, foxed_cubes)\n end",
"def points_n2\n result = [:infinity]\n (0...@p).each do |x|\n (0...@p).each do |y|\n point = [x,y]\n result << point if valid?(point)\n end\n end\n result\n end",
"def get_points(count = 1)\n points = []\n count.times do\n points << get_point\n end\n\n points\n end",
"def initialize\n @points = 10.times.map { Point.new } #.map produeces a new array. 10.times/create a new array - of Point.new. So it creates \n #10 points and puts them into a new array.\n end",
"def initialize\n\t\t@grid = Array.new(10){Array.new(10)}\n\tend",
"def create_graph\n all_coordinates = get_all_coordinates\n all_coordinates.each do |key|\n neighbors = get_neighbor_arr(key)\n add_vertex(key,neighbors)\n end\n @vertices\n end",
"def cell_a(*args)\n case args.size\n when 1 then x, y, z = index_to_xyz(args[0])\n when 3 then x, y, z = *args\n else raise(ArgumentError, \"Expected 1 or 3 but recieved #{args.size}\")\n end\n [cell_width * x, cell_height * y, cell_depth * z,\n cell_width, cell_height, cell_depth]\n end",
"def get_grids(x, y, width, height)\n x = (x*10)-5\n y = (y*10)-5\n end_x= x+(width*10)-1\n end_y= y+(height*10) -1\n return [[y, x], [end_y, end_x]]\n end",
"def get_grids(x, y, width, height)\n x = (x*10)-5\n y = (y*10)-5\n end_x= x+(width*10)-1\n end_y= y+(height*10) -1\n return [[y, x], [end_y, end_x]]\n end",
"def generate\n #create random number generator\n rng = Random.new\n @points = Array.new\n\n #num_points times, make random value in ranges \n @num_points.times do\n @points << [rng.rand(@x_lims), rng.rand(@y_lims)]\n end\n end",
"def rotate\n g = Grid.new\n self.each do |point,v|\n g[Point.new(point.y,point.x)] = v\n end\n (0..g.height - 1).each do |y|\n ( 0..g.width/2.ceil - 1 ).each do |x|\n tmp = g[Point.new(x,y)]\n g[Point.new(x,y)] = g[Point.new(g.width - x - 1, y )]\n g[Point.new(g.width - x - 1,y)] = tmp\n end\n end\n g\n end",
"def start_grid\n Array.new(@lines) { Array.new(@columns) { Cell.new } }\n end",
"def to_n\n Normal3.new(@x, @y, @z)\n end",
"def coordinates\n arr = []\n (0...@size).each do |row|\n (0...@size).each do |column|\n arr << Coordinate.new(x: row,y: column)\n end\n end\n arr\n end",
"def print_grid(points,size)\n grid = []\n for i in 0..size-1\n grid.push([])\n for j in 0..size-1\n if points.include? [j,i]\n # grid.last.push(\"#{j.to_s.reverse[0]}#{i.to_s.reverse[0]}\")\n grid.last.push(\"#{j}#{i}\")\n else\n grid.last.push(\"__\")\n end\n end\n end\n grid.reverse!\n grid.map {|x| puts x.join(\" \")}\nend",
"def points_on_circle(center, normal, radius, numseg)\r\n # Get the x and y axes\r\n axes = Geom::Vector3d.new(normal).axes\r\n center = Geom::Point3d.new(center)\r\n xaxis = axes[0]\r\n yaxis = axes[1]\r\n \r\n xaxis.length = radius\r\n yaxis.length = radius\r\n\r\n # compute the points\r\n da = (Math::PI * 2) / numseg\r\n pts = []\r\n for i in 0...numseg do\r\n angle = i * da\r\n cosa = Math.cos(angle)\r\n sina = Math.sin(angle)\r\n vec = Geom::Vector3d.linear_combination(cosa, xaxis, sina, yaxis)\r\n pts.push(center + vec)\r\n end\r\n \r\n # close the circle\r\n pts.push(pts[0].clone)\r\n\r\n pts\r\nend",
"def print_fine_points(points,size)\n grid = []\n for i in 0..size-1\n grid.push([])\n for j in 0..size-1\n if points.include? [j,i]\n grid.last.push(\"x\")\n else\n grid.last.push(\".\")\n end\n end\n end\n grid.reverse!\n grid.map {|x| puts x.join(\"\")}\nend",
"def set_coordinates\n [rand(-100..100), rand(-100..100)]\n end",
"def get_subgrid(cords)\n subgrid = []\n x_pos = cords[0] - cords[0] % 3\n (x_pos..x_pos + 2).each do |row_num|\n y_pos = cords[1] - cords[1] % 3\n subgrid += @grid[row_num][y_pos, 3]\n end\n subgrid\n end",
"def initialize(width=30, height=30, random=true, random_seed=[true,false].to_a)\n\n @width=width\n @height=height\n\n #create an array\n @cells = ConwayModel::create_grid(width, height, random, random_seed)\n end",
"def surface(x, y, z, option)\n # TODO: check: Arrays have incorrect length or dimension.\n nx = x.length\n ny = y.length\n super(nx, ny, x, y, z, option)\n end",
"def surface(x, y, z, option)\n # TODO: check: Arrays have incorrect length or dimension.\n nx = x.length\n ny = y.length\n super(nx, ny, x, y, z, option)\n end"
] | [
"0.5928719",
"0.570356",
"0.56557053",
"0.56169516",
"0.56094754",
"0.5591064",
"0.55714774",
"0.5485938",
"0.54362124",
"0.5412299",
"0.5383223",
"0.5371151",
"0.53186864",
"0.52793384",
"0.5258932",
"0.52141297",
"0.52060217",
"0.5205415",
"0.517512",
"0.51573133",
"0.51541215",
"0.5153713",
"0.51408494",
"0.5114458",
"0.51144063",
"0.51078653",
"0.51043904",
"0.50894344",
"0.5066011",
"0.50584126",
"0.50404346",
"0.5039085",
"0.50365585",
"0.5030336",
"0.5018354",
"0.5014741",
"0.5007289",
"0.50004375",
"0.50001746",
"0.4969367",
"0.49585173",
"0.49555913",
"0.49552992",
"0.49380106",
"0.4919092",
"0.49042815",
"0.4888399",
"0.48834357",
"0.48825738",
"0.4870999",
"0.4867136",
"0.48610756",
"0.4856297",
"0.48452455",
"0.48439637",
"0.4843447",
"0.48380274",
"0.48365656",
"0.48319075",
"0.48245803",
"0.4822378",
"0.48042688",
"0.4798663",
"0.47882643",
"0.4783099",
"0.47626406",
"0.47611552",
"0.47605935",
"0.47556767",
"0.47384351",
"0.47320065",
"0.4717344",
"0.47148418",
"0.47095728",
"0.4704455",
"0.470124",
"0.46897784",
"0.46880612",
"0.46824247",
"0.46799672",
"0.4678159",
"0.46735838",
"0.4656939",
"0.46561924",
"0.46498114",
"0.46489397",
"0.46489397",
"0.464802",
"0.46478787",
"0.46452126",
"0.46385396",
"0.46341544",
"0.463119",
"0.4621059",
"0.46116352",
"0.46081463",
"0.4601375",
"0.4591614",
"0.4569262",
"0.4569262"
] | 0.7749322 | 0 |
p grid(0, 3) Create triangle strips to represent a NxN mesh. The given array should then contain (N+1)2 points, arranged as N+1 rows of N+1 points. | def mesh2strips(n,a)
dx = 2.0/n
dy = 2.0/n
row = n+1
n.times do |j|
glBegin(GL_TRIANGLE_STRIP)
rowi = j*row
row.times do |x|
add_vertex(a[rowi+x])
add_vertex(a[rowi+row+x])
end
glEnd
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_grid(board_array)\n\t# split into triplets\n\ttriplets_array = []\n board_array.each { |array| triplets_array << array.each_slice(3).to_a }\n\n # shuffle the triplets\n shuffle_container = [[], [], []]\n 9.times do |row|\n 3.times do |column|\n current_array = triplets_array[row][column]\n shuffle_container[column] << current_array\n end\n end\n\n # flatten and re-split\n final_array = []\n shuffle_container.flatten.each_slice(9) { |array| final_array << array }\n\n return final_array\nend",
"def grid(face, n)\n dx = 2.0/n\n dy = 2.0/n\n a = Array.new\n n += 1\n\n n.times do |j|\n y = -1.0 + j*dy\n n.times do |i|\n x = -1.0 + i*dx\n lon, lat = QuadSphere::CSC.inverse(face, x, y)\n sx = Math::cos(lat) * Math::cos(lon)\n sy = Math::cos(lat) * Math::sin(lon)\n sz = Math::sin(lat)\n a << [sx,sy,sz]\n end\n end\n\n a\n end",
"def grid(n, m)\n Array.new(n) { Array.new(n) } # If you attempted to write this as Array.new(n, Array.new(m)) the contents would be repeated for each array rather\nend",
"def grid(n, m)\n arr = Array.new(n) { Array.new(m, :N) }\n arr\nend",
"def pascals_triangle(n)\n triangle = [[1]]\n until triangle.length == n\n triangle << row(triangle[-1])\n end\n triangle\nend",
"def triangles(n)\n\ts = []\n\t1.upto n do |i|\n\t\tn, triangle_n = yield i\n\t\ts << [n, triangle_n]\n\tend\n\ts\nend",
"def pascals_triangle(n)\n triangles = [[1]]\n while triangles.length < n\n triangles << next_line(triangles[-1])\n end\n triangles\nend",
"def pascals_triangle(n)\n triangle = [[1]]\n\n (1...n).each do |lvl_idx| # levels of pyramid by array idx\n current_lvl = []\n prev_lvl = triangle[lvl_idx - 1] \n\n (0..lvl_idx).each do |pos| # elements of level\n left = (pos == 0) ? 0 : prev_lvl[pos - 1]\n right = (pos == lvl_idx) ? 0 : prev_lvl[pos]\n current_lvl[pos] = left + right\n end\n triangle << current_lvl\n end\n triangle\nend",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def create_grid\n grid = Array.new(8) { Array.new(8) { [] } }\n grid.map! do |row|\n if grid.index(row).even?\n row.each { |space| row.index(space).even? ? space << 'white' : space << 'black' }\n else\n row.each { |space| row.index(space).even? ? space << 'black' : space << 'white' }\n end\n row.map! do |space|\n space << [grid.index(row), row.index(space)]\n end\n end\n grid.reverse\n end",
"def pascals_triangle(num)\n ret_arr = [[1]]\n (num-1).times do #|idx|\n new_arr = [1]\n ((ret_arr[-1].length) -1).times do |j|\n new_arr << ret_arr[-1][j] + ret_arr[-1][j+1]\n end\n ret_arr.append(new_arr << 1)\n end\n ret_arr\nend",
"def pascals_triangle(n)\n triangle = []\n (1..n).each do |line|\n level = []\n num = 1\n (1..line).each do |idx|\n level << num\n num = (num * (line - idx) / idx)\n end\n triangle << level\n end\n triangle\nend",
"def p_triangle(n)\n (0..n).each{|i|\n list = [1]\n element = 1\n k = 1\n (0..i-1).step(1){|index|\n element = element * (i-k+1)/k\n list.push element \n k += 1\n }\n yield(list)\n }\nend",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def three_row_grid\n grid = []\n grid << [\n Cell.new(:alive, 0, 0),\n Cell.new(:alive, 0, 1),\n Cell.new(:dead, 0, 2)\n ]\n grid << [\n Cell.new(:alive, 1, 0),\n Cell.new(:dead, 1, 1),\n Cell.new(:dead, 1, 2)\n ]\n grid << [\n Cell.new(:dead, 2, 0),\n Cell.new(:dead, 2, 1),\n Cell.new(:dead, 2, 2)\n ]\n grid\nend",
"def triangulate(vertices)\n\t\tedges = []\n tris = []\n # sort by X coord\n vertices = vertices.sort_by {|p|p.x}\n # center/radius cache used by circum_circle\n cc_cache = {}\n\n # Set up the supertriangle\n # This is a triangle which encompasses all the sample points.\n # The supertriangle coordinates are added to the end of the\n # vertex list. The supertriangle is the first triangle in\n # the triangle list.\n number_of_vertices = vertices.size\n\t\tbounding_p1, bounding_p2, bounding_p3 = get_bounding_vertices(vertices)\n\t\tvertices << bounding_p1 << bounding_p2 << bounding_p3\n\t\ttris << ITRIANGLE.new(number_of_vertices, number_of_vertices+1, number_of_vertices+2)\n\n # Include each point one at a time into the existing mesh\n vertices.each_with_index { |current_point, i|\n edges.clear\n # Set up the edge buffer.\n # If the point (xp,yp) lies inside the circumcircle then the\n # three edges of that triangle are added to the edge buffer\n # and that triangle is removed.\n j = 0\n\t\t\ttris_size = tris.size\n\t\t\twhile j < tris_size\n\t\t\t\tcurrent_triangle = tris[j]\n if !current_triangle.complete\n p1 = vertices[current_triangle.p1]\n p2 = vertices[current_triangle.p2]\n p3 = vertices[current_triangle.p3]\n inside,xc,yc,r = circum_circle(current_point, p1, p2, p3, cc_cache)\n if (xc + r) < current_point.x\n current_triangle.complete = true\n end\n if inside\n\t\t\t\t\t\tedges << IEDGE.new(current_triangle.p1, current_triangle.p2)\n edges << IEDGE.new(current_triangle.p2, current_triangle.p3)\n edges << IEDGE.new(current_triangle.p3, current_triangle.p1)\n tris.delete_at(j)\n\t\t\t\t\t\ttris_size -= 1\n j -= 1\n end\n end\n j += 1\n end #while j\n\t\t\t\n\t\t\twhile !edges.empty?\n\t\t\t\tedge = edges.shift\n\t\t\t\trejected = edges.reject! {|e| e == edge}\n\t\t\t\ttris << ITRIANGLE.new(edge.p1, edge.p2, i) if rejected.nil? \n\t\t \tend\n \n } #each i\n \n\t\t# Remove supertriangle vertices\n\t\t3.times do \n\t\t\tvertices.pop\n\t\tend\n\t\tnumber_of_vertices = vertices.size\n\n # Remove triangles with supertriangle vertices\n # These are triangles which have a vertex number greater than number_of_vertices\n\t\ttris.delete_if {|tri| tri.p1 >= number_of_vertices || tri.p2 >= number_of_vertices || tri.p3 >= number_of_vertices}\n\n [ vertices, tris ]\n end",
"def generate_triangle_numbers(n)\n is_triangle = Array.new(n+1, false)\n \n index = 1\n increment = 1\n while index < is_triangle.length\n is_triangle[index] = true\n increment += 1\n index += increment\n end\n \n return is_triangle\nend",
"def create_inner_arrays(array)\n size = array.size\n array = [array.first((size + 1) / 2), array.last(size / 2)]\nend",
"def generate_rows(array)\n rows = []\n array.each do |line|\n row = [line]\n array.each do |column|\n row << line * column\n end\n rows << row\n end\n\n rows\n end",
"def generate_grid\n grid = []\n @y.times do\n row = []\n @x.times do\n row << nil\n end\n grid << row\n end\n grid\n end",
"def triangles()\n @triangles = []\n loop_start_time = Time.now\n while @triangles.size != @count\n begin\n t = Triangle.new(*random_coordinate_triplet)\n if t.possible? && within_threshold(t) && within_threshold2(t)\n @triangles << t\n else\n if (Time.now - loop_start_time) > 10\n raise 'too much calculation'\n end\n end\n rescue Math::DomainError\n puts \"Out of domain... trying again.\"\n end\n end\n @triangles\n end",
"def generate_surrounding_spaces(x, y)\n surround_array = []\n# Loop over 3x3 grid\n for i in x-1..x+1\n for j in y-1..y+1\n # Exclude the center square and ones not on the grid\n if ((i==x) && (j==y)) || !is_on_grid(i,j)\n next\n end\n surround_array.push([j, i])\n end\n end\n\n return surround_array\nend",
"def triangle(nrows)\n return [[1]] if nrows <= 1\n previous = triangle(nrows-1)\n center = previous[-1].enum_for(:each_cons, 2).map {|a| a[0] + a[1] }\n return previous << ( [1] + center + [1] )\nend",
"def create_grid_from_size(size_arr)\n rows = size_arr[0]\n columns = size_arr[1]\n Array.new(rows) { Array.new(columns) }\n end",
"def identifier_triangle_points\n point_to_triangles = []\n (@maillage_points.length+1).times do\n point_to_triangles << []\n end\n @triangles.length.times do |i|\n t = @triangles[i]\n point_to_triangles[t.p1.num] << i\n point_to_triangles[t.p2.num] << i\n point_to_triangles[t.p3.num] << i\n end\n return point_to_triangles\n end",
"def generate_grid x = @x, y = @y\n new_grid = []\n\n y.times { new_grid << [] }\n new_grid.each do |array|\n x.times do\n array << []\n end\n end\n end",
"def pyramid(n)\n outer_array = []\n 0.upto(n) do |i|\n next if i == 0\n outer_array << Array.new(i, i)\n end\n outer_array\nend",
"def triangle_test(x)\n\t#split input into array\n array = x\n\t\n #delete first array so only dealing with triangle sides\n array.delete_at(0)\n \n #split array into smaller array of arrays of 3 sides each\n triangle_arrays = array.each_slice(3).to_a \n\n #iterate through each \"triangle\"\n triangle_arrays.each do |a, b, c|\n\n if (a == b) && (a == c)\n puts \"Equilateral\"\n elsif (a == b) || (a == c) || (b == c)\n puts \"Isoceles\"\n else\n puts \"None of these\"\n end\n\nend\n \nend",
"def grid\n rows = []\n (1..self.height).to_a.each do |h|\n rows << row(h)\n end\n rows.reverse\n end",
"def pascals_triangle(n)\n triangle = []\n triangle << [1]\n while triangle.length < n\n next_level = []\n current_level = Array.new(triangle.last) # create copy of last row\n current_level.push(0)\n current_level.unshift(0)\n\n iterator = 0\n\n while iterator < current_level.length-1\n\n next_level << current_level[iterator..iterator+1].sum\n iterator += 1\n end\n\n triangle << next_level\n end\n triangle\nend",
"def populate_adjacency_list_via_array(array)\n @vertices = array.flatten.uniq.map { |v| Vertex.new('WHITE', 1, nil, [], v) }\n # Both forward and backward edges are being added to the edges list\n forward_edges = array.map { |edge| Edge.new(find(edge[0]), find(edge[1])) }\n backward_edges = array.map { |edge| Edge.new(find(edge[1]), find(edge[0])) }\n @edges = forward_edges + backward_edges\n populate_adjacency_list\n end",
"def pascals_triangle(num)\r\n triangle = [[1]]\r\n\r\n\r\n\r\nend",
"def split(grid, n)\n grid.split('/').each_slice(n).map do |rows|\n results = Array.new(rows.first.length / n) {[]}\n rows.map {|row| row.split('').each_slice(n).each_with_index {|r, i| results[i] << r.join('')}}\n results.map {|r| r.join('/')}\n end\nend",
"def snail(array)\n return Array.new if array == [[]]\n\n # step_map is an array saying how many\n # steps to take before each turn\n step_map = Array.new\n (1 .. array.length).to_a.reverse.each do |i|\n step_map << i\n step_map << i\n end\n step_map.shift\n\n result = Array.new\n direction = :East\n y = 0\n x = -1\n\n step_map.each do |steps|\n steps.times do\n case direction\n when :East\n x += 1\n when :West\n x -= 1\n when :South\n y += 1\n when :North\n y -= 1\n end\n\n result << array[y][x]\n end\n\n direction = turnFrom direction\n end\n\n result\nend",
"def triangle(n)\n (1..n).each { |row| puts ' ' * (n - row) + '*' * row }\nend",
"def triangles(n)\n space_count = n\n star_count = 1\n\n while star_count <= n\n puts \"#{' ' * space_count}#{'*' * star_count}\"\n space_count -= 1\n star_count += 1\n end\nend",
"def pascals_triangle(num)\n if num == 1\n return [[1]]\n elsif num == 2\n return [[1], [1,1]]\n end\n\n tri = [[1], [1,1]]\n\n until tri.length == num\n tri << lower_level(tri[-1])\n end\n tri\nend",
"def grid(number)\n v = number + 1 # number of vertices\n coefficient = 1\n routes = 0\n 1.upto(v) do |i|\n routes += coefficient * coefficient\n coefficient = coefficient * (v - i) / i\n end\n routes\n end",
"def test_with_irregular_array3D2; show([[[0,0,0]],\n [[0,0,0],[1,1,1]]]) end",
"def test_with_irregular_array3D1; show([[[0,0,0],[1,1,1]],\n [[0,0,0]]]) end",
"def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end",
"def add_triangle(points: nil)\n fail \"Needs an array of 3 points\" if points.nil?\n fail \"Needs an array of 3 points\" unless points.length.eql? 3\n \n self.add_moveto(points[0])\n self.add_lineto(points[1])\n self.add_lineto(points[2])\n self.add_lineto(points[0])\n self.add_closesubpath()\n end",
"def groupCreator(array)\n\t3.times do\n\t\tarray.shuffle!\n\t\t\tnewArray=array.each_slice(4).to_a\n\t\t\tnewArray.each do |x|\n\t\t\t\tif(x.length<4)\n\t\t\t\t\ti=0\n\t\t\t\t\tuntil x.length<=0\t\n\t\t\t\t\t\tnewArray[i]<<x.pop\n\t\t\t\t\t\ti+=1\n\t\t\t\t\tend\n\t\t\t\t\tnewArray.pop\n\t\t\t\tend\n\t\t\tend\n\t\t\tp newArray\n\tend\nend",
"def pascal(n)\n triangle_array = []\n counter = 0\n\n until counter == n\n if triangle_array.empty?\n triangle_array.push([1])\n counter += 1\n else\n pre_layer = triangle_array[counter - 1]\n new_layer = []\n\n pre_layer.each_with_index do |number, index|\n if index == 0\n new_layer.push(1)\n else\n previous_number = pre_layer[index - 1]\n new_layer.push(number + previous_number)\n end\n end\n\n new_layer.push(1)\n triangle_array.push(new_layer)\n counter += 1\n end\n end\n\n triangle_array\nend",
"def split_triangle(e1,e2)\n\tif (sig = e1|e2).count == 3 ; hs = Hash.new\n\t\t(0..4).zip(sig+((0..4).to_a-sig)).each{|i,e| hs[i]=e}\n\t\t[[0,3,2],[3,4,2],[3,1,4]].map{|a| a.map{|i| hs[i]}}\n\tend\nend",
"def create_grid\n spaces = create_spaces\n assign_spaces_to_rows.map do |row|\n row.each.with_index do |coordinates, index|\n row[index] = {coordinates => spaces[coordinates]}\n end\n end\n end",
"def triangle(row)\n # initialize the triangle with row 0 (a single 1)\n list_of_rows = []\n list_of_rows << [1]\n\n # build the rest of the triangle up to the row we need\n (1..row).each do |row_counter|\n previous_row = list_of_rows[row_counter - 1]\n list_of_rows << compute_row(previous_row)\n end\n\n puts list_of_rows.last.join(\", \")\nend",
"def validate_triangulation(triangles, message = true)\n # Remove to enable validation\n if (message)\n log \"=== skipping triangle validation ===\"\n end\n return\n # Partition things first into buckets to speed things up a bit\n buckets = []\n box_size = 2\n -180.step(179, box_size) do |x|\n inner_bucket = []\n -90.step(89, box_size) do |y|\n x_hi = x + box_size\n y_hi = y + box_size\n set = []\n triangles.each do |triangle|\n check = false\n triangle.points.each do |point|\n if (point.x >= x && point.x <= x_hi &&\n point.y >= y && point.y <= y_hi)\n check = true\n end\n end\n if (check)\n set.push(triangle)\n end\n end\n inner_bucket.push(set)\n end\n buckets.push(inner_bucket)\n end\n count = 0\n buckets.each do |bucket|\n bucket.each do |set|\n if (set.length > 0)\n count += set.length\n if (validate_triangle_bucket(set) == false)\n return false\n end\n end\n end\n end\n return true\nend",
"def triangulate(points)\n case points.length\n when 0\n Hull.new([])\n\n when 1\n Hull.new(points)\n\n when 2\n points[0].add(points[1])\n points[1].add(points[0])\n Hull.new(points)\n\n when 3\n h = Hull.new(points)\n\n # Because points are known to be sorted, p1 is leftmost and p3 is rightmost\n p1, p2, p3 = points\n\n # Connect points to each other in counterclockwise order\n cross = p2.cross(p1, p3)\n if cross < 0\n # p2 is right of p1->p3; put p2 on the bottom\n p1.add(p2)\n p2.add(p3)\n p3.add(p1)\n\n p3.add(p2)\n p2.add(p1)\n p1.add(p3)\n elsif cross > 0\n # p2 is left of p1->p3; put p2 on the top\n p1.add(p3)\n p3.add(p2)\n p2.add(p1)\n\n p1.add(p2)\n p2.add(p3)\n p3.add(p1)\n else\n # p2 is on a line between p1 and p3; link left-to-right\n p1.add(p2)\n p2.add(p3)\n\n p3.add(p2)\n p2.add(p1)\n end\n\n h\n\n else\n # 4 or more points; divide and conquer\n n = points.length / 2\n left = points[0...n]\n right = points[n..-1]\n\n merge(triangulate(left), triangulate(right))\n end\n end",
"def triangulate(geometry)\n ring = geometry.exterior_ring\n\n input = ring.points.map { |point| [point.x, point.y] }\n input.pop if input.first == input.last\n\n cdt = Poly2Tri::CDT.new(input)\n cdt.triangulate!\n cdt.triangles\n end",
"def drawXZGrid\n\t\tif !@gridOn then return end\n\t\tglDisable(GL_LIGHTING)\n\t\tglBegin(GL_LINES)\n\t\tglColor(@gridColorXZ)\n\t\tfor i in (-@gridLines..@gridLines)\n\t\t\t# Draw two lines for each iteration\n\t\t\tglVertex( i*@gridSpacing, 0.0, -(@gridLines*@gridSpacing))\n\t\t\tglVertex( i*@gridSpacing, 0.0, (@gridLines*@gridSpacing))\n\t\t\tglVertex( -(@gridLines*@gridSpacing), 0.0, i*@gridSpacing)\n\t\t\tglVertex( (@gridLines*@gridSpacing), 0.0, i*@gridSpacing)\n\t\tend\n\t\tglEnd\n\t\tglEnable(GL_LIGHTING)\n\tend",
"def make_diamond(arr, rows)\n start = 1\n 1.upto(rows) do |iteration|\n arr << start\n iteration < (rows / 2.0).ceil ? start += 2 : start -= 2\n break if arr.length == rows\n end\n arr\nend",
"def create_triangles\n create_helpers\n is_reversed_array = []\n @triangles = Hash.new\n\n @currencies.each do |first, hash_of_seconds|\n hash_of_seconds.each do |second, is_second_ordered|\n if is_second_ordered\n first_pair = \"#{first}-#{second}\"\n is_reversed_array[0] = false\n else\n first_pair = \"#{second}-#{first}\"\n is_reversed_array[0] = true\n end\n\n @currencies[second].each do |third, is_third_ordered|\n # do not want A - B - A pattern\n if third == first\n next\n elsif @pairs.key?(\"#{third}-#{first}\")\n third_pair = \"#{third}-#{first}\"\n is_reversed_array[2] = false\n elsif @pairs.key?(\"#{first}-#{third}\")\n third_pair = \"#{first}-#{third}\"\n is_reversed_array[2] = true\n # there is no connection between the last and first currency\n else\n next\n end\n\n if is_third_ordered\n second_pair = \"#{second}-#{third}\"\n is_reversed_array[1] = false\n else\n second_pair = \"#{third}-#{second}\"\n is_reversed_array[1] = true\n end\n @triangles[\"#{first}-#{second}-#{third}\"] =\n Structures::Triangle.new(\n [@pairs[first_pair], @pairs[second_pair], @pairs[third_pair]],\n is_reversed_array)\n end\n end\n end\n remove_duplicate_triangles\n end",
"def initialize(size = 3)\n @size = size\n @grid = Array.new(size) { Array.new(size) }\n end",
"def each_triangle_number\n n = 1\n index = 1\n\n loop do\n yield n, index\n\n index += 1\n n += index\n end\nend",
"def bezier3d(p1, p2, p3, p4, n)\n\tar = []\n\tar.push(p1)\n\tn.times do |i|\n\t\tt = (i+1).to_f / (n+1)\n\t\tp5 = intp3d(p1, p2, t)\n\t\tp6 = intp3d(p2, p3, t)\n\t\tp7 = intp3d(p3, p4, t)\n\t\tp8 = intp3d(p5, p6, t)\n\t\tp9 = intp3d(p6, p7, t)\n\t\tpz = intp3d(p8, p9, t)\n\t\tar.push(pz)\n\tend\n\tar.push(p4)\nend",
"def sorted_triples(array)\n sort_array = []\n array.each_slice(3) do |group|\n sort_array << group.sort\n end\n return sort_array\nend",
"def smooth ary\n edge_extend(ary).each_cons(3)\n .map {|l,m,r| (l+2.0*m+r)/4.0 }\nend",
"def snail4(array)\n array.shift + snail(array.transpose.reverse)\nend",
"def grid\n \t\t\tfinal, y = Array.new, 0\n \t\t\t@@axis.fetch(:y).times do\n \t\t\t\tfinal[y], x = Array.new, 0\n \t\t\t\t@@axis.fetch(:x).times do\n \t\t\t\t\tfinal[y][x] = init_coord(x, y)\n \t\t\t\t\tx += 1\n \t\t\t\tend\n \t\t\t\ty += 1\n\t\t\tend\n\t\t\tfinal.reverse\n\t\tend",
"def populate_adjacency_list_via_array(array)\n @vertices = array.flatten.uniq.map { |v| Vertex.new('WHITE', 1, nil, [], v) }\n # Only directed edges are being added to the edges list\n @edges = array.map { |edge| Edge.new(find(edge[0]), find(edge[1])) }\n populate_adjacency_list\n end",
"def pyramid(n)\n arr = Array.new(n)\n\n for i in 0..arr.length-1\n arr[i] = Array.new(n)\n end\n\n for y in 0..n/2\n if y == n/2\n if arr[y][y] == nil?\n arr[y][y] = y+1\n end\n break\n end\n for x in y..n-2-y\n arr[y][x] = y+1\n arr[x][n-1-y] = y+1\n arr[n-1-y][n-1-y-x] = y+1\n arr[n-1-y-x][y] = y+1\n end\n end\n\n for a in 0..arr.length-1\n for b in 0..arr[a].length-1\n print \"[#{arr[a][b]}]\"\n end\n print \"\\n\"\n end\n\n return arr\nend",
"def snail(array)\n\n array_size = array.length\n\n if array == [[]]\n return []\n end\n\n array_to_return = []\n\n while array.length > 1 do\n# step 1 - copy out the \"top\" row of elements from the snail, and delete it\n array.delete_at(0).each { |element| array_to_return.push(element)}\n\n# step 2 - pop the last elements of the remaining arrays, going down the \"right side\" of the snail\n array.each { |sub_array| array_to_return.push(sub_array.pop)}\n\n# (need a break clause for 2 x 2 arrays)\n if array_size == 2\n array_to_return.push(array[0].pop)\n end\n\n# step 3 - we now have an n-1 x n-1 sized array. time to capture the \"bottom row\" in reverse order\n array.delete_at(array.length - 1).reverse_each { |element| array_to_return.push(element)}\n\n# step 4 - finally, we go back up the 'left side', removing and capturing the first elements of the remaining arrays\n array.reverse_each { |sub_array| array_to_return.push(sub_array.delete_at(0))}\n end\n\n# final conditional to capture the element left over by odd sized arrays (3x3, 5x5 etc.)\n if array_size.odd?\n array_to_return.push(array[0].pop)\n end\n\n array_to_return\n\nend",
"def iterative n\n return TRIANGLE[n] if n < 2\n\n i = 1\n prev = TRIANGLE[i - 1]\n row = TRIANGLE[i]\n while i <= n do\n prev = row\n row = [1]\n i += 1\n\n prev.each_cons(2) do |a, b|\n row << a + b\n end\n row << 1\n end\n\n return prev\nend",
"def triplify(arr)\n arr.map do |num|\n num * 3\n end\nend",
"def lattice_paths(n_grid)\n # 1) creat a grid (n+1) x (n+1) with all initialize with 1\n grid = Array.new(n_grid + 1) { Array.new(n_grid + 1, 1) }\n\n # 2) iterate through grid\n for row in (0..n_grid)\n for col in (0..n_grid)\n if row - 1 >= 0 && col - 1 >= 0\n # if row-1, col-1 exists, the sum is the value for gird[row, col]\n grid[row][col] = grid[row][col-1] + grid[row-1][col]\n end\n end\n end\n\n #3) return last element in the array\n return grid[n_grid][n_grid]\nend",
"def triangle(n)\n count = 1\n loop do\n p (' ' * (n - count)) + ('*' * count)\n count += 1\n break if count > n\n end\nend",
"def make_grid()\n grid = Array.new(GRID_SIZE) { Array.new(GRID_SIZE) }\n ## Build init grid\n x = 1\n y = 1\n File.readlines(FILENAME).each do |line|\n x = 1\n line.chars.each do |char|\n grid[y][x] = char\n x += 1\n end\n y += 1\n end\n grid\nend",
"def flatten_grid\n height = grid.row_size\n width = grid.column_size\n for i in 0...height\n for j in 0...width\n @grid[i,j].flatten!\n end\n end\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def read_valid_triangles_by_col file_path\n IO.foreach(file_path)\n .map {|line| line.split(\" \").map(&:to_i) }\n .each_slice(3)\n .flat_map {|lines|\n [[lines[0][0], lines[1][0], lines[2][0]],\n [lines[0][1], lines[1][1], lines[2][1]],\n [lines[0][2], lines[1][2], lines[2][2]]]\n }\n .select {|t| valid_triangle? t }\n end",
"def rotate(n)\n ## Builds a grid NXN filled with 0's.\n grid = Array.new(n) { Array.new(n) {0} }\n ## Builds new grid for output\n new_grid = Array.new(n) { Array.new(n) }\n\n ## Iterate through each array/row\n grid.each_with_index do |array, row|\n ## Then by each col of that row\n array.each_with_index do |element, col_index|\n new_grid[col_index][-(row+1)] = element\n end\n end\n new_grid\nend",
"def iterate(arr)\n newArr = []\n (0...arr.size).each do |row|\n newArr[row] = []\n (0...arr.size).each do |col|\n num_neighbors = num_neighbors(row,col,arr)\n if arr[row][col]\n if num_neighbors == 2 || num_neighbors == 3\n newArr[row][col] = true\n else\n newArr[row][col] = false\n end\n else\n if num_neighbors == 3\n newArr[row][col] = true\n else\n newArr[row][col] = false\n end\n end\n end\n end\n arr = newArr\nend",
"def triplify(array)\n \t \n \t new_array = array.map { |i| i * 3 }\n \t p new_array\n end",
"def test_with_irregular_array3D4; show([[[0,1,0.5,0.7]]]) end",
"def triangle(n)\n arr = []\n space = (n - 1)\n star = 1\n \n until n == 0 do\n (space).times do\n arr.push(\" \")\n end\n (star).times do \n arr.push(\"*\")\n end\n puts arr.join\n arr.clear\n space -= 1\n star += 1\n n -= 1\n end\nend",
"def triangle(atomids)\n if atomids.size != 3\n raise SizeError\n end\n atoms = []\n atomids.each do |atomid|\n atom = atom_by_id(atomid)\n raise AtomNotFoundError, atomid unless atom\n atoms << atom\n end\n #pp atoms\n tri = CrystalCell::Povray::Triangle.new(\n *atoms.map { |atom| atom.position.to_v3d(self.axes)},\n CrystalCell::Povray::Element.color( atoms[0].element)\n )\n tri.to_pov\n end",
"def triangle(n)\n n.times{ |i| puts \"#{' ' * (n-i+1)}#{'*' * (i+1)}\" }\nend",
"def triangle(side1, side2, side3)\n arr = [side1, side2, side3].sort\n return :invalid if arr[0] + arr[1] <= arr[2]\n return :equilateral if arr[0] == arr[1] && arr[1] == arr[2]\n return :isosceles if arr.uniq.size == 2\n return :scalene if arr.uniq.size == 3\nend",
"def triangle(side1, side2, side3)\n sides = [side1, side2, side3]\n return :invalid if sides.max > sides.sum / 2 || sides.min.zero?\n case sides.uniq.size\n when 1 then :equilateral\n when 2 then :isosceles\n else :scalene\n end\nend",
"def print_grid(points,size)\n grid = []\n for i in 0..size-1\n grid.push([])\n for j in 0..size-1\n if points.include? [j,i]\n # grid.last.push(\"#{j.to_s.reverse[0]}#{i.to_s.reverse[0]}\")\n grid.last.push(\"#{j}#{i}\")\n else\n grid.last.push(\"__\")\n end\n end\n end\n grid.reverse!\n grid.map {|x| puts x.join(\" \")}\nend",
"def render\n # Every cell is an individual quad\n # using the propane grid convenience function instead of a nested loop\n grid(z.size - 1, z[0].size - 1) do |x, y|\n # one quad at a time\n # each quad's color is determined by the height value at each vertex\n # (clean this part up)\n no_stroke\n push_matrix\n begin_shape(PConstant::QUADS)\n translate(x * scl - w * 0.5, y * scl - h * 0.5, 0)\n fill(z[x][y] + 127, 220)\n vertex(0, 0, z[x][y])\n fill(z[x + 1][y] + 127, 220)\n vertex(scl, 0, z[x + 1][y])\n fill(z[x + 1][y + 1] + 127, 220)\n vertex(scl, scl, z[x + 1][y + 1])\n fill(z[x][y + 1] + 127, 220)\n vertex(0, scl, z[x][y + 1])\n end_shape\n pop_matrix\n end\n end",
"def get_subgrid(cords)\n subgrid = []\n x_pos = cords[0] - cords[0] % 3\n (x_pos..x_pos + 2).each do |row_num|\n y_pos = cords[1] - cords[1] % 3\n subgrid += @grid[row_num][y_pos, 3]\n end\n subgrid\n end",
"def getTri()\n\t#open file\n\tf=File.open(\"tri.txt\", \"r\")\n\t#init tri array\n\ttri = []\n\t#for each line\n\tf.each_line do |line|\n\t\t#strip end line chars\n\t\tline.strip!\n\t\t#read into array of fixnum\n\t\ttri << line.split(' ').map(&:to_i)\n\tend\n\t#close file\n\tf.close\n\t#return triangle array\n\treturn tri\nend",
"def triangle_pixels(tile_x, tile_y, side)\n quad_size = tile_size / 2\n\n case side\n when :top\n p1 = [tile_x, tile_y]\n p2 = [tile_x + tile_size, tile_y + quad_size]\n when :left\n p1 = [tile_x, tile_y]\n p2 = [tile_x + quad_size, tile_y + tile_size]\n when :bottom\n p1 = [tile_x, tile_y + quad_size]\n p2 = [tile_x + tile_size, tile_y + tile_size]\n when :right\n p1 = [tile_x + quad_size, tile_y]\n p2 = [tile_x + tile_size, tile_y + tile_size]\n end\n\n p1 = ChunkyPNG.Point(p1)\n p2 = ChunkyPNG.Point(p2)\n\n [].tap do |pixels|\n (p1.x...p2.x).each do |x|\n (p1.y...p2.y).each do |y|\n pixels << image.get_pixel(x, y)\n end\n end\n end\n end",
"def print_triangle(rows)\n n = 1\n while n <= rows\n n += 1\n x = 1\n while x < n\t\n \tprint \"*\"\n \tx += 1\n end\n puts ' '\n end \nend",
"def create_board(array)\n num = array.length\n board = Array.new(num) { Array.new(num, false) }\n array.each_with_index { |board_position, row| board[row][board_position - 1] = true }\n board\nend",
"def pascals_triangle(num)\n triangle = [[1]]\n\n while triangle.length < num\n above = triangle.last\n next_level = [1]\n next_level += adjacent_sums(above)\n next_level << 1\n triangle << next_level\n end\n triangle\nend",
"def grid3d(*)\n super\n end",
"def initiate_grid\n new_grid = []\n @width.times do |x|\n new_grid[x] = []\n @height.times do |y|\n new_grid[x][y] = 0\n end\n end\n new_grid\n end",
"def create_triangle(box_y_start, value_x, up_triangle, box_mult, colorstr)\n x_points = Array.new\n x_points << value_x - @box_size*box_mult * Math.sqrt(2)*0.2\n x_points << value_x + @box_size*box_mult * Math.sqrt(2)*0.2\n # third point is midway between other 2\n x_points << (x_points[0]+x_points[1])/2\n\n y_points = Array.new\n\t y_points << box_y_start\n\t y_points << box_y_start\n\t if up_triangle\n y_points << box_y_start - @box_size*box_mult * Math.sqrt(2) *0.35\n else\n y_points << box_y_start + @box_size*box_mult * Math.sqrt(2) *0.35\n\t end\n\n\t return Triangle.new(x_points, y_points, colorstr)\n end",
"def pascals_triangle(num)\n triangle = [[1]]\n while triangle.length < num\n level_above = triangle.last\n next_level = [1]\n next_level += adjacent_sums(level_above)\n next_level << 1\n triangle << next_level\n end\n triangle\nend",
"def triangle(n)\n (n *(n + 1)) / 2\nend",
"def gen_array(grid_size)\n\t\ti = 0\n\t\twhile i < grid_size do\n\t\t\t@board_display.push(0)\n\t\t\ti += 1\n\t\tend\n\tend",
"def triangle_sequence(nth)\n sequence = []\n (1..nth).each do |x|\n sequence.push( x * (x + 1) / 2 )\n end\n return sequence\nend",
"def cubes(array)\n array.map { |number| number ** 3 }\nend",
"def setup_triangles(background)\n gc = Magick::Draw.new\n gc.stroke_width(2)\n gc.stroke(\"red\")\n gc.fill(\"blue\")\n # all the triangles are part of the same body\n body = CP::Body.new(Float::MAX, Float::MAX)\n base = 15\n height = 10\n shape_vertices = [CP::Vec2.new(-base, base), CP::Vec2.new(base, base), CP::Vec2.new(0, -height)]\n # make shapes and images\n 8.times do |i|\n 8.times do |j|\n stagger = (j % 2) * 40\n x = i * 80 + stagger\n y = j * 70 + 80\n shape = CP::Shape::Poly.new(body, shape_vertices, CP::Vec2.new(x, y))\n shape.e = 1\n shape.u = 1\n @space.add_static_shape(shape)\n gc.polygon(x - base + 1, y + base - 1, x + base - 1, y + base - 1, x, y - height + 1)\n end\n end\n # do the drawing\n gc.draw(background)\n end",
"def triangle_interp str\r\n\ttriangle = str.split(/\\n/)\r\n\ttriangle.each_with_index { |row, i| triangle[i] = row.split(/\\s/)}\r\nend",
"def triangle(n)\n counter = 1\n\n loop do\n puts \"#{' ' * (n-counter)}#{'*' * counter}\"\n counter += 1\n break if counter > n\n end\nend",
"def walk_grid(g, n)\n Enumerator.new do |enum|\n 0.upto(g.size-1) do |y|\n 0.upto(g.size-1) do |x|\n x_ok = x < (g.size-n)\n y_ok = y < (g.size-n)\n enum.yield :horizontal, fetch_tuple(g, x, y, 1, 0, n) if x_ok\n enum.yield :vertical, fetch_tuple(g, x, y, 0, 1, n) if y_ok\n enum.yield :diagonal, fetch_tuple(g, x, y, 1, 1, n) if x_ok && y_ok\n end\n end\n end.lazy\nend"
] | [
"0.62033063",
"0.60679984",
"0.6010272",
"0.58452564",
"0.58127",
"0.5795336",
"0.5707064",
"0.57053405",
"0.56979764",
"0.5663744",
"0.55985594",
"0.5590872",
"0.55771965",
"0.55767393",
"0.5552159",
"0.55489373",
"0.553704",
"0.5499699",
"0.5486645",
"0.54455215",
"0.53211874",
"0.5319198",
"0.52683645",
"0.52547354",
"0.5211066",
"0.5208506",
"0.51854414",
"0.5156775",
"0.51316756",
"0.5103952",
"0.50623214",
"0.50549453",
"0.50543714",
"0.50479174",
"0.50432414",
"0.50414705",
"0.5035922",
"0.50279224",
"0.5012531",
"0.5010758",
"0.49961403",
"0.4986875",
"0.49862567",
"0.4980726",
"0.49672127",
"0.49549362",
"0.4954213",
"0.49413818",
"0.49384543",
"0.49282143",
"0.49255598",
"0.4906942",
"0.4885748",
"0.48795122",
"0.48721552",
"0.48682898",
"0.4857417",
"0.4840765",
"0.4820143",
"0.4818489",
"0.48127973",
"0.48088786",
"0.48068738",
"0.48033673",
"0.4799995",
"0.47982597",
"0.4795448",
"0.47844347",
"0.47822276",
"0.4777762",
"0.47701442",
"0.47636276",
"0.4759114",
"0.47443897",
"0.47397617",
"0.4735228",
"0.4734301",
"0.47326678",
"0.47263256",
"0.47213885",
"0.4718962",
"0.47161293",
"0.47153535",
"0.46944004",
"0.46938252",
"0.4686841",
"0.46829432",
"0.46757174",
"0.46752676",
"0.4670892",
"0.46577904",
"0.46464798",
"0.46448648",
"0.4641622",
"0.4636313",
"0.46329132",
"0.4632814",
"0.46315506",
"0.46314567",
"0.46224934"
] | 0.7099372 | 0 |
Initialize Author: Puneet Date: 02/02/2018 Reviewed By: Sunil | def initialize(data)
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(title, author)\n @title = title\n @author = author\nend",
"def initialize(title, author,year=\"unknown\", edition=\"unknown\")\n @title = title\n @author = author\n @checked_out = false\n @current_patron = nil\n @year_published = year\n @edition = edition\n @reviews = {}\n end",
"def initialize(title, author)\n @title = title\n @author = author\n end",
"def initialize(title, author)\n# stores title and author as instance variables\n @title = title \n @author = author\n# sets instance variables, @status and @borrower, to default values.\n @status = \"available\"\n @borrower = nil\n end",
"def initialize(author, title)\n @author = author\n @title = title\n end",
"def initialize(title:, author:, release_date:, publisher:, isbn:)\n @title = title\n @author = author\n @release_date = release_date\n @publisher = publisher\n @isbn = isbn\n end",
"def initialize author:, title:, summary:, images:, source:, date:\n @author = author\n @title = title\n @summary = summary\n @images = images\n @source = source\n @date = date\n end",
"def initialize author, title, body, comments = []\n @author = author\n @title = title\n @body = body\n @comments = comments\n end",
"def initialize (author, content)\n @author = author\n @content = content\nend",
"def initialize(title, author, content)\n @title = title\n @author = author\n @content = content\n end",
"def initialize(title, author, desc, year, edition, num_copies)\n @title = title\n @author = author\n @desc = desc\n @year = year\n @num_copies = num_copies\n @year = year\n @edition = edition\n\n @num_copies = num_copies\n @num_in = @num_copies\n @num_out = 0\n @borrowed_by = []\n @reviews = []\n @ratings = []\n @future_check_out = {}\n end",
"def initialize(title:, author:, release_date:, publisher:, isbn:)\n @title = title\n @author = author\n @release_date = release_date\n @publisher = publisher\n @isbn = isbn\n \n @errors = []\n end",
"def initialize(title, author, isbn)\n @title = title\n @author = author\n @isbn = isbn\nend",
"def initialize(title, author)\n @author = author\n @title = title\n @status = \"available\"\n @check_out_date\n @due_date\n @who_checked\n end",
"def initialize(title, author, isbn)\n @title = title\n @author = author\n @isbn = isbn\n\n @due_date = @@due_date\n end",
"def initialize(title, author, isbn)\n @title = title\n @author = author\n @isbn = isbn\n end",
"def initialize(author, content)\n @author = author\n @content = content\n end",
"def initialize(author, content)\n @author = author\n @content = content\n end",
"def initialize(title, entry, author)\n\t\t@title = title\n\t\t@entry = entry\n\t\t@author = author\n\tend",
"def initialize author:, title:, summary:, images:, source:, date:, document_type:, section_name:\r\n super author: author, title: title, summary: summary, images: images, source: source, date: date\r\n @document_type = document_type\r\n @section_name = section_name\r\n end",
"def initialize(author, content)\n\t\t@author = author\n\t\t@content = content\n\t\t#@comments = comments\n\tend",
"def initilize(user_name = 'you')\n @reader = user_name\n @authors = %w(sugamasao takkanm hibariya ryopeko)\n end",
"def initialize #initializes post belonging to author \r\n @post = author\r\n end",
"def author; end",
"def initialize edition, contents, year\n\t\t@edition = edition\n\t\t@contents = contents\n\t\t@year = year\n\tend",
"def initialize(title, author, isbn, available)\n @title = title\n @author = author\n @isbn = isbn\n @available = available\n end",
"def initialize(author, content)\n @content = content\n @author = author\n \n end",
"def initialize(title, author, page)\n @title=title\n @author=author\n @page=page\n end",
"def initialize(details)\r\n\t\t@name=details[:name]\r\n\t\t@language=details[:language]\r\n\t\t@release_date=details[:release_date]\r\n\tend",
"def initialize(title, author, price)\n @title = title\n @author = author\n @price = price\n end",
"def initialize(author, title, published_date, edition = 1)\n @title = title\n @published_date = published_date\n @edition = edition\n @author = author\n\n @@all << self\n end",
"def initialize(name) #instances initialized via argument of Author's name\n @name = name #set the Authors name local var to an instance var\n @posts = [] #set instance var posts to empty array to catch all instances\n end",
"def initialize(title, author, price)\n @title = title\n @author = author\n @price = price\n end",
"def initialize(attributes = {})\n attributes.each do |name, value|\n instance_variable_set(:\"@#{name}\", value)\n end\n\n # Split out the author list and format it\n @author_list = @authors.split(',').map { |a| a.strip } unless @authors.nil?\n @formatted_author_list = @author_list.map { |a| BibTeX::Names.parse(a)[0] } unless @author_list.nil?\n end",
"def initialize(title,author,isbn)\n @title = title\n @author = author\n @isbn = isbn.to_i\n# @borrow = false\n end",
"def initialize(details)\r\n\t\t@name = details[:name]\r\n\t\t@language = details[:language]\r\n\t\t@release_date = details[:release_date]\r\n\r\n\t end",
"def author; @author; end",
"def author; @author; 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(author, content)\n @content = content\n @author = author\n end",
"def print_init_status\n\t\tset_status(@ctx_init_id, \"by #{RsConfig::AUTHOR_FULLNAME} #{RsConfig::AUTHOR_PROMO} - (c) #{Time.now.year}\")\n\tend",
"def initialize (title, artist, genre)\n # insert lines here\n @title = title\n @artist = artist\n\t\t@genre = genre\n\tend",
"def\n initialize(id, title, author)\n @id = id\n @title = title\n @author = author\n @due_date = nil\n end",
"def\n initialize(id, title, author)\n @id = id\n @title = title\n @author = author\n @due_date = nil\n end",
"def user_init; end",
"def initialize(cult, follower)\n @cult = cult\n @follower = follower\n\n #calculate time into right format _YYYY-MM-DD_\n # time_str = \"\"\n # time_str = Time.now.to_s\n time_str = Time.now.to_s.split(\" \")[0]\n\n\n @initiation_date = \"_#{time_str}_\"\n\n @@all << self\n end",
"def initialize(author, time)\n @author = author\n @time = time\n freeze\n end",
"def initialize(attributes = {})\n super\n\n # Don't let any blank strings hang around as values for the Solr\n # fields. This prevents a whole lot of #blank? and #present? calls\n # throughout. Also note that we're explicitly not setting the\n # authors here, that's done specially.\n %i[uid doi license license_url data_source title journal year volume\n number pages].each do |a|\n value = send(a)\n send(\"#{a}=\".to_sym, nil) if value&.strip&.empty?\n end\n\n # Convert the authors into an authors object (and do this even if the\n # string is nil or blank)\n self.authors = RLetters::Documents::Authors.from_list(authors)\n end",
"def initialize(attributes={}) #can set instance variables when creating the instance\n @name = attributes[:name]\n @major = attributes[:major]\n @course = attributes[:course]\n @grade = attributes[:grade]\n end",
"def initialize(title, year)\n @title = \"#{title}\"\n @year_released = \"#{year}\"\n @years_ago = 2015 - @year_released\n end",
"def author_hash; end",
"def initialize (title, artist, genre)\n\t\t# insert lines here\n\t\t@genre = genre\n\tend",
"def initialize(title)\n @title = title\n @author = author\n @@all << self\n end",
"def initialize(first_name, last_name, email, notes) #make a hash so that you can extend more and get nil if you dont have the info\n\t\t@first_name = first_name\n\t\t@last_name = last_name\n\t\t@email = email\n\t\t@notes = notes\n\n\t\t@id = @@id\n\t\t@@id += 1\n\tend",
"def initialize( text, user = nil )\n\t\t\t@comment = text\n\t\t\t@created = DateTime.now()\n\t\t\t@created_by = user == nil ? Etc.getlogin() : user\n\t\tend",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize\r\n\r\n end",
"def initialize\n puts 'GitHub Archiver Challenge'\n # get_input\n get_data\n end",
"def initialize(name, major, year)\n \n @stud_name = name #instance variable for name\n @stud_major = major #instance variable for major\n @stud_year = year #instance variable for year\n end",
"def initialize\n\t\t\n\tend",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def init\n end",
"def init\n end",
"def init\n end",
"def author\n @author ||= get_author\n end",
"def initialize(name, creator)\n @name = name\n @creator = creator\n end",
"def initialize(name, age, hometown) #attributes are determined here\n @name = name\n @age = age\n @hometown = hometown\n end",
"def init\n\n end",
"def initialize(title, date, content)\n\t\t@title = title\n\t\t@date = date\n\t\t@content = content\n\tend",
"def initialize( ticket, comment, original_n, user = nil )\n\t\t\t@created = DateTime.now()\n\t\t\t@ticket = ticket\n\t\t\t@comment = comment\n\t\t\t@created_by = user == nil ? Etc.getlogin() : user\n\t\t\tself.original_name = original_n\n\t\tend",
"def author\n @author ||= Person.new(connection, @attributes[:author])\n end",
"def initialize(first_name, last_name, year_of_birth) # => states\n @first_name = first_name # => instences variable\n @last_name = last_name # => instences variable\n @year_of_birth = year_of_birth # => instences variable\n @job_title = 'Baby'\n end",
"def initialize(args)\n @isbn = args[:isbn] \n @title = args[:title]\n end",
"def initialize()\n\t\t@id = id\n\t\t@first_name = first_name\n\t\t@last_name = last_name\n\t\t@email = email\n\t\t@twitterID = twitterID\n\t\t@notes = notes\n\tend",
"def initialize(reviewHash)\n @critic = reviewHash[\"critic\"]\n @date = reviewHash[\"date\"]\n @publication = reviewHash[\"publication\"]\n @quote = reviewHash[\"quote\"]\n @links = reviewHash[\"links\"]\n @freshness = reviewHash[\"freshness\"]\n end",
"def initialize(name)\n @name = name\n puts \"Welcome to our Library #{@name}. Here's your library card.\" \n @books = [] \n end",
"def initialize(first_name, last_name, year_of_birth) # => states\n @first_name = first_name # => instence variable\n @last_name = last_name # => instence variable\n @year_of_birth = year_of_birth # => instence variable\n @job_title = 'Baby'\n end",
"def pre_initialize; end",
"def initialize(title, author, pages)\n @title = title\n @author = author\n @pages = pages\n end",
"def initialize(release_date)\n @release_date = release_date\n end",
"def resolved_author; end",
"def initialize() end",
"def initialize(\n\t\tfirst_name, \n\t\tlast_name, \n\t\temail, \n\t\tnote\n\t)\n\t\t@first_name = first_name\n\t\t@last_name = last_name\n\t\t@email = email\n\t\t@note = note\n\tend",
"def pre_initialize\n end",
"def initialize(args = [])\n @id = \"No information available\"\n @first_name = \"No information available\"\n @last_name = \"No information available\"\n @gender = \"No information available\"\n @age = \"No information available\"\n @birthdate = \"No information available\"\n end",
"def initialize\n \n end",
"def initialize name\n @name = name\n @version = nil\n @author = nil\n @files = {}\n end",
"def author\n @info[:Author]\n end",
"def initialize(title)\n @title = title \n end",
"def initialize(full_name, age, address, work)\n\tend",
"def initialize( title, description, url)\n #storing inside instance variables so they can be used anywhere else in the class.\n @title = title\n @description = description\n @url = url\n end",
"def initialize(doc); end",
"def initialize(title, source) #why am I not passing upvote as an argument for initialize?\n\t\t@title = title\n\t\t@source = source\n\t\t@upvote = 0\n\tend",
"def initialize(title, first_name, middle_name, last_name)\n\t\t@title = title\n\t\t@first_name = first_name\n\t\t@middle_name = middle_name\n\t\t@last_name = last_name\n\tend",
"def initialize (attributes = {})\n @id = attributes[:id]\n @title = attributes[:title]\n @picture = attributes[:picture]\n @previous_picture = attributes[:previous_picture]\n @content = attributes[:content]\n @_links = attributes[:_links]\n @creator_email = attributes[:creator_email]\n @creatorProfile = attributes[:creatorProfile]\n if !attributes[:date].blank?\n @date = attributes[:date]#milliseconds passed since epoch Jan/1/1970\n else\n @date = Util.date_to_epoch(Time.now.strftime(I18n.t(:date_format_ruby)))\n end\n end",
"def author\n @author ||= Readability::Document.new(@html).author\n end",
"def initialize(revision, message, author)\n @revision = revision\n @message = message\n @author = author\n freeze\n end"
] | [
"0.7232199",
"0.7211749",
"0.71372503",
"0.7125025",
"0.70742327",
"0.7046248",
"0.6949262",
"0.6947915",
"0.69212437",
"0.6879615",
"0.68517184",
"0.6827688",
"0.67746025",
"0.675069",
"0.67459995",
"0.6734091",
"0.67256474",
"0.67256474",
"0.6716489",
"0.66928846",
"0.6681711",
"0.6668454",
"0.6632369",
"0.65782964",
"0.65549654",
"0.65267134",
"0.6510741",
"0.65014803",
"0.64946455",
"0.6459265",
"0.6451349",
"0.6450521",
"0.6434804",
"0.64207906",
"0.64101285",
"0.63895136",
"0.63644415",
"0.63644415",
"0.6347015",
"0.6334316",
"0.6289771",
"0.6279218",
"0.6277131",
"0.6277131",
"0.6208768",
"0.62006366",
"0.61804134",
"0.61622256",
"0.614498",
"0.6131779",
"0.61284155",
"0.6112456",
"0.6104387",
"0.609365",
"0.6079608",
"0.60530424",
"0.60530424",
"0.60530424",
"0.60530424",
"0.60470635",
"0.60451907",
"0.6038182",
"0.6036256",
"0.6033223",
"0.6033223",
"0.60275537",
"0.60275537",
"0.60275537",
"0.6027483",
"0.60253954",
"0.60211045",
"0.6020968",
"0.60190785",
"0.60176957",
"0.60148454",
"0.60112256",
"0.60081434",
"0.6004442",
"0.6003748",
"0.5989963",
"0.59898937",
"0.59842044",
"0.5980513",
"0.5977763",
"0.59754014",
"0.5974592",
"0.5972214",
"0.5971584",
"0.59702003",
"0.59625196",
"0.5957814",
"0.59572464",
"0.595346",
"0.5953445",
"0.59532005",
"0.59498066",
"0.5946239",
"0.5945167",
"0.594271",
"0.59252214",
"0.59146965"
] | 0.0 | -1 |
Perform Author: Puneet Date: 02/02/2018 Reviewed By: Sunil | def perform
set_user(@data['user'])
set_client_token(@data['client_token'])
set_oracle_price_points(@data['oracle_price_points'])
set_pending_critical_interactions(@data['pending_critical_interactions']) if @data['pending_critical_interactions'].present?
set_client_token_planner(@data['client_token_planner']) if @data['client_token_planner'].present?
set_chain_interaction_params(@data['chain_interaction_params']) if @data['chain_interaction_params'].present?
set_client_balances(@data['client_balances']) if @data['client_balances'].present?
set_token_supply_details(@data['token_supply_details']) if @data['token_supply_details'].present?
set_client_stats(@data['client_stats']) if @data['client_stats'].present?
set_api_console_data(@data['api_console_data']) if @data['api_console_data'].present?
set_client_bt_addresses_data(@data['client_bt_addresses']) if @data['client_bt_addresses'].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paper\n reviewer_recommendations_task.paper\n end",
"def pre_submission_date_status\n 'New Announcement'\n end",
"def review_committee_decision\n application_review_decision_type.title if application_review_decision_type\n end",
"def description_complexity(pr)\n pull_req = pull_req_entry(pr[:id])\n (pull_req['title'] + ' ' + pull_req['body']).gsub(/[\\n\\r]\\s+/, ' ').split(/\\s+/).size\n end",
"def submission_decision_author(submission)\n @submission = submission\n\n @authors_text = @submission.get_authors_submitted.map{ |a| a.full_name }.join(', ')\n @title_text = @submission.get_text_submitted.title rescue ''\n\n @journal = @submission.journal\n @user = @submission.user\n @submission_url = submission_url(submission)\n @submission_editor_url = e_submission_url(submission)\n @submission_reviewer_url = r_submission_url(submission)\n\n @decision = @submission.lsr.decision_2 || @submission.lsr.decision_1_cold || @submission.lsr.decision_1\n\n if @decision\n case @decision.decision\n when 'take_for_consideration'\n# subject = \"#{@journal.slug}##{submission.id} The paper was taken for consideration | Статья принята к рассмотрению\"\n subject = \"##{@submission.id} Taken for consideration. Journal Gyroscopy and Navigation | Принято к рассмотрению. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_take_for_consideration' }\n\t\t end\n when 'reject_without_consideration'\n# subject = \"#{@journal.slug}##{submission.id} The paper was rejected without consideration | Статья отклонена без рассмотрения\"\n subject = \"##{@submission.id} Rejected without consideration. Journal Gyroscopy and Navigation | Отклонено без рассмотрения. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_reject_without_consideration' }\n\t\t end\n when 'reject'\n# subject = \"#{@journal.slug}##{submission.id} The paper was rejected | Статья отклонена\"\n subject = \"##{@submission.id} Paper rejected. Journal Gyroscopy and Navigation | Статья отклонена. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_reject' }\n\t\t end\n when 'revise'\n# subject = \"#{@journal.slug}##{submission.id} The paper must be revised | Статью надо доработать\"\n subject = \"##{@submission.id} Paper must be revised. Journal Gyroscopy and Navigation | Статью надо доработать. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_revise' }\n\t\t end\n when 'accept'\n# subject = \"#{@journal.slug}##{submission.id} The paper was accepted | Статья принята\"\n subject = \"##{@submission.id} Paper accepted. Journal Gyroscopy and Navigation | Статья принята. Журнал \\\"Гироскопия и навигация\\\"\"\n \t\tmail(to: @user.email, subject: subject) do |format|\n format.text { render 'submission_decision_author_accept' }\n\t\t end\n when 'wait_decision'\n # Add email for transition to this this state???\n nil\n end\n end\n end",
"def review; end",
"def process_created_review(review_payload)\n pr_name = review_payload['repository']['full_name'].to_s\n pr_number = review_payload['pull_request']['number'].to_s\n comment_user = review_payload['review']['user']['id'].to_s\n approvals = evaluate_review_state(review_payload['review']['state'])\n current_commit_hash = review_payload['pull_request']['head']['sha'].to_s\n\n submit_status(pr_name, pr_number, current_commit_hash, comment_user, approvals)\n end",
"def reviewer_report_task_phase\n get_reviews_phase = paper.phases.where(name: 'Get Reviews').first\n get_reviews_phase || phase\n end",
"def release_summary title = nil\n datestamp_title = title ? Time.now.strftime(\"(%-m/%d) #{title}:\") : Time.now.strftime(\"%-m/%d:\")\n\n if done_cards.empty?\n datestamp_title + \" Nada. 😢\"\n else\n ([datestamp_title] + done_cards.map { |card| '- ' + card['note'] }).join \"\\n\"\n end\nend",
"def reference_document\n if document.blank?\n \"None Assigned\"\n else\n document.refno+\" : \"+document.title+\" : dated \"+document.letterdt.strftime(\"%d-%b-%Y\").to_s\n end\n end",
"def performed_by(params = {})\n #TODO\n end",
"def review\n end",
"def assessment_type_author\n frm.div(:class=>\"tier2\").table(:index=>$frame_index)[1][1].text\n end",
"def pre_initiation_date_status\n 'Pre-announcement'\n end",
"def interview_committee_decision\n application_interview_decision_type.title if application_interview_decision_type\n end",
"def review(*)\n super.tap do\n __debug_sim('REVIEWER initiates review of the submission.')\n end\n end",
"def create_weblog_explain; \"Create a brand new weblog.\"; end",
"def prt\n puts \"Federalist #@fedno\"\n puts \"Title: \" + @title.join(\" \")\n puts \"Publication: \" + @publication.join(\" \")\n puts \"Author: \" + @author.join(\" \")\n \n end",
"def author; end",
"def completed_text_extraction\n end",
"def pr_description\n danger_file.warn('Please provide a summary in the Pull Request description') if danger_file.github.pr_body.length < 3 && danger_file.git.lines_of_code > 10\n end",
"def generate_department_review_title \n review_type = self.scorable_type\n case review_type\n when \"GovernmentScore\"\n self.title = \"#{self.user.name}'s Government Review\"\n when \"ParkScore\"\n self.title = \"#{self.user.name}'s Parks Review\"\n when \"SchoolScore\"\n self.title = \"#{self.user.name}'s Schools Review\"\n when \"PoliceScore\"\n self.title = \"#{self.user.name}'s Police Review\"\n when \"PublicScore\"\n self.title = \"#{self.user.name}'s Public Works Review\"\n end\n end",
"def educational_attainment; end",
"def under_review_status\n 'Under Review'\n end",
"def author; @author; end",
"def author; @author; end",
"def purpose\n end",
"def modeler_description\n return 'This measure swaps old cases with 2017 code compliant cases and more efficient ones.'\n end",
"def resolved_author; end",
"def reviewed_date_time\n return @reviewed_date_time\n end",
"def users_role_with_this_submission(user)\n if self.corresponding_author == user\n return 'Corresponding Author'\n elsif self.coauthors.include?(user)\n return 'Coauthor'\n elsif self.reviewers.include?(user)\n return 'Reviewer'\n elsif section_editors.include?(user)\n return 'Section Editor'\n else\n return 'This user is not associated with this manuscript'\n end \n end",
"def publication_date\n end",
"def essay_writer(title, name, major_accomplishment, year_of_accomplishment, thesis, pronoun)\n\tputs \"Final Assignment Essay:\\n #{title}\n\t\\n\n\t#{date_of_accomplishment} was the year of #{name}. #{major_accomplishment.capitalize},\n\tdoes that ring a bell? That was all thanks to #{name}. \\n \n\t#{thesis} \\n\n\tMuch more could be said of #{name}. #{pronoun.capitalize} is somebody worth remembering. \n\t\"\n\t\nend",
"def vacate_at_attorney_review(mtv_judge, drafting_attorney, lit_support_user)\n # These are ready to be reviewed by the decision drafting attorney on the vacate stream\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"denied\")\n judge_addresses_mtv(jam_task, \"denied\", nil, lit_support_user)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"dismissed\")\n judge_addresses_mtv(jam_task, \"dismissed\", nil, lit_support_user)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"granted\")\n judge_addresses_mtv(jam_task, \"granted\", \"straight_vacate\", drafting_attorney)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"granted\")\n judge_addresses_mtv(jam_task, \"granted\", \"vacate_and_readjudication\", drafting_attorney)\n end\n\n 3.times do\n original_stream = create_decided_appeal(mtv_judge, drafting_attorney)\n mtv_task = create_motion_to_vacate_mail_task(original_stream)\n mtv_task.update!(status: \"on_hold\")\n jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, \"granted\")\n judge_addresses_mtv(jam_task, \"granted\", \"vacate_and_de_novo\", drafting_attorney)\n end\n end",
"def page_title\n \"Changes Introduced by CMVC #{type}#{defect_name}\"\n end",
"def review\n @review\n end",
"def desc() summary; end",
"def reviewers\n \"Here's the current list of JOSS reviewers: https://github.com/openjournals/joss/blob/master/docs/reviewers.csv\"\nend",
"def eval_lecture_head\n b = \"\"\n b << \"\\\\kurskopf{#{title.escape_for_tex}}\"\n b << \"{#{profs.map { |p| p.fullname.escape_for_tex }.join(' / ')}}\"\n b << \"{#{returned_sheets}}\"\n b << \"{#{id}}\"\n b << \"{#{t(:by)}}\\n\\n\"\n unless note.nil? || note.strip.empty?\n b << RT.small_header(I18n.t(:note))\n b << note.strip\n b << \"\\n\\n\"\n end\n b\n end",
"def review_interval\n @sbProject.reviewInterval\n end",
"def review_complete(params)\n # validate these parameters. If this passes, we can safely import.\n params = validate_review_completed_parameters(params)\n self.analyst_id = params[\"analyst_id\"]\n self.analyst_fullname = params[\"analyst_fullname\"]\n self.analyst_approval_datetime = params[\"analyst_approval_datetime\"]\n self.analyst_transaction_id = params[\"analyst_transaction_id\"]\n self.analyst_internal_status_id = params[\"analyst_internal_status_id\"]\n self.decision_code = params[\"decision_code\"]\n self\n end",
"def notes_from_training\n end",
"def performable\n perf = []\n @steps.each do |k, v|\n # Check if all prerequesites have been performed\n # p @performed\n perf << k if (v - @performed).empty?\n end\n # p perf.sort\n # p @performed\n # perf = perf - @performed\n # p perf.sort\n perf.sort\n end",
"def essay_writer(title, name, major_accomplishment, year_of_accomplishment, thesis, pronoun)\n\tputs \"Final Assignment Essay:\\n #{title}\n\t\\n\n\t#{year_of_accomplishment} was the year of #{name}. #{major_accomplishment},\n\tdoes that ring a bell? That was all thanks to #{name}. #{thesis} \n\t\\n\n\tMuch more could be said of #{name}, but I believe in brevity. #{pronoun.capitalize} is somebody worth remembering. \n\t\"\n\t\nend",
"def details\n\t\t\"#{self.title} - #{self.due_date} - #{self.is_completed}\"\n\tend",
"def data\n \"_target: #{target}\\ndatacite.creator: #{creator}\\ndatacite.title: #{title}\\ndatacite.publisher: #{publisher}\\ndatacite.publicationyear: #{publicationyear}\\n\"\n end",
"def main_description; end",
"def title_of_active_review\n conflicting_request_issue.try(:review_title)\n end",
"def get_author_transaction\n if outflow then\n \"Outflow: #{outflow.concept}\"\n else\n movement ? \"Movimiento: #{movement.concept}\" : 'N/A'\n end\n end",
"def word_date()\n #Find date action was completed (from database using date_completed function)\n date_string = self.date_completed\n #Return if date does not exist\n return if date_string == nil\n date_string = self.date_completed\n #Parse date into DATETIME format\n date = DateTime.parse(date_string)\n #if the action has not been completed return string anouncing when the action\n #will occur. Logic needed to check if the date is upcoming or overdue.\n if @completed == 'f'\n if date.to_date > Date.today\n return \"DUE: #{date.strftime(\"%B %e, %Y\")}\"\n elsif date.to_date == Date.today\n return \"DUE Today\"\n elsif date.to_date < Date.today\n return \"OVERDUE: #{date.strftime(\"%B %e, %Y\")}\"\n end\n #if action has already been completed, return the date completed.\n else\n return \"#{date.strftime(\"%B %e, %Y\")}\"\n end\n end",
"def description\n\t\"This task scrapes Hoovers for company info.\"\nend",
"def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end",
"def author\n quote_of_the_day[second_to_last_index(quote_of_the_day, \"~\")..quote_of_the_day.rindex(\"~\")].gsub(/(\\A~\\s*|\\s*~\\z)/, \"\")\n end",
"def reviews_reviewsstory_label\n $tracer.trace(__method__)\n return ToolTag.new(div.className(\"/gi-post/\").h1.className(\"/game-name/\"), __method__)\n end",
"def desc; end",
"def description\n @cafePred.description \n end",
"def proofread_final_manuscript(project, current_user, params)\n @project = project\n @current_user = current_user\n\n subject = \"\"\n if params[:commit] != 'Update Manuscript'\n tokens = {\n 'Content text has been converted to palatino linotype, size 10' => '✔'.html_safe,\n 'Any Acknowledgments, Dedication, Author Notes, etc. that I want included are included in this manuscript' => '✔'.html_safe,\n 'Any and all tracked changes have been accepted or rejected; Comments have been removed' => '✔'.html_safe,\n 'All text is fully justified (text is aligned with both the left and right margin)' => '✔'.html_safe,\n 'Chapter Headings are the way I want them to appear in the final manuscript (e.g. \"Chapter One,\" \"Chapter 1\", \"1\", \"CHAPTER ONE\"). Also, I have reviewed and made sure that Chapter Numbering is correct (No missing or duplicated numbers).' => '✔'.html_safe,\n 'All editing and stylistic choices (italics, caps) have been made and are final' => '✔'.html_safe,\n 'All chapter headings are size 14 font and there is a page break inserted between each chapter' => '✔'.html_safe,\n 'I have looked over and approved the delivered proofreading and the content. Nothing more will be added or removed from this document, and no further changes will be made.' => '✔'.html_safe,\n 'All narrative breaks/scene changes are indicated with three asterisks (***).' => (params['scene_changes'].nil?) ? 'No' : 'Yes',\n 'Does your book contain sub-chapters?' => (params[:project]['has_sub_chapters'] == 'true') ? 'Yes, and all sub-section headers are indicated by increments of increasing font sizes' : 'No',\n 'Does your manuscript contain images?' => (params['does_contain_images'] != '0') ? 'Yes' : 'No',\n 'Imprint' => (! @project.imprint.nil?) ? @project.try(:imprint).try(:name) : 'N/A',\n 'Project Type' => @project.book_type_pretty\n }\n\n if(@project.previously_published == true)\n tokens.store('Previously Published', 'Yes')\n tokens.store('Previously Published Title', @project.previously_published_title)\n tokens.store('Previously Published Year', @project.previously_published_year)\n tokens.store('Previous Publisher', @project.previously_published_publisher)\n else\n tokens.store('Previously Published', 'No')\n end\n\n if(!@project.try(:credit_request).nil?)\n tokens.store('Additional Credits Requested', (\"<pre>\" + @project.credit_request + \"</pre>\").html_safe )\n end\n\n if(params[:dropbox_link] != '')\n tokens.store('Images have been uploaded to Dropbox Folder', params['dropbox_link'])\n end\n\n if(params[:teamtrope_link] != '')\n tokens.store('Images have been uploaded to Teamtrope Docs Section', params['teamtrope_link'])\n end\n\n if(params[:project]['special_text_treatment'] != '')\n tokens.store('Sections requiring special treatment:', (\"<pre>\" +params[:project]['special_text_treatment'] + \"</pre>\").html_safe )\n end\n\n if(! @project.target_market_launch_date.nil?)\n tokens.store('Target Market Launch Date', @project.target_market_launch_date)\n end\n\n tokens.store('Manuscript Word Count:', params[:project]['proofed_word_count'])\n\n subject = \"New Submit Final Proofed Document from #{current_user.name} for #{project.book_title} (#{params[:project]['proofed_word_count']} words)\"\n else\n subject = \"New Verion of Final Proofed Document from #{current_user.name} for #{project.book_title}\"\n end\n\n tokens ||= {}\n\n send_email_message('proofread_final_manuscript', tokens, get_project_recipient_list(@project, roles: [:project_manager, :author]), subject)\n send_email_message('proofread_final_manuscript_admin', tokens, admin_proofread_final_manuscript_list, subject)\n end",
"def description\n \"This task hits the corpwatch API and adds detail for the organization.\"\nend",
"def entry_banner\n 'Interview'\n end",
"def display_goal\n puts \"\\nYOUR CURRENT GOAL IS: #{self.description}\".light_white\n if self.target_date\n puts \"\\nTARGET DATE TO REACH YOUR GOAL: #{self.target_date.strftime('%-d %B %Y')}\".light_white\n end\n if self.attainable\n puts \"\\nWHY I CAN ACHIEVE THIS GOAL: #{self.attainable}\".light_white\n end\n if self.relevant\n puts \"\\nWHY THIS GOAL MATTERS: #{self.relevant}\".light_white\n end\n end",
"def author\n [author_developer.name_and_email, author_date, author_date_gmt_offset]\n end",
"def author\n file.version.author.name\n end",
"def initialize(title, author,year=\"unknown\", edition=\"unknown\")\n @title = title\n @author = author\n @checked_out = false\n @current_patron = nil\n @year_published = year\n @edition = edition\n @reviews = {}\n end",
"def author\n if @submission.user != current_user.sk\n render 'errors/access_refused' and return\n end\n end",
"def submission_title\n self.submission.title(false)\n end",
"def modeler_description\n return 'HVAC system creation logic uses [openstudio-standards](https://github.com/NREL/openstudio-standards) and efficiency values are defined in the openstudio-standards Standards spreadsheet under the *NREL ZNE Ready 2017* template.'\n end",
"def creator\n \"Made by ROUINEB Hamza. 2016\"\n end",
"def homework(title, topic, date, thesis_statement, pronoun)\n\tparagraph = \"#{title}/n The #{topic} was an interesting topic. It happened in #{date}. \n\tI feel that #{topic} was a very important part of #{date} because \n\t#{pronoun}. #{thesis_statement}. This is what made #{topic} really \n\tinteresting part of #{date} and an important part of history.\"\n\treturn paragraph\nend",
"def fecha_publicacion\n run_at = self.publication_date\n end",
"def author\n @info[:Author]\n end",
"def oh_crap_i_forgot(title, person, location, date, thesis, major_accomplishment, pronoun)\n pronoun = 'male' ? p_use = 'he' : p_use = 'she'\n date < 1000 ? e_or_l = 'early era' : e_or_l = 'late era'\n\n puts \"#{title} : The Story of #{person}\"\n puts \" \"\n puts \"In #{e_or_l} #{location}, #{person} was a pretty big deal. #{thesis}. #{pronoun.capitalize} changed the very fabric of #{location} when #{pronoun} #{major_accomplishment}.\"\n puts \" \"\n puts \"All in all, #{e_or_l} #{location} would not have been so successful without #{person}, nor would #{location} be the way it is today without those contributions.\"\n puts \"By Mikee.\"\nend",
"def announcement\n cfg = Configuration.for(\"project\") \n { \n :subject => \"#{cfg.name} #{Crate::VERSION} Released\",\n :title => \"#{cfg.name} version #{Crate::VERSION} has been released.\",\n :urls => \"#{cfg.homepage}\",\n :description => \"#{cfg.description.rstrip}\",\n :release_notes => Utils.release_notes_from(cfg.history)[Crate::VERSION].rstrip \n }\n end",
"def weekly_digest(user)\n \n attachments.inline['whitelogo.png'] = File.read(Rails.root.join('app/assets/images/whitelogo.png'))\n \n @user = user\n @introduction = \"Type an introduction here somehow\"\n @first_item = \"Comment.find(target.comment)\"\n @second_item = \"Comment.find(target.comment)\"\n @third_item = \"Comment.find(target.comment)\"\n \n end",
"def purpose\n \"Intern seeking #{category_name.capitalize} position\"\n end",
"def manual_review_needed_template\n 'manual_review_needed'\n end",
"def closed_submission_status\n 'Closed for Review'\n end",
"def past_participle; end",
"def get_update\n \"Scheduled for disposition in #{fiscal_year(disposition_year)}\"\n end",
"def final_committee_decision\n application_final_decision_type.title if application_final_decision_type\n end",
"def remark_result\n if remark_request_timestamp.nil? || non_pr_results.length < 2\n nil\n else\n non_pr_results.last\n end\n end",
"def title\n \"Interesting commit: #{commit.title}\"\n end",
"def details; end",
"def performed?; end",
"def performed?; end",
"def fineline_accurate_title\n return nil\n end",
"def performable\n perf = []\n @steps.each do |k, v|\n\n # Check if all prerequesites have been performed && not already performed && not currently performing by another worker\n perf << k if (v - @performed).empty? && ! @performed.include?(k) && ! @performing.include?(k)\n end\n # p perf.sort\n # p @performed\n # perf = perf - @performed\n # puts \"Performed: #{@performed}\"\n # puts \"Performing: #{@performing}\"\n # puts \"Performable: #{perf.sort}\"\n perf.sort\n end",
"def initialize(title, author, desc, year, edition, num_copies)\n @title = title\n @author = author\n @desc = desc\n @year = year\n @num_copies = num_copies\n @year = year\n @edition = edition\n\n @num_copies = num_copies\n @num_in = @num_copies\n @num_out = 0\n @borrowed_by = []\n @reviews = []\n @ratings = []\n @future_check_out = {}\n end",
"def sendTally(contents)\n user_email = \"#{@member}@apache.org\"\n pmc = ASF::Committee.find(contents['project'])\n pmc_email = \"#{pmc.mail_list}@apache.org\"\n subject = \"[RESULT]\" + contents['subject']\n last_votes = Hash.new\n votes = contents['votes']\n votes.each { |v|\n last_votes[v['member']] = [v['vote'], v['timestamp']]\n }\n counts=Hash.new(0)\n last_votes.each { |k,v|\n counts[v[0]] += 1\n }\n started = Time.parse votes[0]['timestamp']\n elapsed=(Time.now - started) / (60*60)\n body_text = <<-EOD.gsub(/^ /,'') # Eclipse plugin does not like heredoc squiggle\n Here is the tally of the latest votes from each voter:\n\n #{last_votes.map{ |k,v| \"Member: #{k.ljust(20)} Vote: #{v[0]} Date: #{v[1]}\"}.join(\"\\n\")}\n\n Vote Count\n #{counts.sort_by{|k,v| VALID_VOTES.index(k) || 99}.map{|k,v| \" #{k} #{v.to_s.rjust(5)}\"}.join(\"\\n\")}\n\n Vote started: #{started.to_s[0..9]} Hours elapsed: #{elapsed.to_i}\n EOD\n _body_text body_text # debug\n\n # create the email to the p(pmc)\n mail = Mail.new do\n to pmc_email\n from user_email\n cc user_email\n subject subject\n text_part do\n body body_text\n end\n end\n mail.deliver\nend",
"def attorney_case_reviews\n tasks.map(&:attorney_case_reviews).flatten\n end",
"def description\n \"This task hits the Corpwatch API and creates an object for all found entities.\"\nend",
"def prt\n puts \"Federalist #{@fedNum}\"\n puts \"Title: #{@fedTitle}\"\n puts \"Pub: #{@fedPub}\"\n puts \"Author: #{@fedAuthor}\"\n puts \"Date: #{@fedDate}\"\n puts \"\\n\"\n end",
"def Com6 # Recuperation Info\n \n end",
"def full_line\n RetortApi.markov_chain(identity: { medium: 'bible' })\nend",
"def investor\n end",
"def author\n\t\t@author\n\tend",
"def reviewed_by\n return @reviewed_by\n end",
"def show\n @review = CriticReview.find(params[:id])\n @summary = params[:summary]\n end",
"def reviewed_by=(value)\n @reviewed_by = value\n end",
"def defect_heading(change)\n defect = change.defect\n text change.defect_type.capitalize\n text ' '\n a(defect, href: swinfo_get_path(defect))\n text \": \"\n text change.abstract\n end",
"def read_completion_specs(rows)\n row = rows[0]\n\n index = SampleData.index(row, /\\A\\s*成功年月日/)\n return false unless index\n if /\\A\\s*成功年月日.*(\\d+\\/\\d+\\/\\d+)/ =~ row[index]\n @date_completed = $1\n else\n @date_completed = row[index + 1]\n end\n\n index = SampleData.index(row, /\\A\\s*層名/)\n return false unless index\n if /\\A\\s*層名[::](.*[^\\s ])[\\s ]*\\z/ =~ row[index]\n @reservoir_name = $1.to_s\n else\n @reservoir_name = row[index + 1] || ''\n @reservoir_name = Integer(@reservoir_name).to_s if @reservoir_name.kind_of?(Numeric)\n @reservoir_name = @reservoir_name.remove_spaces_including_zenkaku\n end\n\n index = SampleData.index(row, /\\A\\s*坑井深度/)\n @total_depth = row[index + 1] if index\n\n index = SampleData.index(row, /\\A\\s*仕上深度/)\n if index\n if /\\A\\s*仕上深度.*([\\d.]+).*([\\d.]+)/ =~ row[index]\n @perforation_interval_top = $1\n @perforation_interval_bottom = $2\n else\n row = rows[1]\n index = SampleData.index(row, /\\A\\s*自/)\n @perforation_interval_top = row[index + 1] if index\n\n row = rows[2]\n index = SampleData.index(row, /\\A\\s*至/)\n @perforation_interval_bottom = row[index + 1] if index\n end\n end\n\n return true\n end",
"def author\n page.version.author.name\n end"
] | [
"0.56016713",
"0.5492883",
"0.5434874",
"0.5431683",
"0.536855",
"0.5357148",
"0.5353368",
"0.53416604",
"0.53150004",
"0.5254495",
"0.5253263",
"0.52373445",
"0.5222971",
"0.52184725",
"0.5191292",
"0.5188476",
"0.5155466",
"0.5154289",
"0.515212",
"0.5150933",
"0.51405525",
"0.5139648",
"0.51290566",
"0.5127348",
"0.5124797",
"0.5124797",
"0.5117197",
"0.5105753",
"0.508723",
"0.5074668",
"0.5074357",
"0.5068181",
"0.50469905",
"0.5046785",
"0.5046491",
"0.50417185",
"0.50143",
"0.5000516",
"0.49993268",
"0.49867412",
"0.49552673",
"0.49512517",
"0.49354988",
"0.4930655",
"0.49153072",
"0.4915151",
"0.4911449",
"0.49108022",
"0.49079055",
"0.49004227",
"0.4891734",
"0.48869163",
"0.48827526",
"0.4879329",
"0.4877355",
"0.48732722",
"0.48720092",
"0.48705822",
"0.48619327",
"0.48569182",
"0.48555964",
"0.48466587",
"0.48455733",
"0.48399788",
"0.48360294",
"0.48357525",
"0.48355752",
"0.4834873",
"0.48315275",
"0.48239914",
"0.48198792",
"0.48179898",
"0.48138314",
"0.48121986",
"0.48108202",
"0.48104674",
"0.48096883",
"0.48096627",
"0.4804946",
"0.4799688",
"0.47949532",
"0.47946087",
"0.47940624",
"0.47940624",
"0.4790863",
"0.47907412",
"0.47902834",
"0.4790183",
"0.47878715",
"0.47874555",
"0.47869545",
"0.4786709",
"0.47860834",
"0.47849378",
"0.4780776",
"0.47803453",
"0.4779993",
"0.47787344",
"0.47751215",
"0.4773496",
"0.47732717"
] | 0.0 | -1 |
Set client stats details Author: Puneet Date: 02/02/2018 Reviewed By: | def set_client_stats(client_stats_data)
@client_stats = CompanyApi::Response::Entity::ClientStats.new(client_stats_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_client_usage(client)\n client_id = client.id\n registration_count = User.using_client_shard(client: client).where(client_id: client_id).count\n kyc_submissions_count = UserKycDetail.using_client_shard(client: client).\n where(client_id: client_id).sum(:submission_count)\n\n client_usage_obj = ClientUsage.find_or_initialize_by(client_id: client_id)\n client_usage_obj.registration_count = registration_count\n client_usage_obj.kyc_submissions_count = kyc_submissions_count\n client_usage_obj.save! if client_usage_obj.changed?\n client_usage_obj\n end",
"def update_client_details\n user = @client.user\n self.username = user.screen_name\n self.save!\n end",
"def set_client_info\n @client_info = ClientInfo.find(params[:id])\n end",
"def set_client_info\n @client_info = ClientInfo.find(params[:id])\n end",
"def fetch_setup_details\n\n r = super\n return r unless r.success?\n\n r = SaasApi::Client::FetchStats.new.perform(client_id: @client_id)\n @api_response_data[:client_stats] = r.data if r.success?\n\n success\n\n end",
"def client_info\n #implement\n client_information = \"#{@name_str} #{@age_num} #{@pet_num}\"\n end",
"def update_updated_at_and_by\n #logger.info { \"FILTTERISSÄ: #{response.headers[\"Status\"]}\" }\n if response.headers[\"Status\"] =~ /^20/\n @collection.set_update_info(DateTime.now, (@user ? @user.guid : @client.id))\n # @collection.updated_at = DateTime.now\n # @collection.updated_by = @user ? @user.guid : @client.id\n # @collection.save\n\n end\n end",
"def set_stats\n {\n \"projectId\": '1234',\n \"invalid\": 2,\n \"error\": 1,\n \"info\": 0,\n \"warning\": 2\n }\nend",
"def edit\n today = ServerTime.now.strftime \"%Y-%m-%d\"\n ten_days_ago = (ServerTime.now - 10.days).strftime \"%Y-%m-%d\"\n @total_hits = current_user.total_hits.to_i\n @total_hits_today = current_user.total_hits_today.to_i\n day_keys = (10.days.ago.to_date..ServerTime.now.to_date)\n .map{|d| d.strftime(\"%Y-%m-%d\")}\n stats_for_ten_days = AnalyticData::UserHits.new(current_user.id)\n .stats_for_period ten_days_ago, today\n logger.debug \"hhhhhhhhhhhh========>#{stats_for_ten_days}\"\n @hits_with_date = Hash[day_keys.zip(stats_for_ten_days)]\n super\n end",
"def details\n\t\"#{assigned_to} - #{status} - #{start_date} - #{description} - #{location} - #{Client.find(client_id).name}\"\nend",
"def stats\n @client.stats\n end",
"def details\n\t\t\"#{name}---#{status}-----#{start_date}----#{description}---- #{Client.find(client_id).name}---#{Client.find(client_id).email}\"\n\tend",
"def details\n response = CreateSend.get \"/clients/#{client_id}.json\", {}\n Hashie::Mash.new(response)\n end",
"def setup_superuser_stats # rubocop:disable Metrics/AbcSize\n @stats =\n {\n user_count: User.all,\n dataset_count: Identifier.all,\n user_7days: User.where(['stash_engine_users.created_at > ?', Time.new - 7.days]),\n dataset_started_7days: Resource.joins(:current_resource_state)\n .where(stash_engine_resource_states: { resource_state: %i[in_progress] })\n .where(['stash_engine_resources.created_at > ?', Time.new - 7.days]),\n dataset_submitted_7days: Identifier.where(['stash_engine_identifiers.created_at > ?', Time.new - 7.days])\n }\n end",
"def stats\n @additions ||= 0\n @deletions ||= 0\n @stats_row_one = {\n active_user_count: @active_user_count,\n pull_count: @pull_count,\n comment_count: @comment_count,\n qa_signoff_count: @qa_signoff_count\n }\n @stats_row_two = {\n avg_additions: @additions.round.to_i,\n avg_deletions: @deletions.round.to_i,\n net_additions: @net_additions\n }\n end",
"def set_client_report\n @client_report = Client::Report.find(params[:id])\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 client_id=(client_id); end",
"def client_id=(client_id); end",
"def info_hash(user, client)\n basic_info = basic_hash(user, client)\n basic_info.merge!({:totalResults => readable_items_count(user, client),\n :link => { :rel => \"self\", :href => \"/appdata/#{client.id}/@collections/#{id}\"}\n })\n return basic_info\n end",
"def update!(**args)\n @client = args[:client] if args.key?(:client)\n @threat_info = args[:threat_info] if args.key?(:threat_info)\n end",
"def meta\n {\n exp: 1.day.from_now.to_i,\n iss: 'issuser_name',\n aud: 'client'\n }\n end",
"def client\n OpenSourceStats.client\n end",
"def set_client\n @client = Client.find(current_user.client_id)\n end",
"def create_client_info\n store.hmset(@client.uid, \"gen_func\", \"increment by 1\", \"min_critical\", MIN_CRITICAL, \"max_critical\", MAX_CRITICAL )\n end",
"def set_client\n @client = Client.find(current_user.client_id)\n end",
"def set_stats\n @stats = AppStats.new(Post.all, Quote.all)\n end",
"def set_stats(hunt_stat, str_stat, sneak_stat, chr_stat)\n $stats[:hunt] = hunt_stat\n $stats[:strength] = str_stat\n $stats[:sneak] = sneak_stat\n $stats[:charisma] = chr_stat\n end",
"def set_client_status\n @client_status = ClientStatus.find(params[:id])\n end",
"def client=(client)\n @client = client\n end",
"def client=(client)\n @client = client\n end",
"def client=(client)\n @client = client\n end",
"def client=(client)\n @client = client\n end",
"def set_clientstatus\n @clientstatus = Clientstatus.find(params[:id])\n end",
"def set_client_data\n @client_data = { controller: controller_name, action: action_name }\n end",
"def client_name; 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 set_info\n @page_header = 'Insight Engine'\n @page_secondary = 'Let\\'s get a view at 10,000 feet.'\n @page_title = 'LeadAccount | Insight Engine'\n @page_icon = 'lightbulb'\n end",
"def disp_clients\n @clients.each do |client|\n puts \"Name: #{client.name}\"\n puts \"Age: #{client.age}\"\n end\n end",
"def update_stats\n StatService.new(self).update_stats\n end",
"def update!(**args)\n @client_info = args[:client_info] if args.key?(:client_info)\n @details = args[:details] if args.key?(:details)\n @level = args[:level] if args.key?(:level)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end",
"def client_form\n\tclient_pref = {\n\t\tname: \"\",\n\t\tage: '',\n\t\tchildren: '',\n\t\tdecor: \"\",\n\t}\n\tputs \"Hello, welcome to Interior Solutions. Please help us help you by answering the following questions.\"\n\tclient_pref[:name] = name\n\tclient_pref[:age] = age\n\tclient_pref[:children] = children\n\tclient_pref[:decor] = decor\n\tclient_pref[:color] = color\n\t# Run \"update\" method to determine if any changes need to be made to program\n\tclient_pref = update(client_pref)\n\t# Print the latest version of the hash, and exit the program.\n\tputs \"Here is a summary of your client's information: #{client_pref}.\"\nend",
"def update_front_page_stats\n raise ServiceRecordNotFound, \"No Service Record Found\" if (@front_page/\"div.spotlight h1:nth(0)\").inner_html == \"Halo 3 Service Record Not Found\"\n self.name = (@front_page/\"div.service_record_header.halo3 div:nth(1) ul li h3\").inner_html.split(\" - \")[0].strip\n self.service_tag = (@front_page/\"div.service_record_header.halo3 div:nth(1) ul li:nth(0) h3\").inner_html.split(\" - \")[1].strip\n self.class_rank = (@front_page/\"#ctl00_mainContent_identityStrip_lblRank\").inner_html.split(\": \")[1] || \"Not Ranked\"\n self.emblem_url = \"http://www.bungie.net#{(@front_page/'#ctl00_mainContent_identityStrip_EmblemCtrl_imgEmblem').first[:src]}\"\n self.player_image_url = \"http://www.bungie.net#{(@front_page/'#ctl00_mainContent_imgModel').first[:src]}\".gsub(\"9=145\",\"9=300\") rescue self.player_image_url = \"http://#{RMT_HOST}/images/no_player_image.jpg\"\n self.class_rank_image_url = \"http://www.bungie.net#{(@front_page/'#ctl00_mainContent_identityStrip_imgRank').first[:src]}\" rescue self.class_rank_image_url = \"http://#{RMT_HOST}/images/no_class_rank.jpg\"\n self.campaign_status = (@front_page/'#ctl00_mainContent_identityStrip_hypCPStats img:nth(0)').first[:alt] rescue self.campaign_status = \"No Campaign\"\n self.high_skill = (@front_page/\"#ctl00_mainContent_identityStrip_lblSkill\").inner_html.gsub(/\\,/,\"\").to_i\n self.total_exp = (@front_page/\"#ctl00_mainContent_identityStrip_lblTotalRP\").inner_html.gsub(/\\,/,\"\").to_i\n self.next_rank = (@front_page/\"#ctl00_mainContent_identityStrip_hypNextRank\").inner_html\n self.baddies_killed = (@front_page/\"div.service_box div.littleright div.overallscore ul:nth(0) li.value.green\").inner_html.gsub(/\\,/,\"\").to_i\n self.allies_lost = (@front_page/\"div.service_box div.littleright div.overallscore ul:nth(0) li.value.red\").inner_html.gsub(/\\,/,\"\").to_i\n self.total_games = (@front_page/\"#ctl00_mainContent_pnlHalo3Box div.topper span.counter\").inner_html.split(\": (\")[1].gsub(/\\,/,\"\").to_i\n self.matchmade_games = (@front_page/\"#ctl00_mainContent_pnlHalo3Box ul.legend li:nth(3)\").inner_html.gsub(/\\,/,\"\").to_i + (@front_page/\"div.profile_strip div.profile_body #ctl00_mainContent_pnlHalo3Box ul.legend li:nth(5)\").inner_html.gsub(/\\,/,\"\").to_i\n self.custom_games = (@front_page/\"#ctl00_mainContent_pnlHalo3Box ul.legend li:nth(7)\").inner_html.gsub(/\\,/,\"\").to_i\n self.campaign_missions = (@front_page/\"#ctl00_mainContent_pnlHalo3Box ul.legend li:nth(1)\").inner_html.gsub(/\\,/,\"\").to_i\n self.member_since = (@front_page/\"div.service_box div.bigleft div.info span:nth(0)\").inner_html.split(\" | \")[0].gsub(\"Player Since \", \"\").to_date\n self.last_played = (@front_page/\"div.service_box div.bigleft div.info span:nth(0)\").inner_html.split(\" | \")[1].gsub(\"Last Played \", \"\").to_date\n end",
"def on_client_data(client)\n end",
"def updateservercount(count)\n url = \"https://discordbots.org/api/bots/#{@id}/stats\"\n json = '{\"server_count\":' + count.to_s + '}'\n RestClient.post(url, json, :Authorization => @api, :'Content-Type' => :json)\n \"Successfully set the server count to #{count}\"\n end",
"def client=(client)\n @client = client\n end",
"def client=(client)\n @client = client\n end",
"def user_stats\n system 'clear'\n puts \"-----MY STATS-----\"\n @current_user.display_stats\n end",
"def client=(client)\n client(client)\n end",
"def client_name\n\t\t\n\tend",
"def basic_hash(user, client)\n basic_hash = {\n :id => id,\n :title => title,\n :tags => tags,\n :owner => owner.andand.guid,\n :priv => priv,\n :metadata => metadata,\n :updated_at => updated_at.utc,\n :updated_by => updated_by,\n :read_only => read_only,\n :indestructible => indestructible\n }\n updated_by_name = \"\"\n if ! updated_by.nil?\n if updater = Person.find_by_id(updated_by)\n updated_by_name = updater.name_or_username\n elsif updater = Client.find_by_id(updated_by)\n updated_by_name = updater.name\n end\n end\n\n basic_hash.merge!({:updated_by_name => updated_by_name})\n return basic_hash\n end",
"def client(client_args)\n Staccato.tracker(client_args[:api_key], client_args[:uuid], ssl: true)\n end",
"def initialize client, data\n super\n\n @id = data[\"id\"]\n @name = data[\"name\"]\n @topic = data[\"topic\"]\n @one_on_one = data[\"oneOnOne\"]\n @lurk = data[\"lurk\"]\n @public = data[\"public\"]\n @mentions = data[\"mentions\"]\n @user_count = data[\"userCount\"]\n @unread_items = data[\"unreadItems\"]\n @tags = data[\"tags\"]\n @uri = data[\"uri\"]\n @url = data[\"url\"]\n end",
"def summary\n @puppet_mclient.summary\n end",
"def set_client\n @client = current_user.clients.find(params[:client_id])\n end",
"def set_clients_setting\n @clients = current_client\n end",
"def set_client\n \t@client = Client.find(params[:id])\n end",
"def set_client_profile\n @client_profile = ClientProfile.find(params[:id])\n end",
"def set_client\n\t @client = Client.find(params[:id])\n\t end",
"def set_client\n if current_user && current_user.is_event_admin?\n @client = Client.find(current_user.client_id)\n elsif current_user && current_user.is_crew?\n @client = Client.find(current_user.client_id)\n else\n redirect_to home_pages_home_path\n end\n end",
"def set_sprinter_stat\n @sprinter_stat = SprinterStat.find(params[:id])\n end",
"def get_client_settings\n cp = ClientPlan.get_client_plan_from_memcache(@client_id)\n pepo_campaign = ClientPepoCampaignDetail.get_from_memcache(@client_id)\n web_host = ClientWebHostDetail.get_from_memcache_by_client_id(@client_id)\n token_sale_detail = ClientTokenSaleDetail.get_from_memcache(@client_id)\n kyc_config_detail = @client.client_kyc_config_detail\n super_admins = Admin.where(default_client_id: @client_id, role: GlobalConstant::Admin.super_admin_role).not_deleted.all\n\n super_admins_data = super_admins.map {|x|\n {\n email: x.email,\n password: SecureRandom.hex,\n name: x.name\n }\n }\n\n @client_setting = {\n client_plan: {\n add_ons: cp.add_ons_array,\n kyc_submissions_count: cp.kyc_submissions_count\n },\n super_admins: super_admins_data,\n double_opt_in: @client.is_verify_page_active_for_client?,\n client_name: @client.name,\n pepo_campaign: {\n api_key: pepo_campaign.api_key,\n api_secret: decrypted_value(pepo_campaign.api_secret)\n },\n token_sale_details: {\n token_name: token_sale_detail.token_name,\n token_symbol: token_sale_detail.token_symbol,\n sale_start_timestamp: token_sale_detail.sale_start_timestamp,\n registration_end_timestamp: token_sale_detail.registration_end_timestamp,\n sale_end_timestamp: token_sale_detail.sale_end_timestamp,\n },\n kyc_config: {\n kyc_fields: kyc_config_detail.kyc_fields_array,\n residency_proof_nationalities: kyc_config_detail.residency_proof_nationalities,\n blacklisted_countries: kyc_config_detail.blacklisted_countries,\n auto_send_kyc_emails: kyc_config_detail.auto_send_kyc_emails_array\n }\n }\n\n if web_host.present?\n @client_setting[:web_host] = {\n domain: web_host.domain\n }\n\n r = SandboxManagement::CmsConfigurator::GetPublishedDraft.new(\n {decoded_token_data: {uuid: @uuid}}).perform\n return r unless r.success?\n\n @client_setting[:entity_type_and_data_hash] = r.data[:entity_type_and_data_hash]\n end\n\n success\n\n end",
"def initialize(client)\n @client = client\n\n @id = \"\"\n @project = nil\n @brand = \"\"\n @type = \"\"\n @bank_name = \"\"\n @level = \"\"\n @iin = \"\"\n @last_4_digits = \"\"\n @exp_month = 0\n @exp_year = 0\n @metadata = Hash.new\n @sandbox = false\n @created_at = \"\"\n \n end",
"def set_catcher_stat\n @catcher_stat = CatcherStat.find(params[:id])\n end",
"def set_user\n @client = current_client\n end",
"def update_vscore\n VillageItem.find_each do |vi|\n vi.update commenters_count: vi.comments.group(:customer_id).length\n print \"update #{vi.name}..\\n\"\n end\n vis = VillageItem.all\n vis_count = vis.count\n vis_count += 1\n click_sum = vis.sum(:click_count)\n favor_sum = vis.sum(:favor_count)\n call_sum = vis.sum(:call_count)\n commenter_sum = 0\n vis.each { |v| commenter_sum +=v.commenters_count }\n average_wfc = 100.0*favor_sum / ( click_sum + call_sum + 1)\n average_score = (favor_sum*4+call_sum*2+click_sum*1+commenter_sum*3+1)/(vis.count+1)\n vis.each do |vi|\n #using 14 days as age unit \n age = (Time.now-vi.created_at)/24/60/60/14\n age = 1 if age < 1\n ldrt = (Time.now-14.days)..Time.now\n show_event = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", event_type: \"show_event\", created_at: ldrt).count\n view_event = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", event_type: \"view_event\", created_at: ldrt).count\n call_event = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", event_type: \"call_event\", created_at: ldrt).count\n favor_event = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", event_type: \"favor_event\", created_at: ldrt).count\n unfavor_event = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", event_type: \"unfavor_event\", created_at: ldrt).count\n shop_event = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", event_type: \"shop_event\", created_at: ldrt).count\n cs_count = CustomerEvent.where(target_id: vi.id, name: \"customer_click_village_item\", created_at: ldrt).pluck(:customer_id).uniq.count\n recent_score = show_event + 2*view_event + 2*call_event + 2*shop_event + 3*cs_count + 4*favor_event - 4*unfavor_event + (vi.approved? ? 2 : 1 ) \n history_score = ( vi.favor_count*4+vi.call_count*2+vi.click_count*1+3*vi.commenters_count + ( vi.approved? ? 2 : 1 ) )\n wfc = ( 100.0*vi.favor_count ) / ( vi.click_count + vi.call_count + 1 )\n weight = wfc/average_wfc\n vscore = recent_score * 0.5 + ( history_score - average_score ) * 0.2 + ( weight * age ) * 0.3\n\n vi.update_attribute(:vscore, vscore)\n if vi.level == 2 || vi.level == 3 || vi.level == 4 || vi.level == 5\n vi.update_attribute(:level, 1) if vi.approved_end_at && Time.now > vi.approved_end_at\n end\n end\n end",
"def set_live_sale_for_client\n @client_setting[:client_setting][:token_sale_details].merge!(\n sale_start_timestamp: Time.now.to_i,\n registration_end_timestamp: (Time.now + 1.month).to_i,\n sale_end_timestamp: (Time.now + 1.month).to_i\n )\n end",
"def set_client\n\t @client = Client.find(params[:id])\n\tend",
"def print_init_status\n\t\tset_status(@ctx_init_id, \"by #{RsConfig::AUTHOR_FULLNAME} #{RsConfig::AUTHOR_PROMO} - (c) #{Time.now.year}\")\n\tend",
"def set_client\n\t\t\t@client = Client.find(params[:id])\n\t\tend",
"def update!(**args)\n @api_client = args[:api_client] if args.key?(:api_client)\n @client = args[:client] if args.key?(:client)\n @client_states = args[:client_states] if args.key?(:client_states)\n @threat_info = args[:threat_info] if args.key?(:threat_info)\n end",
"def set_client\n @client = Client.find(params[:id])\n \n end",
"def ClientName=(arg0)",
"def ClientName=(arg0)",
"def client_properties\n end",
"def client_params\n params.require(:client).permit(:register_date, :budge, :insured, :cnpj, :itens, :current_bonus, :insured_type, :supervisor, :supervisor_email, :supervisor_phone, :supervisor_cellphone, :director, :director_email, :director_phone, :director_cellphone, :last_bonus, :validity, :insurer, :assistant, :commercial_supervisor, :city, :estate, :obs)\n end",
"def client_info\n self.class.client_info\n end",
"def set_client\n @client = Client.find_by(id: params[:id], user_id: current_user.co_ids)\n end",
"def set_client\n @client = Client.find(params[:id])\n end",
"def set_client\n if current_user.try(:admin?)\n @client = Client.friendly.find(params[:id])\n else\n @client = current_user.clients.first\n end\n end",
"def set_client\r\n @client = Client.find(params[:id])\r\n end",
"def update\n @client = Client.find(params[:id])\n @states = State.find(:all,:order=>\"short_name\")\n @genders = Gender.find(:all)\n @email_priorities = EmailPriority.find(:all)\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def client_name\n return @client_name\nend",
"def show\n @client_name = Client.find(@activity.client_id).complete_name\n end",
"def set_client\n @client = Client.find(params[:client_id])\n end",
"def accident_stats\n TflApi::Client::AccidentStats.new(self)\n end",
"def broker_stats\n handling_kestrel_errors do\n client.stats!\n end\n end",
"def print_info\n puts \"#{self.country} (#{self.country_code}):\".light_cyan\n puts \" New Confirmed Cases: #{self.new_confirmed}\".light_red\n puts \" Total Confirmed Cases: #{self.total_confirmed}\".light_red\n puts \" New Deaths: #{self.new_deaths}\".light_red\n puts \" Total Deaths: #{self.total_deaths}\".light_red\n puts \" New Recovered Cases: #{self.new_recovered}\".light_red\n puts \" Total Recovered Cases: #{self.total_recovered}\".light_red\n puts \"This information was last updated at #{self.date}\".light_cyan\n end",
"def print_main_user_options\n puts \"-------\".light_magenta\n puts \"Information is updated from the data source approximately every 15 minutes - this information was last updated at #{CovidTracking::Summary.all.first.date}.\".light_magenta\n puts \"-------\".light_magenta\n puts \"What would you like to learn more about - a GLOBAL summary of COVID-19 spread, or a summary for a specific COUNTRY?\".light_magenta\n puts \"Tip: you can also REFRESH the program to see if data has been updated or enter FACTOIDS for some summary facts.\".light_magenta\n puts \"Please enter GLOBAL, COUNTRY, REFRESH, FACTOIDS, or EXIT.\".green\n end",
"def client_detail\n service_response = UserManagement::GetClientDetail.new(params).perform\n render_api_response(service_response)\n end",
"def set_statsupdater\n @statsupdater = Statsupdater.find(params[:id])\n end",
"def admin_comments_stats\n get_admin_stats \"comments\"\n end",
"def set_career_stat\n @career_stat = CareerStat.find(params[:id])\n end",
"def set_client\r\n @client = Client.find(params[:id])\r\n end",
"def update_ranked_stats\n self.ranked_kills = (@career/\"div.statWrap table:nth(0) tr:nth(2) td:nth(1) p\").inner_html.to_i\n self.ranked_deaths = (@career/\"div.statWrap table:nth(0) tr:nth(4) td:nth(1) p\").inner_html.to_i\n self.ranked_games = (@career/\"div.statWrap table:nth(0) tr:nth(6) td:nth(1) p\").inner_html.to_i\n self.ranked_sprees = (@career/\"#ctl00_mainContent_rptMedalRow_ctl01_rptPlayerMedals_ctl00_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n self.ranked_double_kills = (@career/\"#ctl00_mainContent_rptMedalRow_ctl03_rptPlayerMedals_ctl00_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n self.ranked_triple_kills = (@career/\"#ctl00_mainContent_rptMedalRow_ctl03_rptPlayerMedals_ctl01_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n self.ranked_sticks = (@career/\"#ctl00_mainContent_rptMedalRow_ctl04_rptPlayerMedals_ctl03_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n self.ranked_splatters = (@career/\"#ctl00_mainContent_rptMedalRow_ctl04_rptPlayerMedals_ctl07_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n self.ranked_snipes = (@career/\"#ctl00_mainContent_rptMedalRow_ctl04_rptPlayerMedals_ctl02_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n self.ranked_beatdowns = (@career/\"#ctl00_mainContent_rptMedalRow_ctl04_rptPlayerMedals_ctl00_ctl00_pnlMedalDetails div div:nth(2) div.number\").inner_html.gsub(\",\",\"\").to_i\n end",
"def create\n @profile = Profile.new(profile_params)\n @profile.user_id = current_user.id\n \n \n @profile.artist = find_preferred_artist_id\n @profile.advisor = find_preferred_advisor_id\n\n respond_to do |format|\n if @profile.save\n current_user.update(clientstatus: \"free\")\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render :show, status: :created, location: @profile }\n else\n format.html { render :new }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def anonymize_clients(clients)\n clients.each do |client|\n client[:name] = 'Client ' + random_name(3).capitalize\n client[:contact_name] = 'Fred ' + random_name(6).capitalize\n client[:contact_email] = random_name(5) + '@example.com'\n client[:description] = 'A Client Description'\n end\n end",
"def set_client\n @client = Client.find(params[:id])\n end",
"def set_client\n @client = Client.find(params[:id])\n end",
"def set_client\n @client = Client.find(params[:id])\n end"
] | [
"0.632931",
"0.609067",
"0.60432386",
"0.60432386",
"0.6000351",
"0.59391373",
"0.58106226",
"0.5807779",
"0.57885337",
"0.5697464",
"0.569321",
"0.5660587",
"0.5552315",
"0.5550092",
"0.5515177",
"0.5488684",
"0.5468579",
"0.546816",
"0.546816",
"0.54330796",
"0.53912634",
"0.5374654",
"0.53627676",
"0.5329724",
"0.5321153",
"0.5319884",
"0.5309798",
"0.52919436",
"0.52691704",
"0.52673507",
"0.52673507",
"0.52673507",
"0.52673507",
"0.52581125",
"0.5257315",
"0.5251428",
"0.524763",
"0.5231643",
"0.52274793",
"0.5210793",
"0.52019185",
"0.5178211",
"0.5178069",
"0.5173145",
"0.5152558",
"0.51511025",
"0.51511025",
"0.51459765",
"0.5139031",
"0.51356876",
"0.5123762",
"0.5121336",
"0.51091504",
"0.5109107",
"0.51090044",
"0.51060104",
"0.5105272",
"0.5095379",
"0.50953096",
"0.50911933",
"0.50828177",
"0.5079772",
"0.50770664",
"0.50750226",
"0.506118",
"0.50561947",
"0.5054991",
"0.505185",
"0.50457174",
"0.50415295",
"0.50390387",
"0.50317687",
"0.5027618",
"0.5027618",
"0.50271565",
"0.50262487",
"0.5023678",
"0.5006172",
"0.49939728",
"0.49929127",
"0.49830958",
"0.497923",
"0.49781904",
"0.49742922",
"0.4973098",
"0.49726132",
"0.49665862",
"0.49646035",
"0.49625072",
"0.49614426",
"0.49606243",
"0.49486205",
"0.49476287",
"0.49442464",
"0.49395654",
"0.49300632",
"0.49247867",
"0.49235532",
"0.49235532",
"0.49235532"
] | 0.73293805 | 0 |
Set API Console details Author: Puneet Date: 02/02/2018 Reviewed By: | def set_api_console_data(api_console_data)
@api_console_data = CompanyApi::Response::Entity::ApiConsoleData.new(api_console_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def author\n @info[:Author]\n end",
"def set_AuthorUsername(value)\n set_input(\"AuthorUsername\", value)\n end",
"def set_AuthorName(value)\n set_input(\"AuthorName\", value)\n end",
"def author\n @author_data ||= read(\"/user/#{@author}/about.json\", :handler => \"User\")\n end",
"def meta_author\n # Change the value below between the quotes.\n \"Team Tation\"\n end",
"def author\n [author_developer.name_and_email, author_date, author_date_gmt_offset]\n end",
"def reviewed_by=(value)\n @reviewed_by = value\n end",
"def author; @author; end",
"def author; @author; end",
"def cmd_author\n puts(property(Svn::Core::PROP_REVISION_AUTHOR) || \"\")\n end",
"def author\n response = read(\"/user/#{@author}/about.json\", :handler => \"User\") if @author\n @author_data ||= response[0] if response\n end",
"def get_info\n puts \"#{@title} by #{@author} is #{@status}.\"\n if @description\n puts \"#{@title} description: #{@description}.\"\n end\n end",
"def set_author\n author_reference.reference = \"Patient/#{user.icn}\"\n end",
"def author\n # TODO: Return object instead\n @json['project']['meta']['author']\n end",
"def author; end",
"def author_name\n h Settings.author_name\n end",
"def developer name, email\n self.author << name\n self.email << email\n end",
"def author=(author) #setter\n @author = author\n end",
"def author\n page.version.author.name\n end",
"def set_author\n @creator = Creator.find(params[:id])\n end",
"def set_AuthorID(value)\n set_input(\"AuthorID\", value)\n end",
"def print_init_status\n\t\tset_status(@ctx_init_id, \"by #{RsConfig::AUTHOR_FULLNAME} #{RsConfig::AUTHOR_PROMO} - (c) #{Time.now.year}\")\n\tend",
"def author=(new_author = nil)\n @info[:Author] = new_author\n end",
"def author\n url = @json['user']['meta']['author']\n data = client.get url\n client.factory.create(GoodData::Membership, data)\n end",
"def print_created_by\n puts 'Created by James (#1) Bronzan'\n end",
"def inspect\n if @name.nil? or @email.nil? or @url.nil?\n $stderr.puts \"You need to specify a name, url and email for the DLC generator. See the documentation\"\n else\n \"DLC API owner: #{@name} <#{@email}> (#{@url})\"\n end\n end",
"def about\n puts \"The CLI Tracker was developed by Dakota States as part of a Flatiron School CLI Project. The data source: https://covid.ourworldindata.org/data/owid-covid-data.json\"\n end",
"def meta_author\n \"Ahmed Nadar\"\n end",
"def author_bio\n h Settings.author_bio\n end",
"def author\n @author\n end",
"def author\n\t\t@author\n\tend",
"def author() headers['author'] end",
"def author \n user.firstname + ' ' + user.lastname\n end",
"def\n get_author()\n @author\n end",
"def author\n user || OpenStruct.new({\n :nicename => external_author_name,\n :email => \"%s@%s\" % [external_author_id, Doers::Config.app_id]\n })\n end",
"def created_by\r\n\t\t\treturn \"Laura OMalley\"\r\n\t\tend",
"def get_author()\n @author\n end",
"def title()\n puts \"automato.rb v1.5\"\n puts \"Written by: Sanjiv Kawa\"\n puts \"Twitter: @skawasec\"\nend",
"def set_author_name\n # Handles toggling between fake and real names (at edit)\n if anonymouse_changed?\n if self.anonymouse?\n self.author_name = Faker::Name.name\n else\n self.author_name = self.user.name\n end\n end\n # Handles\n if !self.anonymouse?\n self.author_name = self.user.name\n end\n end",
"def info\n puts \"Version #{StaticData::APPLICATION_VERSION}\"\n puts \"Authors : \"\n StaticData::AUTHORS.each do |author| \n puts \"-- #{author}\"\n end \n end",
"def author\n \"#{user.firstname} #{user.lastname}\"\n end",
"def edit_review\n # client should be able to edit a review.\n puts \"Which review would you like to edit?\"\n pp Client.find_by(name: @@client_name).reviews\n puts \"Please enter the ID\"\n input = gets.strip\n selected_review = Review.find_by(id: input)\n puts \"What would you like for the new review to say?\"\n input = gets.strip\n selected_review.update(text_body: input)\n puts \"Your review has been updated, here's the new review:\"\n pp selected_review\n client_continue\n end",
"def created_by\r\n\t\t\t \t\"Lachezar Kostov and Dimitar Bakardzhiev\"\r\n\t\t end",
"def set_ContributorDetails(value)\n set_input(\"ContributorDetails\", value)\n end",
"def set_ContributorDetails(value)\n set_input(\"ContributorDetails\", value)\n end",
"def set_ContributorDetails(value)\n set_input(\"ContributorDetails\", value)\n end",
"def set_ContributorDetails(value)\n set_input(\"ContributorDetails\", value)\n end",
"def set_ContributorDetails(value)\n set_input(\"ContributorDetails\", value)\n end",
"def author=(author)\n @author = author\n end",
"def print_update\n puts \"Attribute to Change\"\n puts \"[1] First Name\"\n puts \"[2] Last Name\"\n puts \"[3] E-mail\"\n puts \"[4] Note\"\n puts \"Enter a number\"\n end",
"def check_author\n return unless self.is_author\n\n self.name = BLARG_CONFIG['admin']['name']\n self.email = BLARG_CONFIG['admin']['email']\n self.url = BLARG_CONFIG['blog']['url']\n self.is_human = BLARG_CONFIG['comments']['is_human_answer']\n end",
"def aria_described_by\n @aria_described_by ||= \"#{hint_id if hint_text.present?} #{error_id if error_list.present?}\".strip\n end",
"def print_main_user_options\n puts \"-------\".light_magenta\n puts \"Information is updated from the data source approximately every 15 minutes - this information was last updated at #{CovidTracking::Summary.all.first.date}.\".light_magenta\n puts \"-------\".light_magenta\n puts \"What would you like to learn more about - a GLOBAL summary of COVID-19 spread, or a summary for a specific COUNTRY?\".light_magenta\n puts \"Tip: you can also REFRESH the program to see if data has been updated or enter FACTOIDS for some summary facts.\".light_magenta\n puts \"Please enter GLOBAL, COUNTRY, REFRESH, FACTOIDS, or EXIT.\".green\n end",
"def set_author\n @author = apply_scopes(Author).find(params[:id]) rescue nil\n end",
"def preetify\n preety_print do |instance|\n org = instance['organization'] || { 'name' => 'N/A' }\n puts 'organization_name'.to_s.ljust(30) + org['name']\n\n %w[submitter assignee].each do |user_key|\n user = instance[user_key] || { 'name' => 'N/A' }\n puts user_key.ljust(30) + user['name']\n end\n end\n end",
"def author\n @author ||= begin\n UnfuddleAPI::People.find(self[:author_id]).username\n rescue\n ''\n end\n end",
"def set_author\n @author = User.find(params[:id])\n end",
"def set_v1_author\n @v1_author = V1::Author.find(params[:id])\n end",
"def set_author\n @author = Author.friendly.find(params[:author_name])\n end",
"def set_info\n @page_header = 'Insight Engine'\n @page_secondary = 'Let\\'s get a view at 10,000 feet.'\n @page_title = 'LeadAccount | Insight Engine'\n @page_icon = 'lightbulb'\n end",
"def verdict_details=(value)\n @verdict_details = value\n end",
"def author=(author)\n @author = author.to_s.strip\n end",
"def auttor_params\n params.require(:auttor).permit(:authorid, :authorname)\n end",
"def author\n \"#{user.name} (#{user.login})\"\n end",
"def head \n meta_author \"Kane Baccigalupi\"\n end",
"def set_author\n @author = Author.find(params[:internet_id])\n end",
"def set_author\n @author = Author.friendly.find(params[:id])\n end",
"def details\n\t\t\"#{name}---#{status}-----#{start_date}----#{description}---- #{Client.find(client_id).name}---#{Client.find(client_id).email}\"\n\tend",
"def details=(_); end",
"def author_id\n get_info[:authorID]\n end",
"def formatAPA\n (prettyOutput(@authors.map { |x| x.to_s }) + \"(\" + @datee.year.to_s + \") \" + @title +\n \"\\n\\t(\" + @edition.to_s + \") \" +\n \"(\" + @editionnumber.to_s + \") \" +\n @url)\n end",
"def set_creator\n @creator = Author.find(params[:id])\n end",
"def cmd_info\n cmd_author\n cmd_date\n cmd_log(true)\n end",
"def set_authordetail\n @authordetail = Authordetail.find(params[:id])\n end",
"def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end",
"def author\n #Este self.object hace referencia al object que se esta serializando\n user = self.object.user\n {\n name: user.name,\n email: user.email,\n id: user.id\n }\n end",
"def print_created_by\n return \"This game was created by Kevin Tripp.\"\n end",
"def details\n\t\"#{assigned_to} - #{status} - #{start_date} - #{description} - #{location} - #{Client.find(client_id).name}\"\nend",
"def resolved_author; end",
"def creator\n \"Made by ROUINEB Hamza. 2016\"\n end",
"def print_person\n puts \"Name: #{name}\"\n puts \"Age: #{age} years old\"\n puts \"ID: VCN#{id}\"\n end",
"def author_params\n params.require(:author).permit(:name, :poetry_header, :about_text, :friendly_header, :order_number,\n :author_id, :additional_info, :last_poem_placeholder, :need_placeholder,\n :title, :subtitle)\n end",
"def get_info\n puts @name + ' [ID: ' + @id.to_s + ' @ '+ @@company + ']'\n end",
"def v1_author_params\n params.require(:v1_author).permit(:first_name, :last_name, :bio)\n end",
"def set_author\r\n @author = Author.find(params[:id])\r\n end",
"def author\n @author ||= get_author\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def set_author\n @author = Author.find(params[:id])\n end",
"def author\n @author ||= Readability::Document.new(@html).author\n end"
] | [
"0.62011385",
"0.5934105",
"0.58770674",
"0.57877433",
"0.5744884",
"0.5721576",
"0.57034785",
"0.5681357",
"0.5681357",
"0.5675775",
"0.56682366",
"0.56624544",
"0.5658912",
"0.5618394",
"0.5610826",
"0.5599454",
"0.55768776",
"0.55716026",
"0.55566204",
"0.55275494",
"0.5520564",
"0.5507962",
"0.55060095",
"0.55044067",
"0.54928863",
"0.54797256",
"0.54700226",
"0.54638165",
"0.5460978",
"0.54549974",
"0.5450487",
"0.54266304",
"0.53841466",
"0.5379495",
"0.53684723",
"0.53476846",
"0.5329894",
"0.5324188",
"0.5322493",
"0.530948",
"0.53044397",
"0.5304417",
"0.5304156",
"0.52979213",
"0.52978677",
"0.52978677",
"0.52978677",
"0.5297332",
"0.52966005",
"0.52955484",
"0.5288839",
"0.5287707",
"0.52847177",
"0.5284026",
"0.5281749",
"0.5276144",
"0.52736944",
"0.5273302",
"0.5266785",
"0.526496",
"0.5262556",
"0.52567",
"0.52439994",
"0.52318335",
"0.5226158",
"0.5215462",
"0.5212391",
"0.5212169",
"0.52075875",
"0.5196752",
"0.5195065",
"0.51839507",
"0.5172684",
"0.5171276",
"0.51430887",
"0.5138619",
"0.5121455",
"0.512096",
"0.5118453",
"0.51141816",
"0.51140416",
"0.5113583",
"0.5109878",
"0.51091164",
"0.51064324",
"0.5098759",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.50985116",
"0.509669"
] | 0.5188679 | 71 |
Set Client BT Addresss Data Author: Puneet Date: 02/02/2018 Reviewed By: | def set_client_bt_addresses_data(client_bt_addresses_data)
@client_bt_addresses = CompanyApi::Response::Entity::ClientBrandedTokenAddresses.new(client_bt_addresses_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_address\n end",
"def set_client_address\n @client_address = ClientAddress.find(params[:id])\n end",
"def set_addresses=(v)\n self.addresses = build_addresses(v)\n end",
"def update_contact_info txn\n AddressManager::set_user_address txn.user, txn\n end",
"def set_client\n @client = Client.find(params[:id])\n @client.nom=@client.nom.force_encoding(\"UTF-8\")\n @client.ville=@client.ville.force_encoding(\"UTF-8\")\n @client.address=@client.address.force_encoding(\"UTF-8\")\n end",
"def set_address\n\t\t@address = Contact.find(params[:contact_id]).address\n\tend",
"def set_address_type\n\n end",
"def set_Addresses(value)\n set_input(\"Addresses\", value)\n end",
"def set_Addresses(value)\n set_input(\"Addresses\", value)\n end",
"def set_Addresses(value)\n set_input(\"Addresses\", value)\n end",
"def set_address_options\n @address_options = Address.all.map{ |a| [ a.label, a.id ]}\n end",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def set_address type, key, params={}\n opts = {:single_quoted => false}\n params = {\n :query => {\n \"ClientToken\" => self.token,\n \"AddressType\" => Type::String.safe_value(type, opts),\n \"VoterKey\" => Type::String.safe_value(key, opts),\n \"AddressLine1\" => Type::String.safe_value(params[:address_1], opts),\n \"AddressLine2\" => Type::String.safe_value(params[:address_2], opts),\n \"AddressCity\" => Type::String.safe_value(params[:city], opts),\n \"AddressState\" => Type::String.safe_value(params[:state], opts),\n \"AddressZip5\" => Type::String.safe_value(params[:zip5], opts),\n \"AddressZip4\" => Type::String.safe_value(params[:zip4], opts)\n }\n }\n\n put 'set_address.php', params\n end",
"def set_street_address_1_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def set_address\n @customer_ship_address = CustomerShipAddress.find(params[:id])\n end",
"def address=(value)\n @address = value\n end",
"def address=(value)\n @address = value\n end",
"def save_address\n end",
"def set_address(address)\n @fields.merge!(address.to_hash)\n end",
"def client_address_params\n params.require(:client_address).permit(:client_id, :appaddress_id, :comments)\n end",
"def set_for_manual_address\n @show_manual_address = true\n @address_read_only = false\n # clear the identifier as this address is no longer from the search\n @address_detail.address_identifier = nil\n end",
"def set_street_address_1_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_1, @customer.street_address_1)\n end",
"def address1_set(address)\n self.address1.set address\n end",
"def update_fetch_address( atts = {} )\n self.fetch_address = (self.fetch_address || {}).merge( atts )\n end",
"def set_address\n @address = Addresslanlng.new\n end",
"def set_address\n @address = Address.find_by(id: params[:id], user_profile_id: current_user.user_profile_id)\n end",
"def bcc=(addresses)\n address_list_assign('Bcc', addresses)\n end",
"def set_street_address_2_update\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_2, @customer.street_address_2)\n end",
"def set_Address1(value)\n set_input(\"Address1\", value)\n end",
"def set_address\n @address = @company.addresses.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_customer_information(name1, name2, addr1, city, state, zip, addr2='', country='')\n @PARAM_HASH['NAME1'] = name1\n @PARAM_HASH['NAME2'] = name2\n @PARAM_HASH['ADDR1'] = addr1\n @PARAM_HASH['CITY'] = city\n @PARAM_HASH['STATE'] = state\n @PARAM_HASH['ZIPCODE'] = zip\n @PARAM_HASH['ADDR2'] = addr2\n @PARAM_HASH['COUNTRY'] = country\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 set_customer_address\n @customer_address = CustomerAddress.find(params[:id])\n end",
"def set_ag_address\n @ag_address = Ag::Address.find(params[:id])\n end",
"def generate_address\n if Rails.env.development?\n resp = $rippleClient.dev_wallet_propose\n if resp.raw.present?\n self.address= resp.raw.address\n self.secret= resp.raw.secret\n end\n else\n resp = $rippleClient.wallet_propose\n if resp.raw.present?\n self.address= resp.resp.account_id\n self.secret= resp.resp.master_seed\n end\n end\n end",
"def pick_address_from_list\n params.each_key do |key|\n next unless key.start_with? 'pick_address'\n\n index = key.to_s.delete_prefix('pick_address_').to_i\n\n @show_manual_address = true\n @address_read_only = true\n @address_summary = AddressSummary.new\n @address_detail = @address_list[index]\n break\n end\n end",
"def client_params\r\n params.require(:client).permit(:address, :balance, :balance_b, :city, :code, :contact, :country, :debit_credit, :domain, :email, :fax, :id, :id_number1, :id_number2, :name, :observations, :state, :telephone, :type, :username, :version, :web, :zip_code)\r\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_street_address_2_save\n @customer = Customer.find(customer_id)\n\n Order.find(id).update_column(:street_address_2, @customer.street_address_2)\n end",
"def create_eth_address_in_db\n\n ClientAddress.create(\n client_id: @client_id,\n ethereum_address: @encrypted_eth_address,\n hashed_ethereum_address: @hashed_eth_address,\n address_salt: @address_salt[:ciphertext_blob],\n status: GlobalConstant::ClientAddress.active_status\n )\n\n CacheManagement::ClientAddress.new([@client_id]).clear\n\n success\n\n end",
"def set_address\n @address = Address.find params[:id]\n end",
"def set_address\n @address = Address.find params[:id]\n end",
"def set_StreetAddress(value)\n set_input(\"StreetAddress\", value)\n end",
"def set_StreetAddress(value)\n set_input(\"StreetAddress\", value)\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 set_client\n @client = Client.preload(:address).find(params[:id])\n end",
"def test_add_address_helper\n contact = create_test_contact\n assert_equal(1, contact.addresses.size)\n\n new_values = {\n :address_type => 'POBOX',\n :line_1 => 'NEW LINE 1',\n :line_2 => 'NEW LINE 2',\n :line_3 => 'NEW LINE 3',\n :line_4 => 'NEW LINE 4',\n :city => 'NEW CITY',\n :region => 'NEW REGION',\n :post_code => '5555',\n :country => 'Australia'\n }\n contact.add_address(new_values)\n\n assert_equal(2, contact.addresses.size)\n assert_kind_of(XeroGateway::Address, contact.addresses.last)\n new_values.each { |k,v| assert_equal(v, contact.addresses.last.send(\"#{k}\")) }\n end",
"def assign_from_address!(address)\n self.address_line1 = address.address_line1\n self.address_line2 = address.address_line2\n self.locality = address.town\n self.county = address.county\n self.country = address.country || 'GB'\n self.postcode = address.postcode\n end",
"def options=(options = {}); @address_impl.setOptions(convert_options(options)); 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 replicate_address_from_current_user_details(id, user)\n\n address = Address.find(id)\n\n address.update(\n line1: user.line1,\n line2: user.line2,\n line3: user.line3,\n town_city: user.townCity,\n county: user.county,\n postcode: user.postcode\n )\n\n end",
"def update_contact_info post\n AddressManager::set_user_address post.user, post\n end",
"def set_user_id(user_id)\n @data_object.order_user_id = user_id\n user = User.with_id(user_id)\n if user\n contact = user.contact\n ship = contact.ship\n \n add = contact.con_name + \"\\r\\n\" + ship.to_s\n\n @data_object.order_ship_address = add\n end\n end",
"def business_details_page_change_business_address(postcode: 'BS1 5AH',\n address: 'HARMSEN GROUP, TRIODOS BANK, DEANERY ROAD, BRISTOL, BS1 5AH')\n\n fill_in 'sPostcode', with: postcode\n click_button 'find_address'\n select address\n business_details_page_submit_business_details_page\n end",
"def edit_address(edited_address)\n address = Address.find(edited_address.uid)\n address.attributes = edited_address.attributes\n address.save!\n end",
"def client_attributes=(params)\n client_to_save = Client.find_or_create_by_name(params[:name])\n self.client = client_to_save\n client_to_save.birth_date = params[:birth_date]\n client_to_save.address1 = params[:address1]\n client_to_save.address2 = params[:address2]\n client_to_save.city = params[:city]\n client_to_save.state = params[:state]\n client_to_save.zip_code = params[:zip_code]\n client_to_save.medicare_num = params[:medicare_num]\n client_to_save.medicaid_num = params[:medicaid_num]\n client_to_save.member_num = params[:member_num]\n client_to_save.soc_sec_care_mgr = params[:soc_sec_care_mgr]\n client_to_save.sscm_ph = params[:sscm_ph]\n client_to_save.nurse_care_mgr = params[:nurse_care_mgr]\n client_to_save.ncm_ph = params[:ncm_ph]\n client_to_save.emer_contact = params[:emer_contact]\n client_to_save.ec_ph = params[:ec_ph]\n client_to_save.pri_care_phy = params[:pri_care_phy]\n client_to_save.pcp_ph = params[:pcp_ph]\n client_to_save.save\n end",
"def set_account_address\n @account_address = AccountAddress.find(params[:id])\n end",
"def ripple_address_params\n params.require(:ripple_address).permit(:managed, :address, :type, :tag, :uid, :data)\n end",
"def testnet_address; end",
"def address_params\n params.require(:address).permit(:first_name, \n :last_name, \n :address_line_1, \n :address_line_2, \n :city, \n :state, \n :country, \n :addressable_id, \n :addressable_type,\n :uuid)\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 address3_set(address)\n self.address3.set address\n end",
"def address\n address = \"#{self.street_address}, #{self.city}, #{self.country}\"\n \n end",
"def billing_address=( address ) \n return unless address and address.is_a? Address\n \n duplicate_address = Address.where( frame_id: address.frame_id,\n first_name: address.first_name,\n last_name: address.last_name,\n address_1: address.address_1,\n address_2: address.address_2,\n city: address.city,\n province: address.province,\n country: address.country,\n postal_code: address.postal_code ).first\n \n if duplicate_address\n self.billing_address_id = duplicate_address.id\n else\n address.save\n self.billing_address_id = address.id\n end\n end",
"def set_user_address\n @user_address = UserAddress.find(params[:id])\n end",
"def set_user_address\n @user_address = UserAddress.find(params[:id])\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def set_address\n @address = Address.find(params[:id])\n end",
"def address=(value)\n self[:address] = if (_value = value.to_s).encode('utf-8').valid_encoding? then _value.encode('utf-8')\n else _value.force_encoding(\"ISO-8859-1\").encode('utf-8')\n end\n end",
"def update_airdrop_contract_address\n\n data = @critical_chain_interaction_log.response_data['data']\n return if data.blank? || data['transaction_receipt'].blank?\n\n contract_address = data['transaction_receipt']['contractAddress']\n\n return if contract_address.blank?\n\n ClientToken.where(id: @critical_chain_interaction_log.client_token_id).\n update_all(airdrop_contract_addr: contract_address)\n\n CacheManagement::ClientTokenSecure.new([@critical_chain_interaction_log.client_token_id]).clear\n\n end",
"def set_user_address\n @user_address = UserAddress.find(current_user.id)\n # @user_address = UserAddress.find(params[:id])\n end",
"def set_adress\n @adress = Adress.find(params[:id])\n end",
"def address=(addr)\n @address = check_address addr\n build_pack\n end",
"def company_address(company, address)\n company.address_line1 = address[:address_line1]\n company.address_line2 = address[:address_line2]\n company.locality = address[:address_town_or_city]\n company.county = address[:address_county_or_region]\n company.country = address[:address_country_code]\n company.postcode = address[:address_postcode_or_zip]\n end",
"def init_addresses\n @@client.describe_addresses.addresses\n end",
"def setup\n @santa_address = OrderAddress.find(order_addresses(:santa_address).id)\n @scrooge_address = OrderAddress.find(order_addresses(:uncle_scrooge_address).id)\n end",
"def address\n post('/api/1/generic/bitcoin/address')['addr']\n end",
"def vcard_address(data)\n address = data['address']\n address += \", #{data['address2']}\" if data['address2']\n {\n 'a' => ['vcard:Address','vcard:Work'],\n 'vcard:country' => data['country'] || 'United States',\n 'vcard:region' => data['state'],\n 'vcard:locality' => data['city'],\n 'vcard:postalCode' => data['zip'],\n 'vcard:streetAddress' => address\n }\n end",
"def address_line_1=(v)\n @address_line_1 = alma_string v\n end",
"def bcc_email_address=(value)\n @bcc_email_address = Array.new\n unless value.nil? || value.empty?\n value.each do |v1|\n if v1.instance_of? AddressJson\n @bcc_email_address.push(v1)\n end\n end\n end\n end",
"def enter_address(first_name, last_name, address1, city, state_province, zip_postal_code, phone_number)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_first_name_field.value = first_name\n chkout_last_name_field.value = last_name\n chkout_address_1_field.value = address1\n chkout_city_field.value = city\n chkout_select_state.value = state_province\n chkout_zip_code_field.value = zip_postal_code\n chkout_phone_number_field.value = phone_number\n end",
"def set_bank_certificate_contents\n set_node(@template, 'pkif|SenderId', @customer_id)\n set_node(@template, 'pkif|CustomerId', @customer_id)\n set_node(@template, 'pkif|RequestId', request_id)\n set_node(@template, 'pkif|Timestamp', iso_time)\n set_node(@template, 'pkif|InterfaceVersion', 1)\n end",
"def enter_billship_address_plus_country(country, first_name, last_name, address1, city, state_province, zip_postal_code, phone_number)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n chkout_country_selector.value = country\n chkout_first_name_field.value = first_name\n chkout_last_name_field.value = last_name\n chkout_address_1_field.value = address1\n chkout_city_field.value = city\n chkout_select_state.value = state_province\n chkout_zip_code_field.value = zip_postal_code\n chkout_phone_number_field.value = phone_number\n end",
"def update_address\n address_zip = ZipCodes.identify(zip_code) || {}\n self.city = address_zip[:city]\n self.state = address_zip[:state_name]\n self.state_code = address_zip[:state_code]\n end"
] | [
"0.6881441",
"0.6312769",
"0.60506237",
"0.6017915",
"0.59968686",
"0.5966925",
"0.59465563",
"0.59386486",
"0.59386486",
"0.59386486",
"0.591972",
"0.5915055",
"0.5915055",
"0.59133244",
"0.59031093",
"0.58883625",
"0.58808154",
"0.58808154",
"0.58686054",
"0.5835885",
"0.5814571",
"0.5792625",
"0.57850313",
"0.5781941",
"0.5763241",
"0.57589567",
"0.57559043",
"0.57522774",
"0.57150275",
"0.5706754",
"0.56834453",
"0.5679466",
"0.5668551",
"0.56640035",
"0.5663365",
"0.56560796",
"0.56285274",
"0.56256",
"0.56131715",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.56125516",
"0.5585504",
"0.55825067",
"0.5577074",
"0.5577074",
"0.5575848",
"0.5575848",
"0.557363",
"0.556769",
"0.55675274",
"0.5562807",
"0.5560559",
"0.55528796",
"0.555218",
"0.55472183",
"0.5543586",
"0.5541723",
"0.5515678",
"0.55067164",
"0.55033165",
"0.5494974",
"0.54704124",
"0.5464068",
"0.5461243",
"0.54554087",
"0.54466033",
"0.54446745",
"0.5444526",
"0.5444526",
"0.5441111",
"0.5433067",
"0.5433067",
"0.5433067",
"0.5433067",
"0.5429577",
"0.54286355",
"0.5412559",
"0.54101646",
"0.5408604",
"0.5405769",
"0.5399075",
"0.5398985",
"0.5397518",
"0.53960514",
"0.53880745",
"0.53792745",
"0.53788936",
"0.5369261",
"0.5366683",
"0.53449416"
] | 0.7541487 | 0 |
get(Symbol) method that returns a node by the id returns | def get id
@nodes[id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node(id)\n @nodes[id.to_i]\n end",
"def get_node(id)\n get_object('node', id)\n end",
"def node_by_id(id)\r\n @nodes.each do |n|\r\n return n if n.attributes['id'] == id \r\n end\r\n end",
"def get_node_by_id(id, options={})\n options[:exactget] ||= {}\n options[:exactget][:id] = id.to_s\n ret = get_nodes(options)\n if ret.empty?\n warn \"Cannot find node #{name}\"\n ret = nil\n elsif ret.values.size == 1\n ret = ret.values[0]\n else\n raise \"Multiple nodes returned for #{name}\"\n end\n ret\n end",
"def []( id )\n get_node_by_id( id ) ||\n get_edge_by_id( id )\n end",
"def get_node(key); end",
"def bnode(id)\n RDF::Node.intern(id)\n end",
"def get(key)\n node_for(key).get(key)\n end",
"def []( id )\n get_tree_by_id( id ) ||\n get_network_by_id( id )\n end",
"def find(id)\n node = @nodes[id]\n return node if node\n\n addr = Directory[id]\n return unless addr\n\n if id == DCell.id\n node = DCell.me\n else\n node = Node.new(id, addr)\n end\n\n @nodes[id] ||= node\n @nodes[id]\n end",
"def get_node(node)\n\t\t\t@nodes[node]\n\t\tend",
"def node_get(node)\n nodes.fetch prepare_key(node), nil\n end",
"def find id\n return nil if node.ids.empty?\n node.send(:orm_class).find id\n end",
"def fetch_node(key)\n node = fetch_node_nt(key)\n raise unless node\n node\n end",
"def node_from_id(input)\n\n site_id = @context['__site_id']\n \n # Attempt to locate the node.\n node = Rails.cache.fetch \"node_id:#{site_id}:#{input}\" do\n n = node_scope.where(:id => input.to_i).first\n n.blank? ? nil : n.to_liquid\n end\n\n node\n \n end",
"def dereference(id)\n crate.dereference(id)\n end",
"def node(node_name)\n nodes(node_name).first\nend",
"def id\n @node.id\n end",
"def get(\n id,\n deadline: nil\n )\n return @nodes.get(\n id,\n deadline: deadline,\n )\n end",
"def get(oid)\n roid=self.oid2roid(oid)\n return nil if roid.empty?\n validate_roid(roid)\n roid_first=roid.first\n node=@nodes[roid_first]\n return node.get(oid) if node\n return nil\n end",
"def find_with_id(id)\n @top_node.search(\"//*[@id='#{id}']\")\n end",
"def get_element id\n @elements[id.to_s]\n end",
"def find_with_id(id)\n @top_node.search(\"//*[@id='#{id}']\")\n end",
"def find_with_id(id)\n @top_node.search(\"//*[@id='#{id}']\")\n end",
"def node(name)\n return node_manager.find(name)\n end",
"def gatherNode(id)\n @nodes.bsearch { |n| n.data == data}\n end",
"def getNode(name)#name is the int for the vertice\n\t\t@graph.select {|nodes| nodes.node == name }[0] \n\tend",
"def [](leaf_id)\n node_hash leaf_node_id(leaf_id)\n end",
"def get_node(string_key)\n pos = self.get_node_pos(string_key)\n return nil if pos.nil?\n\n return @ring[@_sorted_keys[pos]]\n end",
"def node(id, params = {})\n get \"nodes/#{id}\", {query: params}\n end",
"def id\n @id ||= node.attr :tid\n end",
"def bnode(id)\n id.gsub!(/[^A-Za-z0-9\\-_]/, '_')\n @@nodes ||= {}\n @@nodes[id] ||= RDF::Node(id)\n end",
"def get(key)\n node = node_for_key(key)\n node.read(&@block)\n end",
"def [](uri)\n @nodes[uri]\n end",
"def node(name)\n nodes[name]\n end",
"def [](name)\n return @nodes[name]\n end",
"def get(key)\n @nodes[hash(Zlib::crc32(key), @nodes.size)]\n end",
"def [](id)\n @by_id[id]\n end",
"def node\n RDF::Node.new(namer.get_sym)\n 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 [](node_id)\n if node_id <= 0 || node_id >= @leaf_count * 2\n raise InvalidNodeId, \"Invalid node id #{node_id.inspect}\"\n end\n @nodes[node_id]\n end",
"def Node(node_id)\n return group(\"node#{node_id}\")\n end",
"def get(key)\n node = @node_map[key]\n if node\n # clip us out of the chain\n clip_node_from_list(node)\n insert_node_at_head(node)\n node.val\n else\n -1\n end\n end",
"def find_element_by_id(id)\n (e = @doc.at_css(\"##{id}\")) && NodeProxy.new(e)\n end",
"def get_node(id)\n CloudLB::Node.new(self,id)\n end",
"def dom_id\n node['id']\n end",
"def dom_id\n node['id']\n end",
"def lookup(id)\n\t\t@objects[id]\n\tend",
"def id\n source_node[:id]\n end",
"def node\n RDF::Node.new(namer.get_sym)\n end",
"def dom_id\n\t\tnode['id']\n\tend",
"def get id\n @map[id] || (raise \"#{id} not registered\")\n end",
"def fetch_znode(zk, id)\n zk.get(\"#{BROKERS_PATH}/#{id}\")[0]\n rescue ZK::Exceptions::NoNode\n nil\n end",
"def getObject(id)\n\t\tdoc.search(\"[@id='#{id}']\").first\n\tend",
"def get_node(letter)\n @node_pointers[letter.to_sym]\n end",
"def find(key)\n find_node(checked_get_node(key))\n end",
"def _load_node(neo_id)\n return nil if neo_id.nil?\n @graph_db.get_node_by_id(neo_id.to_i)\n rescue Java::OrgNeo4jGraphdb.NotFoundException\n nil\n end",
"def retrieve key\n\t\tnode = traverse @root, key\n\t\tnode.key\n\tend",
"def fetchNode(name)\n n = @node_def_list[name.to_sym]\n n ? n : raise(TypeCheckError, BAD_NODE_NAME + name.to_s)\n end",
"def fetchNode(name)\n n = @node_def_list[name.to_sym]\n n ? n : raise(TypeCheckError, BAD_NODE_NAME + name.to_s)\n end",
"def [](name)\r\n get_or_create_node(name.to_s, false)\r\n end",
"def get_node_by_name(name, options={})\n options[:exactget] ||= {}\n options[:exactget][:name] = name\n ret = get_nodes(options)\n if ret.empty?\n warn \"Cannot find node #{name}\"\n ret = nil\n elsif ret.values.size == 1\n ret = ret.values[0]\n else\n raise \"Multiple nodes returned for #{name}\"\n end\n ret \n end",
"def node_from_set(nodeset, index)\n if index.kind_of?(Integer)\n node = nodeset[index]\n elsif index.kind_of?(Symbol) && nodeset.respond_to?(index) \n node = nodeset.send(index)\n else\n raise \"Could not retrieve node using index #{index}.\"\n end\n \n return node\n end",
"def get(key)\n node = _get(@root, key)\n return nil unless node\n node.value\n end",
"def find_node(node_number)\n @_node_map[node_number]\n end",
"def node(key)\n @network.node(@values[key])\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 find_node_by_name(name)\n @nodes[name]\n end",
"def find(id)\n @data[id]\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 find_by_id(goid)\n self[goid]\n end",
"def node(name)\n name = name.to_sym\n @nodes.detect{|node|\n node.name == name\n }\n end",
"def get_tag_from_id(tag_id, reload = false) get_hash_tags(reload)[tag_id] end",
"def fetch_node_from_db(key)\n # XXX: shorthand object decoding by removing unused & type fields\n obj = db[key][9..-1]\n\n begin\n node = Node.make(obj, 0, :prefix, key, true)\n\n if node && node.inner?\n if node.v2? != v2?\n raise unless root && root.empty?\n if v2?\n @root = make_v2\n else\n @root = make_v1\n end\n end\n end\n\n return node\n rescue Exception\n puts \"TODO: verify\"\n return TreeNode.new\n end\n end",
"def get_node(object)\n @nodes.each do |node|\n return node if node.object == object\n end\n end",
"def [](name)\n @nodes[name.to_s]\n end",
"def get(node_id)\n @@directory_lock.synchronize do\n @@directory[node_id]\n end\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 [](id)\n id = get_id(id) if id.is_a?(Symbol)\n id = 0 unless id.is_a?(Integer) && id_valid?(id)\n return @data[id]\n end",
"def get_variable(id) #method\n @variables[id]\n end",
"def get(id)\n server.get(\"#{name}/#{CGI.escape(id)}\")\n end",
"def get(id)\n return unless id\n with_redis { |redis| redis.get(redis_key_for(id)).try { |data| load(data) } }\n end",
"def dom_id\n node['id']\n end",
"def get_node(root, path)\n return root[path] if path.is_a?(Symbol)\n\n path = path.to_s.split('.') unless path.is_a?(Array)\n node = root\n\n path.each { |key|\n if node.is_a?(Hash)\n node = node[key.to_sym]\n elsif node.is_a?(Array)\n i = key.to_i\n return nil if i.zero? && key != i && key != i.to_s\n node = node[i]\n else\n return nil\n end\n }\n\n node\n end",
"def on_ident(node, compiled_grammar)\n return node.children[0]\n end",
"def tree_lookup(name)\n @pairs[name]\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def [](n)\n if n.class == String\n ret = @lookup_name[n]\n ret = @lookup_mac[n] if !ret\n return ret\n end\n @nodes[n]\n end",
"def get_obj(obj,id)\n a = try(\"@#{obj}s['#{id}'.to_sym] if defined?(@#{obj}s['#{id}'.to_sym])\")\n if a\n print \"+\" if @debug == true\n return a\n else\n print \"-\"\n return nil\n end\n end",
"def nodeWithID(pageID, node)\n if node.pageID == pageID\n return node\n end\n node.childNodes.each do |childNode|\n res = nodeWithID(pageID, childNode)\n if res\n return res\n end\n end\n return nil\nend",
"def [](value)\n Placeholder.resolve(node_data[value.to_s])\n end",
"def get_node(i=0)\n nodes.select {|a| a.number == i.to_i}.first\n end",
"def node\n return @node\n end",
"def lookup_node_by_hw_id(options = { :hw_id => [] })\n unless options[:hw_id].count > 0\n return nil\n end\n matching_nodes = []\n nodes = get_data.fetch_all_objects(:node)\n nodes.each do\n |node|\n matching_hw_id = node.hw_id & options[:hw_id]\n matching_nodes << node if matching_hw_id.count > 0\n end\n\n if matching_nodes.count > 1\n # uh oh - we have more than one\n # This should have been fixed during reg\n # this is fatal - we raise an error\n resolve_node_hw_id_collision\n matching_nodes = [lookup_node_by_hw_id(options)]\n end\n\n if matching_nodes.count == 1\n matching_nodes.first\n else\n nil\n end\n end",
"def find_node(nd_name)\n chef_nodes.find{|nd| nd.name == nd_name }\n end",
"def value_of_node(node_name)\n value_of_nodes(node_name).first\nend",
"def lookup(type_name, id)\n return unless type_name.starts_with?(namespace)\n types.each_pair do |type, graph_type|\n return type.find(id) if graph_type.name == type_name\n end\n nil\n end",
"def [](name)\n name = name.to_sym\n @nodes.detect { |node| node.name == name }\n end",
"def [](value)\n node_data[value.to_s]\n end",
"def get(id)\n return nil if id.nil?\n\n return objects[id] if objects.has_key?(id)\n\n type, content = get_object(id)\n\n klass = TYPE_CLASS[type] or raise NotImplementedError, \"type not supported: #{type}\"\n\n objects[id] = klass.new(self, id, content)\n end"
] | [
"0.77852273",
"0.7746689",
"0.74849606",
"0.7415566",
"0.7203441",
"0.6996068",
"0.6890222",
"0.6885043",
"0.6787701",
"0.6758027",
"0.66858804",
"0.66643023",
"0.66091704",
"0.6607736",
"0.6528776",
"0.65238875",
"0.65092194",
"0.6489196",
"0.64593965",
"0.64387286",
"0.63982904",
"0.63943636",
"0.6388068",
"0.6388068",
"0.63747305",
"0.63708884",
"0.6334485",
"0.6316292",
"0.63036215",
"0.6293563",
"0.62824357",
"0.62690014",
"0.62658",
"0.6253874",
"0.62485784",
"0.6221083",
"0.6195793",
"0.6195348",
"0.6192768",
"0.6183667",
"0.61735886",
"0.6169498",
"0.6169198",
"0.616908",
"0.6163642",
"0.61463463",
"0.61463463",
"0.6142098",
"0.6133443",
"0.6105335",
"0.61041874",
"0.6084872",
"0.6070515",
"0.6069512",
"0.60651964",
"0.6048782",
"0.604855",
"0.60429615",
"0.6041733",
"0.6041733",
"0.6030361",
"0.60293883",
"0.6028477",
"0.6026415",
"0.6024857",
"0.60163087",
"0.6005526",
"0.5993682",
"0.59915656",
"0.5977275",
"0.5974185",
"0.59643006",
"0.59522",
"0.59399986",
"0.59283274",
"0.5921894",
"0.59153914",
"0.5892474",
"0.5890877",
"0.5888338",
"0.5885175",
"0.58818114",
"0.58759964",
"0.5875745",
"0.587393",
"0.58527076",
"0.5841463",
"0.58401513",
"0.5839273",
"0.5838296",
"0.58374",
"0.5836375",
"0.58281654",
"0.5809086",
"0.57976854",
"0.5797103",
"0.57894206",
"0.57884735",
"0.5782611",
"0.5779578"
] | 0.79646957 | 0 |
add(Symbol) method that initialize a node | def add id
return unless @nodes[id].nil?
@nodes[id] = Array.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(node); end",
"def add_node(node)\n if node.respond_to?(:to_sym)\n node = Woodhouse::Layout::Node.new(node.to_sym) \n end\n expect_arg :node, Woodhouse::Layout::Node, node\n @nodes << node\n node\n end",
"def init_node\n end",
"def init_node\n end",
"def add_node(node)\n nodes[node.value] = node\n end",
"def add_node kind, label, attrs\n @node_buffer << Node.new(\n kind: kind,\n label: label,\n attrs: attrs\n )\n end",
"def add_node(name, node)\n language.nodes[name] = node if name\n node\n end",
"def add_node( node )\n super( node )\n __add_node__( node )\n end",
"def on_symbol(node)\n node = node[0] if node.is_a?(Array)\n\n return Node.new(:symbol, node.children, metadata(node))\n end",
"def initialize(name, symbol)\n\t\t@name = name \n\t\t@symbol = symbol\n\tend",
"def new_node(*args)\n add_node(build_node(*args))\n end",
"def add(item)\n\t\t\t@hash[item] = Node.new\n\t\tend",
"def initialize(name, symbol)\n\t\t@name = name\n\t\t@symbol = symbol\n\tend",
"def add(\n symbol: nil,\n type:,\n belongs_to: nil,\n parse_rule: nil\n )\n rule = symbol || parse_rule\n\n @base << {\n symbol: symbol,\n type: type,\n belongs_to: belongs_to,\n parse_rule: parse_rule,\n token_length: calculate_length(rule)\n }\n self\n end",
"def initialize(symbol)\n @symbol = symbol\n super()\n end",
"def add_node(node)\n @nodes[node.uri] ||= node\n end",
"def initialize(name, symbol)\n @name = name\n @symbol = symbol\n end",
"def node=(_arg0); end",
"def createRegister symbol\n s(:send, nil, :register,\n s(:sym, symbol),\n s(:lvar, symbol)\n )\n end",
"def createRegister symbol\n s(:send, nil, :register,\n s(:sym, symbol),\n s(:lvar, symbol)\n )\n end",
"def initialize(node)\n @node = node\n end",
"def add_node(node)\n @nodes.add node\n end",
"def add(term)\n root.add Buffer.new(normalize(term) + delimiter), term\n end",
"def add(name, node)\n raise ArgumentError.new unless name.is_a?(Token)\n raise ArgumentError.new unless node.is_a?(Node)\n\n # Should point to last added variable, as its the stack\n if node.respond_to?(:stack_slot)\n node.stack_slot = $curr_stack_slot\n $curr_stack_slot += node.type.get_stack_slot_size\n end\n\n # If there's another variable with same name in this scope, it's error\n if @members[name.value]\n semantic_error(name, \"duplicate variable `%s'\" % [name.value])\n else\n @members[name.value] = node\n end\n end",
"def initialize symbol, *args, &block\n @symbol = symbol.to_sym\n @args = args\n @block = block\n end",
"def initialize(symbol)\n @symbol = symbol # the printable representation of variable\n end",
"def add(key, value)\r\n \t\t\t# Create new node for key, value to be added and set next to head \r\n \t\t\t# and then set head to the new node\r\n \t\t\tn = Node.new(key, value, @head)\r\n \t\t\t@head = n\r\n \t\tend",
"def initialize(symbol, value, succ)\n @symbol = symbol\n @value = value\n @succ = succ\n end",
"def initialize(node:)\n @node = node\n end",
"def __node(name, params = {}, &block)\n require_relative './node'\n @__nodes << Node.new(name, params, __depth + 1, &block)\n end",
"def node=(_); end",
"def node=(_); end",
"def initialize(node)\n @node = node # the @ symbol makes is an instance variable Which means you can access these variables in ANY METHOD inside the class.\n end",
"def add_node(node)\n #$DEBUG.puts \"Registering #{SNMPPass.num2oid(node.oid)} with #{node}\"\n @fields[node.oid]=node\n end",
"def initialize(val, next_in_line)\r\n\t\t@value = val\r\n\t\t@next_node = next_in_line\r\n\t\tputs \"Initialized a Node with value: \" + @value.to_s\r\n\tend",
"def add(node)\r\n @nodes << node\r\n end",
"def add_node(key, val)\n @store.append(key, val)\n end",
"def initialize(node)\n @node = node\n end",
"def initialize(node)\n @node = node\n end",
"def initialize(node)\n @node = node\n end",
"def initialize(node)\n @node = node\n end",
"def create_node(node, token)\n raise NotImplementedError\n end",
"def initialize(data)\n @head = Node.new(data)\n end",
"def initialize_node(options={})\n raise NotImplementedError\n end",
"def initialize( node )\n @node = node\n end",
"def initialize(sym)\n @sym = sym\n end",
"def add(name, value = nil)\n symbols << [name.to_s, (Integer(value) if value)]\n end",
"def initialize(node)\n @node = node\n end",
"def initialize(node)\n @node = node\n end",
"def initialize n, sym, wall_op, path_op\n @name = n\n @symbol = sym\n @symbolw = (sym.to_s + \"w\").to_sym\n @wall_options = wall_op\n @path_options = path_op\n @@sector_hash[sym] = self # add this to the list.\n end",
"def make_node(type, *args)\n elem = type.new self, *args\n @nodes << elem\n self.core_node ||= elem.id\n elem.expand\n elem\n end",
"def new_node(element)\n Node.new(element)\n end",
"def initialize(ident, parent=nil)\n @ident = ident\n @symtab = {} # key: name, value: symbol\n\n self.parent = parent\n end",
"def initialize(node)\n @node = node\n end",
"def initialize(node)\n @node = node\n end",
"def initialize(symbol)\n\t\t\n\t\tif symbol == \"\" || nil then\n\t\t\traise ArgumentError, \"Must enter a valid symbol\"\n\t\telse\n\t\t\t@symbol = symbol\n\t\tend\n\t\t\n\tend",
"def add(name, &block)\n new_node = self.children.create!(:name => name.to_s)\n yield(new_node) if block_given?\n end",
"def add\r\n node = mul()\r\n\r\n loop do\r\n if consume(\"+\")\r\n node = new_binary(ND_ADD, node, mul())\r\n elsif consume(\"-\")\r\n node = new_binary(ND_SUB, node, mul())\r\n else\r\n return node\r\n end\r\n end\r\nend",
"def add_node(value)\n if @head\n @head = Node.new value, @head\n else\n @head = Node.new value, nil\n end\n end",
"def add_nodes(*args)\n node = super\n node.fontname = @font\n node\n end",
"def initialize(first_value=nil)\n @head = Node.new(first_value)\n end",
"def add_sym ( addr, name )\n\t@syms[addr] = name\n end",
"def add_node(node)\n\t\t\tunless has_node?(node)\n\t\t\t\t@nodes[node] = new_node(node)\n\t\t\t\t@order += 1\n\t\t\tend\n\t\t\tself\n\t\tend",
"def add_lhs(node_name,node_value)\n\t\t@lhs[@nb_lhs]=[node_name,node_value]\n\t\t@nb_lhs+=1\n\tend",
"def _addElement( key, value )\n @token.addElement( key, value )\n end",
"def add_node(value)\n add_node_support(value, :linked_list)\n end",
"def initialize node\n raise ArgumentError, \"Expected SGF::Node argument but received #{node.class}\" unless node.instance_of? SGF::Node\n @root = node\n @current_node = node\n end",
"def initialize(symbol, options, &block)\n @symbol, @options, @block = symbol,options,block\n end",
"def add_node(word, definition)\n if @head.nil?\n add_first_node(word, definition)\n else\n new_node = Node.new(word, definition)\n @last.next = new_node\n @last = new_node\n end\n puts \"Added node with word: #{word} and defintion #{definition}\"\n end",
"def <<(node); add(node); end",
"def initialize(word = '')\n\t\t@children = Hash.new\n\t add(word)\n\tend",
"def add(key,value)\n @root = Node.new(key[0], nil) if (@root == nil)\n @root.add_vertical(key,value)\n end",
"def initialize(node)\n @root_node = node\n end",
"def create_node(value)\n node = Node.new(value)\n end",
"def add(val)\n if @next == nil\n @next = ListNode.new(val)\n else\n @next.add(val)\n end\n end",
"def AddNode(type, xpos, ypos, numRadios = 0)\n\tname = NodeName(xpos, ypos)\n\tnode = Orbit::Topology::Node.new(@lastId, name, type)\n\tnode.SetPos(xpos,ypos)\n\t@lastId=@lastId+1\n\t#let OMF know we have created this node\n\tDefineGroup(node)\n\t@nodes_by_name[name]=node\n\treturn node\n end",
"def add_first(data)\n new_node = Node.new(value, @head)\n @head = new_node\n end",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n end",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n end",
"def add(name, country, continent, timezone, coords, pop, region, node_city, edges=Array.new)\n node = Node.new(name, country, continent, timezone, coords, pop, region)\n @nodes[node_city] = node\n @edges[node_city] = edges\n self\n end",
"def initialize\n @root_node = Node.new\n end",
"def from_node(node); end",
"def setup_node(&blk)\n\t\t\t\tnode_setup_blocks << blk\n\t\t\tend",
"def symbol! sym\n initialize\n s0 = new_state\n s1 = new_state\n set_start(s0)\n set_final(s1, true)\n add_transition(s0, s1, sym)\n if (sym != \"\") && (!@alphabet.include? sym)\n @alphabet.push sym\n end\n end",
"def add_entry(symbol, *options)\r\n @list[0].add_entry(symbol, *options)\r\n end",
"def node(name, ref, *args, &block); end",
"def add(word)\n node = @root\n word.downcase!\n word.each_char do |letter|\n node[letter] ||= Hash.new\n node = node[letter]\n end\n node[:end] = true\n end",
"def initialize(data)\n @node_data = data\n end",
"def initialize(name)\n @children={}\n if name.kind_of? String\n\t\t\t\t@node_name=name.to_sym\n\t\t\telse\n\t\t\t\t@node_name=name\n\t\t\tend\n end",
"def add\n match '+'\n term\n emit_ln 'ADD (SP)+, D1'\nend",
"def initialize ast\n @ast = ast\n end",
"def create_node(node, tag=nil)\n end",
"def test_add_node\r\n reader = GraphReader.new('whatever')\r\n reader.add_node(0, 'A', [1])\r\n assert_equal reader.graph[0].letter, 'A'\r\n end",
"def generate_declaration (node)\n\n\tputs \"Generating a nice declaration...\"\n\n\t\t\n\tentry = $static_table.add(node.children[1].symbol)\n\tlda(\"00\")\n\tsta(entry.address)\n\nend",
"def initialize(node)\n\t\t\t@node = node\n\t\t\t@name = @node[:macro]\n\t\t\t@value = @node[:value]\n\t\t\t@source = @node[:source]\n\t\t\t@escaped_pipe = '‡‡‡‡‡ESCAPED¤PIPE‡‡‡‡‡'\n\t\tend",
"def initialize(player_number, symbol)\n @symbols = %i[O X $ # % & @].reject { |sym| sym == symbol }\n init_name(player_number)\n init_symbol\n end",
"def register_node(address)\n nodes << address.gsub(/\\/.*/, \"\")\n end",
"def insert(node, &block); end",
"def insert(node, &block); end",
"def add_children(char)\n @childrens[char] = Node.new(char)\n end",
"def add_node(data)\n\n\t\t# change tactics if we're adding the first node\n\t\tif @head.nil?\n\n\t\t\tadd_first_node(data)\n\n\t\telse\n\n\t\t\tnew_node = Node.new(data)\n\n\t\t\t# point the last node to our new one\n\t\t\t@last.next = new_node\n\n\t\t\t# set our new node as the official last node\n\t\t\t@last = new_node\n\n\t\tend\n\t\tputs \"Added node with the value: #{data}\"\n\tend"
] | [
"0.7198449",
"0.68868583",
"0.6852834",
"0.6852834",
"0.67188424",
"0.66785353",
"0.64642626",
"0.6371331",
"0.6333908",
"0.6322772",
"0.63000983",
"0.6280861",
"0.62774485",
"0.6263306",
"0.6238344",
"0.6218626",
"0.6192438",
"0.6153654",
"0.6151166",
"0.6151166",
"0.6116891",
"0.608928",
"0.6086363",
"0.6074525",
"0.60692364",
"0.60690933",
"0.6060137",
"0.6025997",
"0.60259664",
"0.6000767",
"0.6000194",
"0.6000194",
"0.5990337",
"0.59506893",
"0.5935221",
"0.5932294",
"0.5927033",
"0.59200495",
"0.59200495",
"0.59200495",
"0.59200495",
"0.5916263",
"0.59116495",
"0.5905261",
"0.588299",
"0.58456635",
"0.58412766",
"0.5840186",
"0.5840186",
"0.5839525",
"0.5833525",
"0.58181834",
"0.58088845",
"0.5801933",
"0.5801933",
"0.5799444",
"0.57953376",
"0.57951033",
"0.57935596",
"0.5790653",
"0.57888955",
"0.57783973",
"0.57720447",
"0.57695174",
"0.5767027",
"0.57668865",
"0.5757709",
"0.57574195",
"0.5751942",
"0.57448727",
"0.57359755",
"0.57302815",
"0.5714951",
"0.57068574",
"0.5698759",
"0.5694589",
"0.56914556",
"0.5684006",
"0.5684006",
"0.56814784",
"0.5672952",
"0.5662954",
"0.56625915",
"0.5659965",
"0.565934",
"0.5653631",
"0.5653448",
"0.56494004",
"0.564882",
"0.56425023",
"0.5638971",
"0.56348354",
"0.5634233",
"0.562587",
"0.56258047",
"0.56236446",
"0.56116086",
"0.5609558",
"0.5609558",
"0.56093735",
"0.5608959"
] | 0.0 | -1 |
connect(Edge) method that adds a connection to the list of nodes returns | def connect edge
self.add edge.src
self.add edge.dst
@nodes[edge.src] << edge
edge
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_nodes(node1, node2)\n # node1.connect(node2)\n end",
"def __connect__(node)\n raise \"Cannot connect to a node which is not on the same graph!\" if node.graph != @this.graph\n node.in.instance_exec(@this) { |n| @others << n }\n @graph.instance_eval { @changed = true }\n end",
"def connectWith(node, weight = 0)\n edge = Edge.new(self, node, weight)\n @edges << edge\n\n edge\n end",
"def connect(vertex1, vertex2, edge_attributes = {})\n self.vertices << vertex1 unless self.vertices.include? vertex1\n self.vertices << vertex2 unless self.vertices.include? vertex2\n edge = Edge.new(edge_attributes)\n self.edges << edge\n edge << vertex1 << vertex2\n end",
"def connect_for!(source, edge_args, target)\n edge = Edge(source, edge_args, target)\n\n self[:graph][source][edge] = target\n\n return target, edge\n end",
"def connect(node0, node1)\n @connections << [node0, node1] unless @connections.include? [node0, node1]\n @connections << [node1, node0] unless @connections.include? [node1, node0]\n end",
"def connect node1, node2\n if !Set.new([node1, node2]).subset? @nodes\n raise BadNodeInput, 'The graph does not have either ' + node1 + ' or ' + node2\n end\n @connections[node1] ||= Array.new\n @connections[node1].push node2\n unless node1.eql? node2\n @connections[node2] ||= Array.new\n @connections[node2].push node1\n end\n end",
"def connect(peer)\n return if @connections[peer]\n @connections[peer] = []\n peer.connections[self] = []\n\n Layout.parallel_links.times do\n local = add_link\n remote = peer.add_link\n @connections[peer].push([local, remote])\n peer.connections[self].push([remote, local])\n end\n end",
"def connect(params)\n order = params[:order]; from = params[:from]; to = params[:to]\n\n if to.kind_of?(Enumerable)\n to.each do |singularized_to|\n connect :from => from, :to => singularized_to, :order => order\n end\n else\n edges.add(from, to, order)\n end\n end",
"def connect_over(node)\n node.inputs.each do |producer_edge|\n node.outputs.each do |consumer_edge|\n connect(\n producer_edge.from,\n consumer_edge.to,\n producer_edge.type,\n producer_edge.label\n )\n end\n end\n end",
"def add_edge(from, to)\n from.adjacents << to\n end",
"def connect(src, tar, distance = 1)\n unless @nodes.include?(src)\n raise ArgumentError, \"No such node: #{src}\"\n end\n unless @nodes.include?(tar)\n raise ArgumentError, \"No such node: #{tar}\"\n end\n @edges.push Edge.new(src, tar, distance)\n end",
"def add_edge(nodeA, nodeB)\n nodeA.adjacents << nodeB\n nodeB.adjacents << nodeA\n\n @nodes << nodeA\n @nodes << nodeB\n end",
"def connect(lnode)\n @lnode = lnode\n end",
"def add_edge(element1, element2)\n index1 = self.dict[element1]\n index2 = self.dict[element2]\n raise Exception.new(\"Nodes not exist!\") unless index1 && index2\n\n head_node2 = self.adj_list_array[index2].head_node\n new_node1 = Node.new(element1, head_node2.next_node)\n head_node2.next_node = new_node1\n\n\n head_node1 = self.adj_list_array[index1].head_node\n new_node2 = Node.new(element2, head_node1.next_node)\n head_node1.next_node = new_node2\n\n self\n end",
"def add_edge(node_a, node_b)\n node_a.adjacents << node_b\n node_b.adjacents << node_a\n end",
"def connect_endpoint(collection, edge)\n if collection.any? { |o| ! edge.equal?(o) && edge.similar?(o) }\n raise DuplicateEdgeError.new(self, edge)\n end\n\n collection.add(edge)\n end",
"def add_edge(a,b)\n @adj_list[a][b] = 1\n end",
"def add_edge(node)\n @adj_nodes.push(node.position)\n end",
"def add_edge(source_vertex, destination_vertex)\n @adjacent_list[source_vertex].push(destination_vertex)\n @indegree[destination_vertex] += 1\n end",
"def connect(a, b, weight = 0.5)\n c = Connection.new a, b, weight\n a.join c\n # Also add the Connection here\n connections << c\n end",
"def add_edge(e)\n @edges[e.from] << e\n end",
"def connect(vert1, vert2)\n # Basically, if the two elements in the edge set are in the @vertices\n # set, then we add the edge to the set.\n edge = [ vert1, vert2 ]\n\n if (edge.to_set & @vertices) == edge.to_set\n @edges.add(edge)\n end\n end",
"def connect(from, to, type, label = nil)\n raise if from == to\n raise if !to.is_a?(PhiNode) && type == :data && label.nil?\n\n edge = Edge.new(from, to, type, label)\n from.outputs << edge\n to.inputs << edge\n end",
"def connect(src, dest, len = 1)\n\t\tif self.include?(src) and self.include?(dest) and !edge_exists?(src, dest) and len > 0\n\t\t\t\t@e << Edge.new(src, dest, len)\n\t\telse\n\t\t\treturn nil\n\t\tend\n\t\ttrue\n\tend",
"def <<(other)\n c = Connection.new\n c.end = other\n other.edges << self unless other.edges.include? self\n self.connections << c\n self\n end",
"def connect_mutually(vertex1, vertex2, distance = 1)\n self.connect vertex1, vertex2, distance\n self.connect vertex2, vertex1, distance\n end",
"def add_edge(from, to, weight = 1.0)\n\t\t\tadd_node(from)\n\t\t\tadd_node(to)\n\t\t\t@size += 1 if connect(from, to, weight)\n\t\t\tself\n\t\tend",
"def add_edge(object_1, object_2)\n node_1 = check_object(object_1)\n node_2 = check_object(object_2)\n node_1.adjacents << node_2\n node_2.adjacents << node_1\n end",
"def add_edge(src, dest)\n # add a edge to the head\n @adjList[src] << dest\n # since this graph is not directed we need to do the oposite also\n # @adjList[dest] << src\n @edges += 1\n end",
"def add_edge(node1, node2, weight)\n nodes[node1.value].add_edge(nodes[node2.value], weight)\n nodes[node2.value].add_edge(nodes[node1.value], weight)\n self\n end",
"def add_edge(edge)\n @edges.push(edge)\n end",
"def connections_to(node)\n node = get_index_from_node(node)\n @adj_mat.map {|row| row[node] }.map.with_index do|el, row_num| \n el == 0 ? nil : @nodes[row_num]\n end.select{ |el| el } \n end",
"def connections_to(node)\n node = get_index_from_node(node)\n @adj_mat.map {|row| row[node] }.map.with_index do|el, row_num| \n el == 0 ? nil : @nodes[row_num]\n end.select{ |el| el } \n end",
"def add_edge( edge )\n super( edge.source, edge.target, edge )\n __add_edge__( edge )\n end",
"def add_edge(id1, id2)\n # YOUR WORK HERE\n end",
"def connect( from: nil, to: nil )\n input_neuron = @neurons[ to ]\n output_neuron = @neurons[ from ]\n input_neuron.add_input( output_neuron )\n end",
"def add_edge(source, dest, weight)\n edges << Edge.new(source, dest, weight)\n end",
"def add_edge(node, weight)\n @adjacent_nodes[node.value] = { weight: weight, node: node }\n self\n end",
"def connectable_nodes_from(nodes)\n @calls << [:connectable_nodes_from, nodes]\n nodes & @accept_nodes\n end",
"def connect_cells(cell)\n @connected_cells << cell\n cell.connected_cells << self\n end",
"def add_edge(from_node, to_node)\n add_node(from_node)\n add_node(to_node)\n @nodes[from_node] << to_node\n @node_dir_ancestors[to_node] << from_node\n\n if self.has_cycle\n puts \"No longer DAG\"\n end\n end",
"def handle_connect *args\n args.each {|a| @node.connect_peer(*a.split(':')) }\n {:state => \"Connecting...\"}\n end",
"def add_edge!(from, to)\n protected_add_edge!(from, to)\n @edge_number += 1\n end",
"def add_edge(src, dest, weight)\n @v << src if !@v.include?(src)\n @v << dest if !@v.include?(dest)\n new_edge = Edge.new(src,dest, weight)\n src.out_edges << new_edge\n dest.in_edges << new_edge\n @e << new_edge\n end",
"def addOtherEdge (node, dist)\n\t\t@edges.push([node, dist])\n\tend",
"def connect_graph(source, target, weight)\n if (!graph.has_key?(source))\n graph[source] = {target => weight}\n else\n graph[source][target] = weight\n end\n if (!locations.include?(source))\n locations << source\n end\n end",
"def add_connections(start_cell, end_cell)\n start_cell.connected_cells.each do |cell|\n (@cells_to_visit << cell).sort_by! { |cell| cell.distance_to(end_cell) } unless cell_array_visited.include?(cell)\n end\n end",
"def internal_connections\n stroke(200, 0, 0, 80)\n nodes[0..nodes.size - 1].each_with_index do |pi, i|\n nodes[i + 1..nodes.size - 1].each do |pj|\n line(pi.x, pi.y, pj.x, pj.y)\n end\n end\n end",
"def add_edge(source, target, weight = 1)\r\n\t\tself.push source unless self.include?(source)\r\n\t\tself.push target unless self.include?(target)\r\n\t\t@edges.push Edge.new(source, target, weight)\r\n\tend",
"def addEdge from, to, directed, weight=nil\n\t\treturn false if !isNode?(to) || !isNode?(from)\n\t\tgetNode(from).addConnection(to,weight)\n\t\tgetNode(to).addConnection(from,weight) if(!directed)\n\tend",
"def join(c)\n connections << c\n end",
"def with_connection_to(nodes, no_exception: false)\n @calls << [:with_connection_to, nodes, { no_exception: no_exception }]\n yield @connected_nodes.nil? ? nodes : @connected_nodes\n end",
"def connect(node, type = node.class.root_class)\n @internal_node.createRelationshipTo(node.internal_node, Neo4j::Relations::RelationshipType.instance(type))\n nil\n end",
"def add_edge(x, y)\n\t\traise if @x_connections[x] != -1\n\t\traise if @y_connections[yIdx(y)] != -1\n\t\t\n\t\t@x_connections[x] = y\n\t\t@y_connections[yIdx(y)] = x\n\t\t\n\t\t@unconnected_x_vertices -= 1\n\t\t\n#\t\traise if @x_connected_vertices.member?(xy[0])\n#\t\traise if @y_connected_vertices.member?(xy[1])\n\t\n\tend",
"def flat_edgelist\n ni = Hash.new\n @nodes.each_with_index { |n,i| ni[n]=i+1 }\n sa = []\n da = []\n @links.each_value do |l| \n sa << ni[l.src]\n da << ni[l.dest]\n end\n sa + da\n end",
"def add_edge(from, to, cost)\n @edges << Edge.new(from, to, cost)\n end",
"def add_connection(source, target, source_point, target_point, s_type, t_type, name, definition)\n\n line = Line2D::Double.new source_point, target_point\n\n source_intersecting_line = get_intersecting_line source, line\n target_intersecting_line = get_intersecting_line target, line\n\n source_intersecting_point = get_intersection_point line.get_p1,\n line.get_p2,\n source_intersecting_line.get_p1,\n source_intersecting_line.get_p2\n\n\n target_intersecting_point = get_intersection_point line.get_p1,\n line.get_p2,\n target_intersecting_line.get_p1,\n target_intersecting_line.get_p2\n\n sEP = add_endpoint s_type, source, source_intersecting_point.get_x, source_intersecting_point.get_y\n tEP = add_endpoint t_type, target, target_intersecting_point.get_x, target_intersecting_point.get_y\n\n connection = Connection.new sEP, tEP, name, definition\n\n [sEP,tEP].each {|ep| ep.connection = connection}\n\n label = JLabel.new name\n @panel.add label\n @cm.register_component label\n\n\n label.set_size label.get_preferred_size\n connection.label = label\n connection.reset_label_position\n\n @connections << connection\n connection\n end",
"def addEdge( from_vertex, to_vertex)\n addVertex( from_vertex )\n addVertex( to_vertex )\n @vertices[from_vertex] << to_vertex\n end",
"def add_edge(source, target, edge = Edge.new)\n _clear_cache\n @pathway.append(Bio::Relation.new(source, target, edge))\n edge\n end",
"def add_edge(node_city_A, node_city_B, distance)\n @edges[node_city_A] << Edge.new(node_city_B, distance)\n end",
"def add_edge(e)\n add_vertex(e.from); add_vertex(e.to)\n (@from_store[e.from].add?(e) && @to_store[e.to].add(e) && e) || edge(e.from, e.to)\n end",
"def get_connection_to(another_vertex)\n @edges.each do |edge|\n if edge.head == another_vertex || edge.tail == another_vertex\n return edge\n end\n end\n end",
"def connect()\n\t\t\t# Check queen(s) for peer list\n\n\t\t\t# Connect to peers\n\t\tend",
"def connect(p0) end",
"def connect(room)\n \n temp=Set.new([room])\n \n #Nil arr = false\n if !@@adjToRoom[self.number-1]\n @@adjToRoom[self.number-1]=temp\n #Add connectivity to reciprocal list \n connectBiDirectional(self,room)\n else \n @@adjToRoom[self.number-1].add(room) \n connectBiDirectional(self,room)\n end \n end",
"def collect_edge! #:yields: source, target, edge\n _clear_cache\n @pathway.relations.each do |rel|\n newedge = yield rel.node[0], rel.node[1], rel.relation\n rel.edge = newedge\n @pathway.append(rel, false)\n end\n self\n end",
"def add_directed_edge(id1,id2)\n @g[id1] ||= Array.new\n @g[id1] << id2\n end",
"def connect_dir(node1, node2)\n node1, node2 = get_index_from_node(node1), get_index_from_node(node2)\n @adj_mat[node1][node2] = 1\n end",
"def connect_dir(node1, node2)\n node1, node2 = get_index_from_node(node1), get_index_from_node(node2)\n @adj_mat[node1][node2] = 1\n end",
"def add_relation source_label, relation, destination_label, direction = '<->'\n # More popular nodes have more weigth\n @node_weights[source_label] += 1\n @node_weights[destination_label] += 1\n\n @edge_buffer << Edge.new(\n source_label: source_label,\n relation: relation,\n destination_label: destination_label,\n direction: direction\n )\n end",
"def attach!(target:raise, edge:raise, source:self)\n target = add!(target)\n\n connect!(target: target, edge: edge, source: source)\n end",
"def add_edge(edge)\n edge.each { |node| add_vertex(node) }\n @structure[edge[0]] << edge[1]\n end",
"def connections_from(node)\n node = get_index_from_node(node)\n @adj_mat[node].map.with_index do |adj_el, col_num|\n adj_el != 0 ? @nodes[col_num] : nil\n end.select{ |el| el }\n end",
"def connections_from(node)\n node = get_index_from_node(node)\n @adj_mat[node].map.with_index do |adj_el, col_num|\n adj_el != 0 ? @nodes[col_num] : nil\n end.select{ |el| el }\n end",
"def add_to_neighbors(node)\n @neighbors << node\n end",
"def add_adjacency(n1, n2)\n n1.adjacents << n2\n n2.adjacents << n1\n end",
"def add_edge(edge)\n @edges << edge\n add_node(edge.n1) unless @nodes.find_index(edge.n1)\n add_node(edge.n2) unless @nodes.find_index(edge.n2)\n @incident_map[edge.n1] << edge\n @incident_map[edge.n2] << edge\n end",
"def addEdge( from, to)\n addVertex( from )\n addVertex( to )\n @vertices[from] << to\n\t@vertices[from].uniq!\n end",
"def append_edge(edge)\n @meeting_edges << edge\n end",
"def addEdge (node, dist)\n\t\t@edges.push([node, dist])\n\t\tnode.addOtherEdge(self, dist)\n\tend",
"def add_edge(source, destiny, weigth)\n source, destiny, weigth = convert_values(source, destiny, weigth)\n\n add_vertex(source)\n add_vertex(destiny)\n\n make_edge(source, destiny, weigth)\n end",
"def connect_nodes(n,m)\n #check if nodes exist in the graph\n return false if (!@nodes.include?(n) || !@nodes.include?(m))\n #check if these nodes are already connected\n return false if (n.adj.include?(m) || m.adj.include?(n))\n n.adj << m\n m.adj << n\n true\n end",
"def add_edge(target_node,value)\n edges[target_node] = Edge.new(target_node,value)\n end",
"def show_connections(other)\n stroke(200, 200, 0, 20)\n stroke_weight(2)\n other_nodes = other.nodes\n nodes.each do |pi|\n other_nodes[0..other_nodes.size - 1].each do |pj|\n line(pi.x, pi.y, pj.x, pj.y)\n end\n end\n end",
"def link(other)\n self.class.graph.join(nil, vertex, other.vertex)\n end",
"def edge(resource,node1,node2) \n label = fetch_fragment(resource) if(@options.showedges)\n color = colour_map(resource) if (@options.colour_code)\n @root.add_edge(node1,node2,:label=>label,:color=>color)\n end",
"def add_connection(location)\n raise 'Error: input arguement to method add_connection' unless location.is_a? Location\n @neighbors << location\n end",
"def connect_action &block\n @actions[:connect] = block\n end",
"def add_edge(source, target = nil, label = nil)\n @reversal = nil\n if target\n edge = Puppet::Relationship.new(source, target, label)\n else\n edge = source\n end\n [edge.source, edge.target].each { |vertex| setup_vertex(vertex) unless vertex?(vertex) }\n @vertices[edge.source].add_edge :out, edge\n @vertices[edge.target].add_edge :in, edge\n @edges << edge\n true\n end",
"def c_edge(other_node, wt = 0)\n (self.outbound_edges.add(other_node, wt) &&\n other_node.inbound_edges.add(self, wt))\n self\n end",
"def add_edge(from_vertex, to_vertex)\n begin\n self[from_vertex].out_edges << to_vertex\n self[to_vertex].in_edges << from_vertex\n rescue NoMethodError => e\n err_suffix = \"in add_edge(#{from_vertex}, #{to_vertex}).\"\n if self[from_vertex].nil?\n puts(\"No vertex with id #{from_vertex} \" << err_suffix)\n else\n puts(\"No vertex with id #{to_vertex} \" << err_suffix)\n end \n end\n end",
"def add_edges(*args)\n edges = []\n len = args.length\n (len-1).times {|i| \n edge = Edge.new(args[i], args[i+1])\n edges.push(edge)\n }\n @list.concat(edges)\n return(edges)\n end",
"def add_edges(*args)\n edges = []\n len = args.length\n (len-1).times {|i| \n edge = Edge.new(args[i], args[i+1])\n edges.push(edge)\n }\n @list.concat(edges)\n return(edges)\n end",
"def connect_layers(source, destination)\n\t\tsource.neurons.each do |src_n|\n\t\t\tdestination.neurons.each do |dest_n|\n\t\t\t\tArrow.new(src_n, dest_n)\n\t\t\tend\n\t\tend\n\tend",
"def add_edge(*e)\n raise InvalidArgumentError if e.size > 2\n \n e = [e] if e.size == 2\n @edges.add(e[0])\n end",
"def r_edge(other_node)\n (self.edges << other_node) && (other_node.edges << self)\n self\n end",
"def test_adding_edge\n \n # Start a new graph with no vertices\n graph = Graph.new()\n \n # Add 2 vertices to the graph\n origin = { \"code\" => \"NYC\" ,\n \"name\" => \"New York\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => { \"N\" => 41, \"W\" => 74 } ,\n \"population\" => 22200000 ,\n \"region\" => 3 }\n \n destination = { \"code\" => \"WAS\" ,\n \"name\" => \"Washington\" ,\n \"country\" => \"US\" ,\n \"continent\" => \"North America\" ,\n \"timezone\" => -5 ,\n \"coordinates\" => {\"N\" => 39, \"W\" => 77} ,\n \"population\" => 8250000 ,\n \"region\" => 3 } \n graph.add_node(origin)\n graph.add_node(destination)\n \n assert_equal( graph.nodes().size, 2)\n \n # Add a two-way edge for the two vertices\n distance = 1370 \n graph.add_edge(origin[\"code\"] , destination[\"code\"], distance)\n graph.add_edge(destination[\"code\"] , origin[\"code\"], distance)\n \n assert_equal( graph.nodes[\"NYC\"].neighbors.size, 1)\n assert_equal( graph.nodes[\"WAS\"].neighbors.size, 1)\n assert_equal( graph.nodes[\"NYC\"].neighbors[\"WAS\"], distance)\n assert_equal( graph.nodes[\"WAS\"].neighbors[\"NYC\"], distance)\n \n end",
"def add_edge( from_key, to_key, weight = 0 )\n add_vertex(from_key) unless @vertices.include? from_key\n add_vertex(to_key) unless @vertices.include? to_key\n @vertices[from_key].add_neighbor( @vertices[to_key], weight )\n end",
"def add_edge(x, y, cost: 1)\n raise\n end"
] | [
"0.7149291",
"0.7143974",
"0.7126218",
"0.69445294",
"0.68873805",
"0.68495196",
"0.672731",
"0.67185426",
"0.6711184",
"0.6705357",
"0.6662451",
"0.65780455",
"0.65737826",
"0.65538955",
"0.6543518",
"0.65326816",
"0.6487913",
"0.6485545",
"0.6385783",
"0.635903",
"0.6352993",
"0.63439983",
"0.6284507",
"0.6256694",
"0.62309754",
"0.6206491",
"0.6183157",
"0.61363924",
"0.61256087",
"0.61122304",
"0.61120176",
"0.6109235",
"0.6101898",
"0.6101898",
"0.6087706",
"0.608201",
"0.606233",
"0.60412914",
"0.6034702",
"0.6032397",
"0.6026361",
"0.6022687",
"0.6018875",
"0.5952378",
"0.59151226",
"0.59143776",
"0.59077823",
"0.590515",
"0.59001505",
"0.5896889",
"0.58851194",
"0.5871885",
"0.5870797",
"0.58466333",
"0.5844968",
"0.5844952",
"0.5836675",
"0.5809807",
"0.5805321",
"0.579628",
"0.5791529",
"0.5743483",
"0.5742707",
"0.5734032",
"0.5713261",
"0.56979924",
"0.56933093",
"0.5684818",
"0.56791407",
"0.56791407",
"0.567217",
"0.56658435",
"0.5662039",
"0.5646372",
"0.5646372",
"0.5645821",
"0.5645667",
"0.5641979",
"0.56225383",
"0.5620935",
"0.5617037",
"0.56078213",
"0.56060165",
"0.5602174",
"0.5596154",
"0.5594035",
"0.5586693",
"0.5568733",
"0.55618274",
"0.5559051",
"0.5552403",
"0.55211776",
"0.5520892",
"0.5520892",
"0.55171263",
"0.55166876",
"0.5509285",
"0.54992723",
"0.54956686",
"0.5470674"
] | 0.8483913 | 0 |
distance(List) return the cost of a given route returns | def distance *path
cost, edge_exists = 0, false
# Adds the cost of the next move
neighbors = @nodes[path.shift]
neighbors.each do |node|
if node.dst == path.first
edge_exists = true
cost += node.length
break
end
end
# Iterates in depth when neighbor exists
return -1 unless edge_exists
if path.length > 1
sub_cost = distance *path
return -1 if sub_cost == -1
cost += sub_cost
end
cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate(route)\n dist = 0\n route.each_cons(2) { |points| dist = dist + points[0].distance(points[1])}\n dist\nend",
"def distance\n distance = 0\n @solution.each { |route| distance += route.distance }\n return distance\n end",
"def distance\n if valid\n route[:distance].to_i\n end\n end",
"def distance\n distance = 0\n distance_2d = 0\n elev_change = 0\n num_waypoints = 0\n if @waypoints.nil? then self.load_processed_waypoints end\n ext_waypoints = self.extrapolated_waypoints()\n for waypoint in ext_waypoints do\n if waypoint.length < 3\n waypoint[2] = get_elevation(waypoint[0],waypoint[1])\n end\n end\n for i in 1..ext_waypoints.length-1\n waypointA = ext_waypoints[i-1]\n waypointB = ext_waypoints[i]\n #num_waypoints += 1 + sub_waypoints(waypointA, waypointB)\n elevation_diff = (waypointB[2]-waypointA[2])\n distance_flat = waypoint_distance(waypointA, waypointB)\n distance_3d = Math.sqrt(distance_flat**2 + elevation_diff**2)\n #pp [distance_3d, elevation_diff, distance_flat]\n distance += distance_3d\n distance_2d += distance_flat\n elev_change += elevation_diff.abs\n end\n return [distance, elev_change, distance_2d]\n \n end",
"def calculate_distance(line_stops, origin_station, destination_station)\n orig_stop = line_stops.index(origin_station)\n dest_stop = line_stops.index(destination_station)\n dist = (orig_stop - dest_stop).abs\nend",
"def distance(start_point, end_point)\n result = prepare_url(start_point, end_point)\n return result[\"routes\"].first[\"legs\"].first[\"distance\"][\"value\"]/1000\n end",
"def distance_calculator\n @trips.each do |trip|\n @total_distance += trip.distance.to_f\n end\n end",
"def distance_list\n [['5 miles', '5'], ['10 miles', '10'], ['15 miles', '15'], \n ['25 miles', '25'], ['35 miles', '35'], ['50 miles', '50'],\n ['75 miles', '75'], ['100 miles', '100']]\n end",
"def total_distance_driven\n distances = rides.map{ |ride| ride.distance }\n distances.reduce(:+)\n end",
"def distance(arrListe)\n km = 0\n arrListe.each_with_index do |val, index|\n km += dist @poi[val], @poi[arrListe[index.next]] unless arrListe[index.next] == nil\n end\n return km.round(3)\n end",
"def parse_and_find_distance(full_route)\n cities = full_route.split('-')\n distance=0 \n cities.each_with_index do|city,index|\n if cities[index+1]\n route = prev_find{|route| route.start_city.to_s==city && route.end_city.to_s==cities[index+1]}\n if route\n distance += route.distance.to_i\n else\n return \"No Such Route\"\n end\n end\n end\n distance==0 ? \"No Such Route\" : distance\n end",
"def get_distance(view_list,a,b,n) \n start = view_list.index(a)\n finish = view_list.index(b)\n dist = (start-finish).abs\n return [dist,n-dist].min\n end",
"def distance_calculator(start, destination)\n #http://forrst.com/posts/Read_JSON_data_using_Ruby-13V\n url = \"http://maps.googleapis.com/maps/api/distancematrix/json?origins=#{start}&destinations=#{destination}&mode=driving&sensor=false\"\n \n buffer = open(url).read\n result = JSON.parse(buffer)\n \n duration = result[\"rows\"].first[\"elements\"].first[\"duration\"][\"value\"]\n distance = result[\"rows\"].first[\"elements\"].first[\"distance\"][\"value\"]\n return duration.to_f/60, distance.to_f/1000\nend",
"def total_distance\n approved_flights.sum(:distance)\n end",
"def distance\n return nil unless @locations.size > 1\n locations.each_cons(2).reduce(0) do |acc, (loc1, loc2)|\n acc + loc1.distance_to(loc2)\n end\n end",
"def cost\n cost = 0\n @solution.each { |route| cost += route.travel_time_and_cost[0] }\n return cost\n end",
"def distance\n distance_and_arc[:distance]\n end",
"def distance\n distance_and_arc[:distance]\n end",
"def distance(ride)\n point_pairs(ride).inject(0) do |total, pair|\n pair.first.distance = total\n pair.last.distance = total + distance_between(*pair)\n end\n end",
"def total_distance\n distances = self.rides.map { |ride| ride.distance }\n distances.inject(:+).to_f\n end",
"def total_distance\n rides.reduce(0) {|total, ride| total + ride.distance}\n end",
"def total_distance\n rides.reduce(0) {|total, ride| total + ride.distance}\n end",
"def calculate_distance_from_destination_for_all\n if @destination.nil?\n raise ArgumentError, 'Destination coordinates must be provided'\n end\n\n @customers.each do |customer|\n if valid_record?(customer)\n customer_lat_long = customer['latitude'], customer['longitude']\n end\n destination_lat_long = @destination[0], @destination[1]\n distance_between = DistanceBetween.new(customer_lat_long, destination_lat_long).calculate\n add_distance_to_customer_records(customer, distance_between)\n end\n end",
"def distance_price\n distance * price_per_km\n end",
"def total_distance()\n self.rides().map() { | ride | ride.distance() }.reduce(:+)\n end",
"def dist(*vertex_names)\n total, total_old = 0, 0\n vertex_names[0..-2].each_with_index do |name, index|\n vertex_start = adj_lists[vertex_num_for(name)]\n neighbor = vertex_start.adj_list\n\n while !neighbor.nil?\n if neighbor.name == vertex_names[index + 1]\n total += neighbor.weight\n break\n else\n neighbor = neighbor.next\n end\n end\n\n return \"NO SUCH ROUTE\" if total == total_old\n total_old = total\n end\n total\n end",
"def calculate_distance_with_math\n distance = []\n @params.each do |args|\n args.each_with_index do |arg, _index|\n validate(arg)\n lat1 = arg[0][0].to_f * Math::PI / 180\n lat2 = arg[1][0].to_f * Math::PI / 180\n lon1 = arg[0][1].to_f * Math::PI / 180\n lon2 = arg[1][1].to_f * Math::PI / 180\n dlat = lat2 - lat1\n dlon = lon2 - lon1\n\n a = (Math.sin(dlat / 2)**2) + (Math.cos(lat1) * Math.cos(lat2) * Math.sin(dlon / 2)**2)\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))\n\n distance << radius * c\n end\n end\n distance\n end",
"def distance_on_path(t)\n # for now, just average\n average_speed * t\n end",
"def trip_distance(duration)\n duration * @speed\n end",
"def total_distance\n sum = 0\n previous_city = nil\n @city_names.each do |city|\n sum += @fully_connected_map.get_distance(previous_city, city) if previous_city\n previous_city = city\n end\n \n return sum\n end",
"def trip_duration(distance)\n distance/speed\n end",
"def route\n index = @possible_distances.index(@possible_distances.min)\n @array_of_city_arrangements[index]\n end",
"def estimate_price(from, dest)\n distance = from.zip(dest).map { |x| x.reduce(:-).abs }.sum\n @total_pay = distance * 300\n \"Distance : #{distance}\\nThe price is #{total_pay}\"\n end",
"def distance (hash, dep_station, line, intersect)\n # line = hash.fetch(line.to_sym)\n stops = line.each_index.select{|i| line[i] == intersect}.join.to_i - line.each_index.select{|i| line[i] == dep_station}.join.to_i \n if stops < 0\n return -stops\n else\n return stops\n end\nend",
"def calculateDistance(r1,c1,r2,c2)\r\n\treturn Math.sqrt(((c1-c2) ** 2 + (r1 -r2) ** 2))\r\nend",
"def find_by_route\n @result = Array.new\n @distancias = Array.new\n\n @ride = Ride.order('id')\n if params[:radio] != '0'\n @ride.each do |p|\n distancia1 =Geocoder::Calculations.distance_between([params[:destLatitud],params[:destLongitud]], [p.destPointLat,p.destPointLong])\n distancia2 =Geocoder::Calculations.distance_between([params[:startLatitud],params[:startLongitud]], [p.startPointLat,p.startPointLong])\n if distancia1 <params[:radio].to_f && distancia2 <params[:radio].to_f\n @result.push(p)\n #@distancias.push(distancia1)\n end\n end\n # json_response={\n # result: @result,\n # distancias: @distancias\n # } \n respond_with @result , location: nil\n end\n if params[:radio] == '0'\n respond_with @ride,location: nil\n end \n #Ride.find_by_destPointLat_and_destPointLong(params[:latitud],params[:longitud])\n \n end",
"def calculate_distance(vals1, vals2)\n vals1_sum = vals1.inject(:+)\n vals2_sum = vals2.inject(:+)\n\n (0..11).map { |i| ((vals1[i].to_f/vals1_sum)-(vals2[i].to_f/vals2_sum))**2 }.inject(:+)\nend",
"def trip_cost(distance, miles_per_gal, price_per_gal)\n result = (((distance.to_f / 100) * miles_per_gal) * price_per_gal) #can also do distance / 100.0 because as long as one of the numbers is a floating point it will return a decimal number\n return result\nend",
"def distance\n distance = 0\n (@path.size - 1).times { |i| distance += Vertex.euclidean_distance(@path[i], @path[i+1]) }\n return distance\n end",
"def dist(line_start, stop_start, stop_finish)\n x = $mta[line_start].index(stop_start)\n y = $mta[line_start].index(stop_finish)\n return (x - y).abs \nend",
"def distance_price\n distance * car.price_per_km\n end",
"def distance_of_items(loc1, loc2, loc3)\n items = [loc1, loc2, loc3]\n low, high = items.map { |item| find_location_bays(item) }.minmax\n high - low\nend",
"def find_distance(type: :min)\n distance = @cities.permutation(@cities.size).map do |path|\n path.each_cons(2).reduce(0) do |sum, pair|\n sum + @distances[distance_key(pair[0], pair[1])]\n end\n end.send(type)\n end",
"def getTotalDistance\n return @totalDistance\n end",
"def totalDistance\n @distanceTraveled \n @gasCost = @milage * @distanceTraveled\n @gasCost\n \"You've spent $#{@gasCost} for gas so far!\"\n end",
"def totalDistance\n @distanceTraveled \n @gasCost = @milage * @distanceTraveled\n @gasCost\n \"You've spent $#{@gasCost} for gas so far!\"\n end",
"def get_distance_duration(start_locations, end_locations)\n origins = start_locations.map{ |l| l.map(&:to_s).join(\",\") }.join(\"|\")\n destinations = end_locations.map{ |l| l.map(&:to_s).join(\",\") }.join(\"|\")\n\n request_url = \"https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=\"+\n \"#{origins}&destinations=#{destinations}&mode=bicycling&key=#{ENV['GOOGLE_MAPS_API_KEY_TEST']}\"\n\n response = HTTP.get(request_url).parse\nend",
"def totalDistance\n @gasCost = @milage * @distanceTraveled\n \"You've spent $#{@gasCost} for gas so far!\"\n end",
"def flat_distance(ride)\n flat_point_pairs(ride).inject(0) { |total, pair| total + distance_between(*pair) }\n end",
"def compute_stops(route)\n route.visited_stops\n end",
"def test_with_multiple_possi_routes\n routes = Routes.new 'ab1 bc4 bd1 dc1'\n assert_equal(2, routes.find_by_distance_less_than('a', 'c', 6).length)\n end",
"def distance(queue = [self], visited = [], distance = 0)\n until queue.empty?\n newqueue = []\n queue.each do |area|\n if yield area, distance\n return distance\n end\n newconnections = area.connections - visited\n newqueue |= newconnections\n visited |= newconnections\n end\n queue.replace(newqueue)\n distance += 1\n end\n end",
"def dist(r1, c1, r2, c2)\r\n return Math.sqrt((c1-c2)**2 + (r1-r2)**2)\r\nend",
"def distance\n return \"\" if @establishments.empty?\n (@establishments.first[\"Distance\"].to_f * METRES_IN_A_MILE).to_i\n end",
"def get_num_stops(origin, destination, stops)\n (stops.index(destination) - stops.index(origin)).abs\nend",
"def distance x1, y1, x2, y2\n ((x1-x2)**2+(y1-y2)**2)**0.5\nend",
"def get_cost(current_coordinates, goal_vector)\n\t\t\tNMath.sqrt(((current_coordinates - goal_vector) ** 2).sum)\n\t\tend",
"def total_cost(distance, mpg, cpg)\n\tprice = (distance / mpg) * cpg \nend",
"def cost\n unless @cost\n @cost = 0\n @nodes_v.each do |v|\n @cost += @nodes_s.map { |s| v.distance_to(s) }.min\n end\n end\n\n @cost\n end",
"def distance\n return @distance if @distance\n unless @status == 'OK'\n @distance = 0\n else\n @distance = @doc.css(\"distance value\").last.text\n end\n end",
"def distance loc1, loc2\n rad_per_deg = Math::PI/180 \n rkm = 6371 \n rm = rkm * 1000 \n\n dlat_rad = (loc2[0]-loc1[0]) * rad_per_deg \n dlon_rad = (loc2[1]-loc1[1]) * rad_per_deg\n\n lat1_rad, lon1_rad = loc1.map {|i| i * rad_per_deg }\n lat2_rad, lon2_rad = loc2.map {|i| i * rad_per_deg }\n\n a = Math.sin(dlat_rad/2)**2 + Math.cos(lat1_rad) * Math.cos(lat2_rad) * Math.sin(dlon_rad/2)**2\n c = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a))\n\n rm * c \nend",
"def getPathDistance(view_path_coordinates)\n dist = 0.0\n p1 = view_path_coordinates.first\n for p2 in view_path_coordinates.drop(1) do\n dist += getGeoDistance(p1,p2)\n p1 = p2\n end\n return dist\n end",
"def trip_duration(distance)\n distance / @speed\n end",
"def distance\n # we use memoization because calculating distance is expensive\n @distance ||= begin\n self.points.inject(nil) do |a, p|\n new_pt = p\n if a\n last_pt = Ubiquity::Point.new(a[:last_lat], a[:last_lon], {'ele' => a[:last_ele]})\n d = last_pt.to new_pt\n a[:dist] += d\n else\n a=Hash.new\n a[:dist]=0\n end\n a[:last_lat]=new_pt.lat\n a[:last_lon]=new_pt.lon\n a[:last_ele]=new_pt.elems['ele']\n a\n end[:dist]\n end\n end",
"def distance\n @data['distance']['value']\n end",
"def compute_total_distance(distances)\n if distances.size != 0\n distances.reduce(:+)\n else\n 0\n end\n end",
"def distance(point2)\n end",
"def getTotalDistance\n\t\t# Get all the connections in the supply chain\n\t\tsupply_chain_connections = SupplierConnection.where(supply_chain_id: self.id)\n\t\t\n\t\t# Add up all distances\n\t\ttotal_distance = 0\n\t\tsupply_chain_connections.each do |c|\n\t\t\ttotal_distance += c.distance\n\t\tend\n\n\t\t# Return the total distance\n\t\ttotal_distance\n\tend",
"def dist(cities)\n @possible_distances = []\n shuffle_cities(cities).each do |array_of_array| \n @possible_distances.push(move_count(array_of_array))\n end\n @possible_distances.min\n end",
"def calculate_distance(latitude, longitude)\n self.distance_to([latitude, longitude])\n end",
"def getDistanceAndPath(costs, start, last) \n result = []\n distance = 0\n node = last\n result.push(last)\n while (node != start) \n distance += costs[node][:cost]\n node = costs[node][:parent]\n result.unshift(node)\n end\n # record distance for start node to rest of path\n distance += costs[node][:cost]\n \n return {\n distance: distance,\n path: distance == Float::INFINITY ? [] : result # If distance is Infinity, there is no path\n }\n end",
"def distance\n properties['distance']\n end",
"def distanceCalculation(x1, y1, _z1, x2, y2, z2)\n Math.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (y1 - z2)**2)\n end",
"def descending_distance(ride)\n descending_point_pairs(ride).inject(0) { |total, pair| total + distance_between(*pair) }\n end",
"def distance(value1, value2)\n n1_path = path(value1)\n return -1 if n1_path.empty?\n n2_path = path(value2)\n return -1 if n2_path.empty?\n lca = n1_path & n2_path\n return -1 if lca.empty?\n n1_path.length + n2_path.length - (2* lca.length)\n end",
"def distance(x1,y1,x2,y2)\n return ((x2 - x1)**2 + (y2 - y1)**2)**0.5\nend",
"def get_distance(lat1, long1, lat2, long2)\n\tdistance = 0\n\tdistance = Math.sqrt((lat2 - lat1)**2 + (long2-long1)**2)\n\treturn distance\nend",
"def dist(a1, a2)\n Math.sqrt(a1.zip(a2).map { |x| (x[1] - x[0])**2 }.reduce(:+))\n end",
"def travel_cost( dest )\n sp = shortest_path( dest )\n path_cost( sp )\n end",
"def cost(shake, cities)\n distance = 0\n shake.each_with_index do |c1, i|\n c2 = (i == (shake.size - 1)) ? shake[0] : shake[i + 1]\n # +++ get distance between two cities\n distance += euc_2d cities[c1], cities[c2]\n end\n distance\n end",
"def compute_distance\n if exercise_rows\n exercise_rows.sort_by_part_order.inject(0) do |sum, row|\n actual_row_distance = row.compute_displayable_distance(distance).to_i\n actual_row_distance = distance if actual_row_distance == 0\n sum + actual_row_distance\n end\n else\n distance\n end\n end",
"def trip_calc dist, miles_per_g, price_per_g, speed_mph\n gallons_used = dist / miles_per_g\n cost = gallons_used * price_per_g\n time = dist / speed_mph\n return {cost: cost.to_f.round(2), time: time.to_f.round(2)}\nend",
"def calculateTravelTime( distance, speed )\n time = distance / speed\n\n return time.round( 2 )\nend",
"def grab_nearest_by_location(distance, loc)\n\n end",
"def calculateFuelCost( distance, distancePerGallon, pricePerGallon )\n # Cost = ( Distance * Price per gallon ) / Efficiency\n cost = ( distance * pricePerGallon ) / distancePerGallon\n\n return cost.round( 2 )\nend",
"def get_distance(atomid1, atomid2)\n # calculate distance matrix on request\n if not @distance_matrix\n calculate_distancematrix\n end\n\n return @distance_matrix.get_value(atomid1, atomid2)\n end",
"def add_distances(points)\n points_dist = points.select { |p| p.key? :distance }\n\n return DistResultAlreadyValid.new(points) \\\n if points_dist.length == points.length\n\n return DistResultInvalid.new('Only some points with distance') \\\n unless points_dist.empty?\n\n points.each_index do |idx|\n if idx.zero?\n points[0][:distance] = 0.0\n else\n src = points[idx - 1]\n dst = points[idx]\n points[idx][:distance] = \\\n src[:distance] + \\\n Haversine.distance(src[:latitude],\n src[:longitude],\n dst[:latitude],\n dst[:longitude]).to_meters\n end\n end\n\n DistResultValid.new(points)\nend",
"def distance(capabilities)\n distance_value = 0\n center_value = 0\n \n self.each do |c|\n center_value += 1\n distance_value += 1 if capabilities.include?(c.name)\n end\n \n (center_value - (2 * distance_value))\n end",
"def count_distance(departure, arrival, sub)\n\tdeparture_line = get_station_line(sub, departure)\n\tarrival_line = get_station_line(sub, arrival)\n\n\tif departure_line.to_s == 'red_line'\n\t\tdistance_first = (get_station_no(sub, departure) - 2).abs\n\telse \n\t\tdistance_first = (get_station_no(sub, departure) - 3).abs\n\tend\n\t\n\tif arrival_line.to_s == 'red_line'\n\t\tdistance_second = (get_station_no(sub, arrival) - 2).abs\n\telse \n\t\tdistance_second = (get_station_no(sub, arrival) - 3).abs\n\tend\n\treturn distance_first + distance_second\n\nend",
"def find_closest_distance\n closest_distance = 1\n closest_clusters = [nil, nil]\n\n @clusters.combination(2) do |c|\n dist = c[0].distance_to(c[1])\n if dist < closest_distance\n closest_distance = dist\n closest_clusters = [c[0], c[1]]\n end\n end\n\n return closest_distance, closest_clusters[0], closest_clusters[1]\n end",
"def distance_metric(product1, product2) (get_value(product1) - get_value(product2)).abs end",
"def distance_between(src, tar)\n @edges.each do |edge|\n return edge.distance if edge.src == src and edge.tar == tar\n end\n nil\n end",
"def distance(loc1, loc2)\n\n lat1 = loc1[0].to_f\n lon1 = loc1[1].to_f\n\n lat2 = loc2[0].to_f\n lon2 = loc2[1].to_f\n\n dLat = conv_deg_rad(lat2 - lat1)\n dLon = conv_deg_rad(lon2 - lon1)\n\n a = Math.sin(dLat/2) * Math.sin(dLat/2) +\n Math.cos(lat1/180 * Math::PI) * Math.cos(lat2/180 * Math::PI) *\n Math.sin(dLon/2) * Math.sin(dLon/2)\n\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))\n\n d = 6371e3 * c #meters\n\n return d\n end",
"def distance loc1, loc2\n lat1, lon1 = loc1\n lat2, lon2 = loc2\n dLat = (lat2-lat1).to_rad;\n dLon = (lon2-lon1).to_rad;\n a = Math.sin(dLat/2) * Math.sin(dLat/2) +\n Math.cos(lat1.to_rad) * Math.cos(lat2.to_rad) *\n Math.sin(dLon/2) * Math.sin(dLon/2);\n c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));\n d = 6371 * c; # Multiply by 6371 to get Kilometers\nend",
"def distance_of_bays(loc1, loc2, loc3, loc4)\n items = [loc1, loc2, loc3, loc4]\n low, high = items.map { |item| find_location_bays(item) }.minmax\n high - low\nend",
"def traveling_time(distance)\n \n hour = Time.new.hour\n bus_speed = 0\n taxi_speed = 0\n \n # vehicle speeds depend on time of day\n case hour\n when 5..8\n bus_speed = 0.6 # km/minute 30km/hour\n \n when 9..13\n bus_speed = 0.5\n \n when 14..16\n bus_speed = 0.6\n \n when 17..20\n bus_speed = 0.4\n \n when 21..23\n bus_speed = 0.8\n \n when 0..4\n bus_speed = 0.000001\n end\n\n case hour\n when 5..8\n taxi_speed = 0.9 # km/minute 30km/hour\n \n when 9..13\n taxi_speed = 0.8\n \n when 14..16\n taxi_speed = 0.9\n \n when 17..20\n taxi_speed = 0.6\n \n when 21..23\n taxi_speed = 0.9\n \n when 0..4\n taxi_speed = 1.0\n end\n \n time_taken_in_bus = distance.to_f / bus_speed.to_f\n time_taken_in_taxi = distance.to_f / taxi_speed.to_f\n return time_taken_in_bus #, time_taken_in_taxi\nend",
"def distance_measurement; end",
"def distance(p1, p2)\n dx = ED * (p1['lat']-p2['lat'])\n dy = ED * Math::cos(Math::PI*p1['lat']/180)*(p1['lon']-p2['lon'])\n return (dx**2 + dy**2)**0.5\nend",
"def distance(a,b)\n\t(a-b).abs\nend",
"def distance(p1, p2)\n\t\tc = p1.count\n\t\tt = 0\n\t\tc.times do \t|n|\n\t\t\te = (p1[n] - p2[n]) ** 2\n\t\t\tt = t + e\t\t\n\t\tend\t\n\t\tt = Math.sqrt(t)\n\tend"
] | [
"0.7838013",
"0.7424868",
"0.7113017",
"0.70428985",
"0.6720807",
"0.67075056",
"0.66964525",
"0.66530675",
"0.6548845",
"0.64613354",
"0.642989",
"0.6380129",
"0.63785625",
"0.6377925",
"0.6353721",
"0.6333371",
"0.6329722",
"0.6329722",
"0.6278009",
"0.62769645",
"0.62708724",
"0.62708724",
"0.62541956",
"0.6220667",
"0.62021667",
"0.620069",
"0.6134258",
"0.612447",
"0.6094378",
"0.60833406",
"0.60771185",
"0.6077069",
"0.605885",
"0.60564995",
"0.6032487",
"0.6028206",
"0.6028004",
"0.6027806",
"0.6023308",
"0.6019446",
"0.6016835",
"0.59953105",
"0.5988284",
"0.5983885",
"0.59691095",
"0.59691095",
"0.5967885",
"0.59517825",
"0.595002",
"0.5940122",
"0.5921361",
"0.5917834",
"0.59121",
"0.58954984",
"0.58783257",
"0.5878146",
"0.58536345",
"0.5853486",
"0.5851295",
"0.5847332",
"0.58470833",
"0.58462596",
"0.5843115",
"0.5840856",
"0.584037",
"0.58262426",
"0.58213407",
"0.58106273",
"0.5804908",
"0.5801414",
"0.5792644",
"0.57896155",
"0.57788837",
"0.5778134",
"0.5774588",
"0.57735044",
"0.5770772",
"0.57548225",
"0.5751265",
"0.57388645",
"0.5736172",
"0.5719492",
"0.5707588",
"0.570528",
"0.56989026",
"0.5685092",
"0.5676946",
"0.566722",
"0.5662443",
"0.56610334",
"0.566046",
"0.5652008",
"0.5650247",
"0.5647729",
"0.5644123",
"0.5644106",
"0.5641489",
"0.56402713",
"0.56395364",
"0.5636325"
] | 0.6151295 | 26 |
step_number(List, Symbol, Hash, String) return the number of steps from the first route returns | def step_number visit_path, dst, limits, condition=nil
return route(visit_path, dst, limits, UNTIL).first.nodes.length - 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opinion_wizard_step_number(step)\n step.to_s.split(\"_\").last.to_i\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def path_count(steps, current=0)\n if current == steps\n 1\n elsif current > steps\n 0\n else\n path_count(steps, current + 1) +\n path_count(steps, current + 2) +\n path_count(steps, current + 3)\n end\nend",
"def step_number(string)\n return string.split('-',5)[2].to_i\n end",
"def steps\n @steps ||= 0\n end",
"def next_step_number\n progress = current_progress\n progress ? current_progress.step.number + 1 : 0\n end",
"def steps(n)\nend",
"def next_step\n (history.keys.last.to_i + 1).to_s\n end",
"def num_steps(n)\n return 1 if n <= 1\n num_steps(n-1) + num_steps(n-2)\nend",
"def step count\n @algorithm.call count\n end",
"def num_steps(n)\n if n < 4\n initial = [1,2,4]\n return initial[n-1]\n else\n num_steps(n-1) + num_steps(n-2) + num_steps(n-3)\n end\nend",
"def num_steps(n)\n # if n = 1\n # 1\n # elsif n = 2\n # 2\n # elsif n = 3\n # num_steps(1) + num_steps(2)\n # elsif n = 4\n # num_steps(2) + num_steps(3)\n # end\n if n < 3\n n\n else\n num_steps(n-2) + num_steps(n-1)\n end\nend",
"def n_steps(stairs)\n return 1 if stairs <= 1 \n count = 0\n count += n_steps(stairs - 1) + n_steps(stairs - 2)\nend",
"def steps\n\t\tres = calc_steps @start, []\n\t\t# Always includes step for A, thus minumal value if solution exists is 2\t\n\t\tres > 0 ? res-1 : 0\n\tend",
"def step_number\n @step_number ||= (@time.to_f/60.0*sign.tempo).floor\n end",
"def steps(steps)\n @step_lengths = steps.map {|keyword, name| (keyword+name).unpack(\"U*\").length}\n @max_step_length = @step_lengths.max\n @step_index = -1\n end",
"def steps(steps)\n @step_lengths = steps.map {|keyword, name| (keyword+name).unpack(\"U*\").length}\n @max_step_length = @step_lengths.max\n @step_index = -1\n end",
"def trips_number(start, finish, opts, graph = MainGraph)\n RoutePlanner.new(graph).trips_number(start, finish, opts)\n end",
"def step_count listing\n listing.free? ? 2 : !listing.new? ? 2 : 3 rescue 2\n end",
"def kaprekar_step(n)\n\n # TODO: Solve it!\n\n end",
"def getStepCount(input1,input2,input3,input4)\n\tways = possible_moves(input1,input2,input3,input4)\n\tfound = true\n\tcount = 1\n\n\twhile found do\n\t temp = []\n\t\tways.each do |way|\n\t\t\tmoves = possible_moves(way.first,way.last,input3,input4)\n\t\t\tif moves.include?([input3,input4])\n\t\t\t\tfound = false\n\t\t\tend\n\t\t\tmoves.each {|arr| temp.push(arr) }\n\t\tend\n\t\tcount += 1\n\t\tways = temp\n\tend\n\tcount\nend",
"def numberOfSteps(steps, m)\n ((steps/2 + steps%2)..steps).find{ |n| n%m==0 } || -1\nend",
"def take_steps(n, steps = 1)\n\treturn 0 if n < 0\n\n\treturn 1 if n == 0\n\treturn @hash[n] unless @hash[n].nil?\n\t\n\t@hash[n] = take_steps(n - 1) + take_steps(n - 2) + take_steps(n - 3)\n\treturn @hash[n]\nend",
"def count_ways_up_stairs(steps)\n return 0 if steps < 0\n return steps if steps <= 2\n\n paths = []\n paths[0] = 1\n paths[1] = 1\n paths[2] = 2\n\n (3...steps).each do |i|\n count = paths[0] + paths[1] + paths[2]\n paths[0] = paths[1]\n paths[1] = paths[2]\n paths[2] = count\n end\n\n paths[2]\nend",
"def count_routes(n)\n\n\treturn 0\nend",
"def next_step\n self.step_flow.next_step if can_increment_step\n end",
"def step_count\r\n Api.proj_concatoperation_get_step_count(self.context, self)\r\n end",
"def currentStepIndex\n @current_step_index\n end",
"def new_step\n # noinspection RubyMismatchedReturnType\n index(index&.succ || 0)\n end",
"def get_step_name(scenario)\n @step_counter ||= 0\n step = scenario.steps.to_a[@step_counter]\n @step_counter += 1\n if step == nil\n step\n else\n step.name\n end\n end",
"def steps\n %w[first last]\n end",
"def step_indices\n @step_indices ||= step_keys.each_with_index.map { |step, index| [step, index] }.to_h\n end",
"def step_indices\n @step_indices ||= step_keys.each_with_index.map { |step, index| [step, index] }.to_h\n end",
"def solve(directions)\n directions = parse(directions)\n steps = map(directions)\n\n count(steps)\nend",
"def step_size\n self['Step'] || 0\n end",
"def step_result; end",
"def stepPerms(n)\n return 0 if n < 0\n return 1 if n == 0\n \n stepPerms(n - 1) + stepPerms(n - 2) + stepPerms(n - 3)\nend",
"def how_many_steps?\n steps=0\n loop do\n steps += 1\n puts \"Add another step\"\n break\nend\nend",
"def how_many_steps?\n puts \"Left\"\n puts \"Right\"\n puts \"/1\\nRight\\n2\\nLeft/\"\n puts \"/3/\"\n puts \"/4/\"\n puts \"/5/\"\n puts \"/6/\"\nend",
"def count_flow_entries switch, spec=\"\"\n count = 0\n `trema dump_flows #{ switch }`.each_line do | line |\n next if line =~ /^NXST_FLOW/\n found = true\n spec.split(/[, ]+/).each do | param |\n found = false if not line.include?( param )\n end\n count += 1 if found\n end\n return count\nend",
"def number_of_paths(n)\n return 0 if n < 0\n return 1 if n == 1 || n == 0\n number_of_paths(n - 1) + number_of_paths(n - 2) + number_of_paths(n - 3)\nend",
"def step(words)\n @step ||= 0\n @step += 1\n \"#{@step}) #{words}\\n\"\n end",
"def upa_steps=(_arg0); end",
"def create_steps(value, expected)\n temp = []\n st_count = 0\n\n value.each do |x|\n temp[st_count] = {}\n temp[st_count][:step_number] = \"#{st_count+1}\"\n temp[st_count][:actions] = \"<p>#{x.strip}</p>\"\n temp[st_count][:expected_results] = expected unless expected.nil?\n temp[st_count][:execution_type] = \"1\"\n temp[st_count][:active] = \"1\"\n st_count += 1\n end\n return temp\n end",
"def next_step(n)\n if n.even?\n n/2.to_i\n else\n 3*n+1\n end\nend",
"def steps\n %w[\n household_member_demographics_step\n household_member_address_step\n household_member_address_search_results_step\n household_member_citizenship_step\n household_member_education_step\n household_member_employments_step\n household_member_assessment_employment_step\n household_member_incomes_step\n household_member_unearned_incomes_step\n household_member_expenses_step\n household_member_resources_step\n household_member_relations_step\n ]\n end",
"def make_step\n @result\n end",
"def dir_count(route, dir)\n route.count(dir)\nend",
"def calc_no_of_valleys(\n steps:\n )\n # Convert it to a char array\n char_array = steps.split('')\n result, temp, stack = 0, 0, [0]\n char_array.each do |step|\n \t# If step is U increment temp else decrement\n \ttemp = step.eql?('U') ? temp+1 : temp-1\n \t# Empty the stack\n \tstack_var = stack.pop\n \t# Increment result if we move from 0 to -ve\n \tresult += 1 if (stack_var == -1 && temp == 0)\n \t# Push the last state into stack\n \tstack.push(temp)\n end\n # Return result\n result\nend",
"def calculate_route\n\t\t@cl = init_loc\n\t\t@steps << cl\n\n\t\twhile not at_rightmost_side?\n\t\t\t@cl = next_step\n\t\t\t@steps << cl\n\t\tend \t\t\n\tend",
"def step1\n\n end",
"def get_step_count(features)\n count = 0\n features = features.instance_variable_get(\"@features\")\n features.each do |feature|\n #get background steps\n if feature.instance_variable_get(\"@background\")\n background = feature.instance_variable_get(\"@background\")\n background.init\n background_steps = background.instance_variable_get(\"@steps\").instance_variable_get(\"@steps\")\n count += background_steps.size\n end\n #get scenarios\n feature.instance_variable_get(\"@feature_elements\").each do |scenario|\n scenario.init\n #get steps\n steps = scenario.instance_variable_get(\"@steps\").instance_variable_get(\"@steps\")\n count += steps.size\n\n #get example table\n examples = scenario.instance_variable_get(\"@examples_array\")\n unless examples.nil?\n examples.each do |example|\n example_matrix = example.instance_variable_get(\"@outline_table\").instance_variable_get(\"@cell_matrix\")\n count += example_matrix.size\n end\n end\n\n #get multiline step tables\n steps.each do |step|\n multi_arg = step.instance_variable_get(\"@multiline_arg\")\n next if multi_arg.nil?\n matrix = multi_arg.instance_variable_get(\"@cell_matrix\")\n count += matrix.size unless matrix.nil?\n end\n end\n end\n return count\n end",
"def steps\n step_flows.collect(&:current_step)\n end",
"def getStepType(offset, parts)\n pow = 1\n # type 1 if there are 4 parts or less\n if (parts / 4 <= 1)\n return 1\n else\n # reduce offset by quads\n parts = parts / 4\n while (offset >= parts)\n offset -= parts\n end\n end\n # type 1\n if (offset == 0)\n return 1\n end\n\n (2..5).each do |i|\n pow *= 2\n part = parts / pow\n if (part != part.to_i)\n break\n elsif (offset - part == 0)\n return i\n elsif (offset - part > 0)\n offset -= part\n end\n end\n return 8\nend",
"def path_number visit_path, dst, limits, condition=EG\n paths = route(visit_path, dst, limits, condition)\n select_condition = condition == EG ? EG : condition == UNTIL ? LESS : UNTIL\n return (paths.select {|path| eval final_eval( select_condition, limits )}).length\n end",
"def get_number(lines)\n lines.shift.to_i\n end",
"def steps\n return @steps if @steps\n\n @filesizes = {}.with_indifferent_access\n\n # Get info from `rclone size` (will not work on Google Drive and Google Photos)\n total_size = files.keys.map do |file|\n size = RcloneUtil.size(src_remote, file).fetch('bytes', 0)\n @filesizes[file] = { :size => size, :transferred => 0 }\n size\n end.sum\n\n @steps = total_size\n end",
"def steps\n @steps ||= []\n end",
"def increase_steps\r\n @steps = [@steps + 1, 9999999].min\r\n end",
"def calculate_step(_ranks)\n raise NotImplementedError\n end",
"def previous_step\n (history.keys.last.to_i - 1).to_s\n end",
"def steps\n %w[name time]\n end",
"def step1\n \n end",
"def assert_step_number_label(label)\n current_step, total_steps = label.split(\" of \")\n expect(find(\"div.cucumber-mandate-registration-step-number\").text).to eq(\"#{current_step} /#{total_steps}\")\n end",
"def start_step?\n params_hash[\"start\"]\n end",
"def steps\n find_solution\n end",
"def process_steps\n result = nil\n steps.map(&:to_s).each do |step_name|\n result = process_step(step_name)\n return result if @success == false || stop == true\n end\n result\n end",
"def trip(url, steps=10) # (1) \n\n steps.times do # (2) \n page = fetch(url)\n book_info = scrape_book_info(page)\n puts format_output(book_info)\n \n next_book = scrape_affinity_list(page)[0]\n\n url = next_book[:url]\n end\nend",
"def total_paths(initial_s)\n reachable_stops(initial_s).count\n end",
"def step?(step)\n @current_step.nil? || current_step + 1 == step\n end",
"def kids_ways(length, steps_so_far=0)\n return 1 if steps_so_far == length\n return 0 if steps_so_far > length\n [1,2,3].map do |n|\n kids_ways(length, steps_so_far + n)\n end.reduce(:+)\nend",
"def step_params\n params.require(:step).permit(:step_number, :pattern_step, :counter_open, :row_count, :rep_count, :pattern_id)\n end",
"def sheets_steps= value ; @sheets_steps = value end",
"def start_num\n return @start_num\n end",
"def steps\n Rails.cache.fetch([self, \"pill_sequence_steps\"]) { pill_sequence_steps }\n end",
"def routing_number; end",
"def _next_num_index(string_copy)\n unless string_copy[0] =~ /\\d/ || string_copy[0] == '-'\n return nil\n end\n for i in 1..string_copy.length\n unless string_copy[i] =~ /\\d/\n if string_copy[i] =~ /\\^/\n return nil\n else\n return i - 1\n end\n end\n end\n return string_copy.length - 1\n end",
"def steps(value)\n factor = 10**(Math.log10(value).floor - 1)\n case \n when value < factor * 10\n factor\n when value < 5 * factor * 10\n 5 * factor\n else\n 10 * factor\n end\n end",
"def steps(value)\n factor = 10**(Math.log10(value).floor - 1)\n case \n when value < factor * 10\n factor\n when value < 5 * factor * 10\n 5 * factor\n else\n 10 * factor\n end\n end",
"def current_step \n @current_step || steps.first\n end",
"def start_pass(index)\n end",
"def get_steps(category)\n steps = []\n params.each do |k,v|\n if (k.starts_with? \"step\") && (cat_number(k) == category[1])\n name = v\n num = step_number(k)\n steps << [cat_number(k),num,name]\n end\n end\n return steps\n end",
"def calculation\n wizard_step(nil) { { next_step: :calculate_next_step, cache_index: LbttController } }\n end",
"def upa_steps; end",
"def onboarding_step_increment!\n session[:onboarding_step] += 1\n # See if we need to skip the next onboarding step\n # while(Onboarding.skip_onboarding_step?(session[:onboarding_step]))\n # session[:onboarding_step] += 1\n # end\n session[:onboarding_step]\n end",
"def climb_stairs(steps)\n return steps if steps <= 2\n cache = {}\n cache[1] = 1\n cache[2] = 2\n 3.upto(steps) do |n|\n cache[n] = cache[n - 2] + cache[n - 1]\n end\n cache[steps]\nend",
"def advance_step\n @step += 1\n @scheduling.step\n end",
"def step_points\n points.select { |point| point.kind == \"Step\" }\n end",
"def get_num_paths(grid_width)\n n, r = grid_width * 2, grid_width\n ((n - r + 1)..n).inject(:*) / (1..r).inject(:*)\nend",
"def line_number\n\t\t\t@line_index + 1\n\t\tend",
"def _next_num_index(string_copy)\n for i in 0..string_copy.length\n unless string_copy[i] =~ /\\d/\n if i == 0\n return nil\n end\n if string_copy[i] =~ /\\^/\n return nil\n else\n return i - 1\n end\n end\n end\n return string_copy.length - 1\n end",
"def stepPerms(n)\n # dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]\n \n dp = Array.new(n + 1, 0)\n dp[0] = 1 # when number of steps are 0 there is only 1 way\n \n (1..n).each do |i|\n dp[i] += dp[i - 1] if i - 1 >= 0\n dp[i] += dp[i - 2] if i - 2 >= 0\n dp[i] += dp[i - 3] if i - 3 >= 0\n end\n\n dp[n]\nend",
"def current_step\n\t\t@current_step || steps.first\t\n\tend",
"def sequence_number; end",
"def next_route_order\n signers.map(&:routing_order).compact.sort.last.to_i + 1\n end",
"def getsteps\n\t\t@hide_menu = true\n\n puts \"In Steps\"\n recId = params['query'].inspect\n #this is the link to the API\n url = \"https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/\" + recId[1..-2] + \"/analyzedInstructions?stepBreakdown=true\"\n stepss = Unirest.get url,\n headers:{\n \"X-Mashape-Key\" => \"UpZLcnOR83mshtXvuIOPFXBkfhn5p1UWi1ejsnsTLWoVXrOppm\",\n \"Accept\" => \"application/json\"\n }\n allSteps = stepss.body\n\n recSteps = Hash.new\n\n counter = 1\n #this is how the recipe information is formatted\n allSteps.each do |key|\n key.each do |key2,steps|\n if(key2.eql? \"steps\")\n steps.each do |step|\n step.each do |key3, lastStep|\n if(key3.eql? \"step\")\n recSteps[counter] = lastStep\n counter += 1\n #this gives each step a number, for ease of use\n end\n end\n end\n end\n end\n end\n puts recSteps\n\n @recipeData = recSteps\n render template: \"recipes/data3\"\n end",
"def start_result_number\n ((page - 1) * per_page) + 1\n end",
"def next_station_index\n current_station_index + 1\n end"
] | [
"0.69344",
"0.67370206",
"0.67370206",
"0.67370206",
"0.65958005",
"0.65727234",
"0.65630835",
"0.6475925",
"0.64521587",
"0.63310933",
"0.63210225",
"0.6263403",
"0.62130374",
"0.62116575",
"0.6207247",
"0.61998117",
"0.61928505",
"0.61400825",
"0.61400825",
"0.6122192",
"0.60112464",
"0.5902307",
"0.590161",
"0.58907574",
"0.58880895",
"0.58746564",
"0.5837174",
"0.58177817",
"0.5806177",
"0.57475996",
"0.5733114",
"0.5691767",
"0.562885",
"0.562688",
"0.562688",
"0.56263304",
"0.5572874",
"0.5540656",
"0.5525311",
"0.54753816",
"0.5462797",
"0.54597294",
"0.54421186",
"0.5430109",
"0.53665847",
"0.5362499",
"0.535205",
"0.53504217",
"0.532655",
"0.5303337",
"0.52957916",
"0.5290899",
"0.5285419",
"0.5259996",
"0.525243",
"0.5249562",
"0.5237499",
"0.52225405",
"0.5221334",
"0.52108383",
"0.520828",
"0.5201842",
"0.520024",
"0.51992536",
"0.51942074",
"0.51897746",
"0.5186863",
"0.51730597",
"0.5165761",
"0.5161428",
"0.5159175",
"0.51591176",
"0.51523834",
"0.51515114",
"0.51461494",
"0.51414734",
"0.51280826",
"0.51264817",
"0.5120845",
"0.5115407",
"0.5115407",
"0.510976",
"0.50963706",
"0.50947",
"0.5067137",
"0.50633633",
"0.5062005",
"0.5054068",
"0.5046779",
"0.5046293",
"0.503702",
"0.50362426",
"0.5034674",
"0.50339144",
"0.5020815",
"0.50140285",
"0.5013188",
"0.5009684",
"0.50058097",
"0.500038"
] | 0.6662546 | 4 |
path_number(List, Symbol, Hash, String) return the number of paths with in the limits returns | def path_number visit_path, dst, limits, condition=EG
paths = route(visit_path, dst, limits, condition)
select_condition = condition == EG ? EG : condition == UNTIL ? LESS : UNTIL
return (paths.select {|path| eval final_eval( select_condition, limits )}).length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_count(*args)\n path_rels(*args).size\n end",
"def get_num_paths(grid_width)\n n, r = grid_width * 2, grid_width\n ((n - r + 1)..n).inject(:*) / (1..r).inject(:*)\nend",
"def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend",
"def path_count(steps, current=0)\n if current == steps\n 1\n elsif current > steps\n 0\n else\n path_count(steps, current + 1) +\n path_count(steps, current + 2) +\n path_count(steps, current + 3)\n end\nend",
"def path_captures\n return 0 unless conditions[:path]\n Behavior.count_parens_up_to(conditions[:path], conditions[:path].size)\n end",
"def number_of_paths(n)\n return 0 if n < 0\n return 1 if n == 1 || n == 0\n number_of_paths(n - 1) + number_of_paths(n - 2) + number_of_paths(n - 3)\nend",
"def num_paths\n @num_paths ||= begin\n self[width - 1, height - 1]\n end\n end",
"def actual_path_length\n folders.count\n end",
"def total_paths(initial_s)\n reachable_stops(initial_s).count\n end",
"def count()\n return @child_path_parts.count\n end",
"def path_as_number(request)\n number_or_zero(path_contents(request))\n end",
"def dir_count(route, dir)\n route.count(dir)\nend",
"def count_routes(n)\n\n\treturn 0\nend",
"def numPaths(start_from, vertices,edge_weights)\n graph = RGL::DirectedAdjacencyGraph.new\n graph.add_vertices vertices\n edge_weights.each { |(bag1, bag2), w| graph.add_edge(bag1, bag2) }\n\n num_paths = 0\n vertices.map do |vert|\n unless vert.eql?(start_from)\n num_paths+=1 if graph.path?(start_from,vert)\n end\n end\n num_paths\nend",
"def path_length(guess)\n Log.indent(\"path_length #{guess.inspect}\") do\n do_path_length(guess).tap{|x| Log.debug(\"returning #{x.inspect}\")}\n end\n end",
"def path_length(path)\n return 0 if path.size <= 1\n (0..path.size - 2).map {|i| dist(path[i], path[i + 1])}.inject(&:+)\n end",
"def step_number visit_path, dst, limits, condition=nil\n return route(visit_path, dst, limits, UNTIL).first.nodes.length - 1\n end",
"def paths(n)\n return nCr(2*(n-1),n)\nend",
"def howManyMineHits(path)\n path.select { |i| @structure[i] & MINE > 0 }\n end",
"def get_count(path)\n file = scope.get(path)\n InvalidPath.raise! {!file}\n return 0 if !file.is_dir\n file.files_count\n end",
"def count\n @count ||= begin\n Grim.processor.count(@path)\n end\n end",
"def number_of_paths_to_end_from_point(start_point)\n \n tabs = \"\\t\" * ([start_point.x, start_point.y].max)\n puts \"#{tabs} (#{start_point.x}, #{start_point.y})\"\n \n # only 1 path to end from the edges\n return 1 if (start_point.y == 2 || start_point.x == 2)\n \n # last point\n return 0 if (start_point.x == 2 && start_point.y == 2)\n \n # otherwise, it's the sum of the paths that can be taken when adding the ones from right and the ones from below\n right_point = Point.new(start_point.x + 1, start_point.y)\n down_point = Point.new(start_point.x, start_point.y + 1)\n \n right = number_of_paths_to_end_from_point(right_point)\n down = number_of_paths_to_end_from_point(down_point)\n \n # puts \"From: (#{start_point.x}, #{start_point.y}) -> #{right + down} \"\n \n return right + down\nend",
"def n_paths(graph, from)\n counter = { from => 1 }\n graph.topsort.each do |v|\n next if v == from\n in_edges = graph.edges.select { |e| e.target == v && graph.adjacent(v, :direction => :in).include?(e.source) }\n counter[v] = in_edges.map { |e| counter[e.source] }.inject(:+)\n end\n counter\nend",
"def paths()\n assert( @maximum.exists?, \"you cannot obtain paths() for an infinite Repeater\" )\n assert( @maximum <= 10, \"if you really need to obtain paths() for a Repeater with greater than 10 elements, change this assertion\" )\n \n #\n # First, compile the element to its paths. We will end up with a BranchPoint.\n \n element_paths = nil\n if @element.is_an?(ExpressionForm) then\n element = @element.paths\n else\n element = BranchPoint.new( Sequence.new(@element) )\n end\n \n #\n # Next, produce a BranchPoint with a Sequence for each count we are doing.\n \n run = Sequence.new()\n minimum.times do\n run << element\n end\n \n result = BranchPoint.new( run )\n (maximum - minimum).times do\n run = Sequence.new( run, element )\n run.minimal = false\n result << run\n end\n \n \n #\n # Finally, get the paths of the produced Sequence.\n \n return result.paths\n end",
"def birth_path_number(birthdate)\n path_number = birthdate.reduce(:+)\n if path_number > 9\n second_number = path_number.to_s.split(//).map(&:to_i)\n third_number = second_number.reduce(:+)\n else\n explanation(birth_path_message)\n end\nend",
"def number_of_edges\n @pathway.relations.size\n end",
"def depth\n PathExpression.range(path)[1]\n end",
"def get_max_path(num_pyramid)\n num_pyramid.each_index do |i|\n next if i == 0\n num_pyramid[i].each_index do |j|\n num_pyramid[i][j] += [num_pyramid[i - 1][j], num_pyramid[i - 1][j + 1]].max\n end\n end\n\n num_pyramid[-1].first\nend",
"def countSubst(path)\n count = 0\n path.each do | atom |\n if @atoms[atom].size > 2 then\n count += (@atoms[atom].size - 2)\n end\n end\n count\n end",
"def path_number(birthdate)\n# Access birthdate numbers with array, so must be integers; add all together\n number = birthdate[0].to_i + birthdate[1].to_i + birthdate[2].to_i + birthdate[3].to_i + birthdate[4].to_i + birthdate[5].to_i + birthdate[6].to_i + birthdate[7].to_i\n \n# Convert number back to string to use array to again access each number \n number = number.to_s\n# Convert back to integers and use array to get each number\n number = number[0].to_i + number[1].to_i\n\n# If number is greater than 9, must be reduced again \n if number > 9\n number = number[0].to_i + number[1].to_i\n end\n \n return number\nend",
"def get_links_count page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/links'\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Links']['List'].length\n \n \n rescue Exception=>e\n print e\n end\n end",
"def max_path_sum(root)\n @max = -999999\n max_path_recursive(root)\n return @max\nend",
"def numImages(path)\n\t\tDir.entries(path).size\n\tend",
"def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end",
"def num_routes(x,y)\n unless @num_routes[x][y]\n if (x == size - 1) # right side\n @num_routes[x][y] = num_routes(x,y+1)\n elsif (y == size - 1) # bottom side\n @num_routes[x][y] = num_routes(x+1,y)\n else\n @num_routes[x][y] = num_routes(x+1,y) + num_routes(x,y+1)\n end\n end\n @num_routes[x][y]\n end",
"def get_path_weight(graph, path_array)\n result = graph.get_path_weight(path_array)\n result.nil? ? \"NO SUCH ROUTE\" : result\nend",
"def find_max_path_length_recursively\n if self.outgoing_edges.exists?\n available_path_lengths = self.next_vertices.map do |vertex|\n [vertex.id, 1 + vertex.find_max_path_length_recursively]\n end\n longest = available_path_lengths.max{|a,b| a[1] <=> b[1]}[1]\n return longest\n else\n return 0;\n end\n end",
"def symbolic_count(count); end",
"def demand\n demand = 0\n (@path.size - 1).times { |i| demand += @path[i].demand }\n return demand\n end",
"def route_count\n @routes.size\n end",
"def folders_count\n wayfinder.ephemera_folders_count\n end",
"def cost_for_path(path_cpy, amount)\n\tcost = 0\n\tpath = path_cpy\n\t\t\n\twhile(path.length > 1)\n\t\tloc1 = path.shift\n\t\tloc2 = path[0]\n\t\t\t\n\t\tcost += cost_between(loc1, loc2, amount)\n\tend\n\treturn cost\n end",
"def number_of_internal_links_to_page(link)\n @ilps[link]\n end",
"def path_len_tile(path, target)\n # print target\n if path\n result = nil\n for i in path\n # print i\n if target.include? i\n # print \"In target\"\n result = i, path.index(i)\n break\n end\n end\n # print result\n if result == nil\n result = path[-1], path.index(path[-1])\n end\n else\n result = 0,0\n end\n # print result\n return result\n end",
"def depth\n @breadcrumb.scan( \"/\" ).size\n end",
"def number_closed(file)\n numClosed = 0;\n line = file.gets\n if line == nil then return end\n # read additional lines\n while line = file.gets do\n # begins with \"path\", must be path specification\n if line[0...4] != \"path\" \n if (!(line.include? \"u\") && !(line.include? \"d\") &&\n !(line.include? \"l\") && !(line.include? \"r\"))\n numClosed += 1;\n end\n end\n end\n puts \"#{numClosed}\"\nend",
"def segment_count\n children.map(&:segment_count).inject(:+).to_i + 2\n end",
"def check_params(params_number, request_path_info)\n # check if the route is plural or not\n if !request.path_info.include? \"s\"\n return 1\n else\n if params_number\n number = params_number.to_i <= 100 ? params_number.to_i : 100\n else\n number = 10\n end\n return number\n end\nend",
"def total_views_per_file_path\n iterate_over_file_paths.group_by { |x| x }.map { |k, v| [k, v.count] }\n end",
"def find_paths(grid_size)\n # array/list sums records the sum of paths in a grid of size sums[i+1]\n sums = [1] * 20\n for i in 0...grid_size\n for j in 0...i do\n sums[j] = (sums[j] + sums[j-1])\n end\n sums[i] = 2 * sums[i-1]\n end\n sums[grid_size - 1]\nend",
"def number_of_args_expected_by_named_route_helper(helper_name)\n ActionController::Routing::Routes.named_routes.routes[helper_name.to_sym].segment_keys.size\n end",
"def paths_with_complexity_increase\n path_complexity_history.select do |_, complexity_history|\n _, head_complexity = complexity_history.first\n _, previous_complexity = complexity_history.first(2).last\n\n head_complexity > previous_complexity\n end\n end",
"def link_calculate(count)\n num_chunks = (count**0.5).ceil\n min_links_in_chunk = (count/num_chunks).floor if num_chunks > 0\n max_links = min_links_in_chunk + 1 if min_links_in_chunk.present?\n return max_links \n end",
"def parse_maximum_paths(config)\n values = config.scan(/maximum-paths\\s+(\\d+)\\s+ecmp\\s+(\\d+)/).first\n { maximum_paths: values[0].to_i, maximum_ecmp_paths: values[1].to_i }\n end",
"def get_length(arr)\n $index = 0\n def reroute(arr)\n arr.each do |entry| # bad because if array then the remaining numbers will not be counted but works\n if entry.class != Array \n $index += 1\n else \n reroute(entry)\n end\n end \n end\n reroute(arr)\n return $index\nend",
"def path_weight(p)\n unless path?(p)\n return nil\n else\n weight = 0\n p.each_cons(2){|x|\n weight += @source[x[0]][x[1]]}\n return weight\n end\n end",
"def get_path_pins(path); end",
"def get_path_pins(path); end",
"def depth\n return 0 if %w(index 404).include?(self.fullpath)\n self.fullpath.split('/').size\n end",
"def birth_path_number(birthday)\r\n\tnumber = birthday[0].to_i + birthday[1].to_i + birthday[2].to_i + birthday[3].to_i + birthday[4].to_i + birthday[5].to_i + birthday[6].to_i + birthday[7].to_i\r\n\tnumber = number.to_s\r\n\tnumber = number[0].to_i + number[1].to_i\r\n\r\n\tif (number > 9)\r\n\t\tnumber = number.to_s\r\n\t\tnumber = number[0].to_i + number[1].to_i\r\n\tend\r\n\treturn number\r\nend",
"def directory_size(path)\n\ta = get_dir_size(path)\n\tdisplay(a)\n\t@calls = 0\n\treturn a\nend",
"def slash_count_in_slashes_regexp=(value)\n configure_slashes(value) { |current| [current, value].max }\n end",
"def get_birth_path_num(birthdate)\n\tnumber = birthdate[0].to_i + birthdate[1].to_i + birthdate[2].to_i + birthdate[3].to_i + birthdate[4].to_i + birthdate[5].to_i + birthdate[6].to_i + birthdate[7].to_i\n\n\tnumber = number.to_s\n\tnumber = number[0].to_i + number[1].to_i\n\n\tif number > 9\n\t\tnumber = number.to_s\n\t\t\n\t\t# Assign the return value to a variable\n\t\tnumber = number[0].to_i + number[1].to_i\n\tend\n\n\treturn number\nend",
"def count_paths(grid, x, y, w, h)\n\tcount = 0\n\n\tputs \"Visiting x:#{x}, y:#{y}\"\n\n\t# if already visited, return so we can do down a different path\n\treturn count if grid[x][y]\n\n\t#puts \"Valid move\"\n\t# mark tile as visited\n\tgrid[x][y] = true\n\n\t# how this works is we only count the path once we have hit our end point\n\t# otherwise keep calling the function\n\n\t# We can go in all directions but we are constrained by the grid and we can't go to a visited\n\t# square\n\t# if x = 0, try to go right\n\n\t# Always prefer to go right\n\tcount += count_paths(grid, x+1, y, w, h) if x < w - 1\n\n\t# Go down, if allowed\n\tcount += count_paths(grid, x, y+1, w, h) if y < h - 1\n\n\t# Go left\n\tcount += count_paths(grid, x-1, y, w, h) if x > 0\n\n\t# Go up\n\tcount += count_paths(grid, x, y-1, w, h) if y > 0\n\n\n\n\n\t#count += count_paths(grid, x, y, w, h) if \n\n\t# if we are on the left, we can only go (down,right, up)\n\t# if we are on top we can only go (down right or up)\n\t# if we have reached the bottom, (up, right or left)\n\t#count += count_paths(grid, x, y, w, h) if \n\n\t# We have reached the destination\n\t#puts \"Reached destination\" if (x == w - 1) && (y == h -1)\n\tcount += 1 if (x == w - 1) && (y == h -1)\n\n\tcount\nend",
"def depth\n breadcrumbs.size\n end",
"def calculate_total_paths(m,n)\n return 1 if m == 1 and n == 1\n paths = []\n for i in (0..m)\n paths << Array.new(0,n)\n end\n\n # initialze borders\n for j in (0...n)\n paths[0][j] = 1\n end\n\n for i in (0...m)\n paths[i][0] = 1\n end\n\n paths[0][0] = 0\n\n for i in (1...m)\n for j in (1...n)\n paths[i][j] = paths[i][j-1] + paths[i-1][j]\n end\n end\n paths[m-1][n-1]\nend",
"def paths_above_threshold\n path_complexity_change.select do |_, (complexity_increase)|\n complexity_increase >= @change_threshold\n end\n end",
"def line_count(file_list)\n file_list.empty? ?\n nil :\n %x{wc -l #{file_list.join(' ')} | awk 'END {print $1}'}.to_i\n end",
"def max_path_sum(node)\n\t@result = -2147483648 # Minimum value\n\treturn @result if node == nil\n max_path_sum_util(node)\n\t@result\nend",
"def pagination_size(headers)\n if headers.key?('link')\n links = headers.fetch('link') \\\n .scan(/<(.*?)>/).flatten\n\n links.last.split('=').last.to_i\n else\n 1\n end\n end",
"def legend_for( path, count )\n \"#{path_type(path)}s(<span id='count'>#{count}</span>)\"\n end",
"def file_count(dir_path)\n Dir.entries(dir_path).count - 2\n end",
"def fulltree_count(*args)\n fulltree_rels(*args).size\n end",
"def run\n # Digits 1,4,7,8 have 2,4,3,7 segments respectively\n @list.map{|line| line[1]}.flatten.map(&:length).filter{|len| [2, 4, 3, 7].include?(len)}.count\n end",
"def get_star_number(born_path)\n\tstar_number = born_path[0].to_i + bd1 = born_path[1].to_i + bd2 = born_path[2].to_i + bd3 = born_path[3].to_i + bd4 = born_path[4].to_i + bd5 = born_path[5].to_i + bd6 = born_path[6].to_i + bd7 = born_path[7].to_i\n\n\tstar_number = star_number.to_s\n\tstar_number = star_number[0].to_i + star_number[1].to_i\n\n\tif star_number > 9\n\t\tstar_number = star_number[0].to_i + star_number[1].to_i\n\tend\n\t\n\treturn star_number\nend",
"def depth_of_index(link)\n self.avoid_zero_division(1, self.avoid_zero_division(self.depth_of_page_in_url(link), @dpus.values.max))\n end",
"def trip_count\n trips.length\n end",
"def trip_count\n trips.length\n end",
"def trip_count\n trips.length\n end",
"def path_ids\n ancestry_ascendente_directo.split(',').map{|a| a.to_i if a.present?}.compact\n end",
"def count_num_trees\n print 'Please enter the upper number :: '\n num_keys = gets.chomp.to_i\n sum = count_num_trees_supp(num_keys)\n puts \"Possible different binary trees having unique structure :: #{sum}\"\n end",
"def trip_count\n trips.length\nend",
"def size(ref = nil)\n tree_map_for(ref || @ref).inject(0) do |num, entry|\n num + (::Gollum::Page.valid_page_name?(entry.name) ? 1 : 0)\n end\n rescue Gollum::Git::NoSuchShaFound\n 0\n end",
"def page_nums(req, count)\n first = page(req) - SPREAD\n last = bound_first(first) + (SPREAD * 2)\n first = bound_last(last, count) - (SPREAD * 2) if bound_last(last, count) == last_page(count)\n bound_first(first)..bound_last(last, count)\n end",
"def num_of_choices(current_page, pages)\n\tchoices = 0\n\tpages.select { |k,v| choices += 1 if k.include?(\"~#{current_page}:c\")}\n\tchoices\nend",
"def count_ways_up_stairs(steps)\n return 0 if steps < 0\n return steps if steps <= 2\n\n paths = []\n paths[0] = 1\n paths[1] = 1\n paths[2] = 2\n\n (3...steps).each do |i|\n count = paths[0] + paths[1] + paths[2]\n paths[0] = paths[1]\n paths[1] = paths[2]\n paths[2] = count\n end\n\n paths[2]\nend",
"def subdirectories\n path_length - 1\n end",
"def num_open_cells(file)\n open_cells = 0\n\n while line = file.gets \n if line == nil then return end\n\n if line[0...4] != \"path\"\n x, y, ds, w = line.split(/\\s/,4)\n ds = ds.chars\n if(ds.length() == 4)\n open_cells+=1\n end\n end\n end\n return open_cells\nend",
"def parent_count(*args)\n parent_rels(*args).size\n end",
"def get_quota_files\n rpc_get_fact_direct('quota_files').to_i\n end",
"def number_of_expression_parts(login=nil)\n count_by_frbr(login, :contains, :how_many_expressions?) \n end",
"def number_of_crumbs(item_container)\n count = 0\n item_container.items.each do |item|\n next unless item.selected?\n count += 1\n end\n return count\n end",
"def getStepCount(input1,input2,input3,input4)\n\tways = possible_moves(input1,input2,input3,input4)\n\tfound = true\n\tcount = 1\n\n\twhile found do\n\t temp = []\n\t\tways.each do |way|\n\t\t\tmoves = possible_moves(way.first,way.last,input3,input4)\n\t\t\tif moves.include?([input3,input4])\n\t\t\t\tfound = false\n\t\t\tend\n\t\t\tmoves.each {|arr| temp.push(arr) }\n\t\tend\n\t\tcount += 1\n\t\tways = temp\n\tend\n\tcount\nend",
"def countNumX(res, x)\n\t\tsCount = 0\n\n\t\tif res == nil || res.length == 0\n\t\t\treturn sCount\n\t\tend\n\n\t\t# res is an array of constiuents\n\t\tres.each do |constituent|\n\t\t\tif(constituent.pos == x)\n\t\t\t\tsCount = sCount + 1\n\t\t\tend\n\n\t\t\t#search children\n\t\t\tsCount = sCount + countNumX(constituent.children, x)\n\t\tend\n\n\t\treturn sCount\n\tend",
"def line_count\n entries.inject(0) do |count, entry|\n count + (entry.dir? ? 0 : entry.lines.size)\n end\n end",
"def depth\n crumbs.size\n end",
"def zlexcount(key, min, max); end",
"def longest_path_1(edges)\nend",
"def count\r\n @internal_list.length\r\n end",
"def ancestors_count(*args)\n ancestor_rels(*args).size\n end"
] | [
"0.7148266",
"0.7054428",
"0.6922436",
"0.6717221",
"0.6602749",
"0.6582553",
"0.65792847",
"0.62654996",
"0.6254104",
"0.623642",
"0.62050784",
"0.61050344",
"0.610447",
"0.60559106",
"0.60262126",
"0.6015799",
"0.6009623",
"0.5996869",
"0.58924735",
"0.57638484",
"0.5754598",
"0.573807",
"0.5702635",
"0.5694975",
"0.5678772",
"0.56779146",
"0.5613398",
"0.56117314",
"0.5604654",
"0.5532958",
"0.5513692",
"0.5467107",
"0.546619",
"0.54553926",
"0.5441269",
"0.54406124",
"0.5432218",
"0.54280436",
"0.5415119",
"0.54106635",
"0.5408444",
"0.5404747",
"0.5402677",
"0.53933173",
"0.53636706",
"0.53624046",
"0.53567606",
"0.5312426",
"0.5309373",
"0.5306757",
"0.52883214",
"0.5265702",
"0.5251355",
"0.52500105",
"0.5225699",
"0.52124304",
"0.5207106",
"0.5207106",
"0.5201844",
"0.5200661",
"0.5191878",
"0.51818067",
"0.5180015",
"0.51780725",
"0.51731133",
"0.51636875",
"0.51620287",
"0.5153941",
"0.5136838",
"0.5132307",
"0.51285946",
"0.5115944",
"0.51124805",
"0.51115197",
"0.50983423",
"0.5085202",
"0.5080579",
"0.5080579",
"0.5080579",
"0.5075097",
"0.5072982",
"0.50703686",
"0.50701094",
"0.5054559",
"0.5051035",
"0.50389487",
"0.5036308",
"0.50362396",
"0.5033951",
"0.503182",
"0.502889",
"0.5028445",
"0.5027307",
"0.5024707",
"0.50242835",
"0.5024178",
"0.5020945",
"0.50189745",
"0.50070727",
"0.49996835"
] | 0.7635548 | 0 |
step_number(List, Symbol, String) return cost of the shortest route returns | def shortest_route visit_path, dst, condition=nil
return route(visit_path, dst).first.cost
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend",
"def min_cost_climbing_stairs(cost)\n [step(cost, 0), step(cost, 1)].min\nend",
"def min_cost(stairs)\n min_step_cost = [stairs[0], stairs[1]]\n idx = 2\n while idx < stairs.length\n min_step_cost[idx] = stairs[idx] + [min_step_cost[idx - 1], min_step_cost[idx - 2]].min\n idx += 1\n end\n p min_step_cost\n [min_step_cost[-2], min_step_cost[-1]].min\nend",
"def travel_cost( dest )\n sp = shortest_path( dest )\n path_cost( sp )\n end",
"def path_cost( path )\n path.inject( 0 ) { |sum,hex|\n sum + entrance_cost( hex )\n }\n end",
"def trips_number(start, finish, opts, graph = MainGraph)\n RoutePlanner.new(graph).trips_number(start, finish, opts)\n end",
"def cost\n cost = 0\n @solution.each { |route| cost += route.travel_time_and_cost[0] }\n return cost\n end",
"def min_cost(costs)\n prev_color_path1 = 0\n prev_color_path2 = 1\n path1 = costs[0][prev_color_path1]\n path2 = costs[0][prev_color_path2]\n \n if costs[0][2] < path1\n if path1 < path2\n path2 = path1\n prev_color_path2 = prev_color_path1\n path1 = costs[0][2]\n prev_color_path1 = 2\n end\n elsif costs[0][2] < path2\n if path2 < path1\n path1 = path2\n prev_color_path1 = prev_color_path2\n path2 = costs[0][2]\n prev_color_path2 = 2\n end\n end\n\n costs[1..-1].each do |cost|\n min1 = nil\n min1idx = nil\n # for first path\n cost.each_with_index do |amt, idx|\n next if idx == prev_color_path1\n if min1\n if amt < min1\n min1 = amt\n prev_color_path1 = idx\n else\n next\n end\n else\n min1 = amt\n min1idx = idx\n end\n end\n path1 += min1\n\n \n min2 = nil\n min2idx = nil\n # for second path\n cost.each_with_index do |amt, idx|\n next if idx == prev_color_path2\n if min2\n if amt < min2\n min2 = amt\n prev_color_path2 = idx\n else\n next\n end\n else\n min2 = amt\n min2idx = idx\n end\n end\n \n path2 += min2\n end\n\n path1 < path2 ? path1 : path2\nend",
"def travel_time_and_cost\n cost = 0\n travel_time = 0\n (@path.size - 1).times do |i|\n current_vertex = @path[i]\n next_vertex = @path[i+1]\n # travel time = travel distance\n distance = Vertex.euclidean_distance(current_vertex, next_vertex)\n travel_time += distance\n # calculate how early or how late is service\n early_cost = (next_vertex.ready_time - travel_time) > 0 ? (next_vertex.ready_time - travel_time) : 0\n late_cost = (travel_time - next_vertex.due_time) > 0 ? (travel_time - next_vertex.due_time) : 0\n # calculate penalty cost\n cost += early_cost * @penalty_coefficient + late_cost * @penalty_coefficient\n # add service_time and early_cost (wait-for-service time) to travel time\n travel_time += next_vertex.service_time + early_cost\n end\n return cost, travel_time\n end",
"def cost_of_trip #Time cost of the trip used to calculate shortest path.\n (self.end_of_trip - self.date_of_trip).round\n end",
"def cost\n start_value\n end",
"def cost_for_path(path_cpy, amount)\n\tcost = 0\n\tpath = path_cpy\n\t\t\n\twhile(path.length > 1)\n\t\tloc1 = path.shift\n\t\tloc2 = path[0]\n\t\t\t\n\t\tcost += cost_between(loc1, loc2, amount)\n\tend\n\treturn cost\n end",
"def min_cost(cost, inf)\n # dist[i] stores minimum cost to reach station i from station 0.\n dist = {};\n\n i = 0\n n = cost.length\n while i < n do\n dist[i] = inf\n i += 1\n end\n dist[0] = 0\n\n # Go through every station and check if using it as an intermediate station gives better path\n i = 0\n while i < n do\n j = i + 1\n while j < n do\n c = dist[i] + cost[i][j]\n dist[j] = c if dist[j] > c\n j += 1\n end\n i += 1\n end\n return dist[n-1];\nend",
"def min_remaining_cost(path)\n return 0 if @goal_location == path.location\n (path.turns + 1 ... path.turns + path.location.manhattan_distance(@goal_location)).sum + @costs[*@goal_location]\n end",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def cost_function start_morph, to\n @cost_function ||\n ->(point) {\n @metric.zip(to, lowest(start_morph.size)).inject(0) {|memo, x|\n single_metric, target_distance, low_boundary = x\n distance = single_metric.call(start_morph, point)\n unless @boundaries.nil?\n start_to_lowest = single_metric.call(start_morph, low_boundary)\n current_to_lowest = single_metric.call(point, low_boundary)\n if start_to_lowest > current_to_lowest\n distance *= -1.0\n end\n end\n memo += (distance - target_distance) ** 2\n } ** 0.5\n }\n end",
"def calculate(route)\n dist = 0\n route.each_cons(2) { |points| dist = dist + points[0].distance(points[1])}\n dist\nend",
"def cost(state)\n return fungsi(state[0], state[1])\nend",
"def min_cost(costs)\n costs.reduce([0]*3) { |prev, now| now.map { |n| n + prev.rotate![0,2].min } }.min\nend",
"def shortest_single_flight\n\n min_distance = @largest_integer\n flight = \"\"\n @query.get_graph.each_key do |city|\n route_dict = get_outgoing_routes(city)\n route_dict.each do |dest, dist|\n if dist < min_distance\n min_distance = dist\n flight = \"#{get_city_info(city,\"name\")}-#{dest}\"\n end\n end\n end\n\n return flight\n\n end",
"def calculate_route\n\t\t@cl = init_loc\n\t\t@steps << cl\n\n\t\twhile not at_rightmost_side?\n\t\t\t@cl = next_step\n\t\t\t@steps << cl\n\t\tend \t\t\n\tend",
"def getDistanceAndPath(costs, start, last) \n result = []\n distance = 0\n node = last\n result.push(last)\n while (node != start) \n distance += costs[node][:cost]\n node = costs[node][:parent]\n result.unshift(node)\n end\n # record distance for start node to rest of path\n distance += costs[node][:cost]\n \n return {\n distance: distance,\n path: distance == Float::INFINITY ? [] : result # If distance is Infinity, there is no path\n }\n end",
"def min_cost_climbing_stairs(cost)\n cost = cost + [0]\n table = Array.new(cost.length) { nil }\n table[0] = cost[0]\n table[1] = cost[1]\n\n table.each_with_index do |_val, i|\n next if i < 2\n table[i] = [table[i-1], table[i-2]].min\n table[i] += cost[i]\n end\n\n table.last\nend",
"def min_cost_climbing_stairs(cost)\n cost = cost + [0]\n\n last = cost[1]\n last_last = cost[0]\n\n cost[2..-1].each do |cost|\n new_cost = cost + [last, last_last].min\n last_last = last\n last = new_cost\n end\n\n last\nend",
"def select_possible_path(possible_paths)\n vertex, data = possible_paths.min_by do |vertex, data|\n data[:cost]\n end\n vertex\nend",
"def shortest_length(start, finish)\n infinity = (2**(0.size * 8 - 2) - 1) # max Fixnum integer value\n distances = {} # smallest distance from starting vertex to this one\n previous = {}\n cyclic = start == finish # true if starting vertex = ending vertex\n loops = 0 # useful for cyclic path\n vertex_pq = PriorityQueue.new\n\n adj_lists.each do |vertex|\n vname = vertex.name\n if vname == start\n distances[vname] = 0\n vertex_pq.enq(vname, 0)\n else\n distances[vname] = infinity\n vertex_pq.enq(vname, infinity)\n end\n previous[vname] = nil\n end\n\n while vertex_pq\n loops += 1\n # if cyclic, pretend starting vertex is unvisited. put it back in queue.\n if cyclic && loops == 2\n vertex_pq.enq(start, infinity)\n distances[start] = infinity\n end\n # vertex currently being checked. picks closest one first.\n current = vertex_pq.deq\n vname = current.keys.first\n\n # if we've arrived at final vertex, return shortest distance\n # if cyclic, skip this code during first loop\n if vname == finish && loops > 1\n shortest_path = []\n vname2 = vname\n while previous[vname2]\n shortest_path << vname2\n vname2 = previous[vname2]\n previous[start] = nil if cyclic # pretend starting vertex is unvisited\n end\n shortest_path = [start] + shortest_path.reverse\n print \"Shortest path: #{shortest_path}, Length = #{path_length(shortest_path)}\\n\"\n return distances[finish]\n end\n\n # leave if we never get to final vertex\n break if vname == nil || distances[vname] == infinity\n\n adj_vertices(vname, adj_lists).each do |vertex|\n alt_distance = distances[vname] + dist(vname, vertex)\n # if total distance to neighbor < last minimum total distance\n # to neighbor, replace it with this new distance\n if alt_distance < distances[vertex]\n distances[vertex] = alt_distance\n previous[vertex] = vname\n vertex_pq.enq(vertex, alt_distance)\n end\n end\n end\n\n end",
"def get_path(start, stop)\n @graph.dijkstra_shortest_path(@weight_map, start, stop)\n end",
"def curatorWaypointCost _args\n \"curatorWaypointCost _args;\" \n end",
"def shortest_paths(source, dest)\n\t\t\t@source = source\n\t\t\tdijkstra source\n\t\t\tprint_path dest\n\t\t\treturn @distance[dest]\n\t\tend",
"def next_distances(save = true) ; next_task(@@DISTANCE_TASKS, save) ; end",
"def min_cost(costs)\n n = costs.length\n return 0 if n == 0\n \n (1..n - 1).each do |i|\n costs[i][0] += [costs[i - 1][1], costs[i - 1][2]].min\n costs[i][1] += [costs[i - 1][0], costs[i - 1][2]].min\n costs[i][2] += [costs[i - 1][0], costs[i - 1][1]].min\n end\n \n [costs[n - 1][0], costs[n - 1][1], costs[n - 1][2]].min \n \nend",
"def run\n start = rand(20)\n puts \" Starting at: #{@locations[start].name}\"\n tripDesc = \"\" # human-readable List of moves for current trip segment\n @locations[start].visited = true\n visited = 1\n totalTime = 0\n while visited < 20\n group = group_nearest(start)\n best_time = 9999999999\n\n for i in 0..3\n result = getBestPath(start, group[i]) if group[i]\n if result[0] < best_time\n best_time = result[0]\n best_path = result[1]\n best_dest = group[i]\n end\n end\n tripDesc << best_path\n totalTime += best_time\n @locations[best_dest].visited = true\n start = best_dest\n visited += 1\n end\n\n puts \"*********** Total Trip Time = #{secondstoHMS(totalTime)} **************\"\n confirm = \"Complete.\\n\"\n for i in 0..19\n confirm = \"Error, not all locations visited!!\\n\" if !@locations[i].visited\n end\n tripDesc << confirm\n return [totalTime, tripDesc]\n\n end",
"def min_cost_climbing_stairs(cost)\n i = cost.length - 3\n while i >= 0\n cost[i] += [cost[i+1], cost[i+2]].min\n i -= 1\n end\n\n [cost[0], cost[1]]\nend",
"def shortest_circuit()\n shortest_cir = Array.new\n shortest_weight = 99999\n\n vert = vertex_list()\n start_point = vert[0]\n vert.delete_at(0)\n\n vert_perm = vert.permutation.to_a()\n\n vert_perm.each{ |x|\n x.insert(0,start_point)\n x.insert(x.length,start_point)\n weight = path_weight(x)\n \n if weight == nil\n weight = 99999\n end\n\n if weight < shortest_weight\n shortest_weight = path_weight(x)\n shortest_cir = x\n end\n }\n return \"Shortest Circuit = \",shortest_cir.inspect, \"\\nWeight = \", shortest_weight\n\n end",
"def singleTrip (start_station, end_station, line)\n start_index = MTA[line].index(start_station)\n end_index = MTA[line].index(end_station)\n\n if start_index < end_index\n stops = MTA[line][start_index ... end_index]\n num_stops = end_index - start_index\n end\n\n if end_index < start_index\n stops = MTA[line][end_index ... start_index]\n stops = stops.reverse\n num_stops = start_index - end_index\n\n end\n print = \"You must travel through the following stops on the #{line}: #{stops}\"\n # print = \"#{num_stops} in total\"\nend",
"def find_target_sum_ways(nums, s)\n return calculate(nums, 0, 0, s, cache={})\nend",
"def shortest_paths(source, dest)\n @graph_paths=[]\n @source = source\n dijkstra source\n @path=[]\n find_path dest\n actual_distance=if @distance[dest] != INFINITY\n @distance[dest]\n else\n \"no path\"\n end\n \"Shortest route and distance : #{@path.join(\"-->\")}, #{actual_distance} km\"\n end",
"def cost\n unless @cost\n @cost = 0\n @nodes_v.each do |v|\n @cost += @nodes_s.map { |s| v.distance_to(s) }.min\n end\n end\n\n @cost\n end",
"def parse_and_find_distance(full_route)\n cities = full_route.split('-')\n distance=0 \n cities.each_with_index do|city,index|\n if cities[index+1]\n route = prev_find{|route| route.start_city.to_s==city && route.end_city.to_s==cities[index+1]}\n if route\n distance += route.distance.to_i\n else\n return \"No Such Route\"\n end\n end\n end\n distance==0 ? \"No Such Route\" : distance\n end",
"def solve(points)\r\n min_dis = BigDecimal(\"-1\")\r\n p min_dis.class\r\n \r\n min_route = []\r\n (1..points.length-1).to_a.permutation(points.length-1).to_a.each do |route|\r\n route.unshift(0)\r\n #p route\r\n dis = BigDecimal(\"0\")\r\n (0...route.length-1).each do |i|\r\n dis += Math.sqrt((BigDecimal(points[route[i]][0].to_s) - BigDecimal(points[route[i+1]][0]))**2 + (BigDecimal(points[route[i]][1]) - BigDecimal(points[route[i+1]][1]))**2)\r\n end\r\n dis += Math.sqrt((BigDecimal(points[route[route.length-1]][0]) - BigDecimal(points[route[0]][0]))**2 + (BigDecimal(points[route[route.length-1]][1]) - BigDecimal(points[route[0]][1]))**2)\r\n #p dis\r\n if min_dis == -1 || min_dis > dis\r\n #p dis.class\r\n min_dis = dis\r\n min_route = route\r\n end\r\n end\r\n\r\n p min_dis.class\r\n print \"{{\"\r\n (0...min_route.length).each do |i|\r\n print \"#{min_route[i]+1},\"\r\n end\r\n print \"1},#{min_dis}}\\n\"\r\n #p min_dis\r\n #p min_route\r\n\r\nend",
"def solve(directions)\n directions = parse(directions)\n steps = map(directions)\n\n count(steps)\nend",
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end",
"def travel_time\n travel_time = 0\n @solution.each { |route| travel_time += route.travel_time_and_cost[1] }\n return travel_time\n end",
"def can_complete_circuit(gas, cost)\n total = 0\n trip = 0\n start = 0\n (0...gas.size).each { |i|\n trip += gas[i] - cost[i]\n total += trip\n if trip < 0\n trip = 0\n start = i + 1\n end\n }\n \n total < 0 ? - 1 : start\nend",
"def shortest_paths(s)\n @source = s\n dijkstra s\n puts \"Source: #{@source}\"\n @nodes.each do |dest|\n puts \"\\nTarget: #{dest}\"\n print_path dest\n if @d[dest] != @INFINITY\n puts \"\\nDistance: #{@d[dest]}\"\n else\n puts \"\\nNO PATH\"\n end\n end\n end",
"def trip_cost(distance, miles_per_gal, price_per_gal)\n result = (((distance.to_f / 100) * miles_per_gal) * price_per_gal) #can also do distance / 100.0 because as long as one of the numbers is a floating point it will return a decimal number\n return result\nend",
"def minCostTravel( days, costs)\n\tn = days.length\n\tmax = days[n - 1]\n\tdp = Array.new(max + 1){0}\n\tj = 0\n\ti = 1\n\twhile (i <= max)\n\t\tif (days[j] == i)\n\t\t\t# That days is definitely travelled.\n\t\t\tj += 1\n\t\t\tdp[i] = dp[i - 1] + costs[0]\n\t\t\tdp[i] = min(dp[i],dp[max(0,i - 7)] + costs[1])\n\t\t\tdp[i] = min(dp[i],dp[max(0,i - 30)] + costs[2])\n\t\telse\n\t\t\tdp[i] = dp[i - 1]\n\t\tend\n\t\ti += 1\n\tend\n\treturn dp[max]\nend",
"def min_cost(cost, m, n)\n if n < 0 || m < 0\n return 100000\n elsif m == 0 && n == 0\n return cost[m][n]\n else\n return cost[m][n] + find_min( min_cost(cost, m-1, n-1),\n min_cost(cost, m-1, n),\n min_cost(cost, m, n-1))\n end\nend",
"def min_cost_connect_points(points)\n total = 0\n visited = [true] + [false] * (points.length - 1)\n min_costs = {}\n current_id = 0\n\n (points.length - 1).times do\n min = nil\n next_id = nil\n points.each_with_index do |point, index|\n next if visited[index]\n\n new_min = manhattan_distance(points[current_id], points[index])\n\n if !min_costs[index] || min_costs[index] > new_min\n min_costs[index] = new_min\n else\n new_min = min_costs[index]\n end\n\n if !min || new_min < min\n min = min_costs[index] < new_min ? min_costs[index] : new_min\n next_id = index\n end\n end\n\n total += min\n visited[next_id] = true\n current_id = next_id\n end\n\n total\nend",
"def bfs_shortest_path(node1, node2)\n distance, route = breadth_first_search(node1)\n step = distance[node2]\n node = node2\n path = [ node2 ]\n while node != node1 and route[node]\n node = route[node]\n path.unshift(node)\n end\n return step, path\n end",
"def distance_on_path(t)\n # for now, just average\n average_speed * t\n end",
"def route\n index = @possible_distances.index(@possible_distances.min)\n @array_of_city_arrangements[index]\n end",
"def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end",
"def next_distances(save = true)\n next_task(@@DISTANCE_TASKS, save)\n end",
"def min_cost_climbing_stairs(arr)\n next_one, next_two = 0, 0\n curr = 0\n\n (arr.length - 1).downto(0).each do |i|\n curr = arr[i] + min(next_one, next_two)\n next_two = next_one\n next_one = curr\n end\n\n return min(next_one, next_two)\nend",
"def calculate_next_location(food)\n\n x = food[0] - @location[0]\n y = food[1] - @location[1] \n\n distance = (x**2 + y**2) ** 0.5\n next_location = [@location[0] + x*@speed/distance, @location[1] + y*@speed/distance]\n\n return next_location\n end",
"def next_step_to_shortest_path(from_x, from_y, to_x, to_y)\n move = shortest_path(from_x, from_y, to_x, to_y)&.first\n return nil unless move\n if move[0] == from_x && move[1] == from_y + 1\n return 'S'\n elsif move[0] == from_x && move[1] == from_y - 1\n return 'N'\n elsif move[0] == from_x + 1 && move[1] == from_y\n return 'E'\n elsif move[0] == from_x - 1 && move[1] == from_y\n return 'W'\n end\n raise 'This should not happen'\n end",
"def dist(*vertex_names)\n total, total_old = 0, 0\n vertex_names[0..-2].each_with_index do |name, index|\n vertex_start = adj_lists[vertex_num_for(name)]\n neighbor = vertex_start.adj_list\n\n while !neighbor.nil?\n if neighbor.name == vertex_names[index + 1]\n total += neighbor.weight\n break\n else\n neighbor = neighbor.next\n end\n end\n\n return \"NO SUCH ROUTE\" if total == total_old\n total_old = total\n end\n total\n end",
"def shortest_paths(s)\n\t\t@source = s\n\t\tdijkstra s\n\t\tputs \"Source: #{@source}\"\n\t\t@nodes.each do |dest|\n\t\t\tputs \"\\nTarget: #{dest}\"\n\t\t\tprint_path dest\n\t\t\tif @d[dest] != @INFINITY\n\t\t\t\tputs \"\\nDistance: #{@d[dest]}\"\n\t\t\telse\n\t\t\t\tputs \"\\nNO PATH\"\n\t\t\tend\n\t\tend\n\tend",
"def get_cost(current_coordinates, goal_vector)\n\t\t\tNMath.sqrt(((current_coordinates - goal_vector) ** 2).sum)\n\t\tend",
"def plan_trip (first_l, first_s, last_l, last_s)\n# Get the program to work for a single line:\n# Different way to do global use $\n stations = [ ]\n start = $train_lines[first_l.to_s].index(first_s.to_s)\n finish = $train_lines[last_l.to_s].index(last_s.to_s)\n\n# 2.7.2 :012 > $train_lines.values\n# => [[\"Times Square\", \"34th\", \"28th\", \"23rd\", \"Union Square\", \"8th\"], [\"8th\", \"6th\", \"Union Square\", \"3rd\", \"1st\"], [\"Grand Central\", \"33rd\", \"28th\", \"23rd\", \"Union Square\", \"Astor Place\"]]\n# 2.7.2 :013 > $train_lines.keys\n# => [\"lineN\", \"lineL\", \"line6\"]\n\n if start < finish\n stations = $lineN[start..finish]\n elsif\n stations = $lineN[finish..start].reverse\n end\n\n return stations\n\nend",
"def shortest_distance_between_nodes(initial, destination)\n shortest_path_between_nodes(initial, destination).last.distance\n end",
"def cost_to_visit(pos, prev_pos, gem)\n cost = (pos[0] - gem[0]).abs + (pos[1] - gem[1]).abs\n cost += 2 if opposite_direction(pos, prev_pos, gem)\n cost\nend",
"def kaprekar_step(n)\n\n # TODO: Solve it!\n\n end",
"def getShortFlight(csa)\n number2 = 10000000\n @parse.map{ |airport| \n if( airport[\"name\"] == csa) \n airport[\"destinations\"].map do |element|\n number1 = element[\"distance\"]\n if(number1<number2)\n number2 = number1\n end\n end\n airport[\"destinations\"].map{ |dest| \n if(number2==dest[\"distance\"])\n puts \"The min distance is \" + number2.to_s + \" in the fligth between \"+ dest[\"ports\"].to_s\n end\n }\n end\n }\n end",
"def fuel_cost\n ((amount * 100) / (mileage - predecessor.mileage)).round(1) if predecessor\n end",
"def shortest_distance_to_all_nodes(initial)\n Hash[shortest_path_to_all_nodes(initial).map {|n| [n, n.distance]}]\n end",
"def shortest_distance_to(node)\n @distances[node]\n end",
"def min_cost2(costs)\n return 0 if costs.empty?\n \n pre_red = costs[0][0]\n pre_green = costs[0][1]\n pre_blue = costs[0][2]\n\n costs[1..-1].each_with_index do |cost, i|\n current_red = cost[0] + [pre_blue, pre_green].min\n current_green = cost[1] + [pre_red, pre_blue].min\n current_blue = cost[2] + [pre_red, pre_green].min\n\n pre_red = current_red\n pre_green = current_green\n pre_blue = current_blue\n end\n\n # p [pre_red, pre_green, pre_blue]\n [pre_red, pre_green, pre_blue].min\nend",
"def find_shortest(rootCode,goalCode)\n\tself.findHops(rootCode, goalCode, lambda{|flight,oldweight| oldweight+1})\nend",
"def dijkstra_shortest_path(start, finish)\n visited, unvisited = Array.new, Array.new\n distances = Hash.new\n\n distances[start] = 0\n unvisited << start\n\n # find the distance\n while not unvisited.empty?\n curr_node = unvisited.pop\n visited << curr_node\n get_edges(curr_node).each do |edge| \n if visited.find_index(edge.out_vertex) == nil\n unvisited.unshift(edge.out_vertex) if unvisited.find_index(edge.out_vertex) == nil\n curr_distance, min_distance = distances[curr_node], distances[edge.out_vertex] || 1.0 / 0.0\n if curr_distance + edge.distance < min_distance\n distances[edge.out_vertex] = curr_distance + edge.distance\n end\n end\n end\n end\n\n # figure out the path\n previous = finish\n path = Array.new() \n path << previous\n while distances[previous] != 0\n get_edges(previous).each do |edge|\n if previous != edge.in_vertex && distances[edge.in_vertex] + edge.distance == distances[previous]\n previous = edge.in_vertex\n path << previous\n break\n end\n end\n end\n \n return distances[finish], path.reverse\n end",
"def shortest_distance()\n min = 1000000\n s = \"\"\n @edges.each do |city, dests|\n dests.each do |dest|\n if min > dest.distance\n min = dest.distance\n s = \"#{city} to #{dest.name}\"\n end\n end\n end\n \"Shortest distance is #{min} from #{s}\"\n end",
"def reachable_by_step(pc)\n (-2..2).map {|x| (x + pc) %12}\nend",
"def getMinimumCost(k, c)\n c.sort.reverse.map.with_index do |cost, i|\n cost * (1 + i / k)\n end.sum\nend",
"def steps\n\t\tres = calc_steps @start, []\n\t\t# Always includes step for A, thus minumal value if solution exists is 2\t\n\t\tres > 0 ? res-1 : 0\n\tend",
"def shortest_path\n dist, previous = Hash.new(Infinity), {}\n dist[@source] = 0.0\n queue = @graph.vertex_set.dup\n\n until queue.empty?\n u = queue.min { |a,b| dist[a.name] <=> dist[b.name] }\n break if dist[u.name].infinite?\n queue.delete(u)\n\n u.each_edge do |e, v|\n alt = dist[u.name] + e.weight\n if alt < dist[v.name]\n dist[v.name] = alt\n previous[v.name] = u.name\n end\n end\n end\n\n path = []\n u = @dest\n until previous[u].nil?\n path.unshift(u)\n u = previous[u]\n end\n\n path.unshift(@source)\n end",
"def total_paths(initial_s)\n reachable_stops(initial_s).count\n end",
"def can_complete_circuit(gas, cost)\n return -1 if gas.size != cost.size\n local_trip = 0\n total_trip = 0\n idx = 0\n (0...gas.size).each { |i|\n local_trip += gas[i] - cost[i]\n total_trip += local_trip\n if local_trip < 0\n local_trip = 0\n idx = (i + 1) % gas.size\n end\n }\n \n return total_trip < 0 ? -1 : idx\nend",
"def total_cost(distance, mpg, cpg)\n\tprice = (distance / mpg) * cpg \nend",
"def distance\n distance = 0\n @solution.each { |route| distance += route.distance }\n return distance\n end",
"def cost\n schedule.reduce(0) do |cost, day|\n cost + COSTS[day.city][day.cost]\n end\n end",
"def path_count(steps, current=0)\n if current == steps\n 1\n elsif current > steps\n 0\n else\n path_count(steps, current + 1) +\n path_count(steps, current + 2) +\n path_count(steps, current + 3)\n end\nend",
"def get_path(start, finish) \n @retreat_algorithm.set_graph(memory.construct_grid) \n @retreat_algorithm.run(start, finish)\n end",
"def run\n closed_squares = []\n opened_squares = [@start]\n\n @start.current_path_cost = 0\n\n while opened_squares.any?\n current_square = opened_squares.sort do |a, b|\n a.estimated_total_cost(@finish) <=> b.estimated_total_cost(@finish)\n end.first\n\n if current_square == @finish\n return find_path(current_square)\n end\n\n closed_squares.push(current_square)\n opened_squares.delete(current_square)\n\n @board.neighbours(current_square).each do |neighbour|\n if closed_squares.include?(neighbour)\n next\n end\n\n if !opened_squares.include?(neighbour)\n opened_squares.push(neighbour)\n end\n\n if current_square.current_path_cost + neighbour.move_cost >= neighbour.current_path_cost\n next\n end\n\n neighbour.path_via = current_square\n neighbour.current_path_cost = current_square.current_path_cost + neighbour.move_cost \n end\n end\n end",
"def plan_trip(stop1, line1, stop2, line2)\n\n trains = {\n \"N\" => [\"Times Square\", \"34th\", \"28th\", \"23rd\", \"Union Square\", \"8th\"],\n \"L\" => [\"8th\", \"6th\", \"Union Square\", \"3rd\", \"1st\"],\n \"6\" => [\"Grand Central\", \"33rd\", \"28th\", \"23rd\", \"Union Square\", \"Astor Place\"]\n }\n\n transfer = \"Union Square\" #DEFAULT TRANSFER STATION\n if line1 != line2 && stop1 == \"Union Square\" #PREVENTS BOARDING THE WRONG TRAIN AT UNION SQUARE\n puts \"Just board the correct train.\"\n line1 = line2\n end\n if line1 == line2 #there may be a clearer way to do this, but this allows a single train line output\n transfer = stop2\n end\n\n route1 = trains[line1] #this is just for readability\n route2 = trains[line2]\n\n if route1.index(stop1) < route1.index(transfer) #this always fires, and is either the only or first segment\n first_path = route1[(route1.index(stop1) + 1)..(route1.index(transfer))]\n puts \"You must travel through the following stops on the #{line1} line: #{first_path.join(\", \")}.\"\n else\n uptown = route1.reverse()\n first_path = uptown[(uptown.index(stop1) + 1)..(uptown.index(transfer))]\n puts \"You must travel through the following stops on the #{line1} line: #{first_path.join(\", \")}.\"\n end\n if line2 == line1\n puts \"A total of #{first_path.length} stops.\"\n end\n\n if line1 != line2 #this only fires if there's a second line\n puts \"Transfer at Union Square.\"\n if route2.index(\"Union Square\") < route2.index(stop2)\n second_path = route2[(route2.index(\"Union Square\") + 1)..(route2.index(stop2))]\n puts \"You must continue through the following stops on the #{line2} line: #{second_path.join(\", \")}.\"\n else\n uptown = route2.reverse()\n second_path = uptown[(uptown.index(\"Union Square\") + 1)..(uptown.index(stop2))]\n puts \"You must continue through the following stops on the #{line2} line: #{second_path.join(\", \")}.\"\n end\n puts \"A total of #{first_path.length + second_path.length} stops.\"\n end\n\nend",
"def shortest_paths(dest)\n position = dest\n final = {}\n analisados = {}\n route = []\n route << dest\n @previous['a'] = -1\n\n @nodes.each do |n|\n analisados[n] = false\n end\n analisados[position] = true\n\n while analisados(analisados)\n adyacentes(position, analisados).each do |n|\n if @distance[n] == (@distance[position] - graph[n][position])\n @previous[position] = n\n position = n\n route << n\n end\n analisados[n] = true\n end\n\n end\n route << 'a'\n route\n end",
"def trip_calc dist, miles_per_g, price_per_g, speed_mph\n gallons_used = dist / miles_per_g\n cost = gallons_used * price_per_g\n time = dist / speed_mph\n return {cost: cost.to_f.round(2), time: time.to_f.round(2)}\nend",
"def trip_distance(duration)\n duration * @speed\n end",
"def shipping_cost(length, width, height)\n cost = (length * width * height) * 1.25\n end",
"def find_optimal(rootCode,goalCode)\n\tfindHops(rootCode, goalCode, \n\t\tlambda{|flight,oldweight| \n\t\t\toldweight + (flight.date.date.to_i + (flight.flightDuration).seconds - @date.date.to_i)/1200 + 100 + flight.seatprice/5 \n\t\t\t# oldweight + (number of hours between arrival and departure + 100 (per hop))*3 + seatprice/5 (~25-250)\n\t\t\t})\nend",
"def distance_for_stage(stage)\n d = [30, 16, 8, 4, 2, 1]\n return d[stage/2]\n end",
"def ways(s,m)\n CALLS[0] += 1\n return 1 if s == 0\n return 0 if m == 0\n return 1 if m == 1\n WAYS[[s,m]] ||= ways(s,m-1) + ways(s-m,[s-m,m].min)\nend",
"def track_wire(instructions)\n pt = [0,0]\n points = {}\n moves = 0\n instructions.each do |str|\n direction = str[0]\n steps = str.slice(/\\d+/).to_i\n while steps > 0 do\n moves += 1\n pt[0] += @compass[direction][0]\n pt[1] += @compass[direction][1]\n # add first crossing only (lowest steps wins)\n if !points.has_key? pt\n points[pt.dup] = moves\n end\n steps -= 1\n end\n # break if moves > 5000\n end\n points\nend",
"def trip(line, start_stop, end_stop)\n trip_line = s_line(line)\n p trip_line\n start_index = trip_line.index(start_stop)\n end_index = trip_line.index(end_stop)\n stops = \"\"\n\n if start_index < end_index\n until start_index == end_index\n stops += trip_line[start_index]\n start_index += 1\n end\n else\n until start_index == end_index\n stops += trip_line[start_index]\n start_index -= 1\n end\n end\n return stops\nend",
"def distance *path\n cost, edge_exists = 0, false\n\n # Adds the cost of the next move\n neighbors = @nodes[path.shift]\n neighbors.each do |node|\n if node.dst == path.first\n edge_exists = true\n cost += node.length\n break\n end\n end\n\n # Iterates in depth when neighbor exists\n return -1 unless edge_exists\n if path.length > 1\n sub_cost = distance *path\n return -1 if sub_cost == -1\n cost += sub_cost\n end\n cost\n end",
"def lesstrips(start, finish, max_distance)\n total_paths, distance = 0, 0\n path, paths = [], []\n visited = [start]\n cycles = all_cycles # all cycles in graph\n puts \"MAX DISTANCE = #{max_distance}\\n\"\n total_paths += lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n puts \"\\n==> Total paths from #{start} to #{finish}, with distance < #{max_distance}: #{total_paths}\\n\"\n total_paths\n end",
"def compute_stops(route)\n route.visited_stops\n end",
"def plan_trip (first_s, last_s)\n stations = []\n beginning = $lineN.index(first_s.to_s)\n ending = $lineN.index(last_s.to_s)\n this_many = beginning + ending\n stations = $lineN[beginning, this_many]\n return stations\nend",
"def shortest_way(source, dest)\n\t\t@source = source\n dijkstra source\n \n if @distances[dest] != @infinity\n return @distances[dest]\n end\n\tend",
"def trip_time(distance, speed)\n result = (distance / speed)\n return result\nend"
] | [
"0.64945066",
"0.63051593",
"0.62998176",
"0.62081134",
"0.6085776",
"0.6065148",
"0.6048964",
"0.60050386",
"0.5935265",
"0.5918307",
"0.58405596",
"0.5838905",
"0.57887113",
"0.57626945",
"0.57612133",
"0.5753281",
"0.575032",
"0.57486767",
"0.5683631",
"0.5676609",
"0.56447566",
"0.5590196",
"0.5589414",
"0.5566334",
"0.5565182",
"0.55392766",
"0.5505545",
"0.5505491",
"0.54833114",
"0.5467638",
"0.54630494",
"0.54487836",
"0.54476464",
"0.544248",
"0.5431319",
"0.54294145",
"0.5418841",
"0.54003626",
"0.5386833",
"0.5383019",
"0.53820306",
"0.5380226",
"0.53709614",
"0.53684443",
"0.53684247",
"0.5346392",
"0.53420854",
"0.53395253",
"0.533549",
"0.5335406",
"0.53332746",
"0.53149515",
"0.53141934",
"0.5289827",
"0.52680475",
"0.52679455",
"0.526759",
"0.52557296",
"0.525553",
"0.5251054",
"0.5243825",
"0.52413946",
"0.522913",
"0.52185595",
"0.5214416",
"0.5214403",
"0.5207511",
"0.5198416",
"0.5193151",
"0.51891625",
"0.5178095",
"0.51775235",
"0.51773393",
"0.5173646",
"0.5172052",
"0.51703805",
"0.51565987",
"0.5151486",
"0.5149056",
"0.51481056",
"0.5140086",
"0.51399004",
"0.5135655",
"0.51293486",
"0.512663",
"0.5124197",
"0.5119435",
"0.51160246",
"0.5114592",
"0.5097723",
"0.50953496",
"0.50949997",
"0.508873",
"0.50811887",
"0.5080686",
"0.507398",
"0.5067354",
"0.50591654",
"0.50535446",
"0.5051859"
] | 0.60641307 | 6 |
route(List, Symbol, Hash, String) return a list of routes returns | def route visit_path, dst=nil, limits=nil, condition=UNTIL
paths = trips(visit_path, dst, limits, condition)
return paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes_list\n response = RestClient.get(\n BASE_URL,\n params: {command: 'routeList', a: AGENCY}\n )\n\n parse_routes_response(response.body)\n end",
"def routes(&block); end",
"def routes(&block); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes(context={})\n \n routes = [ \n ]\n \n end",
"def routes_map; end",
"def routes\n request :get, '/routes'\n end",
"def routes_normal\n return Array.new\n end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def routes; end",
"def route\n #TODO\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def routes\n @routes ||= []\n end",
"def routes\n routes_method.call\n end",
"def route\n @route\n end",
"def route() request.route end",
"def get_routes(params)\n graph_data = create_data(params)\n if graph_data.is_a?(Array)\n graph_data.each do |data|\n add_vertex(data[0][0], data[0][1])\n end\n path_array = shortest_path(params[:source], params[:destination])\n if path_array.is_a?(Array)\n get_path_description(path_array, params)\n else\n path_array\n end\n else\n graph_data\n end\n end",
"def routes\n @route_map.dup\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def getRoutesTo(station)\n routeList = @toNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end",
"def routes\n [@name.downcase]\n end",
"def routes\n ['Agriculture, environmental and animal care', 'Business administration', 'Catering and hospitality' \\\n 'Construction',\n 'Creative and design', 'Digital', 'Engineering and manufacturing', 'Hair and beauty', 'Health and science',\n 'Legal, finance and accounting', 'Protective services', 'Sales, marketing and procurement', 'Transport']\n end",
"def routes\n @db[:routes].\n select(:route_id, :route_long_name).\n where(:route_id => routes_for_today).\n order(:route_long_name).\n all\n end",
"def route_sets; end",
"def route_list(library, paths)\n if paths && !paths.empty? && paths.first =~ /^(?:features|tags)$/\n case paths.shift\n when \"features\"; cmd = Commands::ListFeaturesCommand\n when \"tags\"; cmd = Commands::ListTagsCommand\n end\n cmd.new(final_options(library, paths)).call(request)\n else\n core_route_list(library,paths)\n end\n end",
"def routes\n routes = get('/gtfs/routes')\n routes.map do |route|\n Route.from_json(route)\n end\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def all_routes\n matching_routes\n end",
"def routes\n raise NotImplementedError\n end",
"def getRoutes\n # [[\"MTA NYCT_B65\", \"B65\", \"Downtown Brooklyn - Crown Heights\", \"via Bergen St & Dean St\"]...]\n url = \"http://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=#{APIKEY}\"\n xml_str = Net::HTTP.get URI(url)\n xml = Nokogiri::XML(xml_str)\n xml.css(\"response data list route\").to_a.map{|rte| [rte.css('id').text, rte.css('shortName').text, rte.css('longName').text, rte.css('description').text]}\nend",
"def list_routes request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_routes_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::Datastream::V1::ListRoutesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def route_for(request) #:nodoc:\n index, params = match(request)\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def route_index; end",
"def list_routes request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_routes_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::Datastream::V1alpha1::ListRoutesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def list\n ret = get()\n return [] if ret.is_a? Hash and ret.has_key? :error\n ret.map do |item|\n if item[:content_type].nil? or item[:content_type].empty? then\n item[:content_type] = 'application/json'\n end\n # XXX should this update the script header?\n RouteItem.new(item)\n end\n end",
"def getRoutesFrom(station)\n routeList = @fromNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end",
"def routes_list\n Route.all.each.with_index(1) do |(route), index|\n puts \"#{index}. Маршрут: #{route.stations.first.name} - #{route.stations.last.name}\"\n end\n end",
"def to_a\n @routes\n end",
"def routes\n context[:routes]\n end",
"def each_route &block\n @routes_lookup.each do |key,route|\n next unless Array === key\n block.call route, key[0], key[1]\n end\n end",
"def routes(context={})\n \n routes = [{:path => '/admin/system',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/system/, \n :title => 'Sistema', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/admin/logger',\n :parent_path => '/admin/system',\n :regular_expression => /^\\/admin\\/logger/, \n :title => 'Trazas', \n :description => 'Reads the log messages',\n :fit => 1,\n :module => :system },\n {:path => '/logger-config',\n :regular_expression => /^\\/admin\\/logger-config/, \n :title => 'Logger configuration', \n :description => 'Configure the logger',\n :fit => 1,\n :module => :system }, \n {:path => '/business-events',\n :regular_expression => /^\\/admin\\/business-events/, \n :title => 'Business events',\n :description => 'Manage the business events.',\n :fit => 1,\n :module => :system }]\n \n end",
"def show_all_routes\n if @routes.empty?\n routes_void\n else\n routes_list\n end\n end",
"def _routes; end",
"def routes\n @logger.info \"#{__method__}\"\n fill_in \"JourneyPlanner$txtNumberOfPassengers\", with: \"1\"\n country_routes = list_countries.inject([]) do |country_result, country|\n @logger.info \"routes for #{country}\"\n select(country, :from => \"JourneyPlanner_ddlLeavingFromState\")\n sleep 3\n to_from = list_leaving_from.inject([]) do |from_result, from|\n @logger.info \"routes from #{from}\"\n sleep 2\n select(from, :from => \"JourneyPlanner$ddlLeavingFrom\")\n from_result << {from => list_travelling_to}\n from_result\n end\n country_result << {country => to_from}\n country_result\n end\n end",
"def each_route(&block)\n\t\tget_routes().each(&block)\n\tend",
"def routes\n routes = {}\n self.class.each_route do |route|\n #routes[:name] = route.app.name # \"SomeSinatraApp\"\n info = {}\n routes[route.path.to_s.to_sym] = info # that's the path given as argument to get and akin\n info[:verb] = route.verb # get / head / post / put / delete\n info[:file] = route.file # \"some_sinatra_app.rb\" or something\n info[:line] = route.line # the line number of the get/post/... statement\n info[:pattern] = route.pattern # that's the pattern internally used by sinatra\n info[:keys] = route.keys # keys given when route was defined\n info[:conditions] = route.conditions # conditions given when route was defined\n info[:block] = route.block # the route's closure\n end\n routes\n end",
"def routes\n cached_routes\n end",
"def kml_routes(routes, name, xml)\n return nil unless routes.any?\n routes = routes.map{|r| r.sort_by{|x| @airport_details[x][:iata]}}.uniq.sort_by{|y| [@airport_details[y[0]][:iata], @airport_details[y[1]][:iata]]}\n \n xml.Folder do\n xml.name_(name)\n routes.each do |route|\n detail = route.map{|airport| @airport_details[airport]}\n xml.Placemark do\n xml.name_(detail.map{|a| a[:iata]}.join(\"–\"))\n xml.styleUrl(\"#flightPath\")\n xml.LineString do\n xml.tessellate(\"1\")\n xml.coordinates(detail.map{|a| \"#{a[:longitude]},#{a[:latitude]},0\"}.join(\" \"))\n end\n end\n end\n end\n return nil\n end",
"def route_descriptor_ar(routeset)\n routeset.routes.collect do |route|\n name = routeset.named_routes.routes.index(route).to_s\n verb = route.conditions[:method].to_s.upcase\n path = route.segments.inject(\"\") { |str,s| str << s.to_s }\n path.chop! if path.length > 1\n { :name=>name, :verb=>verb, :path=>path }.merge(route.requirements)\n end ; end",
"def index\n if params[:query].present? && params[:for].present?\n query = params[:query]\n case params[:for]\n when 'route_id'\n @routes = Route\n .where(route_id: query)\n\n when 'description'\n @routes = Route\n .where('description like ?', \"%#{query}%\")\n\n when 'user_name'\n @routes = Route\n .joins(:user)\n .where(users: {name: query})\n\n when 'location'\n # TODO\n raise \"-- not implemented (location) --\"\n\n else\n @routes = Route.all\n end\n\n else\n @routes = Route.all\n end\n\n sort_column = 'created_at'\n if params[:sort].present?\n case params[:sort]\n when 'played_count'\n sort_column = 'played_count'\n\n when 'achievement_count'\n sort_column = 'achievement_count'\n\n end\n end\n\n order = (params[:order] == 'asc') ? 'ASC' : 'DESC'\n @routes.order!(\"#{sort_column} #{order}\")\n end",
"def find_my_routes(*args)\n bounds = args[0][:bounds].nil? ? default_coordinates : args[0][:bounds].dup\n routes = case args[0][:filter]\n when \"recommended\"\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(visibility: 'recommended')\n when \"liked\"\n # TODO need to build this\n else # 'my' or blank\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(owner_id: id)\n end\n end",
"def index\n @routes = Route.all\n end",
"def index\n @routes = Route.all\n end",
"def index\n @routes = Route.all\n end",
"def index\n @routes = Route.all\n end",
"def map(&block)\n @routes.map(&block)\n end",
"def routes\n { :static => @route_ids, :dynamic => @dynamic }\n end",
"def my_routes\n my_routes = []\n exceptions = %w(Login Signin)\n self.class.routes['GET'].each do |r|\n route = r.first.to_s.gsub(/\\W+|mix/,'').capitalize\n my_routes << route unless exceptions.include?(route)\n end\n return my_routes\n end",
"def route_name; end",
"def route_name; end",
"def route14\n end",
"def route(stock_url)\n url=stock_url.split(/\\/+/).join(\"/\")\n @routes.keys.each do |x|\n #@logger.msginfo(\"Main:route:Looking at '#{url}' (#{url[0,@routes[x]['path_length']]}) for '#{x}'\")\n if (x == url[0,@routes[x][\"path_length\"]])\n #@logger.msginfo(\"Main:route: #{@routes[x][\"handler\"].class.to_s} will do '#{url}'\")\n return @routes[x][\"handler\"]\n end\n end\n return nil #Bad, nothing matched\n end",
"def route_for(request)\n index, params = if @around_match\n send(@around_match, request) { match(request) }\n else\n match(request)\n end\n route = routes[index] if index\n if !route\n raise ControllerExceptions::NotFound, \n \"No routes match the request: #{request.uri}\"\n end\n [route, params]\n end",
"def index\n @routes = Route.get_active\n end",
"def list_climbing_routes(climbing_routes)\n # puts climbing_routes\n climbing_routes.each do |climbing_route|\n marker = '[ ]'\n marker = '[x]' if climbing_route.done\n puts \"name: #{climbing_route.name} - level: #{climbing_route.level} - done: #{marker}\"\n end\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"vrp\", Routific.token, data)\n RoutificApi::Route.parse(result)\n end",
"def get_routes from, to, options = {}\n options[:start_type] = check_point_type(from) || options[:start_type]\n options[:target_type] = check_point_type(to) || options[:target_type]\n # default options\n options = {\n :time => Time.now, \n :depth => 0, \n :include_coords => true, \n :limit => 2,\n :time_relation => :depature,\n :identify_part_prices => :none }.merge(options)\n\n options[:time] = options[:time].in_time_zone(\"Berlin\") #+ 10.minutes # Ansonsten liegt die erste Verbindung in der Vergangenheit\n page = @agent.get @@options[:url_route]\n \n result = submit_form page.forms.first, from, to, options\t\t\n routes = []\n links = result.links_with(:href => /details=opened!/).select { |l| l.to_s.size > 0} # only select connection links, no warning links\n links.reverse! if options[:time_relation] == :arrival # respect :time_relation for route processing\n \n link_threads = Array.new\n links.each_index do |idx|\n link_threads[idx] = Thread.new {\n # maybe we are too fast in requesting :-)\n (1..5).each do |i|\n page = links[idx].click \n break unless page.title.match(/Fehler/)\n # puts \"link.click error: %i\" % i\n sleep(1)\n end\n Thread.current[:route] = Route.new(page, options)\n }\n break if idx == options[:limit]\n end\n\n link_threads.each { |t| t.abort_on_exception = true}\n routes = link_threads.map { |t| t.join; t[:route] }\n\n # Keine Station gefunden also suchen wir nach der nächstbesten Adresse/Station\n if links.count == 0 && options[:depth] == 0\n if options[:start_type] == :address\n from = find_address(from, options)\n options[:start_type] = from.station_type\n from = from.name\n elsif options[:start_type] == :station\n from = find_station(from, options)\n options[:start_type] = from.station_type\n from = from.name\n end\n \n if options[:target_type] == :address\n to = find_address(to, options)\n options[:target_type] = to.station_type\n to = to.name\n elsif options[:target_type] == :station\n to = find_station(to, options)\n options[:target_type] = to.station_type\n to = to.name\n end\n \n return get_routes from, to, options.merge(:depth => options[:depth]+1)\n end\n \n raise \"no_route\" if routes.count == 0 || links.count == 0\t\t\t\n\n # attach price information for each routepart if necessary\n identify_part_prices(routes, options) unless options[:identify_part_prices] == :none\n \n return routes\n end",
"def custom_routes; end",
"def recognized_routes_for(env)\n Array(router.recognize(env).first)\n end",
"def anchored_routes; end",
"def build_route_list\n @csr = []\n csr = []\n tempcsr = []\n calllist = Calllist.all\n calllist.each do |c|\n if c.csr && !tempcsr.include?(c.csr)\n tempcsr.push(c.csr)\n end\n end\n\n csr = tempcsr.sort\n if !session[:called_csr] || session[:called_csr == '']\n # not returning from update of called flag\n session[:called_csr] = csr[0]\n end\n\n i = 1\n @selected_csr = 0\n csr.each do |c|\n select_item = []\n select_item.push(c)\n select_item.push(i)\n @csr.push(select_item)\n if c == session[:called_csr]\n @selected_csr = i\n end\n i += 1\n end\n session[:calllist_csrs] = @csr\n\n @route = []\n route = []\n temproute = []\n routes = Shipto.all\n calllist = Calllist.all\n route_array = []\n shipto_array = []\n routes.each do |r|\n route_array.push(r.route_code)\n shipto_array.push(r.shipto_code)\n end\n\n # Set up the call list for the first route or the returning route\n @route_calllists = []\n\n if !session[:called_route] || session[:called_route == '']\n # the route has not been set so default to the first route I know is valid (this is bad code)\n session[:called_route] = 'AM'\n end\n\n calllist.each do |c|\n if c.csr\n i = shipto_array.index(c.shipto)\n if i && route_array[i] && !temproute.include?(route_array[i])\n # found a match on shipto so store the accompanying route\n temproute.push(route_array[i])\n end\n if c.shipto && i && route_array[i] == session[:called_route] && c.csr == session[:called_csr]\n # include call list records that are a direct match for route via shipto\n @route_calllists.push(c)\n end\n end\n end\n route = temproute.sort\n i = 1\n @selected_route = 0\n route.each do |c|\n select_item = []\n select_item.push(c)\n select_item.push(i)\n @route.push(select_item)\n if c == session[:called_route]\n @selected_route = i\n end\n i += 1\n end\n session[:calllist_routes] = @route\n end",
"def bus_api_getdirections(route)\n url_safe_route = URI.encode(route)\n apiKey = \"UPGw2J5PBxNnF967CAMyHygeB\"\n apiLink = \"http://www.ctabustracker.com/bustime/api/v1/getdirections?key=#{apiKey}&rt=#{url_safe_route}\"\n apiResults = open(apiLink).read\n return Hash.from_xml(apiResults)\n end",
"def route_for(name, *args); end",
"def routes(context={})\n \n routes = [{:path => '/admin/media',\n :parent_path => '/admin',\n :regular_expression => /^\\/admin\\/media/,\n :title => 'Medios',\n :description => 'Gestión de medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/config',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/config/,\n :title => 'Configuración',\n :description => 'Configuración medios',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/album',\n :parent_path => '/admin/media',\n :regular_expression => /^\\/admin\\/media\\/album/,\n :title => 'Albums',\n :description => 'The albums admin tools to create and modify media albums',\n :fit => 1,\n :module => :media_gallery}, \n {:path => '/admin/media/photo/:album_name',\n :parent_path => '/admin/media/album',\n :regular_expression => /^\\/admin\\/media\\/photo\\/.+/,\n :title => 'Photos',\n :description => 'It manages the album\\'s photos. Used to upload and edit the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery},\n {:path => '/gallery/:album_name',\n :regular_expression => /^\\/photo_gallery\\/.+/,\n :title => 'Photos',\n :description => 'It shows the album\\'s photos.',\n :fit => 1,\n :module => :media_gallery}]\n \n end",
"def route(index_or_name)\n case index_or_name\n when Integer\n Rails.application.routes.routes[index_or_name]\n when Symbol # named route\n Rails.application.routes.named_routes.get index_or_name\n end\nend",
"def describe_route!(route)\n route_descriptions << ::Simple::Httpd::Route.build(route)\n end",
"def route_hash\n {}\n end",
"def route_type_listing(route)\n yield :file, route.file_path if @file_extensions.include? route.extension\n return unless handle_type? route.extension\n @extensions[route.extension].each do |value|\n yield value[:instruction], \"#{route.file_path}#{value[:extra_extension]}\"\n end\n end",
"def named_routes=(_arg0); end",
"def get_routes\n @agency = params[:name]\n request_url = \"http://services.my511.org/Transit2.0/GetRoutesForAgency.aspx?token=#{@@token}&agencyName=#{@agency}\"\n request_url = request_url.gsub(/ /,\"%20\")\n @routes = search_for_key(parse_request(request_url), \"Route\")\n @routes = [@routes] unless @routes.kind_of?(Array)\n respond_to do |format|\n format.js {}\n end\n end",
"def routes_out_of_region\n return Array.new\n end",
"def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def routes(routes, destination)\n routes.keys.each { |route| return route if routes[route] == destination }\n nil\nend",
"def routes\n return @routes unless @routes.nil?\n r = Parse::API::Hooks::TRIGGER_NAMES_LOCAL + [:function]\n @routes = OpenStruct.new(r.reduce({}) { |h, t| h[t] = {}; h })\n end",
"def named_route; end",
"def index\n @routes = Route.hottest\n end",
"def named_routes; end"
] | [
"0.7126989",
"0.707113",
"0.707113",
"0.6921695",
"0.6921695",
"0.6921695",
"0.685512",
"0.685512",
"0.67470664",
"0.6745525",
"0.67106533",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.6656632",
"0.65361536",
"0.653387",
"0.65072",
"0.65072",
"0.649729",
"0.6479417",
"0.6439691",
"0.6416874",
"0.6407174",
"0.6401619",
"0.63974553",
"0.6341667",
"0.6339976",
"0.63355136",
"0.6319056",
"0.6318076",
"0.6316162",
"0.6293434",
"0.62906504",
"0.62758034",
"0.6243867",
"0.624352",
"0.6229055",
"0.62284976",
"0.6221241",
"0.62011707",
"0.62009495",
"0.6200249",
"0.61442727",
"0.6142577",
"0.61226326",
"0.6121949",
"0.6102814",
"0.60829884",
"0.6074964",
"0.6051694",
"0.6042622",
"0.6029943",
"0.6024379",
"0.6022053",
"0.6019048",
"0.6013598",
"0.6013459",
"0.6013459",
"0.6013459",
"0.6013459",
"0.60101986",
"0.59917617",
"0.5988093",
"0.5977892",
"0.5977892",
"0.5969353",
"0.5968761",
"0.5955506",
"0.5954662",
"0.5950457",
"0.59484017",
"0.5944571",
"0.59407145",
"0.59348947",
"0.59164464",
"0.5900917",
"0.5895751",
"0.58907145",
"0.58855575",
"0.5877891",
"0.5874175",
"0.5863841",
"0.5862454",
"0.5858807",
"0.5841594",
"0.5830531",
"0.5820713",
"0.5810616",
"0.5805994",
"0.5800868",
"0.5799342",
"0.5793405",
"0.57869685"
] | 0.0 | -1 |
route(List, Symbol, Hash, String) method that calculate all the possible routs from a source to a destination params: visit_path: A list of nodes that represent a path that is been visit dst: The end node limits There are two types of limits that restrict the search by cost and by depth condition The conditions that the limits need to valid paths Paths to explore dst_paths Path that reached condition | def trips visit_path, dst, limits, condition, paths=Array.new, dst_paths=Array.new
node = visit_path.nodes.last
neighbors = @nodes[node]
if neighbors.empty?
visit_path.fanal = true
paths << visit_path
return paths
end
neighbors = neighbors.sort_by {|node| node.length}
neighbors.each do |neighbor|
path = Path.new visit_path.nodes.clone
path.cost = visit_path.cost + neighbor.length
path.final = path.nodes.include? neighbor.dst
path.final = eval final_eval( condition, limits ) unless limits.nil?
path.nodes << neighbor.dst
if (neighbor.dst == dst && !path.final)
d_path = Path.new path.nodes.clone
d_path.cost = path.cost
d_path.final = true
dst_paths << d_path
end
paths << path
end
while(paths.length > 0 && paths.map {|path| path.final}.include?(false))
path = paths.shift
unless path.final
trips( path, dst, limits, condition, paths, dst_paths)
else
dst_paths << path
end
end
paths = (dst_paths + paths).select { |path| path.nodes.last == dst && path.final == true }
return paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route visit_path, dst=nil, limits=nil, condition=UNTIL\n paths = trips(visit_path, dst, limits, condition)\n return paths\n end",
"def get_routes(params)\n graph_data = create_data(params)\n if graph_data.is_a?(Array)\n graph_data.each do |data|\n add_vertex(data[0][0], data[0][1])\n end\n path_array = shortest_path(params[:source], params[:destination])\n if path_array.is_a?(Array)\n get_path_description(path_array, params)\n else\n path_array\n end\n else\n graph_data\n end\n end",
"def routes\n @logger.info \"#{__method__}\"\n fill_in \"JourneyPlanner$txtNumberOfPassengers\", with: \"1\"\n country_routes = list_countries.inject([]) do |country_result, country|\n @logger.info \"routes for #{country}\"\n select(country, :from => \"JourneyPlanner_ddlLeavingFromState\")\n sleep 3\n to_from = list_leaving_from.inject([]) do |from_result, from|\n @logger.info \"routes from #{from}\"\n sleep 2\n select(from, :from => \"JourneyPlanner$ddlLeavingFrom\")\n from_result << {from => list_travelling_to}\n from_result\n end\n country_result << {country => to_from}\n country_result\n end\n end",
"def get_routes from, to, options = {}\n options[:start_type] = check_point_type(from) || options[:start_type]\n options[:target_type] = check_point_type(to) || options[:target_type]\n # default options\n options = {\n :time => Time.now, \n :depth => 0, \n :include_coords => true, \n :limit => 2,\n :time_relation => :depature,\n :identify_part_prices => :none }.merge(options)\n\n options[:time] = options[:time].in_time_zone(\"Berlin\") #+ 10.minutes # Ansonsten liegt die erste Verbindung in der Vergangenheit\n page = @agent.get @@options[:url_route]\n \n result = submit_form page.forms.first, from, to, options\t\t\n routes = []\n links = result.links_with(:href => /details=opened!/).select { |l| l.to_s.size > 0} # only select connection links, no warning links\n links.reverse! if options[:time_relation] == :arrival # respect :time_relation for route processing\n \n link_threads = Array.new\n links.each_index do |idx|\n link_threads[idx] = Thread.new {\n # maybe we are too fast in requesting :-)\n (1..5).each do |i|\n page = links[idx].click \n break unless page.title.match(/Fehler/)\n # puts \"link.click error: %i\" % i\n sleep(1)\n end\n Thread.current[:route] = Route.new(page, options)\n }\n break if idx == options[:limit]\n end\n\n link_threads.each { |t| t.abort_on_exception = true}\n routes = link_threads.map { |t| t.join; t[:route] }\n\n # Keine Station gefunden also suchen wir nach der nächstbesten Adresse/Station\n if links.count == 0 && options[:depth] == 0\n if options[:start_type] == :address\n from = find_address(from, options)\n options[:start_type] = from.station_type\n from = from.name\n elsif options[:start_type] == :station\n from = find_station(from, options)\n options[:start_type] = from.station_type\n from = from.name\n end\n \n if options[:target_type] == :address\n to = find_address(to, options)\n options[:target_type] = to.station_type\n to = to.name\n elsif options[:target_type] == :station\n to = find_station(to, options)\n options[:target_type] = to.station_type\n to = to.name\n end\n \n return get_routes from, to, options.merge(:depth => options[:depth]+1)\n end\n \n raise \"no_route\" if routes.count == 0 || links.count == 0\t\t\t\n\n # attach price information for each routepart if necessary\n identify_part_prices(routes, options) unless options[:identify_part_prices] == :none\n \n return routes\n end",
"def find_routes_to(destination_object, options = {})\n if options[:via]\n unless options[:via].kind_of? Array\n options[:via] = [ options[:via] ]\n end\n end\n options[:via] ||= []\n \n counter = 0\n via_object_names = []\n via_object_declarations = options[:via].collect do |active_record_object|\n counter += 1\n via_object_names << \"obj#{counter}\"\n \"(obj#{counter} {#{active_record_object.neo_id}})\"\n end\n \n via_object_declarations_str = via_object_declarations.join(', ')\n via_object_declarations_str += \", \" if via_object_declarations_str.present?\n nodes_to_connect = [\"self\"] + via_object_names + [\"destination_object\"]\n \n # Note: Providing the :direction option if the direction is known,\n # may reduce the query time considerably.\n #\n if options[:direction] == :outgoing\n relation_str = \"-[:is_parent_of*1..100]->\"\n elsif options[:direction] == :incoming\n relation_str = \"<-[:is_parent_of*1..100]-\"\n else\n relation_str = \"-[:is_parent_of*1..100]-\"\n end\n \n find_related_nodes_via_cypher(\"\n match \n #{via_object_declarations_str}\n (destination_object {#{destination_object.neo_id}}),\n paths = (#{nodes_to_connect.join(')' + relation_str + '(')})\n return paths\n order by length(paths)\n \") || []\n end",
"def shortest_route visit_path, dst, condition=nil\n return route(visit_path, dst).first.cost\n end",
"def shortest_paths(dest)\n position = dest\n final = {}\n analisados = {}\n route = []\n route << dest\n @previous['a'] = -1\n\n @nodes.each do |n|\n analisados[n] = false\n end\n analisados[position] = true\n\n while analisados(analisados)\n adyacentes(position, analisados).each do |n|\n if @distance[n] == (@distance[position] - graph[n][position])\n @previous[position] = n\n position = n\n route << n\n end\n analisados[n] = true\n end\n\n end\n route << 'a'\n route\n end",
"def get_allpaths(source, dest, visited, path)\n # mark visited\n visited[source] = 1\n path << source\n\n if source.eql? dest\n @paths << path.dup\n else\n # recurse for all neighboring nodes\n @nnmap[source].each do |n|\n get_allpaths(n, dest, visited, path) if visited[n].eql? 0\n end\n end\n\n path.pop\n visited[source] = 0\n end",
"def compute_other_paths(routes, route)\n routes\n .reject { |r| r == route }\n .select { |r| train_type(route.train) == train_type(r.train) }\n .flat_map(&:paths)\n end",
"def route_params\n params.require(:route).permit(:from_id, :to_id, :calculation_basis, :distance, :status)\n end",
"def traverse_route_map(origin, destination, path, matches, &block)\n route_map[origin].each do |route|\n\n new_path = path ? path.dup : Path.new\n new_path << route\n\n action = yield(new_path)\n\n matches << new_path if action == :match\n\n if action == :continue || action == :match\n traverse_route_map(route.destination, destination, new_path, matches, &block)\n end\n\n end\n end",
"def calculate_route\n\t\t@cl = init_loc\n\t\t@steps << cl\n\n\t\twhile not at_rightmost_side?\n\t\t\t@cl = next_step\n\t\t\t@steps << cl\n\t\tend \t\t\n\tend",
"def route_params\n params.require(:route).permit(:origin_id, :destination_id, :distance)\n end",
"def traverse_road(next_field,vt=Set.new,solution)\n @visited_tiles = vt\n avail_pos = available_ways_to_go_to(next_field,solution).to_set - @visited_tiles\n\n @visited_tiles << next_field\n avail_pos.each do |nf|\n if ((solution[nf[0],nf[1]] == 0) && (!@visited_tiles.include? nf))\n # print_board create_solution_board @visited_tiles\n traverse_road(nf,@visited_tiles,solution)\n end\n end\n @visited_tiles\n end",
"def compute_path(source_x, source_y, destination_x, destination_y)\n build_structures(source_x, source_y)\n path([destination_x, destination_y])\n backtrace(source_x, source_y, destination_x, destination_y)\n end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def routes=(_arg0); end",
"def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end",
"def get_paths(source, target, iterate_only_if=nil, &result_filter)\n iterate_only_if = result_filter if iterate_only_if.nil?\n queue=[[0, source]]\n result=[]\n while queue.any?\n node = queue.shift\n @graph.each_adjacent(node.last) do |edge, weight|\n nnode = node.dup\n nnode[0]= node[0] + weight\n nnode << edge\n nlevel = nnode.length - 2\n if edge == target\n if result_filter.call(nnode[0], nlevel)\n result << nnode\n end\n end\n\n if iterate_only_if.call(nnode[0], nlevel)\n queue << nnode\n end\n end\n end\n result\n end",
"def router\n\n subway_router = {\n \"n\" => [\"times square\", \"34th\", \"n line 28th\", \"23rd\", \"union square\", \"8th\"],\n \"l\" => [\"8th\", \"6th\", \"union square\", \"3rd\", \"1st\"],\n \"6\" => [\"grand central\", \"33rd\", \"line 6 28th\", \"23rd\", \"union square\", \"astor place\"]\n}\n\n # inserts the line got on and off from the HTML form into a local variale\n line_got_on = params[\"line_got_on\"]\n line_get_off = params[\"line_got_off\"]\n\n # saves the stop on and off to a local variable from the form\n stop_got_on = params[\"stop_got_on\"]\n stop_get_off = params[\"stop_get_off\"]\n\n # works out the index of the lines on and off\n first_range = subway_router[line_got_on].index(stop_got_on)\n second_range = subway_router[line_got_on].index(stop_get_off)\n\n # checks the index of the line on or off\n line_on_index = subway_router[line_got_on].index(stop_got_on)\n line_off_index = subway_router[line_get_off].index(stop_get_off)\n\n # checks unions index on your current line\n union_index_on = subway_router[line_got_on].index(\"union square\")\n union_index_off = subway_router[line_get_off].index(\"union square\")\n\n\n # checks if the line you get on at is the same as line got off\n # deals with the cross over and union indexes\n if line_get_off != line_got_on\n\n # checks if the line you got on index is less than the union index\n if line_on_index < union_index_on\n\n #checks if the line you get off index is higher than the union index\n if line_off_index > union_index_off\n\n part1 = subway_router[line_got_on][line_on_index..union_index_on]\n \"----------TRANSFER------------\"\n part2 = subway_router[line_get_off][union_index_off..line_off_index]\n\n @route = part1 | part2\n\n # checks if the line you get off index is less than the union index\n elsif line_off_index < union_index_off\n\n part1 = subway_router[line_got_on][line_on_index..union_index_on]\n \"----------TRANSFER------------\"\n part2 = subway_router[line_get_off][line_off_index..union_index_off].reverse\n\n @route = part1 | part2\n\n end\n end\n\n # checks if the line on index is higher than the union index\n if line_on_index > union_index_on\n\n # checks if the line off index is greter than the union index\n if line_off_index > union_index_off\n\n part1 = subway_router[line_got_on][union_index_on..line_on_index].reverse\n \"----------TRANSFER------------\"\n part2 = subway_router[line_get_off][union_index_off..line_off_index]\n\n @route = part1 | part2\n\n # checks the line off index is less than the union index\n elsif line_off_index < union_index_off\n\n part1 = subway_router[line_got_on][union_index_on..line_on_index].reverse\n \"----------TRANSFER------------\"\n part2 = subway_router[line_get_off][line_off_index..union_index_off].reverse\n\n @route = part1 | part2\n\n end\n end\n # if line_got_on > union_index_on\n\n # For one line trips\n else\n if (first_range < second_range)\n\n \"Your route is:\"\n\n @route = subway_router[line_got_on][first_range..second_range]\n\n elsif (second_range < first_range)\n\n \"Your route is:\"\n\n @route = subway_router[line_got_on][second_range..first_range].reverse\n\n end\n end\n\nend",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def route_go_ride(from, dest)\n from = from.map{|x|x+1}\n dest = dest.map{|x|x+1}\n\n x=from[0]\n y=from[1]\n\n route = \"The route is\\n\\tstart at (#{x},#{y})\"\n\n if from[0]!=dest[0]\n if from[0]<dest[0]\n until x == dest[0]\n x = x + 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n route += \"\\n\\tturn right\" if y>dest[1]\n route += \"\\n\\tturn left\" if y<dest[1]\n\n else from[0]>dest[0]\n until x == dest[0]\n x = x - 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n route += \"\\n\\tturn left\" if y>dest[1]\n route += \"\\n\\tturn right\" if y<dest[1]\n end\n end\n\n if from[1]!=dest[1]\n if from[1]<dest[1]\n until y == dest[1]\n y = y + 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n else from[1]>dest[1]\n until y == dest[1]\n y = y - 1\n end\n route += \"\\n\\tgo to (#{x},#{y})\"\n end\n end\n\n route += \"\\n\\tfinish at (#{x},#{y})\"\n route\n\n end",
"def lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n totald = distance + dist(visited.last, vertex)\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach max distance\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, 0, max_distance)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, 0, max_distance)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && totald != \"NO SUCH ROUTE\" && totald < max_distance\n visited << vertex\n path = visited\n distance = totald\n\n if vertex == finish\n paths << path\n print \"\\n*** Path: #{path}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3)\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def build_route_list\n @csr = []\n csr = []\n tempcsr = []\n calllist = Calllist.all\n calllist.each do |c|\n if c.csr && !tempcsr.include?(c.csr)\n tempcsr.push(c.csr)\n end\n end\n\n csr = tempcsr.sort\n if !session[:called_csr] || session[:called_csr == '']\n # not returning from update of called flag\n session[:called_csr] = csr[0]\n end\n\n i = 1\n @selected_csr = 0\n csr.each do |c|\n select_item = []\n select_item.push(c)\n select_item.push(i)\n @csr.push(select_item)\n if c == session[:called_csr]\n @selected_csr = i\n end\n i += 1\n end\n session[:calllist_csrs] = @csr\n\n @route = []\n route = []\n temproute = []\n routes = Shipto.all\n calllist = Calllist.all\n route_array = []\n shipto_array = []\n routes.each do |r|\n route_array.push(r.route_code)\n shipto_array.push(r.shipto_code)\n end\n\n # Set up the call list for the first route or the returning route\n @route_calllists = []\n\n if !session[:called_route] || session[:called_route == '']\n # the route has not been set so default to the first route I know is valid (this is bad code)\n session[:called_route] = 'AM'\n end\n\n calllist.each do |c|\n if c.csr\n i = shipto_array.index(c.shipto)\n if i && route_array[i] && !temproute.include?(route_array[i])\n # found a match on shipto so store the accompanying route\n temproute.push(route_array[i])\n end\n if c.shipto && i && route_array[i] == session[:called_route] && c.csr == session[:called_csr]\n # include call list records that are a direct match for route via shipto\n @route_calllists.push(c)\n end\n end\n end\n route = temproute.sort\n i = 1\n @selected_route = 0\n route.each do |c|\n select_item = []\n select_item.push(c)\n select_item.push(i)\n @route.push(select_item)\n if c == session[:called_route]\n @selected_route = i\n end\n i += 1\n end\n session[:calllist_routes] = @route\n end",
"def trips_dfs(start, finish, stops, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n s = visited.size # stops, including added vertex\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles if we hit finish vertex too early\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach stops\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, stops, 0)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, stops, 0)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && dist(visited.last, vertex) != \"NO SUCH ROUTE\" && s <= stops\n visited << vertex\n path = visited\n\n if vertex == finish && s == stops\n paths << path\n print \"\\n*** Path: #{path}, Stops: #{s}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n trips_dfs(start, finish, stops, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3) && stops <= 1\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def route_params\n params.require(:route).permit(:city_start_id, :station_start_id, :date_start, :city_end_id, :station_end_id, :date_end, :carrier_id, :cost, :currency)\n end",
"def route_params\n params.require(:route).permit(:user_id, :car_id, :title, :description, :from_lat, :from_lng, :to_lat, :to_lng, :waypoints, :departure, :cost, :users_in_route, :active, :spaces_available, :ratings, :userRating, :comments)\n end",
"def shortest_paths(source, dest)\n @graph_paths=[]\n @source = source\n dijkstra source\n @path=[]\n find_path dest\n actual_distance=if @distance[dest] != INFINITY\n @distance[dest]\n else\n \"no path\"\n end\n \"Shortest route and distance : #{@path.join(\"-->\")}, #{actual_distance} km\"\n end",
"def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end",
"def plan(s1, s2)\r\n if s1 == s2\r\n return []\r\n end\r\n\r\n condensed_path = Array.new\r\n full_path = Array.new\r\n temp = BFS.new(graph, find_node(s1)).shortest_path_to(find_node(s2))\r\n\r\n temp.each {|x| full_path.push(x.to_s)}\r\n condensed_path.push(full_path.first)\r\n condensed_path = condensed_path + transfer_stations(full_path)\r\n \r\n if condensed_path.last != full_path.last #need to test this more\r\n condensed_path << full_path.last\r\n end\r\n\r\n return condensed_path\r\n end",
"def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end",
"def route_params\n params.require(:route).permit(:origin, :destination, :driving_distance, :driving_time)\n end",
"def routes_for(grid_size)\n choices = grid_size * 2\n \n factorial(choices) / (factorial(grid_size) * factorial(choices - grid_size))\nend",
"def travel_cost( dest )\n sp = shortest_path( dest )\n path_cost( sp )\n end",
"def compute_stops(route)\n route.visited_stops\n end",
"def routing(rule_name, info)\n\n # Get to the advanced page.\n self.goto_advanced(rule_name, info)\n \n # Get to the \"Routing\" page.\n begin\n @ff.link(:text, 'Routing').click\n self.msg(rule_name, :info, 'routing', 'Reached page \\'Routing\\'.')\n rescue\n self.msg(rule_name, :error, 'routing', 'Did not reach \\'Routing\\' page')\n return\n end\n \n # Check the key.\n if ( info.has_key?('section') and info.has_key?('subsection') ) then\n # Right,go on.\n else\n self.msg(rule_name,:error,'routing','Some key NOT found.')\n return\n end\n \n if info.has_key?('Operation') then\n \n\tcase info['Operation']\n\t\n \t##############################\t\n \t# \"New Route\"\n \t##############################\t\n \twhen 'New route'\n\t begin\n\t\t@ff.link(:text,'New Route').click\n\t\tself.msg(rule_name,:info,'Operation','Reached page of \\'Operation\\' route.')\n\t rescue\n\tputs \"baby\"\n\t\tself.msg(rule_name,:error,'Operation','Can not \\'Operation\\' route page.')\t\n\t\treturn\n\t end\n\t \n\t if @ff.text.include?'Route Settings' then\n\t\t# Right,go on;\n\t else\n\t\tself.msg(rule_name,:error,'Route Setting','Does NOT Enter Route Setting page.')\n\t\treturn\n\t end\n\t # Select name for route;\n\t if info.has_key?('Name')\n\t\t\n\t\tcase info['Name']\n\t\t\n\t\t when 'Broadband Connection (Ethernet)'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"Broadband Connection (Ethernet)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\n\t\t when 'Broadband Connection (Coax)'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"Broadband Connection (Coax)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\n\t\t when 'WAN PPPoE'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"WAN PPPoE)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\t\n\t\t when 'WAN PPPoE 2'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"WAN PPPoE 2\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\n\t\t when 'Network (Home/Office)'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"Network (Home/Office)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\t\t else \n\t\t\t\n\t\t\t# Wrong\n\t\t\tself.msg(rule_name,:error,'Name','Can NOT configure \\'Name\\'.')\n\t\t\treturn\n\t\t \n\t\t end # End of case\n end # End of 'Name'\n\t if info.has_key?('Destination') and info['Destination'].size > 0\n\t\t\n\t\toctets=info['Destination'].split('.')\n\t\t@ff.text_field(:name,'dest0').value=(octets[0])\n\t\t@ff.text_field(:name,'dest1').value=(octets[1])\n\t\t@ff.text_field(:name,'dest2').value=(octets[2])\n\t\t@ff.text_field(:name,'dest3').value=(octets[3])\n\t\tself.msg(rule_name,:info,'Doset_destination',\"Destination = \"+info['Destination'])\n\n\t end\n\t if info.has_key?('Netmask') and info['Netmask'].size > 0\n\t\t\n\t\toctets=info['Netmask'].split('.')\n\t\t@ff.text_field(:name,'netmask0').value=(octets[0])\n\t\t@ff.text_field(:name,'netmask1').value=(octets[1])\n\t\t@ff.text_field(:name,'netmask2').value=(octets[2])\n\t\t@ff.text_field(:name,'netmask3').value=(octets[3])\n\t\tself.msg(rule_name,:info,'Doset_Netmask',\"Netmask = \"+info['Netmask'])\n\n\t end\n\t if info.has_key?('Gateway') and info['Gateway'].size > 0\n\t\t\n\t\toctets=info['Gateway'].split('.')\n\t\t@ff.text_field(:name,'gateway0').value=(octets[0])\n\t\t@ff.text_field(:name,'gateway1').value=(octets[1])\n\t\t@ff.text_field(:name,'gateway2').value=(octets[2])\n\t\t@ff.text_field(:name,'gateway3').value=(octets[3])\n\t\tself.msg(rule_name,:info,'Doset_gateway',\"Gateway = \"+info['Gateway'])\n\n\t end\n\t if info.has_key?('Metric') then\n\t\t\n\t\t@ff.text_field(:name,'metric').value=info['Metric']\n\t\tself.msg(rule_name,:info,'Set metric','Metric value is \\'Metric\\'.')\n\t else\n\t\tself.msg(rule_name,:error,'Set metric','Can Not set metric value to \\'Metric\\'.')\n\t\treturn\n\t end\n\t \n\t # Apply to save new route;\t\t\n\t @ff.link(:text,'Apply').click\n\t self.msg(rule_name,:info,'Apply','\\'Apply\\' to save new route.')\n\n\t if @ff.text.include?'Input Errors'\n\t\t\n\t\t# Find table\n\t\tsTable = false\n\t\t@ff.tables.each do |t|\n\t\t \n\t\t if ( t.text.include? ':' and\n\t\t\t(not t.text.include? 'Input Errors') and \n\t\t\t(not t.text.include? 'Cancel') and\n\t\t\tt.row_count >= 1 ) then\n\t\t\t\tsTable = t\n\t\t\tbreak\n\t\t end\n\t\tend\n\t\t# Wrong here\n\t if sTable == false\n\t\t self.msg(rule_name,:error,'New route','Did NOT find the target table.')\n\t\t return\n\t\tend\n\t\t\n\t\tsTable.each do |row|\n\t\t\t\n\t\t if row[1] == \"\" or row[2] == nil\n\t\t next\n\t\t end\n\t\n\t\t self.msg(rule_name,:error,row[1],row[2])\n\t\tend\n\n\t\t# Cancel\n\t\t@ff.link(:text,'Cancel').click\n\t\treturn\n\t \n\t end # end of 'Input Error'\t\t\t\n\t##############################\t\n \t# \"Multi Route\"\n \t##############################\t\n \twhen 'Multi route'\n\t \n\t if info.has_key?('Max route') then\n\t\tself.msg(rule_name,:info,'Multi route','Go on adding multi-route and Max route is : \\'Max route\\'.')\n\t end\n\t count=1\t\n\t \n\t if info.has_key?('Destination') and info['Destination'].size > 0\n\t\toctets=info['Destination'].split('.')\n\n\t\toctets2=(octets[2]).to_i\n\t\t#puts \"#{octets2}\"\n\t\toctets3=(octets[3]).to_i\n\t\t#puts \"#{octets3}\"\n\t\tself.msg(rule_name,:info,'Get address of destination',\"Destination = \"+info['Destination'])\n\t end\n\t \n\t while count <= info['Max route'].to_i \n\t #for i in octets3.to_i..info['Max route'].to_i\n\t\tbegin\n\t\t @ff.link(:text,'New Route').click\n\t\t self.msg(rule_name,:info,'Operation','Reached page of \\'Operation\\' route.')\n\t\trescue\n\t\t self.msg(rule_name,:error,'Operation','Can not \\'Operation\\' route page.')\t\n\t\t return\n\t\tend\n\t \n\t\tif @ff.text.include?'Route Settings' then\n\t\t # Right,go on;\n\t\telse\n\t\t self.msg(rule_name,:error,'Route Setting','Does NOT Enter Route Setting page.')\n\t\t return\n\t\tend\n\t\t# Select name for route;\n\t\tif info.has_key?('Name')\n\t\t\n\t\t case info['Name']\n\t\t\n\t\t when 'Broadband Connection (Ethernet)'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"Broadband Connection (Ethernet)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\n\t\t when 'Broadband Connection (Coax)'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"Broadband Connection (Coax)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\n\t\t when 'WAN PPPoE'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"WAN PPPoE)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\t\n\t\t when 'WAN PPPoE 2'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"WAN PPPoE 2\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\n\t\t when 'Network (Home/Office)'\n\n\t\t\t# Set name to 'Broadband Connection (Ethernet)'\n\t\t\t@ff.select_list(:name,'combo_device').select(\"Network (Home/Office)\")\t\n\t\t\tself.msg(rule_name,:info,'Name',info['Name'])\n\t\t else \n\t\t\t\n\t\t\t# Wrong\n\t\t\tself.msg(rule_name,:error,'Name','Can NOT configure \\'Name\\'.')\n\t\t\treturn\n\t\t \n\t\t end # End of case\n\t\tend # End of 'Name'\n\t\tif info.has_key?('Destination') and info['Destination'].size > 0\n\t\t\n\t\t octets=info['Destination'].split('.')\n\n\t\t @ff.text_field(:name,'dest0').value=(octets[0])\n\t\t @ff.text_field(:name,'dest1').value=(octets[1])\n\t\t @ff.text_field(:name,'dest2').value=octets2.to_i\n\t\t @ff.text_field(:name,'dest3').value=octets3.to_i\n\t\t self.msg(rule_name,:info,'Doset_destination',\"Destination = \"+info['Destination'])\n\n\t\tend\n\t\tif info.has_key?('Netmask') and info['Netmask'].size > 0\n\t\t\n\t\t octets=info['Netmask'].split('.')\n\t\t @ff.text_field(:name,'netmask0').value=(octets[0])\n\t\t @ff.text_field(:name,'netmask1').value=(octets[1])\n\t\t @ff.text_field(:name,'netmask2').value=(octets[2])\n\t\t @ff.text_field(:name,'netmask3').value=(octets[3])\n\t\t self.msg(rule_name,:info,'Doset_Netmask',\"Netmask = \"+info['Netmask'])\n\n\t\tend\n\t\tif info.has_key?('Gateway') and info['Gateway'].size > 0\n\t\t\n\t\t octets=info['Gateway'].split('.')\n\t\t @ff.text_field(:name,'gateway0').value=(octets[0])\n\t\t @ff.text_field(:name,'gateway1').value=(octets[1])\n\t\t @ff.text_field(:name,'gateway2').value=(octets[2])\n\t\t @ff.text_field(:name,'gateway3').value=(octets[3])\n\t\t self.msg(rule_name,:info,'Doset_gateway',\"Gateway = \"+info['Gateway'])\n\n\t\tend\n\t\tif info.has_key?('Metric') then\n\t\t\n\t\t @ff.text_field(:name,'metric').value=info['Metric']\n\t\t self.msg(rule_name,:info,'Set metric','Metric value is \\'Metric\\'.')\n\t\telse\n\t\t self.msg(rule_name,:error,'Set metric','Can Not set metric value to \\'Metric\\'.')\n\t\t return\n\t\tend # End of if\n\n\t\t# Apply to save new route;\t\t\n\t\t@ff.link(:text,'Apply').click\n\t\tself.msg(rule_name,:info,'Apply','\\'Apply\\' to save new route.')\n\n\t\tif @ff.text.include?'Input Errors'\n\t\t\n\t\t # Find table\n\t\t sTable = false\n\t\t @ff.tables.each do |t|\n\t\t \n\t\t\t if ( t.text.include? ':' and\n\t\t\t (not t.text.include? 'Input Errors') and \n\t\t\t (not t.text.include? 'Cancel') and\n\t\t\t t.row_count >= 1 ) then\n\t\t\t\t sTable = t\n\t\t\t break\n\t\t\t end\n\t\t end\n\t\t # Wrong here\n\t\t if sTable == false\n\t\t\tself.msg(rule_name,:error,'New route','Did NOT find the target table.')\n\t\t\treturn\n\t\t end\n\t\t\n\t\t sTable.each do |row|\n\t\t\t\n\t\t\tif row[1] == \"\" or row[2] == nil\n\t\t\tnext\n\t\t\tend\n\t\n\t\t\tself.msg(rule_name,:error,row[1],row[2])\n\t\t end\n\n\t\t # Cancel\n\t\t @ff.link(:text,'Cancel').click\n\t\t return\n\t \n\t\tend # end of 'Input Error'\n\t\t\n\t\tcount = count + 1\n\t\tputs \"Adding the No.#{count} route.\"\n\t\toctets3 = octets3 + 1\n\t\t#puts octets3\n\t\t# re-setup ipaddress when the ipaddress over 254;\n\t\tif octets3 == 255 then\n\t\t octets3 = 1\n\t\t octets2 = octets2 + 1\n\t\tend\n\t end # End of while\n\n \t##############################\t\n \t# \"del Route\"\n \t##############################\n \twhen 'del route'\n\t\t\n\t if @ff.text.include?'Routing Table'\n\t\t\n\t\t# Find route table\n\t\tsTable = false\n\t\t@ff.tables.each do |t|\n\t\t if ( t.text.include? 'Routing Table' and \n\t\t\t(not t.text.include? 'Routing Protocols') and \n\t\t\t(not t.text.include? 'IGMP') and\n\t\t\t(not t.text.include? 'Domain Routing') and \n\t\t\tt.row_count >= 2 ) then\n\t\t\t\tsTable = t\n\t\t\tbreak\n\t\t end\n\t\tend\n\t\t\n\t\t# Wrong here\n\t\tif sTable == false\n\t\t\t\n\t\t\tself.msg(rule_name,:error,'Del route','Can NOT find right route table.')\n\t\t\treturn\n\t\tend\n\n\t\tnum = 0\n\t\tsTable.each do |row|\n\t\t if row[7] != nil then\n\t\t\t# row[7].links.each do |l|\n\t\t\t# puts l.name\n\t\t\t# end\n\t\t\tif row[7].link(:name,'route_remove').exist?\n\t\t\t #puts \"haha\"\n\t\t\t #puts @ff.text_field(:name,row[7]).to_s\n\t\t\t @ff.link(:href,row[7].link(:name,'route_remove').href).click\n\t\t\tend\n\t\t end\t\n\t\t\t\t# Output the result\n\t\t\t\t#self.msg(rule_name,:info,'Name' + num.to_s,row[1])\n\t\t\t\t#self.msg(rule_name,:info,'Destination' + num.to_s,row[2])\n\t\t\t\t#self.msg(rule_name,:info,'Gateway' + num.to_s,row[3])\n\t\t\t\t#self.msg(rule_name,:info,'Netmask' + num.to_s,row[4])\n\t\t\t\t#self.msg(rule_name,:info,'Metric' + num.to_s,row[5])\n\t\t\t\t#self.msg(rule_name,:info,'Status' + num.to_s,row[5])\n\t\t\t\t#num = num + 1\n\t\tend # End of table;\n\n end # End of 'Del route'\n\n\t\t# pasre the table of route\n\t\t# delete these\n\t\tself.msg(rule_name,:info,'Del route','Delete the list is successful. ')\n\telse\n \t# Wrong here.\n \tself.msg(rule_name,:error,'routing','No \\'New Route\\' key.')\n \treturn\n \tend # End of Case\n\n end # End of 'Operation'\n \n #-------------------------------------------#\n # \"Internet Group Management Protocol(IGMP)\"\n #-------------------------------------------#\n if info.has_key?('Internet Group Management Protocol(IGMP)') then\n\t# \"Internet Group Management Protocol(IGMP)\"\n \tcase info['Internet Group Management Protocol(IGMP)']\n \t \n\t when 'on'\n \t# Select mcast_enabled\n \t@ff.checkbox(:name,'mcast_enabled').set\n \tself.msg(rule_name,:info,'Internet Group Management Protocol(IGMP)','on')\n \t when 'off'\n \t# Don't select it.\n \t@ff.checkbox(:name,'mcast_enabled').clear\n \tself.msg(rule_name,:info,'Internet Group Management Protocol(IGMP)','off')\n else\n \t# Wrong here.\n \tself.msg(rule_name,:error,'routing','No \\'Internet Group Management Protocol(IGMP)\\' key.')\n \treturn\n \tend\n\n end # End of 'IGMP'\n\n #-------------------------------------------#\n # \"Domain Routing\"\n #-------------------------------------------#\n if info.has_key?('Domain Routing') then\n \t\n\t# \"Internet Group Management Protocol(IGMP)\"\n \tcase info['Domain Routing']\n \n\t when 'on'\n \t# Select it\n \t@ff.checkbox(:name,'dns_routing_enabled').set\n \tself.msg(rule_name,:info,'Domain Routing','on')\n when 'off'\n \t# Don't select it.\n \t@ff.checkbox(:name,'dns_routing_enabled').clear\n \tself.msg(rule_name,:info,'Domain Routing','off')\n \t else\n \t# Wrong here.\n \tself.msg(rule_name,:error,'routing','No \\'Domain Routing\\' key.')\n \treturn\n \t end\n\n end # End of 'Domain Routing'\n \n # Apply for the change\n @ff.link(:text,'Apply').click\n \n # Jump out an \"attention\" message?\n if @ff.text.include? 'Attention'\n \t@ff.link(:text,'Apply').click\n end\n \n # routing success\n self.msg(rule_name,:info,'Routing','SUCCESS')\n\n \n end",
"def path_from_src_to_dest(graph, src=0, dest=0)\n\t\t# Update source and destination\n\t\t@source, @destination = src, dest\n\n\t\t# Check if source is undefined, if so return empty path\n\t\tif @source == 0\n\t\t\treturn []\n\t\tend\n\n\t\t# Generate a connections hash based on graph edges\n\t\toutgoing = Hash.new()\n\t\tnodes = graph.nodes.keys\n\t\tresult = Array.new()\n\n\t\tgraph.nodes.keys.each {|key| outgoing[key] = Hash.new() }\n\t\tgraph.edges.values.each do |edge|\n\t\t\t# Is it possible for any two issues to have multiple links\n\t\t\t# between them?\n\t\t\toutgoing[edge.a.id][edge.b.id] = edge\t\t\n\t\tend\n\n\t\t# If an edge already exists in the graph from source to destination\n\t\tif outgoing[@source].has_key?(@destination)\n\t\t\tresult.push(outgoing[@source][@destination].id)\n\t\t\treturn result\n\t\tend\n\t\t\t\n\t\t# Compute all paths from source\n\t\tpaths_tracer, paths_distances, relationships_on_paths = compute_paths_from_source(outgoing, nodes)\n\t\t\n\t\t# Find the shortest path through the graph between source and destination\n\t\tif destination != 0\n\t\t\treturn trace_path_src_to_dest(outgoing, paths_tracer)\n\t\tend\n\n\t\t# This happens only if the destination is 0, as it would have returned otherwise.\n\t\t# Return available relationships, distances, \n\t\treturn important_relationships_from_source(paths_tracer, paths_distances, relationships_on_paths)\n\tend",
"def add_path(destination, knights_action, knights_path)\n visited_destinations << destination\n knights_path << { position: destination, source: knights_action }\n end",
"def traverse (from, to, points_visited_so_far = [])\n \n return points_visited_so_far if from.eql?(to)\n\n # Select those adjacent points that that has not been already traversed\n # and that do not represent walls\n possible_steps = adjacent_traversible_points(from).select { |point| \n (not points_visited_so_far.include?(point))\n }\n\n # For each possible step, take that step, and find out the list of points\n # that need to be traversed to reach \"to\" point. In case there were more\n # than one possible steps, pick the one that has smaller number of steps\n # to destination\n points_to_destination_from_here = []\n possible_steps.each do |point|\n traversal_result = traverse(point, to, points_visited_so_far + [point])\n if not traversal_result.empty?\n points_to_destination_from_here = traversal_result if \n (points_to_destination_from_here.empty? or\n traversal_result.size < points_to_destination_from_here.size)\n end\n end\n \n return points_to_destination_from_here\n\n end",
"def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end",
"def route_params\n params.require(:route).permit(:from, :to)\n end",
"def optimize_for_location(params)\n flight_floor = params[:flight_floor] || 5000 #meters\n flight_ceiling = params[:flight_ceiling] || 60000 #meters\n\n #verify parameters\n params = params.with_indifferent_access\n\n raise 'No start altitude (params[:start][:altitude])' unless params[:start][:altitude].present?\n raise 'No start latitude (params[:start][:lat])' unless params[:start][:lat].present?\n raise 'No start longitude (params[:start][:lon])' unless params[:start][:lon].present?\n raise 'No start time (params[:start][:time])' unless params[:start][:time].present?\n\n raise 'No finish latitude (params[:finish][:lat])' unless params[:finish][:lat].present?\n raise 'No finish longitude (params[:finish][:lon])' unless params[:finish][:lon].present?\n\n # creates a filter lambda to check that any path passes certain conditions\n filter = lambda {|node, previous|\n node.altitude < flight_ceiling &&\n node.altitude > flight_floor &&\n # (!x || y) checks y only if x is true\n (!params[:use_faa] || node.faa_zones_approx(previous)) && #no restricted zones\n (!params[:check_countries] || node.countries(previous))\n }\n\n #run the search with the provided start, duration, and performance factor\n greedy_search({\n start: Node.from_pos(\n params[:start][:lat].to_f, params[:start][:lon].to_f,\n params[:start][:altitude].to_f, params[:start][:time]\n ),\n finish: Node.from_pos(\n params[:finish][:lat].to_f, params[:finish][:lon].to_f,\n params[:start][:altitude].to_f, params[:start][:time]\n ),\n movement_cost: lambda {|current|\n #vent / ballast costs are proportional to the square of the altitude change\n (current.parent.altitude - current.altitude).abs/1200000.0\n },\n heuristic: lambda {|current|\n ((current.parent.lon - current.lon) / Prediction::time_variance)\n },\n neighbors: lambda {|current|\n current.neighbors(filter)\n },\n build_from_finish: lambda{|finish|\n finish.build_chain\n },\n timeout: params[:timeout],\n performance: params[:performance]\n })\n\n end",
"def routes(&block); end",
"def routes(&block); end",
"def route_sets; end",
"def process_routes src\n RoutesProcessor.new(@tracker).process_routes src\n end",
"def gen_route(dep_map)\n text = \"// Dependency Route: #{dep_map[\"class_indexed_name\"]} -> #{dep_map[\"dclass_indexed_name\"]}\\n\"\n temp = 0\n eta = 100\n if(dep_map[\"strength\"].nil?)\n dep_map[\"strength\"] = DEFAULT_SHIPS\n end\n while(temp < dep_map[\"strength\"])\n text += \"var #{dep_map[\"indexed_name\"]}_#{temp} = new Ship({\n name: \\\"#{dep_map[\"indexed_name\"]}_#{temp}\\\",\n material: new THREE.SpriteMaterial({map: trade_texture, color: 0xffffff, fog: true}),\n origin: #{dep_map[\"class_indexed_name\"]}.mesh,\n target: #{dep_map[\"dclass_indexed_name\"]},\n offset: #{eta*temp/dep_map[\"strength\"]},\n eta: #{eta},\n loop: true});\n#{dep_map[\"class_indexed_name\"]}.trade[#{dep_map[\"class_indexed_name\"]}.trade.length] = #{dep_map[\"indexed_name\"]}_#{temp};\n#{dep_map[\"indexed_name\"]}_#{temp}.spr.scale.set(2,2,1);\\n\\n\"\n temp += 1\n end\n return text\nend",
"def find_routes_for_from_and_to(from_city,to_city)\n\n # Finding all the line color routes where a souce city belongs\n line_route_ids = CityRoute.where(city_id: from_city).distinct.pluck(:line_color_route_id)\n \n @line_id = [] #For holding the line color route id after filtering\n \n line_route_ids.each do |a|\n\n if LineColorRoute.find_by(id: a).is_active\n\n # checking whether destination exits on that particular line route or not\n var_to = LineColorRoute.find(a).city_routes.where(city_id: to_city)\n if var_to.present? \n var_from = LineColorRoute.find(a).city_routes.where(city_id: from_city)\n\n\n #checking the allowed direction of travel and saving the valid result in @line_id\n if (var_to.last.id - var_from.first.id) > 0\n # p \"------There is a route(#{LineColorRoute.find(a).name})--------------\"\n @line_id << a\n end \n else\n # p \"-------error----------\"\n end\n\n end\n\n end\n end",
"def all_paths_source_target(graph)\n current_path = []\n results = []\n\n dfs(graph, results, 0, current_path)\n return results\nend",
"def routes_map; end",
"def find(source, destination)\n @source_station = @network.find_station_by_name(source)\n @destination_station = @network.find_station_by_name(destination)\n return {} unless @source_station && @network.find_station_by_name(destination)\n\n prepare\n visit(@source_station)\n @routes\n end",
"def show_direct_route options={}\n map unless is_mapped?\n start_cell= options[:start_cell] || random_cell\n end_cell= options[:end_cell] || random_cell\n unhighlight_all\n\n start_stack = [current_cell = start_cell]\n distance=current_cell.distance\n until distance==0 do\n temp=current_cell.neighbors.select {|dir, cell|\n next unless current_cell.passable? dir\n cell.distance == distance-1\n }[0][1]\n distance-=1\n current_cell=temp\n start_stack<< current_cell\n end\n\n end_stack = [current_cell = end_cell]\n distance=current_cell.distance\n until distance==0 do\n current_cell=current_cell.neighbors.select {|dir, cell|\n next unless current_cell.passable? dir\n cell.distance == distance-1\n }[0][1]\n distance-=1\n end_stack<< current_cell\n end\n \n path = start_stack.reverse + end_stack\n common = (start_stack & end_stack).sort_by {|cell| cell.distance }\n path = path - common[0...-1]\n\n path.each {|cell| cell.set_highlight }\n display options\n end",
"def path_number visit_path, dst, limits, condition=EG\n paths = route(visit_path, dst, limits, condition)\n select_condition = condition == EG ? EG : condition == UNTIL ? LESS : UNTIL\n return (paths.select {|path| eval final_eval( select_condition, limits )}).length\n end",
"def draw_route\n # Delete all sprites in drawing of path\n @arrow_path.each{|a| a.dispose}\n @arrow_path = []\n \n return if @passed_positions.empty?\n start_pos = [@unit.x, @unit.y]\n new_pos = start_pos\n type = \"\"\n # Get direction from unit to first tile in path\n last_dir = case [@passed_positions[0].x - @unit.x, @passed_positions[0].y - @unit.y]\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n # Loop through path positions, evaluating two elements at a time\n for i in 0...@passed_positions.size\n p1 = @passed_positions[i]\n p1 = [p1.x, p1.y]\n p2 = (@passed_positions[i+1] == nil ? 0 : @passed_positions[i+1])\n if p2.is_a?(MoveTile)\n p2 = [p2.x, p2.y] \n # Figure out the direction taken to get from p1 to p2\n dir = [p2[0] - p1[0], p2[1] - p1[1]]\n dir = case dir\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n else\n dir = 0\n end\n # Evaluate the last direction taken to get to current spot\n case last_dir\n when 2\n new_pos[1] += 1\n type = case dir\n when 0 then \"d\"\n when 2 then \"v\"\n when 4 then \"ru\"\n when 6 then \"lu\"\n end\n when 4\n new_pos[0] -= 1\n type = case dir\n when 0 then \"l\"\n when 2 then \"ld\"\n when 4 then \"h\"\n when 8 then \"lu\"\n end\n when 6\n new_pos[0] += 1\n type = case dir\n when 0 then \"r\"\n when 2 then \"rd\"\n when 6 then \"h\"\n when 8 then \"ru\"\n end\n when 8\n new_pos[1] -= 1\n type = case dir\n when 0 then \"u\"\n when 4 then \"rd\"\n when 6 then \"ld\"\n when 8 then \"v\"\n end\n end\n last_dir = dir\n @arrow_path.push(Arrow_Sprite.new($spriteset.viewport1, type, new_pos))\n end\n end",
"def route_params\n params[:route].permit(:start, :end)\n end",
"def path(name, *args)\n params = args.last.is_a?(Hash) ? args.pop : {}\n candidates = @routes.select { |route| route.name == name }\n fail InvalidRouteException if candidates.empty?\n i = 0\n route = candidates.sort_by! { |candidate|\n # Tries to find the route that matches more, but with fewer names, in stable order\n [(params.keys.map(&:to_s) - candidate.matcher.names).length, candidate.matcher.names.size, i += 1] }.shift\n matcher = route.matcher\n params_for_expand = params.dup\n if !args.empty? && matcher.mustermann?\n matcher.names.each_with_index do |matcher_name, index|\n params_for_expand[matcher_name.to_sym] ||= args[index]\n end\n end\n matcher.mustermann? ? matcher.expand(params_for_expand) : route.path_for_generation\n end",
"def trip_with_maximum_stops(from_city,to_city,max_stops,has_exact=false,max_distance=0)\n max_stops = max_stops.to_i + 1\n max_distance = max_distance.to_i\n # store the intermediate cities in Queue\n intermedite_cities = Queue.new\n\n # Store the start city\n intermedite_cities.push [from_city,from_city]\n\n all_possible_routes = []\n\n #Find routes\n until intermedite_cities.empty?\n #pop up the first element in queue\n city = intermedite_cities.pop\n if max_distance> 0\n has_maximum_or_equal_stops = parse_and_find_distance(city.last).to_i < max_distance\n else\n has_maximum_or_equal_stops = has_exact ? (city.last.split('-').size ==max_stops) : (city.last.split('-').size <=max_stops)\n end\n\n # Add the reached route in array\n if city.first == to_city && has_maximum_or_equal_stops && city.last.split('-').size > 1\n all_possible_routes << city.last\n next\n end\n\n #store adjucent cities in queue\n old_distance = city.last\n\n if max_distance > 0\n condition = \"parse_and_find_distance(old_distance+'-'+adjust_city.first).to_i < max_distance\"\n else\n condition = \"(max_stops >= (old_distance+'-'+adjust_city.first).split('-').size)\"\n end\n\n for adjust_city in adjucent_cities(city.first)\n if eval(condition)\n intermedite_cities.push [adjust_city.first,old_distance+'-'+adjust_city.first]\n end\n end\n \n end\n all_possible_routes\n\n end",
"def enum_moves\n @scratch = dup_maze(@maze)\n @locs.each_with_index do |loc, robot|\n @cost = 1\n leading_edge = [loc]\n loop do\n next_edge = []\n leading_edge.each do |x, y|\n next_edge.concat search_from(x, y, robot)\n end\n break if next_edge.empty?\n leading_edge = next_edge\n @cost += 1\n end\n end\n\n @moves\n end",
"def optimal_town(routes, current)\n\t\troutes = remove_visited(routes, current)\n\n\t\tif routes.length == 0 then \n\t\t\tputs \"Stuck at: #{current.name}\" \n\t\t\tputs \"Can't get to: #{Place.find_by_id(@to_visit_ids[0]).name}\"\n\t\tend\n\n\t\toptimal = routes[0]\n\t\tlow_method = optimal_method(routes[0])\n\t\tlow_time = method_time(low_method, routes[0])\n\t\tother = routes[0].other_town(current.id)\n\n\n\t\troutes.each do |r|\n\t\t\tr_low_method = optimal_method(r)\n\t\t\tr_low_time = method_time(r_low_method, r)\n\n\t\t\tif r_low_time < low_time then \n\t\t\t\tlow_time = r_low_time\n\t\t\t\tlow_method = optimal_method(r)\n\n\t\t\t\tother = r.other_town(current.id)\n\t\t\t\tif not @visited_ids.include?(other.id) then\n\t\t\t\t \tif @to_visit_ids.include?(other.id) then \n\t\t\t\t \t\toptimal = r \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tif @to_visit_ids.include?(other.id) then\n\t\t\t[optimal.other_town(current.id), optimal, low_method]\n\t\telse \n\t\t\tputs \"Journey broken\"\n\t\t\tnil\n\t\tend\n\tend",
"def route_search_params\n params.require(:route_search).permit(:Source, :Destination)\n end",
"def all_paths(source, target, graph)\n\n def search(source, target, graph, all_paths)\n return all_paths[source] if all_paths.key?(source)\n return [[target]] if source == target\n source_paths = []\n graph.each_adjacent(source) { |v| source_paths += search(v, target, graph, all_paths) }\n all_paths[source] = source_paths.map { |path| [source] + path }\n end\n\n search(source, target, graph, {})\n end",
"def find_by_route\n @result = Array.new\n @distancias = Array.new\n\n @ride = Ride.order('id')\n if params[:radio] != '0'\n @ride.each do |p|\n distancia1 =Geocoder::Calculations.distance_between([params[:destLatitud],params[:destLongitud]], [p.destPointLat,p.destPointLong])\n distancia2 =Geocoder::Calculations.distance_between([params[:startLatitud],params[:startLongitud]], [p.startPointLat,p.startPointLong])\n if distancia1 <params[:radio].to_f && distancia2 <params[:radio].to_f\n @result.push(p)\n #@distancias.push(distancia1)\n end\n end\n # json_response={\n # result: @result,\n # distancias: @distancias\n # } \n respond_with @result , location: nil\n end\n if params[:radio] == '0'\n respond_with @ride,location: nil\n end \n #Ride.find_by_destPointLat_and_destPointLong(params[:latitud],params[:longitud])\n \n end",
"def get_path(start, finish) \n @retreat_algorithm.set_graph(memory.construct_grid) \n @retreat_algorithm.run(start, finish)\n end",
"def get_outgoing_routes(city)\n\n route_dict = {}\n\n # edges_dict will be a Hash of destinations (keys) and route data (values)\n edges_dict = @query.json_graph_api.get_outgoing_edges(city)\n edges_dict.each { |dest, data| route_dict.store(get_city_info(dest,\"name\"), data[\"distance\"]) }\n\n return route_dict\n\n end",
"def route_params\n params.require(:route).permit(:driver_id, :province_from, :city_from, :province_to, :city_to)\n end",
"def find_optimal_route(origin:, destination:, arrival_deadline:)\n params = { origin: origin, destination: destination, deadline: arrival_deadline }\n to_transit_path(client.get(API_PATH, params))\n end",
"def restructure_path(visited_nodes, target_nodes) \n candidate_nodes = target_nodes.map do |target_node|\n following_node = visited_nodes[visited_nodes.index(target_node) + 1]\n \n unvisited_neighbours_of(following_node, visited_nodes).map { |neighbour|\n [ [target_node, neighbour], unvisited_neighbours_of(neighbour, visited_nodes).length ]\n }\n end.flatten(1)\n \n if candidate_nodes.length > 0 \n maximal_unvisited_count = candidate_nodes.map(&:last).max\n \n pivot_node, additional_node = candidate_nodes.rassoc(maximal_unvisited_count).first\n pivot_index = visited_nodes.index(pivot_node)\n \n visited_nodes = visited_nodes[0..pivot_index] + visited_nodes[(pivot_index + 1)..-1].reverse\n visited_nodes << additional_node\n end\n \n visited_nodes = grow_basic_path(visited_nodes)\n end",
"def match\n @current_route = Route.find(params[:id])\n \n @dep_lat = @current_route.departure_lat \n @dep_lng = @current_route.departure_lng\n @dep_lat_range = @current_route.distance_departure_range * 0.009\n @dep_lng_range = @current_route.distance_departure_range * 0.008\n \n @arr_lat = @current_route.arrival_lat \n @arr_lng = @current_route.arrival_lng\n @arr_lat_range = @current_route.distance_arrival_range * 0.009\n @arr_lng_range = @current_route.distance_arrival_range * 0.008\n \n @time_min = @current_route.time_range_from\n @time_max = @current_route.time_range_to\n\n @date = @current_route.date\n \n if @current_route.offer == true\n @status = false\n else\n @status = true\n end\n \n @routes = Route.find(:all, :conditions => \n [\"`routes`.`date` = ? AND \n `routes`.`active` = 1 AND \n `routes`.`offer` = ? AND \n (`routes`.`departure_lat` BETWEEN ? AND ?) AND \n (`routes`.`departure_lng` BETWEEN ? AND ?) AND \n (`routes`.`arrival_lat` BETWEEN ? AND ?) AND \n (`routes`.`arrival_lng` BETWEEN ? AND ?) AND \n ( (`routes`.`time_range_to` BETWEEN ? AND ?) OR \n (`routes`.`time_range_from` BETWEEN ? AND ?) OR\n (`routes`.`time_range_from` < ? AND `routes`.`time_range_to` > ?) \n )\",\n @date, \n @status,\n @dep_lat - @dep_lat_range, @dep_lat + @dep_lat_range,\n @dep_lng - @dep_lng_range, @dep_lng + @dep_lng_range,\n @arr_lat - @arr_lat_range, @arr_lat + @arr_lat_range, \n @arr_lng - @arr_lng_range, @arr_lng + @arr_lng_range,\n @time_min, @time_max, @time_min, @time_max, @time_min, @time_max]);\n \n \n # @routes = Route.find(:all, :conditions => \n # [\"`routes`.`date` = ? AND \n # `routes`.`active` = 1 AND \n # `routes`.`offer` = ? AND \n # (`routes`.`departure_lat` BETWEEN ? AND ?) AND \n # (`routes`.`departure_lng` BETWEEN ? AND ?) AND \n # (`routes`.`arrival_lat` BETWEEN ? AND ?) AND \n # (`routes`.`arrival_lng` BETWEEN ? AND ?) AND \n # ((`routes`.`time_range_to` BETWEEN ? AND ?) OR (`routes`.`time_range_from` BETWEEN ? AND ?))\",\n # @date, \n # @status,\n # @dep_lat - @dep_lat_range, @dep_lat + @dep_lat_range,\n # @dep_lng - @dep_lng_range, @dep_lng + @dep_lng_range,\n # @arr_lat - @arr_lat_range, @arr_lat + @arr_lat_range, \n # @arr_lng - @arr_lng_range, @arr_lng + @arr_lng_range,\n # @time_min, @time_max,@time_min, @time_max]);\n \n # @routes = Route.where(:departure_lat => @dep_lat - @dep_lat_range..@dep_lat + @dep_lat_range,\n # :departure_lng => @dep_lng - @dep_lng_range..@dep_lng + @dep_lng_range,\n # :arrival_lat => @arr_lat - @arr_lat_range..@arr_lat + @arr_lat_range, \n # :arrival_lng => @arr_lng - @arr_lng_range..@arr_lng + @arr_lng_range,\n # :date => @date,\n # :time_range_to => @time_min..@time_max,\n # :active => true,\n # :offer => @status).limit(20).all \n \n respond_to do |format|\n format.html \n format.json { render json: @routes }\n end\n end",
"def draw_route\n # Delete all sprites in drawing of path\n if @arrow_path != nil\n @arrow_path.each{|a|\n a.dispose\n }\n end\n # Initialize variables\n @arrow_path = []\n return if @passed_positions.empty?\n start_pos = [@selected_unit.x, @selected_unit.y]\n new_pos = start_pos\n type = \"\"\n # Get direction from unit to first tile in path\n last_dir = case [@passed_positions[0].x - @selected_unit.x, @passed_positions[0].y - @selected_unit.y]\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n # Loop through path positions, evaluating two elements at a time\n for i in 0...@passed_positions.size\n p1 = @passed_positions[i]\n p1 = [p1.x, p1.y]\n p2 = (@passed_positions[i+1] == nil ? 0 : @passed_positions[i+1])\n if p2.is_a?(MoveTile)\n p2 = [p2.x, p2.y] \n # Figure out the direction taken to get from p1 to p2\n dir = [p2[0] - p1[0], p2[1] - p1[1]]\n dir = case dir\n when [0, 1] then 2\n when [-1,0] then 4\n when [1, 0] then 6\n when [0,-1] then 8\n end\n else\n dir = 0\n end\n # Evaluate the last direction taken to get to current spot\n case last_dir\n when 2\n new_pos[1] += 1\n case dir\n when 0 then type = \"d\"\n when 2 then type = \"v\"\n when 4 then type = \"ru\"\n when 6 then type = \"lu\"\n end\n when 4\n new_pos[0] -= 1\n case dir\n when 0 then type = \"l\"\n when 2 then type = \"ld\"\n when 4 then type = \"h\"\n when 8 then type = \"lu\"\n end\n when 6\n new_pos[0] += 1\n case dir\n when 0 then type = \"r\"\n when 2 then type = \"rd\"\n when 6 then type = \"h\"\n when 8 then type = \"ru\"\n end\n when 8\n new_pos[1] -= 1\n case dir\n when 0 then type = \"u\"\n when 4 then type = \"rd\"\n when 6 then type = \"ld\"\n when 8 then type = \"v\"\n end\n end\n last_dir = dir\n @arrow_path.push(Arrow_Sprite.new(@arrows_viewport, type, new_pos))\n end\n end",
"def get_route(start_arr, end_arr)\n root = Position.new(start_arr[0], start_arr[1])\n target = Position.new(end_arr[0], end_arr[1])\n solution = get_target_value(target, root)\n\n route = []\n route.unshift([target.x, target.y])\n location = solution.parent\n until location == nil\n route.unshift [location.x, location.y]\n location = location.parent\n end\n return route\nend",
"def hop_on_hop_off\n if params[:route_id].present? && params[:type] == \"From\"\n @current_route = MainRoute.find_by_id(params[:route_id]) \n #@cities=(MainRoute.joins(:line_color_routes).joins('LEFT OUTER JOIN \"city_routes\" ON \"city_routes\".\"line_color_route_id\" = \"line_color_routes\".\"id\" LEFT OUTER JOIN \"cities\" ON \"cities\".\"id\" = \"city_routes\".\"city_id\"').select(\"main_routes.id\",\"main_routes.name\",\"cities.name as city_name\",\"cities.id as city_id\").where(:main_routes => {id: @current_route.id}).distinct.pluck(\"cities.id,cities.name\") + City.where(name: MainRoute.find_by_id(@current_route.id).start_point.downcase!).pluck(:id,:name)).sort{|a,b| a[1] <=> b[1]}\n city = []\n @current_route.line_color_routes.each do |a|\n a.city_routes.pluck(:city_id).each do |b|\n city << b\n end\n end\n @cities = City.where(id: city.uniq).pluck(:id,:name)\n\n \n\n #@cities = []\n @cities.each do |city| \n city[1] = city[1].titleize if city.present?\n\n end\n\n\n\n\n end \n if params[:route_id].present? && params[:type] == \"To\"\n #@city= City.find_by_id(params[:city_id])\n # @cities = City.where(name: Bus.where(start_point: @city.name).pluck(:end_point)).pluck(:id,:name) \n #@cities = (City.where(name: Bus.where(start_point: @city.name).pluck(:end_point)).pluck(:id,:name)).sort{|a,b| a[1] <=> b[1]}\n \n\n #my code starts here...\n\n @current_route = MainRoute.find_by_id(params[:route_id]) \n cit = []\n @current_route.line_color_routes.each do |a|\n a.city_routes.pluck(:city_id).each do |b|\n cit << b\n end\n end\n arr = cit.uniq\n arr.delete(params[:city_id].to_i)\n # p \"------#{arr}--#{params[:city_id].to_i}-------\"\n @cities = City.where(id: arr).pluck(:id,:name)\n @cities.each do |city| \n city[1] = city[1].titleize if city.present?\n\n end\n end \n respond_to do |format|\n format.html \n format.json { render :json => {:cities=>@cities } }\n end\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"vrp\", Routific.token, data)\n RoutificApi::Route.parse(result)\n end",
"def make_paths\n visited = {}\n path = []\n return path if @nmap.empty? || @nnmap.empty?\n\n # 0 is false\n @nmap.each do |k, _|\n visited[k] = 0\n end\n\n # for each node that is not an end node to an end node\n @nnmap.each do |s, _|\n # if s is an end node\n @paths << [s] if @ends.include? s\n\n # for each end node as desintation\n @ends.each do |d|\n get_allpaths(s, d, visited, path)\n end\n end\n @paths.sort_by(&:length).reverse\n end",
"def destination_params\n params.require(:destination).permit(:name, :arrived_on, :left_on, :lng, :lat, :visited)\n end",
"def find(name) \n print(\"finding route for #{name}\\n\")\n res={}\n resList=[]\n @route.each_pair do |p,d|\n match=if p.class==String\n name==p\n elsif p.class==Regexp\n name=~p\n else\n print \"Routes::find: got #{p.class}\\n\"\n false\n end\n if match\n prio=d.options[:prio]\n if res.include?(d.dest)\n if res[d.dest][:prio]>prio\n res[d.dest]=d.options\n end\n else\n res[d.dest]=d.options\n end\n end\n end\n resList=res.to_a.map {|r| RouteEntry.new(r[0], r[1])} # as array of RouteEntry\n resList.sort! {|a,b| a.options[:prio] <=> b.options[:prio]} # sort by prio\n end",
"def directions\n @start_abbr = Station.name_to_abbr(params[:start])\n @dest_abbr = Station.name_to_abbr(params[:end])\n\n @start = params[:start]\n @dest = params[:end]\n # Should be something like\n # Station.find_fastest(start: @start, end: @end)\n # And it should return Hash\n @fastest = Station.find_fastest(@start_abbr, @dest_abbr)\n\n if @fastest.is_a?(String)\n render :directions\n return\n end\n\n # Should be something like\n # Station.find_optimal(start: @start, end: @end)\n # And it should return Hash\n # @optimal = {\n # transfer: 'civic',\n # currentDeparture: '17:26',\n # upsteamColor: 'RED',\n # upsteamDestination: 'mlbr',\n # transferArrival: '17:30',\n # transferDeparture: '17:42',\n # downstreamColor: 'YELLOW',\n # downstreamDestination: 'ptsb',\n # finalEta: '18:15',\n # chanceOfStand: 'Very likely',\n # chanceOfSeat: 'Likely'\n # }\n @optimal =\n if @fastest[:waitTime] < 5\n \"Cannot catch the same train upstream\"\n else\n Station.find_optimal(@start_abbr, @dest_abbr, @fastest)\n end\n\n # Should be soething like\n # If Optimal chanceOfSeat is bad then\n # Station.find_guaranteed_seat(start: @start, end: @end)\n # And it should return Hash\n # @guaranteed_seat = {\n # transfer: 'UN Plaza',\n # currentDeparture: '17:30',\n # upstreamColor: 'RED',\n # upstreamDestination: 'mlbr',\n # transferArrival: '17:35',\n # transferDeparture: '17:52',\n # downstreamColor: 'YELLOW',\n # downstreamDestination: 'ptsb',\n # finalEta: '18:25',\n # chanceOfStand: 'Very likely',\n # chanceOfSeat: 'Likely'\n # }\n @guaranteed_seat =\n if @optimal.is_a?(String) ||\n @optimal[:chanceOfSeat] != 'Very likely' \n\n Station.find_guaranteed_seat(@start_abbr, @dest_abbr)\n else\n \"Optimal is guaranteed seat\"\n end\n p \"results\"\n p @fastest\n p @optimal\n p @guaranteed_seat\n render :directions\n end",
"def plan_trip(stop1, line1, stop2, line2)\n\n trains = {\n \"N\" => [\"Times Square\", \"34th\", \"28th\", \"23rd\", \"Union Square\", \"8th\"],\n \"L\" => [\"8th\", \"6th\", \"Union Square\", \"3rd\", \"1st\"],\n \"6\" => [\"Grand Central\", \"33rd\", \"28th\", \"23rd\", \"Union Square\", \"Astor Place\"]\n }\n\n transfer = \"Union Square\" #DEFAULT TRANSFER STATION\n if line1 != line2 && stop1 == \"Union Square\" #PREVENTS BOARDING THE WRONG TRAIN AT UNION SQUARE\n puts \"Just board the correct train.\"\n line1 = line2\n end\n if line1 == line2 #there may be a clearer way to do this, but this allows a single train line output\n transfer = stop2\n end\n\n route1 = trains[line1] #this is just for readability\n route2 = trains[line2]\n\n if route1.index(stop1) < route1.index(transfer) #this always fires, and is either the only or first segment\n first_path = route1[(route1.index(stop1) + 1)..(route1.index(transfer))]\n puts \"You must travel through the following stops on the #{line1} line: #{first_path.join(\", \")}.\"\n else\n uptown = route1.reverse()\n first_path = uptown[(uptown.index(stop1) + 1)..(uptown.index(transfer))]\n puts \"You must travel through the following stops on the #{line1} line: #{first_path.join(\", \")}.\"\n end\n if line2 == line1\n puts \"A total of #{first_path.length} stops.\"\n end\n\n if line1 != line2 #this only fires if there's a second line\n puts \"Transfer at Union Square.\"\n if route2.index(\"Union Square\") < route2.index(stop2)\n second_path = route2[(route2.index(\"Union Square\") + 1)..(route2.index(stop2))]\n puts \"You must continue through the following stops on the #{line2} line: #{second_path.join(\", \")}.\"\n else\n uptown = route2.reverse()\n second_path = uptown[(uptown.index(\"Union Square\") + 1)..(uptown.index(stop2))]\n puts \"You must continue through the following stops on the #{line2} line: #{second_path.join(\", \")}.\"\n end\n puts \"A total of #{first_path.length + second_path.length} stops.\"\n end\n\nend",
"def route(m, n, i, j, k, l)\n return 0 if i > k || j > l\n start_to_end(k-i+1, l-j+1)\n end",
"def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end",
"def path(start, goals, mode=:move_to, ignore={})\n start = start.map(&:to_i)\n goals = goals.flatten.size == 3 ? [goals.flatten] : goals\n\n if goals.reject { |goal| (start[0] - goal[0]).abs + (start[1] - goal[1]).abs + (start[2] - goal[2]).abs > MAX_PATH_SIZE }.empty?\n puts \"target too far away\"\n return nil\n elsif mode == :move_to && goals.select { |g| allowed?(*g) }.empty?\n puts \"can't go there...\"\n return nil\n # elsif mode == :next_to && goals.map { |g| available(*g, :next_to).any? { |l| allowed?(*l) } }.empty?\n # puts \"nothing to move next to anymore...\"\n # return nil\n end\n visited = {}\n next_to = {}\n examined = 0\n\n heap = Heap.new { |a, b| a.cost <=> b.cost }\n heap.add Path.new(start, goals, [])\n\n while !heap.empty?\n point = heap.next\n\n if point.path.size > MAX_PATH_SIZE\n puts \"examined #{examined} paths before giving up\"\n return nil\n end\n\n next if visited[point.point]\n visited[point.point] = point\n\n examined += 1\n\n case mode\n when :move_to\n if goals.include?(point.point)\n final_path = point.path + [point.point]\n final_path.shift # don't need the start point, we're already there\n # puts \"examined #{examined} paths\"\n return final_path\n end\n\n when :away_from\n above = point.point.dup\n above[1] += 1\n if !goals.include?(point.point) && !goals.include?(above)\n final_path = point.path + [point.point]\n return final_path\n end\n\n when :next_to\n next_to[point.point] ||= available(*point.point, :build)\n available_for_building = next_to[point.point]\n if available_for_building.any? { |a| goals.include? a }\n final_path = point.path + [point.point]\n final_path.shift # don't need the start point, we're already there\n # puts \"examined #{examined} paths\"\n return final_path\n end\n\n else\n raise \"unknown pathfinding mode: #{mode.inspect}\"\n end\n\n next_available = available(*point.point, :move, ignore).each do |test|\n next if visited[test]\n heap.add Path.new(test, goals, point.path + [point.point])\n end\n end\n nil\n end",
"def lesstrips(start, finish, max_distance)\n total_paths, distance = 0, 0\n path, paths = [], []\n visited = [start]\n cycles = all_cycles # all cycles in graph\n puts \"MAX DISTANCE = #{max_distance}\\n\"\n total_paths += lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n puts \"\\n==> Total paths from #{start} to #{finish}, with distance < #{max_distance}: #{total_paths}\\n\"\n total_paths\n end",
"def route_params\n params.require(:route).permit(:route_code, :truck, :driver, :user_id, :badge, :issued_flag, :returned_flag)\n end",
"def route_params\n params.require(:route).permit(:departure_point, :arrival_point, :departure_date, :departure_time, :estimated_arrival_time, :place_number, :price, \n :animal_permission, :smoker_permission, :luggage, :user_id , :passenger_or_conducter)\n end",
"def route\n index = @possible_distances.index(@possible_distances.min)\n @array_of_city_arrangements[index]\n end",
"def add_possible_destination(position, knights_action, knights_path)\n\n possible_destinations = possible_destinations(position)\n\n possible_destinations.each do |possible_destination|\n add_path(possible_destination, knights_action, knights_path)\n end\n end",
"def routes\n raise NotImplementedError\n end",
"def getRoutesTo(station)\n routeList = @toNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end",
"def create_sub_graph(spec_edges, move_dist = nil)\n # declare locals\n time = Time.now\n m = $game_map\n map_width,map_height = m.width, m.height\n MoveUtils.init_ev_passables\n \n if !move_dist\n dist = spec_edges[:move] ||= TactBattleManager::Defaults::Move\n else\n dist = move_dist\n end\n \n x_low = x_high = y_low = y_high = nil\n if @source\n x_low, x_high = [@source.x-dist, 0].max, [@source.x+dist,map_width-1].min\n y_low, y_high = [@source.y-dist, 0].max, [@source.y+dist,map_height-1].min \n else\n x_low, x_high = 0, [dist,map_width-1].min\n y_low, y_high = 0, [dist,map_height-1].min\n end\n \n @jump_time = 0\n @optim_cache = {}\n x_low.upto(x_high).each do |x|\n y_low.upto(y_high).each do |y|\n expand_graph_adj(v=Vertex.new(x,y, m.terrain_tag(x,y)), spec_edges[:pass])\n add_adjacent_jumpables(v.x,v.y,dist,spec_edges)if spec_edges[:jump_length]>0\n end\n end\n self\n end",
"def trips(start, finish, stops1, stops2)\n total_paths = 0\n cycles = all_cycles # all cycles in graph\n (stops1..stops2).each do |stops|\n path, paths = [], []\n visited = [start]\n puts \"\\nSTOPS GOAL = #{stops}\\n\"\n num_paths = trips_dfs(start, finish, stops, visited, path, paths, cycles)\n puts \"\\n--- Total paths for #{stops} stops: #{num_paths}\"\n total_paths += num_paths\n end\n puts \"\\n==> Total paths from #{start} to #{finish}, for #{stops1} to #{stops2} stops: #{total_paths} <==\\n\"\n total_paths\n end",
"def shortest_paths(source, dest)\n\t\t\t@source = source\n\t\t\tdijkstra source\n\t\t\tprint_path dest\n\t\t\treturn @distance[dest]\n\t\tend",
"def build_path(start, end_pos)\n node = Node.new(start[0], start[1])\n target = Node.new(end_pos[0], end_pos[1])\n visited_nodes = []\n next_moves = [node]\n until next_moves.empty? do\n node = next_moves.shift\n puts \"Current node: #{node.x}, #{node.y}\"\n if node.x == target.x && node.y == target.y \n return node\n end\n visited_nodes.push(node)\n node.moves = get_moves(node)\n node.moves.reject do |square|\n visited_nodes.include?(square)\n end\n node.moves.each do |move| \n next_moves.push(move)\n end\n end\n return node\nend",
"def add_route(city1, city2, direction)\n if(node_hash[city1] == nil || node_hash[city2] == nil)\n puts \"INVALID CITY CODES\"\n return\n else\n puts \"Enter route distance\"\n distance = gets\n distance = distance.to_i()\n if(!validate_input(distance))\n puts \"Distance should be positive\"\n return\n end\n if(direction == \"FORWARD\")\n puts \"Adding #{city2} to #{city1} routes\"\n add_city_to_linked(node_hash[city1].linked_cities, city2, distance)\n elsif(direction == \"BACKWARD\")\n puts \"Adding #{city1} to #{city2} routes\"\n add_city_to_linked(node_hash[city2].linked_cities, city1, distance)\n elsif(direction == \"BOTH\")\n puts \"Adding #{city1} to #{city2} routes\"\n puts \"Adding #{city2} to #{city1} routes\"\n if(add_city_to_linked(node_hash[city1].linked_cities, city2, distance) && add_city_to_linked(node_hash[city2].linked_cities, city1, distance))\n route_name = city1.to_s() + \"-\" + city2.to_s()\n routes_hash[route_name] = distance\n end\n else\n puts \"INVALID DIRECTION INPUT\"\n end\n end \n end",
"def map(url, *args)\n #if the last element of args is a hash, take it off and set options\n #to it. Now, if that was there, it should be a hash containing key\n #'default', which, itself has a key of another hash\n #if it wasn't there, then sed options{:default} to the empty Hash\n options = {}\n options = args.pop if args[-1].is_a?(Hash)\n options[:default] ||= {}\n\n #set destintation to nil, and then set it to whatever is at\n #the last inddex of args. Which looks like should be 0 because\n #after that pop, if there's anything left, then we raise an error\n destination = nil\n destination = args.pop if args.size > 0\n raise \"Too many args!\" if args.size > 0\n\n #similar to how we did in controller_and_action get the parts of the\n #url split up into an array based on the forward slash, then take\n #out empty parts (so if the url contained \"//\")\n parts = url.split(\"/\")\n parts.reject! { |part| part.empty? }\n\n #vars and regex_parts are both set to the empty array\n vars, regex_parts = [], []\n\n #so now loop through each part of the array. Each of which is a\n #String\n parts.each do |part|\n #so we're looking at the first letter\n case part[0]\n #if it's a colon, add every following character to the next\n #index of vars. Then put in the next index of regex_parts\n #that the thing to match is any alphanumeric character\n #SO VARS WILL CONTAIN ALL OF OUR SYMBOLS - PATTERNS like\n #:controller, :action, :id\n when \":\"\n vars << part[1..-1]\n regex_parts << \"([a-zA-Z0-9]+)\"\n #if it's a star, add every following character to the next\n #index of vars. And regex_parts gets a /.*/ to match on\n when \"*\"\n vars << part[1..-1]\n regex_parts << \"(.*)\"\n #otherwise, regex_parts simple gets the string at this part of the\n #url (always ignoring \"/\" from the URL of course)\n else\n regex_parts << part\n end\n end\n\n #ok so now we're combining all of the regex parts into a single\n #string, which will be our total regex to match on later\n\n #vars is an array that contains all of the strings that had : or *\n #at the beginning\n\n #destination is either nil or what was at index 0 of args\n #options is either a blank hash or what was the hash at inded 1\n #of args\n regex = regex_parts.join(\"/\")\n @rules.push({ regex: Regexp.new(\"^/#{regex}$\"),\n vars: vars, destination: destination,\n options: options })\n end",
"def record_route(departure_time, arrival_time, from, to)\n from ||= \"\"\n to ||= \"\"\n @routes[@current_route] ||= {}\n @routes[@current_route][from] ||= {}\n @routes[@current_route][from][:departures] ||= []\n @routes[@current_route][from][:departures] << {:to => to, :time => departure_time, :days => @current_days}\n @routes[@current_route][to] ||= {}\n @routes[@current_route][to][:arrivals] ||= []\n @routes[@current_route][to][:arrivals] << {:from => from, :time => arrival_time, :days => @current_days}\n @routes\nend",
"def find_my_routes(*args)\n bounds = args[0][:bounds].nil? ? default_coordinates : args[0][:bounds].dup\n routes = case args[0][:filter]\n when \"recommended\"\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(visibility: 'recommended')\n when \"liked\"\n # TODO need to build this\n else # 'my' or blank\n Route.where(:\"overview_points.latlng\".within(:box) => bounds).where(owner_id: id)\n end\n end",
"def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend",
"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 routes; end",
"def routes; end"
] | [
"0.7423867",
"0.68454725",
"0.6655849",
"0.6323839",
"0.60121167",
"0.58929586",
"0.5879709",
"0.57561725",
"0.5721653",
"0.57182723",
"0.56451654",
"0.56361437",
"0.55888575",
"0.5572061",
"0.5567938",
"0.5552057",
"0.5552057",
"0.5552057",
"0.5524382",
"0.5513683",
"0.55053204",
"0.5502896",
"0.5496374",
"0.5487208",
"0.54799557",
"0.5478868",
"0.5476557",
"0.5465704",
"0.5462976",
"0.5462753",
"0.5444392",
"0.5435992",
"0.53974354",
"0.5388322",
"0.5373571",
"0.5371398",
"0.53637904",
"0.5330003",
"0.53299123",
"0.5316421",
"0.52966535",
"0.52877945",
"0.5279734",
"0.52685297",
"0.52685297",
"0.52495843",
"0.5249422",
"0.5248396",
"0.5243884",
"0.5243735",
"0.5242438",
"0.5231469",
"0.5231376",
"0.52098376",
"0.520705",
"0.52058154",
"0.5201595",
"0.51915264",
"0.5190844",
"0.518707",
"0.5186346",
"0.5184357",
"0.5177215",
"0.51760876",
"0.51745003",
"0.51663166",
"0.5158243",
"0.5151193",
"0.5148561",
"0.51475793",
"0.5147255",
"0.5143317",
"0.51078445",
"0.51027924",
"0.50906694",
"0.50826126",
"0.50792974",
"0.5076795",
"0.50754684",
"0.5071907",
"0.5066834",
"0.50620073",
"0.5058044",
"0.50552356",
"0.50531423",
"0.5045336",
"0.50386626",
"0.5036958",
"0.5023414",
"0.50178343",
"0.50065464",
"0.50039685",
"0.5003572",
"0.499697",
"0.49920586",
"0.49857718",
"0.4983043",
"0.49743977",
"0.4971251",
"0.4971251"
] | 0.6666883 | 2 |
step_number(Hash, String) return the eval expression for the conditions returns | def final_eval condition, limits
return "#{condition[:steps]}#{limits[:steps]}" if limits.has_key? :steps
return "#{condition[:cost]}#{limits[:cost]}" if limits.has_key? :cost
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculation\n wizard_step(nil) { { next_step: :calculate_next_step, cache_index: LbttController } }\n end",
"def opinion_wizard_step_number(step)\n step.to_s.split(\"_\").last.to_i\n end",
"def next_step\n (history.keys.last.to_i + 1).to_s\n end",
"def step_result; end",
"def steps(n)\nend",
"def step_number(string)\n return string.split('-',5)[2].to_i\n end",
"def take_steps(n, steps = 1)\n\treturn 0 if n < 0\n\n\treturn 1 if n == 0\n\treturn @hash[n] unless @hash[n].nil?\n\t\n\t@hash[n] = take_steps(n - 1) + take_steps(n - 2) + take_steps(n - 3)\n\treturn @hash[n]\nend",
"def expr1\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n value = nil\n e = nil\n\n begin\n # at line 28:5: e= number ( '*' e= number | '/' e= number )*\n @state.following.push( TOKENS_FOLLOWING_number_IN_expr1_207 )\n e = number\n @state.following.pop\n # --> action\n value = e \n # <-- action\n # at line 29:5: ( '*' e= number | '/' e= number )*\n while true # decision 2\n alt_2 = 3\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == T__12 )\n alt_2 = 1\n elsif ( look_2_0 == T__13 )\n alt_2 = 2\n\n end\n case alt_2\n when 1\n # at line 29:7: '*' e= number\n match( T__12, TOKENS_FOLLOWING_T__12_IN_expr1_217 )\n @state.following.push( TOKENS_FOLLOWING_number_IN_expr1_221 )\n e = number\n @state.following.pop\n # --> action\n value *= e \n # <-- action\n\n when 2\n # at line 30:7: '/' e= number\n match( T__13, TOKENS_FOLLOWING_T__13_IN_expr1_231 )\n @state.following.push( TOKENS_FOLLOWING_number_IN_expr1_235 )\n e = number\n @state.following.pop\n # --> action\n value /= e \n # <-- action\n\n else\n break # out of loop for decision 2\n end\n end # loop for decision 2\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n end\n \n return value\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def number_of_steps\n case current_instruction.opcode\n when 3, 4\n 2\n else\n 4\n end\n end",
"def kaprekar_step(n)\n\n # TODO: Solve it!\n\n end",
"def flow_expression\n\n @dict.fexp\n end",
"def num_steps(n)\n # if n = 1\n # 1\n # elsif n = 2\n # 2\n # elsif n = 3\n # num_steps(1) + num_steps(2)\n # elsif n = 4\n # num_steps(2) + num_steps(3)\n # end\n if n < 3\n n\n else\n num_steps(n-2) + num_steps(n-1)\n end\nend",
"def execute(step)\n end",
"def make_step\n @result\n end",
"def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n arg0imm = (instcode / 100) % 10 == 1\n arg1imm = (instcode / 1000) % 10 == 1\n\n argcount = ARGCOUNT[opcode] || 0\n args = @memory[@ip + 1..@ip + argcount]\n arg0 = (arg0imm ? args[0] : @memory[args[0]]) if argcount >= 1\n arg1 = (arg1imm ? args[1] : @memory[args[1]]) if argcount >= 2\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = arg0 + arg1\n when 2 # mul\n @memory[args[2]] = arg0 * arg1\n when 3 # in\n raise \"input past end\" unless @inputs.any?\n @memory[args[0]] = @inputs.shift\n when 4 # out\n @outputs << arg0\n when 5 # jnz\n jump_target = arg1 if arg0 != 0\n when 6 # jz\n jump_target = arg1 if arg0 == 0\n when 7 # lt\n @memory[args[2]] = (arg0 < arg1) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (arg0 == arg1) ? 1 : 0\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end",
"def k_num!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 47 )\n\n\n\n type = K_NUM\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 441:4: ( 'round' | 'aleatorio' | 'between' )\n # at line 441:4: ( 'round' | 'aleatorio' | 'between' )\n alt_14 = 3\n case look_14 = @input.peek( 1 )\n when 0x72 then alt_14 = 1\n when 0x61 then alt_14 = 2\n when 0x62 then alt_14 = 3\n else\n raise NoViableAlternative( \"\", 14, 0 )\n\n end\n case alt_14\n when 1\n # at line 441:5: 'round'\n match( \"round\" )\n\n\n when 2\n # at line 441:13: 'aleatorio'\n match( \"aleatorio\" )\n\n\n when 3\n # at line 441:25: 'between'\n match( \"between\" )\n\n\n end\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__, 47 )\n\n\n end",
"def steps(value)\n factor = 10**(Math.log10(value).floor - 1)\n case \n when value < factor * 10\n factor\n when value < 5 * factor * 10\n 5 * factor\n else\n 10 * factor\n end\n end",
"def steps(value)\n factor = 10**(Math.log10(value).floor - 1)\n case \n when value < factor * 10\n factor\n when value < 5 * factor * 10\n 5 * factor\n else\n 10 * factor\n end\n end",
"def next_step\n self.step_flow.next_step if can_increment_step\n end",
"def eval_shop_condition(formula)\n @@interpreter.eval_shop_condition(formula)\n end",
"def parse_condition(exp); end",
"def create_steps(value, expected)\n temp = []\n st_count = 0\n\n value.each do |x|\n temp[st_count] = {}\n temp[st_count][:step_number] = \"#{st_count+1}\"\n temp[st_count][:actions] = \"<p>#{x.strip}</p>\"\n temp[st_count][:expected_results] = expected unless expected.nil?\n temp[st_count][:execution_type] = \"1\"\n temp[st_count][:active] = \"1\"\n st_count += 1\n end\n return temp\n end",
"def sheets_steps= value ; @sheets_steps = value end",
"def next_hash\n result = @stmt.step\n return nil if result.nil?\n unless result.kind_of?(Hash)\n result_ary = result\n result = {}\n result_ary.each_with_index do |el, i|\n result[@stmt.column_name(i)] = el\n end\n end\n result\n end",
"def compute(expr)\n\n\t\tj=0;\n\t\twhile j<=expr.size\n\t if !expr[j+1].nil?\n\t\t\t\tif expr[j+1].chr=='`' || expr[j+1].chr==\"'\"\n\t\t\t\t\t(expr[j].chr=='1') ? k=\"0\" : k=\"1\"\n\t\t\t\t\texpr=expr.slice(0,j).to_s+k+expr.slice(j+2..-1).to_s\n\t\t\t\t\t#j=j-1\n\t\t\t\tend\n\t end\n\t\t\tj+=1\n\t\tend\n\n\t\tj=0\n\t while(j<=expr.size)\n\t if !expr[j+1].nil?\n\t\t\t\tif (expr[j].chr=='0' || expr[j].chr=='1') && (expr[j+1].chr=='0' || expr[j+1].chr=='1')\n\t\t\t\t\t(expr[j].chr=='1' && expr[j+1].chr=='1') ? k=\"1\" : k=\"0\"\n\t\t\t\t\texpr=expr.slice(0,j).to_s+k+expr.slice(j+2..-1).to_s\n\t\t\t\t\t#j=j-1;\n\t\t\t\telsif (expr[j].chr=='0' || expr[j].chr=='1') && expr[j+1].chr=='^'\n\t\t\t\t\t(expr[j].chr==expr[j+2].chr) ? k=\"0\" : k=\"1\"\n\t\t\t\t\texpr=expr.slice(0,j).to_s+k+expr.slice(j+3..-1).to_s\n\t\t\t\t\t#j=j-1;\n\t\t\t\tend\n\t end\n\t\t\tj+=1\n\t\tend\n\t\tk=0\n\n\t\tj=0\n\t\twhile(j<expr.size)\n\t\t\tif expr[j].chr=='1'\n\t\t\t\tk=1\n\t\t\t\treturn k\n\t\t\tend\n\t\t\tj+=1\n\t\tend\n\t\treturn k\n\n\tend",
"def expression; end",
"def step count\n @algorithm.call count\n end",
"def hash_for(expression)\n\n end",
"def start_step?\n params_hash[\"start\"]\n end",
"def step_number visit_path, dst, limits, condition=nil\n return route(visit_path, dst, limits, UNTIL).first.nodes.length - 1\n end",
"def define_step(regex, &blk)\n steps[regex] = blk\n end",
"def previous_step\n (history.keys.last.to_i - 1).to_s\n end",
"def steps\n %w[\n household_member_demographics_step\n household_member_address_step\n household_member_address_search_results_step\n household_member_citizenship_step\n household_member_education_step\n household_member_employments_step\n household_member_assessment_employment_step\n household_member_incomes_step\n household_member_unearned_incomes_step\n household_member_expenses_step\n household_member_resources_step\n household_member_relations_step\n ]\n end",
"def step1\n\n end",
"def num!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n\n type = NUM\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 37:9: ( '1' .. '9' ) ( '0' .. '9' )*\n # at line 37:9: ( '1' .. '9' )\n # at line 37:10: '1' .. '9'\n match_range( 0x31, 0x39 )\n\n # at line 37:19: ( '0' .. '9' )*\n while true # decision 1\n alt_1 = 2\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0.between?( 0x30, 0x39 ) )\n alt_1 = 1\n\n end\n case alt_1\n when 1\n # at line 37:20: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n break # out of loop for decision 1\n end\n end # loop for decision 1\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__, 5 )\n\n end",
"def next_step(resource, mikyung)\n conditions.each do |c|\n if c.should_run_for(resource, self)\n return c.execute(resource, self, mikyung)\n end\n end\n nil\n end",
"def step1\n \n end",
"def calculate_step(_ranks)\n raise NotImplementedError\n end",
"def wizard_value(step_name)\n step_name\n end",
"def step\n case\n when check( /program\\s+/ )\n start_group :keyword, scan( /program\\s+/ )\n start_group :function, scan_until( /(?=[;(\\s]|#{EOL})/ )\n when check( /subroutine\\s+/ )\n start_group :keyword, scan( /subroutine\\s+/ )\n start_group :function, scan_until( /(?=[;(\\s]|#{EOL})/ )\n when check( /function\\s+/ )\n start_group :keyword, scan( /function\\s+/ )\n start_group :function, scan_until( /(?=[;(\\s]|#{EOL})/ )\n when check( /module\\s+/ )\n start_group :keyword, scan( /module\\s+/ )\n start_group :function, scan_until( /(?=[;\\s]|#{EOL})/ )\n when check( /\\.true\\.|\\.false\\.|\\.TRUE\\.|\\.FALSE\\./ )\n start_group :constant,\n scan(/\\.true\\.|\\.false\\.|\\.TRUE\\.|\\.FALSE\\./)\n when scan( /(\\d+\\.?\\d*|\\d*\\.?\\d+)([eEdDqQ][+-]?\\d+)?(_\\w+)?/ )\n start_group :number, matched\n when scan( /[bB]\\'[01]+\\'|[oO]\\'[0-7]+\\'|[zZ]\\'[0-9a-fA-F]+\\'/ )\n start_group :number, matched\n else\n case peek(1)\n when /[\\n\\r]/\n start_group :normal, scan( /\\s+/ )\n when /\\s/\n start_group :normal, scan( /\\s+/ )\n when \"!\"\n start_group :comment, scan( /![^\\n\\r]*/ )\n when /[A-Za-z]/\n word = scan( /\\w+/ )\n if KEYWORDS.include?(word)\n start_group :keyword, word\n elsif TYPES.include?(word)\n start_group :type, word\n elsif INTRINSICS.include?(word)\n start_group :function, word\n elsif\n start_group :ident, word\n end\n when '\"'\n # allow for continuation characters within strings\n start_group :string, scan(/\"([^\"]*(&[ ]*[\\n\\r]+)?)*\"/)\n when \"'\"\n # allow for continuation characters within strings\n start_group :string, scan(/'([^']*(&[ ]*[\\n\\r]+)?)*'/)\n when /[-!?*\\/+=<>()\\[\\]\\{}:;,&|%]/\n start_group :punct, scan(/./)\n else\n # pass everything else through\n append getch\n end\n end\n end",
"def next_step(n)\n if n.even?\n n/2.to_i\n else\n 3*n+1\n end\nend",
"def process_true(exp)\n return \"1\"\n end",
"def calculate_step_completion(live_step, actual_confirmation, level_object, lang_attribute_value, hours_per_workday)\n\t\tduration_days = self.duration_days\n\t\tduration_minutes = self.duration_minutes\n\t\tduration_multiplier = self.duration_multiplier\n\t\tcomp = 1\n\t\tlang = 1\n\n\t\tif level_object.present?\n\t\t\trework_components = 0\n\t\t if level_object.class.name == 'L3'\n\t\t if level_object.num_component.to_i > 0\n\t\t \tcomp = level_object.num_component.to_i - level_object.num_component_in_rework.to_i\n\t\t end\n\t\t\telse\n\t\t\t\tcomp = level_object.num_component.present? ? level_object.num_component : 1\n end\n\n if comp.to_i <= 0\n comp = 1\n end\n\n\t\tend\n\n\t\tif lang_attribute_value.present?\n\t\t\tlang = lang_attribute_value.value.present? ? lang_attribute_value.value : 1\n\t\t\tlang = lang.to_i\n\t\tend\n\t\t\n\t\tnumberDays = duration_days.present? ? duration_days : 0\n\t\tnumberMinute = duration_minutes.present? ? duration_minutes : 0\n\n\t\t\t\t\t\t# Duration Multiplier\n\t\tif duration_multiplier == 'C'\n\t\t\tnumber_days = numberDays*comp\n\t\t\tnumber_minutes = numberMinute*comp\n\t\telsif duration_multiplier == 'L'\n\t\t\tnumber_days = (numberDays*comp)/lang\n\t\t\tnumber_minutes = (numberMinute*comp)/lang\n\t\telse\n\t\t\tnumber_days = numberDays\n\t\t\tnumber_minutes = numberMinute\n\t\tend\n\n\t\tif !live_step.is_active?\n\t\t\tnumber_days = 0\n\t\t\tnumber_minutes = 0\n\t\tend\n\n\t\t\t\t\t\t# Covnert minutes to hours and minutes\n\t\thours_frm_minutes, reminaing_minutes = number_minutes.divmod(60)\n\t\tdays_frm_hours, remaining_hours = hours_frm_minutes.divmod(hours_per_workday)\n\t\tnumber_days = number_days + days_frm_hours\n\n\t\tactual_confirmation = actual_confirmation.to_datetime.strftime('%Y-%m-%d %H:%M')\n\t\tactual_confirmationTime = Time.parse(actual_confirmation)\n\t\tactual_confirmation_time = remaining_hours.business_hours.after(actual_confirmationTime)\n\t\t\n\t\tif number_days > 0\n\t\t\tactual_confirmation_time = number_days.business_days.after(actual_confirmation_time)\n\t\tend\n\t\t\n\t\treturn actual_confirmation_time + reminaing_minutes.minutes\n\n\t\t# end_of_day = workflow.end_of_day.to_time.strftime( \"%I %M %p\" )\n\t\t# calculated_end_of_day = actual_confirmation_time + reminaing_minutes.minutes\n\t\t# if calculated_end_of_day > end_of_day\n\t\t# \textra_seconds = calculated_end_of_day.to_time.strftime( \"%I %M %p\" ) - end_of_day.to_time.strftime( \"%I %M %p\" ))\n\t\t# \textra_minutes = extra_seconds/3600\n\t\t# \tactual_confirmation = actual_confirmation_time + reminaing_minutes.minutes\n\t\t# \tactual_confirmation = actual_confirmation.to_time.strftime('%Y-%m-%d %H:%M')\n\t\t# \tactual_confirmationTime = Time.parse(actual_confirmation)\n\t\t# \tactual_confirmation_time = 0.business_hours.after(actual_confirmationTime)\n\t\t# \treturn actual_confirmation_time + extra_minutes\n\t\t# else\n\t\t# \treturn calculated_end_of_day\n\t\t# end\n\tend",
"def get_equation(n)\n eval \"@yp#{n}\"\n end",
"def evaluate(bindings = {})\n stack = []\n @expr.split.each do |token|\n case token\n when /\\A\\d+\\z/\n number = Number.new(token)\n stack.push(number)\n when \"+\"\n right = stack.pop(1)\n left = stack.pop(1)\n value.add(left, right)\n end\n end\n stack.pop\n end",
"def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n\n value = nil\n\n\n a = nil\n b = nil\n\n\n begin\n # at line 9:28: a= mul ( ADD b= mul | SUB b= mul )*\n @state.following.push( TOKENS_FOLLOWING_mul_IN_expression_44 )\n a = mul\n @state.following.pop\n # at line 9:33: ( ADD b= mul | SUB b= mul )*\n while true # decision 1\n alt_1 = 3\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0 == ADD )\n alt_1 = 1\n elsif ( look_1_0 == SUB )\n alt_1 = 2\n\n end\n case alt_1\n when 1\n # at line 10:5: ADD b= mul\n match( ADD, TOKENS_FOLLOWING_ADD_IN_expression_51 )\n @state.following.push( TOKENS_FOLLOWING_mul_IN_expression_55 )\n b = mul\n @state.following.pop\n\n # --> action\n a += b \n # <-- action\n\n\n when 2\n # at line 11:5: SUB b= mul\n match( SUB, TOKENS_FOLLOWING_SUB_IN_expression_63 )\n @state.following.push( TOKENS_FOLLOWING_mul_IN_expression_67 )\n b = mul\n @state.following.pop\n\n # --> action\n a -= b \n # <-- action\n\n\n else\n break # out of loop for decision 1\n end\n end # loop for decision 1\n\n\n # --> action\n value = a \n # <-- action\n\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n\n end\n\n return value\n end",
"def calc(expr)\n return 0 if expr.empty?\n expr.split(' ').inject([]) { |a, i|\n a << (i =~ /\\d+/ ? i.to_i : a.pop(2)[0].send(i, a.pop(2)[1]))\n }.pop\nend",
"def calculate_next_step\n flbt_type = @lbtt_return.flbt_type\n\n next_steps = if flbt_type == 'CONVEY'\n CONVEYANCE_STEPS\n elsif flbt_type == 'LEASERET'\n LEASE_STEPS\n elsif %w[LEASEREV ASSIGN TERMINATE].include? flbt_type\n LEASE_REV_ASSIGN_TERMINATE_STEPS\n end\n\n raise Error::AppError.new('Return type', \"Invalid return type for calc #{flbt_type}\") if next_steps.nil?\n\n next_steps\n end",
"def next_step_number\n progress = current_progress\n progress ? current_progress.step.number + 1 : 0\n end",
"def steps\n @steps ||= 0\n end",
"def eval_num(num)\n if num <= 50\n puts \"#{num} is 50 or less\"\n else\n puts \"#{num} is 51 or above\"\n end\nend",
"def eval_ex(e)\n case e\n when Symbol\n value = @var_tables.reverse_each.find{|var| break var[e] if var[e] }\n raise \"undefined variable: #{e}\" if value.nil?\n return value\n when Array\n method = e.first\n case method\n when :if0\n if0(e[1], e[2], e[3])\n when :fold\n fold(e[1], e[2], e[3])\n when *OP1\n send(method, e[1])\n when *OP2\n send(method, e[1], e[2])\n else\n raise \"unexpected expression method: #{method.inspect}\"\n end\n when Numeric\n e\n else\n raise \"unexpected expression: #{e.inspect}\"\n end\n end",
"def _reduce_367(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n \n result\nend",
"def evaluate(exp, env)\n # exp: A current node of AST\n # env: An environment (explained later)\n\n case exp[0]\n\n#\n## Problem 1: Arithmetics\n#\n\n when \"lit\"\n exp[1] # return the immediate value as is\n when \"*\"\n evaluate(exp[1], env) * evaluate(exp[2], env)\n when \"/\"\n evaluate(exp[1], env) / evaluate(exp[2], env)\n when \"%\"\n evaluate(exp[1], env) % evaluate(exp[2], env)\n when \"+\"\n evaluate(exp[1], env) + evaluate(exp[2], env)\n when \"-\"\n evaluate(exp[1], env) - evaluate(exp[2], env)\n# ... Implement other operators that you need\n when \"<\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs < rhs\n when \">\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs > rhs\n when \"<=\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs <= rhs\n when \"==\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs == rhs\n when \">=\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs >= rhs\n when \"==\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs == rhs\n when \"!=\"\n lhs, rhs = exp[1..-1].map { |v| evaluate(v, env) }\n lhs != rhs\n\n\n#\n## Problem 2: Statements and variables\n#\n\n when \"stmts\"\n # Statements: sequential evaluation of one or more expressions.\n #\n # Advice 1: Insert `pp(exp)` and observe the AST first.\n # Advice 2: Apply `evaluate` to each child of this node.\n statements = exp[1..-1]\n statements.each do |v|\n evaluate(v, env)\n end\n\n# The second argument of this method, `env`, is an \"environement\" that\n# keeps track of the values stored to variables.\n# It is a Hash object whose key is a variable name and whose value is a\n# value stored to the corresponded variable.\n\n when \"var_ref\"\n var_name = exp.last\n env[var_name]\n\n when \"var_assign\"\n name, inner_exp = exp[1..-1]\n env[name] = evaluate(inner_exp, env)\n\n\n#\n## Problem 3: Branchs and loops\n#\n\n when \"if\"\n condition = evaluate(exp[1], env)\n if condition\n evaluate(exp[2], env)\n else\n evaluate(exp[3], env)\n end\n\n\n when \"while\"\n condition = evaluate(exp[1], env)\n while condition\n evaluate(exp[2], env)\n condition = evaluate(exp[1], env)\n end\n\n# Loop.\n\n\n#\n## Problem 4: Function calls\n#\n\n when \"func_call\"\n # Lookup the function definition by the given function name.\n func = $function_definitions[exp[1]]\n\n if func.nil?\n # We couldn't find a user-defined function definition;\n # it should be a builtin function.\n # Dispatch upon the given function name, and do paticular tasks.\n case exp[1]\n when \"p\"\n # MinRuby's `p` method is implemented by Ruby's `p` method.\n p(evaluate(exp[2], env))\n when \"Integer\"\n evaluate(exp[2], env).to_i\n when \"fizzbuzz\"\n n = evaluate(exp[2], env).to_i\n if n % 15 == 0\n 'FizzBuzz'\n elsif n % 3 == 0\n 'Fizz'\n elsif n % 5 == 0\n 'Buzz'\n else\n n.to_s\n end\n else\n raise(\"unknown builtin function\")\n end\n else\n arg_names = func.arg_names\n execution = func.execution\n arguments = exp[2..-1].map { |ast| evaluate(ast, env) }\n env = arg_names.zip(arguments).to_h\n evaluate(execution, env)\n\n #\n ## Problem 5: Function definition\n #\n\n # (You may want to implement \"func_def\" first.)\n #\n # Here, we could find a user-defined function definition.\n # The variable `func` should be a value that was stored at \"func_def\":\n # parameter list and AST of function body.\n #\n # Function calls evaluates the AST of function body within a new scope.\n # You know, you cannot access a varible out of function.\n # Therefore, you need to create a new environment, and evaluate the\n # function body under the environment.\n #\n # Note, you can access formal parameters (*1) in function body.\n # So, the new environment must be initialized with each parameter.\n #\n # (*1) formal parameter: a variable as found in the function definition.\n # For example, `a`, `b`, and `c` are the formal parameters of\n # `def foo(a, b, c)`.\n end\n\n when \"func_def\"\n # Function definition.\n #\n # Add a new function definition to function definition list.\n # The AST of \"func_def\" contains function name, parameter list, and the\n # child AST of function body.\n # All you need is store them into $function_definitions.\n #\n # Advice: $function_definitions[???] = ???\n func_name = exp[1]\n arg_names = exp[2...-1].flatten\n execution_ast = exp.last\n $function_definitions[func_name] = Function.new(arg_names, execution_ast)\n\n\n#\n## Problem 6: Arrays and Hashes\n#\n\n# You don't need advices anymore, do you?\n when \"ary_new\"\n exp[1..-1].map { |ast| evaluate(ast, env) }\n\n when \"ary_ref\"\n array, index = exp[1..2].map { |ast| evaluate(ast, env) }\n array[index]\n\n when \"ary_assign\"\n array, index, value = exp[1..3].map { |ast| evaluate(ast, env) }\n array[index] = value\n\n when \"hash_new\"\n exp[1..-1].map { |ast| evaluate(ast, env) }.each_slice(2).to_h\n\n else\n p(\"error\")\n pp(exp)\n raise(\"unknown node\")\n end\nend",
"def eval(expr, *rest) end",
"def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n argcount = ARGCOUNT[opcode] || 0\n addressing_modes = argcount.times.map { |ix| (instcode / (10 ** (ix + 2))) % 10 }\n args = addressing_modes.each_with_index.map do |am, ix|\n raw_arg = @memory[@ip + ix + 1]\n translate_arg(opcode, ix, raw_arg, am)\n end\n\n if TRACE\n STDERR.puts \"#{@id} @ip=#{@ip} @base=#{@base} inst=#{@memory[@ip..@ip+argcount].inspect} opcode=#{opcode} am=#{addressing_modes.inspect} args=#{args.inspect}\"\n end\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = args[0] + args[1]\n when 2 # mul\n @memory[args[2]] = args[0] * args[1]\n when 3 # in\n if @inputs.any?\n @memory[args[0]] = @inputs.shift\n else\n return :need_input\n end\n when 4 # out\n @outputs << args[0]\n when 5 # jnz\n jump_target = args[1] if args[0] != 0\n when 6 # jz\n jump_target = args[1] if args[0] == 0\n when 7 # lt\n @memory[args[2]] = (args[0] < args[1]) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (args[0] == args[1]) ? 1 : 0\n when 9 #base\n @base += args[0]\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end",
"def parse line\n line.match(/^Step (\\w) must be finished before step (\\w)/).captures\nend",
"def steps(steps)\n @step_lengths = steps.map {|keyword, name| (keyword+name).unpack(\"U*\").length}\n @max_step_length = @step_lengths.max\n @step_index = -1\n end",
"def steps(steps)\n @step_lengths = steps.map {|keyword, name| (keyword+name).unpack(\"U*\").length}\n @max_step_length = @step_lengths.max\n @step_index = -1\n end",
"def _reduce_367(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n\n result\nend",
"def _reduce_345(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n \n result\nend",
"def _reduce_343(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n \n result\nend",
"def _reduce_357(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n \n result\nend",
"def how_many_steps?\n puts \"Left\"\n puts \"Right\"\n puts \"/1\\nRight\\n2\\nLeft/\"\n puts \"/3/\"\n puts \"/4/\"\n puts \"/5/\"\n puts \"/6/\"\nend",
"def run(args) # :nodoc\n condition = nil\n opts = {}\n if args.size == 1\n step_count = 1\n else\n replace_cmd = Keyword_to_related_cmd[args[1]]\n if replace_cmd\n cmd = @proc.commands[replace_cmd]\n return cmd.run([replace_cmd] + args[2..-1])\n elsif 'until' == args[1]\n try_condition = args[2..-1].join(' ')\n if valid_condition?(try_condition)\n condition = try_condition\n opts[:different_pos] = false\n step_count = 0\n end\n else\n step_str = args[1]\n opts = @proc.parse_next_step_suffix(args[0])\n count_opts = {\n :msg_on_error => \n \"The #{NAME} command argument must eval to an integer. Got: %s\" % \n step_str,\n :min_value => 1\n }\n step_count = @proc.get_an_int(step_str, count_opts)\n return unless step_count\n end\n end\n \n @proc.step('step', step_count, opts, condition)\n end",
"def step\n log_iteration_start\n\n\n @current_task = tasks_list.shift\n status.no_tasks! and return unless current_task #empty tasks list\n\n solve_current_task\n\n return unless current_basis_plan # no optimal plan, so we don't change record and continue\n\n if current_target_function <= record # not interested as previsous record is higher\n status.target_less_than_record!\n elsif task.satisfies_integer?(current_basis_plan)\n change_record\n else\n split_current_task\n end\n log_status\n end",
"def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n\n\n value = nil\n\n\n type = nil\n a = nil\n b = nil\n\n\n begin\n # at line 185:5: a= relation (type= ( '&&' | '||' ) b= expression )?\n @state.following.push( TOKENS_FOLLOWING_relation_IN_expression_1389 )\n a = relation\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = a \n # <-- action\n end\n\n # at line 186:3: (type= ( '&&' | '||' ) b= expression )?\n alt_45 = 2\n look_45_0 = @input.peek( 1 )\n\n if ( look_45_0 == T__33 || look_45_0 == T__54 )\n alt_45 = 1\n end\n case alt_45\n when 1\n # at line 186:6: type= ( '&&' | '||' ) b= expression\n type = @input.look\n\n if @input.peek(1) == T__33 || @input.peek(1) == T__54\n @input.consume\n @state.error_recovery = false\n\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n\n mse = MismatchedSet( nil )\n raise mse\n\n end\n\n\n @state.following.push( TOKENS_FOLLOWING_expression_IN_expression_1410 )\n b = expression\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = DoubleOperandExpressionEval.new(type.text, a, b) \n # <-- action\n end\n\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 29 )\n\n\n end\n\n return value\n end",
"def execute_expression\n valid_input\n to_roman(to_num(@operand_one).send(@operator, to_num(@operand_two)))\n end",
"def evaluate\n\n end",
"def _reduce_343(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n\n result\nend",
"def expr\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 3 )\n value = nil\n e = nil\n\n begin\n # at line 35:5: e= expr1 ( '+' e= expr1 | '-' e= expr1 )*\n @state.following.push( TOKENS_FOLLOWING_expr1_IN_expr_262 )\n e = expr1\n @state.following.pop\n # --> action\n value = e \n # <-- action\n # at line 36:5: ( '+' e= expr1 | '-' e= expr1 )*\n while true # decision 3\n alt_3 = 3\n look_3_0 = @input.peek( 1 )\n\n if ( look_3_0 == T__14 )\n alt_3 = 1\n elsif ( look_3_0 == T__15 )\n alt_3 = 2\n\n end\n case alt_3\n when 1\n # at line 36:7: '+' e= expr1\n match( T__14, TOKENS_FOLLOWING_T__14_IN_expr_272 )\n @state.following.push( TOKENS_FOLLOWING_expr1_IN_expr_276 )\n e = expr1\n @state.following.pop\n # --> action\n value += e \n # <-- action\n\n when 2\n # at line 37:7: '-' e= expr1\n match( T__15, TOKENS_FOLLOWING_T__15_IN_expr_286 )\n @state.following.push( TOKENS_FOLLOWING_expr1_IN_expr_290 )\n e = expr1\n @state.following.pop\n # --> action\n value -= e \n # <-- action\n\n else\n break # out of loop for decision 3\n end\n end # loop for decision 3\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 3 )\n\n end\n \n return value\n end",
"def run(args) # :nodoc\n opts = @proc.parse_next_step_suffix(args[0])\n condition = nil\n if args.size == 1\n # Form is: \"step\" which means \"step 1\"\n step_count = 0\n else\n replace_cmd = Keyword_to_related_cmd[args[1]]\n if replace_cmd\n cmd = @proc.commands[replace_cmd]\n return cmd.run([replace_cmd] + args[2..-1])\n elsif 'until' == args[1]\n try_condition = args[2..-1].join(' ')\n if valid_condition?(try_condition)\n condition = try_condition\n opts[:different_pos] = false\n step_count = 0\n end\n elsif 'to' == args[1]\n if args.size != 3\n errmsg('Expecting a method name after \"to\"')\n return\n elsif !@proc.method?(args[2])\n errmsg(\"#{args[2]} doesn't seem to be a method name\")\n return\n else\n opts[:to_method] = args[2]\n opts[:different_pos] = false\n step_count = 0\n end\n elsif 'thread' == args[1]\n condition = \"Thread.current.object_id == #{Thread.current.object_id}\"\n opts[:different_pos] = false\n step_count = 0\n else\n count_str = args[1]\n int_opts = {\n :msg_on_error =>\n \"The 'step' command argument must eval to an integer. Got: %s\" %\n count_str,\n :min_value => 1\n }.merge(opts)\n count = @proc.get_an_int(count_str, int_opts)\n return unless count\n # step 1 is core.step_count = 0 or \"stop next event\"\n step_count = count - 1\n end\n end\n @proc.step(step_count, opts, condition)\n end",
"def eval(n)\n case n\n when Sum[e1 = _, e2 = _] then eval(e1) + eval(e2)\n when Number[n = _] then n\n end\nend",
"def drinking_hash(rundate, divisor)\n # Validate\n raise ArgumentError, 'Cannot predict future' if rundate > Date.today\n num = magic_number(rundate - 7)\n result = (num % divisor.to_i).zero?\n # return a hash\n { result: result, magic_number: num, divisor: divisor }\n end",
"def step_number\n @step_number ||= (@time.to_f/60.0*sign.tempo).floor\n end",
"def process_hash(exp)\n kv_list = exp\n raise if kv_list.length % 2 != 0 \n\n args = \n without_result do\n want_expression do\n kv_list.map {|i| process(i)}.join(\",\")\n end\n end\n\n str = @model.lookup_constant('::Hash') + \".\"\n if kv_list.empty?\n # empty Hash\n @model.add_method_call(m = @model.encode_method(\"new\"))\n str << \"#{m}()\" \n else\n @model.add_method_call(m = @model.encode_method(\"new_from_key_value_list\"))\n str << \"#{m}(#{@model.encode_nil},#{args})\" \n end\n\n exp.clear\n\n return str\n end",
"def currentStepIndex\n @current_step_index\n end",
"def step(words)\n @step ||= 0\n @step += 1\n \"#{@step}) #{words}\\n\"\n end",
"def step_params\n params.require(:step).permit(:number, :description, :locator, :skip, :testcase_id, :actionValue)\n end",
"def steps\n %w[/14/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/educations\n /12/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /13/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_scores\n /41/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /42/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /15/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/work/characteristics/index\n /29/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_immunization/show\n /ASSESSMENT/disability/characteristics/index\n /ASSESSMENT/mental/characteristics/index\n /35/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/substance_abuse/characteristics/index\n /32/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/domestic/characteristics/index\n /38/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /39/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/clients/medical_pregnancy/show\n /19/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /21/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /22/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /23/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /24/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /25/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /26/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /2/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/employments\n /ASSESSMENT/legal/characteristics/index\n /7/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /assessment_careers/interest_profiler_questions/interest_profiler_question_wizard_initialize\n ]\n\n end",
"def step_1_regex\n @step_1_regex ||= /(.*)(#{step_1_exceptions.keys.join(\"|\")})$/u\n end",
"def step_from_event\n @step = resource.try(:event).try(:to_sym)\n \n if @step && (!self.respond_to?(:current_step_is_next_step_after_event) || current_step_is_next_step_after_event) \n @step = next_step(@step)\n end\n end",
"def is_equal?(step_nr)\n return step_nr == self.step\n end",
"def eval_expression\n # Shoes.show_log\n @numbers = @input.split(\" \")\n @first_number = @numbers.shift.to_f\n @numbers.unshift(@first_number)\n\n @last_number = @numbers.pop.to_f\n @numbers.push(@last_number.to_s)\n\n @input = @numbers.join\n @input = eval(@input).to_s\n @output.text = @input\n end",
"def new_step\n # noinspection RubyMismatchedReturnType\n index(index&.succ || 0)\n end",
"def step\n @next_step = @next_step.call\n return self\n end",
"def step(steps)\r\n\tdirection = (steps > 0) ? :brighten : :dim\r\n\tnsteps = steps.abs\r\n\twhile nsteps > 0\r\n\t n = (nsteps > 6) ? 6 : nsteps\r\n\t @controller.command(@house, @unit, direction, n)\r\n\t nsteps -= n\r\n\tend\r\n end",
"def calculate_expr_part(cond_expr, row_val)\n\n\t\tcnt2 = -1 # counter for row_val\n\t\tcnt3 = -1 # counter for operators\n\t\tboolean_expr = \"\"\n\n\t\toperators = cond_expr.to_s.scan(/\\)(.*?)\\(/)\n\n\t\tcond_expr.to_s.scan(/\\((.*?)\\)/).each do |e|\n\t\t\te = e.to_s.delete(\"(\").delete(\")\")\n\n\t\t\trel_operator = get_relational(e)\n\t\t\tls = e.split(\"#{rel_operator}\")[0].scan(/\\[(.*?)\\]/)\n\t\t\trs = e.split(\"#{rel_operator}\")[1]\n\n\t\t\tif ls.size == 0\n\t\t\t\tif rs.nil?\n\t\t\t\t\t# replace vars with val\n\t\t\t\t\t# call compute()\n\n\t\t\t\t\te = e.to_s.replace_with_space(@vars)\n\t\t\t\t\texpr_part = \"\"\n\t\t\t\t\te.split(\" \").each do |v|\n\n\t\t\t\t\t\t(@vars.include? v) ? (expr_part += row_val[cnt2+=1] || '') : ( (v == \"&\") ? (expr_part += \"\") : (expr_part += v.to_s) )\n\t\t\t\t\tend\n\n\t\t\t\t\tboolean_expr += (compute(expr_part).to_s + operators[cnt3+=1].to_s)\n\t\t\t\telse\n\t\t\t\t\tls = e.split(\"#{rel_operator}\")[0]\n\t\t\t\t\tls = ls.to_s.replace_with_space(@vars)\n\t\t\t\t\texpr_part = \"\"\n\t\t\t\t\tls.split(\" \").each do |v|\n\t\t\t\t\t\t(@vars.include? v) ? expr_part += row_val[cnt2+=1] : (v == \"&\") ? expr_part += \"\" : expr_part += v.to_s\n\t\t\t\t\tend\n\n\t\t\t\t\tif compare_ls_rs(compute(expr_part), rel_operator, rs)\n\t\t\t\t\t\tboolean_expr += (\"1\" + operators[cnt3+=1].to_s)\n\t\t\t\t\telse\n\t\t\t\t\t\tboolean_expr += (\"0\" + operators[cnt3+=1].to_s)\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif compare_ls_rs(cal_group_val(row_val[cnt2+1..cnt2+=ls.size]), rel_operator, rs)\n\t\t\t\t\tboolean_expr += (\"1\" + operators[cnt3+=1].to_s)\n\t\t\t\telse\n\t\t\t\t\tboolean_expr += (\"0\" + operators[cnt3+=1].to_s)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n=begin\n\t\tif (cond1)\n\t\t\tout 1\n\t\telse if (cond2)\n\t\t\tout 2\n\t\telse\n\t\t\tout 3\n\t\tend\n=end\n\t\tif compute(boolean_expr) == 1\n\t\t\t# Return output mentioned with cnt1 condition\n\t\t\treturn get_output\n\t\telse\n\t\t\t# go for next condition\n\t\t\t# call - calculate_expr(cond_expr, row_val)\n\t\t\tif !@expr_arr[@cnt1+=1].nil?\n\t\t\t\tcalculate_expr_part(@expr_arr[@cnt1], row_val)\n\t\t\telse\n\t\t\t\t# return last output mentioned in ELSE part\n\t\t\t\treturn get_output\n\t\t\tend\n\t\tend\n\n\tend",
"def expansion(n)\n \"1 + 1/#{nesting(n)}\"\nend",
"def step?(step)\n @current_step.nil? || current_step + 1 == step\n end",
"def eval(_)\n value\n end",
"def _reduce_351(val, _values, result)\n else_t, else_ = val[4]\n result = [ val[0],\n @builder.condition(val[0], val[1], val[2],\n val[3], else_t,\n else_, nil),\n ]\n \n result\nend",
"def regex_divisible_by(n)\n return '^(0|1)*$' if n == 1\n fsm = FinitStateMachine.new(n)\n fsm.find_regexp\nend",
"def execute_step(step)\n result = case\n when step.respond_to?(:call) then step.call\n when step.kind_of?(Symbol) then send(step)\n else\n fail \"Invalid step. Must be a callable object or symbol method reference.\"\n end\n fail \"Step #{step} did not return a valid result\" unless result.is_a?(StepResult)\n result\n end",
"def [](name)\n steps[name]\n end",
"def [](name)\n steps[name]\n end",
"def nextStep()\n\n @simulationLog = @simulationLog + \"Entering XpdlObject.nextStep() ... \\n\"\n\n # Set of transitions found for this transition (If found more than 1,\n # then need to check the dataField var in MockData File)\n transFound = [] \n\n # Find the Transitions tag\n transitions = @dom.find('//xpdl:Transition')\n transitions.each do |transition|\n if (transition.attributes['From'] == @currActID)\n #@currActID = transition.attributes['To']\n transFound.push(transition)\n end\n end\n \n\n # Check Size of transFound[]\n if transFound.length > 0\n otherwiseTrans = nil \n conditionTrans = []\n normalTrans = nil # a transition without any <Condition tag\n\n # Parse through all transition objects, if one of them has an 'OTHERWISE' \n # condition, then set it to 'otherwiseTrans' var, and pop it out of array\n transFound.each do |transition|\n conds = transition.find(\".//xpdl:Condition\")\n if conds.length != 0 # if a condition tag is found\n if conds[0].attributes['Type'] == \"OTHERWISE\"\n otherwiseTrans = transition\n elsif conds[0].attributes['Type'] == \"CONDITION\"\n puts \"found a condition...\"\n conditionTrans.push(transition)\n end\n else # No Condition for this transition (a normal transition)\n # Perform transition\n #performTrans(transition)\n normalTrans = transition\n end\n end # transFound.each\n\n # Perform transition now (parse through conditionTrans[], then do otherwiseTrans if necessary)\n\n if normalTrans != nil # if this is just a normal transition\n performTrans(normalTrans)\n else # if this transition has conditions\n transPerformed = 0 # Flag to determine if transition has been performed or not\n conditionTrans.each do |con|\n if evalCondition(con)\n performTrans(con) \n transPerformed = 1\n break\n else\n if @power == \"OFF\"\n return \"ERROR\"\n end\n end\n end\n # Now check to see if a valid condition was found or not\n if transPerformed == 0 and otherwiseTrans != nil\n performTrans(otherwiseTrans)\n @simulationLog = @simulationLog + \"NO CONDITION MATCHED: \" + \"Transitioning to 'OTHERWISE' Transition\\n\"\n elsif transPerformed == 0 and otherwiseTrans == nil\n @simulationLog = @simulationLog + \"FATAL ERROR: Unable to find a valid Condition for transition for Activity ID: \" + @currActID + \"\\n\"\n puts \"FATAL ERROR: Unable to find a valid Condition for transition for Activity ID: \" + @currActID + \"\\n\"\n self.terminate() \n return \"ERROR\"\n end\n end # normalTrans != nil\n\n else # transFound.length > 0\n @simulationLog = @simulationLog + \"FATAL ERROR: Unable to find a transition for Activity ID: \" + @currActID + \"\\n\"\n puts \"FATAL ERROR: Unable to find a transition for Activity ID: \" + @currActID + \"\\n\"\n self.terminate() \n return \"ERROR\"\n end \n\n\n \n\n\n #############################################\n \n \n @simulationLog = @simulationLog + \"Successfully Moved to the Next Step... \\n\"\n @simulationLog = @simulationLog + \"@currActID is: \" + @currActID + \"\\n\"\n\n if self.isLastActivity(@currActID)\n @simulationLog = @simulationLog + \"This is the Last Activity, The Simulation is Now Over :( ... POWERING OFF ... GoodBye ^_^ \\n\"\n # Update @mockDataHash and @resultJSON\n update_resultJSON(@currActID)\n update_mockDataHash(@currActID)\n self.terminate()\n return \"ERROR\"\n end\n\n # Update @mockDataHash and @resultJSON\n update_resultJSON(@currActID)\n update_mockDataHash(@currActID)\n\n # Return the Current Active ID: @currActID\n return @currActID\n\n end",
"def stepPerms(n)\n return 0 if n < 0\n return 1 if n == 0\n \n stepPerms(n - 1) + stepPerms(n - 2) + stepPerms(n - 3)\nend"
] | [
"0.5798169",
"0.56881636",
"0.5677804",
"0.5475534",
"0.54139423",
"0.53727996",
"0.5353041",
"0.5338501",
"0.53065944",
"0.53065944",
"0.53065944",
"0.5299751",
"0.5289309",
"0.52679855",
"0.52373195",
"0.5217548",
"0.5089139",
"0.50588447",
"0.50575215",
"0.50575215",
"0.505702",
"0.50484395",
"0.50376534",
"0.5036761",
"0.50056845",
"0.498579",
"0.49814457",
"0.4977812",
"0.49721935",
"0.4949935",
"0.4945839",
"0.49291423",
"0.4926664",
"0.4921769",
"0.490141",
"0.48992166",
"0.48966223",
"0.4879675",
"0.48789695",
"0.48604953",
"0.48598635",
"0.48560616",
"0.4853742",
"0.48466805",
"0.483494",
"0.4833089",
"0.48313418",
"0.48273617",
"0.48206973",
"0.48195186",
"0.481662",
"0.481477",
"0.48118132",
"0.48110536",
"0.48003727",
"0.4792436",
"0.4791693",
"0.47836322",
"0.4778544",
"0.4766423",
"0.4766423",
"0.4762696",
"0.47617623",
"0.4761513",
"0.4759547",
"0.47536895",
"0.47480762",
"0.4743065",
"0.473657",
"0.47360313",
"0.4731795",
"0.47277004",
"0.47219613",
"0.4718177",
"0.47118124",
"0.47104383",
"0.47088355",
"0.46941748",
"0.46909717",
"0.4679595",
"0.46784043",
"0.46745083",
"0.46714202",
"0.46658906",
"0.46628907",
"0.4657549",
"0.46538293",
"0.46467146",
"0.46429133",
"0.46417433",
"0.46350116",
"0.46339393",
"0.46315953",
"0.46305987",
"0.46305466",
"0.46282926",
"0.46277928",
"0.46277928",
"0.4627668",
"0.4625122"
] | 0.5814103 | 0 |
Sends password reset email. | def send_reset_email
UserMailer.password_reset(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_password_reset_email\n\t\tUserMailer.password_reset(id, self.reset_token).deliver_later\n \tend",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end",
"def send_passwordreset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n\t\tUserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end",
"def send_password_reset_email\r\n UserMailer.password_reset(self).deliver!\r\n end",
"def send_password_reset_email\n AgentMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n PasswordResetMailer.password_reset_email(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_reset_email\n\t\tUserMailer.reset_password(self).deliver_now\n\tend",
"def send_password_reset_email\n\t UserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n \t\tUserMailer.password_reset(self).deliver_now\n \tend",
"def send_password_reset_email\n\t UserMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n \t\tUserMailer.password_reset(self).deliver_now\n \tend",
"def send_password_reset_email\n \tUserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n create_password_reset_digest\n update_attribute(:sent_reset_at, Time.zone.now)\n UserMailer.password_reset(self).deliver_later\n end",
"def send_password_reset_email\n\t\tMemberMailer.password_reset(self).deliver_now\n\tend",
"def send_password_reset_email\n GolferMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n #UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end",
"def send_password_reset_email\n UserMailer.password_reset(self).deliver_now\n end"
] | [
"0.8788405",
"0.8677096",
"0.8677096",
"0.8661554",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86603385",
"0.86564267",
"0.8650267",
"0.86485726",
"0.8646728",
"0.8630811",
"0.8630811",
"0.8630811",
"0.8630811",
"0.8630811",
"0.8630811",
"0.86260355",
"0.8616442",
"0.85810626",
"0.85437965",
"0.854042",
"0.8539287",
"0.8537045",
"0.8529",
"0.8516614",
"0.85158235",
"0.84977293",
"0.8479944",
"0.8479944",
"0.8479944",
"0.8479944",
"0.8479944",
"0.8479944",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733",
"0.8471733"
] | 0.0 | -1 |
two below methods are in this section because they are callbacks called during particular time during user object's life | def downcase_email
self.email = email.downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callbacks; end",
"def callbacks; end",
"def callback\n end",
"def callback\n\n end",
"def callback_phase\n super\n end",
"def callback\n\tend",
"def after_set_callback; end",
"def after_update; end",
"def after_update; end",
"def after_generate_callbacks; end",
"def ready; end",
"def ready; end",
"def callback &block\n super\n end",
"def callback &block\n super\n end",
"def notifier; end",
"def notifier; end",
"def fires_in; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def events; end",
"def called_from; end",
"def called_from; end",
"def after_players_ready\r\n end",
"def before_players_ready\r\n end",
"def on_ready\n end",
"def on_init; end",
"def on_init; end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize; end",
"def after_initialize(&block); end",
"def event; end",
"def event; end",
"def event; end",
"def listener; end",
"def after_create(obj); end",
"def on_update; end",
"def onStart\r\n end",
"def after_initialized\n end",
"def pausable; end",
"def post_init\n end",
"def callback_type; end",
"def callback=(_arg0); end",
"def death_handlers; end",
"def onmessage(&blk); super; end",
"def post_init\n end",
"def after_initialize \n end",
"def ready=(_); end",
"def private; end",
"def listeners; end",
"def post_init\n\tend",
"def after_cycle; end",
"def did_attach() end",
"def around_hooks; end",
"def after_initialize\n end",
"def after_initialize\n end",
"def after_created; end",
"def enter_pending; end",
"def started; end",
"def after_create_cb\n Rails.logger.warn \"after_create_cb #{self}\"\n end",
"def after_update\n end",
"def after_update\n end",
"def connection_completed\n\tend",
"def callback\n false\n end",
"def after_initialize\n end",
"def recup_handle\n\t\t\n\tend",
"def post_process; end",
"def after_remembered; end",
"def after_processing_hook; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def receiver; end",
"def on_data_changed; end",
"def on_after_load\n end",
"def awake\n\t\tend",
"def monitor; end",
"def on_present()\n end",
"def who_we_are\r\n end",
"def events=(_); end",
"def after_sync\n end",
"def after_initialize\n end",
"def event_bus; end",
"def event_bus; end",
"def post_initialize\n end",
"def running; end",
"def running; end",
"def callbacks\n @callbacks ||= {}\n end",
"def initialize()\n @callbacks = {}\n end",
"def hook_owner; end",
"def after_processing\n end",
"def before_run; end",
"def handle; end"
] | [
"0.7751526",
"0.7751526",
"0.6975495",
"0.6904932",
"0.68906814",
"0.68224365",
"0.6565693",
"0.64858997",
"0.64858997",
"0.64770776",
"0.64602613",
"0.64602613",
"0.6431811",
"0.6431811",
"0.63858294",
"0.63858294",
"0.63473094",
"0.6336997",
"0.6336997",
"0.6336997",
"0.6336997",
"0.6336997",
"0.6336997",
"0.6336997",
"0.6336997",
"0.6306225",
"0.6306225",
"0.627879",
"0.62449455",
"0.6234702",
"0.62298113",
"0.62298113",
"0.62122804",
"0.62122804",
"0.62122804",
"0.62122804",
"0.61994475",
"0.6194449",
"0.6194449",
"0.6194449",
"0.6161703",
"0.61529714",
"0.61478335",
"0.6123167",
"0.60891134",
"0.60867274",
"0.6062604",
"0.6048702",
"0.60395384",
"0.6031",
"0.60111666",
"0.6001463",
"0.5989505",
"0.5983403",
"0.59813696",
"0.5967685",
"0.59617895",
"0.59612125",
"0.59478927",
"0.59448344",
"0.59411645",
"0.59411645",
"0.5940139",
"0.5926839",
"0.59197974",
"0.59193444",
"0.5911983",
"0.5911983",
"0.5906188",
"0.5898688",
"0.5896531",
"0.589002",
"0.58894765",
"0.5887129",
"0.5882245",
"0.5876939",
"0.5876939",
"0.5876939",
"0.5876939",
"0.5876939",
"0.5876939",
"0.5873444",
"0.5872259",
"0.5868339",
"0.5860233",
"0.5853952",
"0.585318",
"0.58519363",
"0.585155",
"0.5843303",
"0.5830557",
"0.5830557",
"0.5825667",
"0.5825278",
"0.5825278",
"0.58238214",
"0.5823264",
"0.58144504",
"0.58126867",
"0.5811078",
"0.5810776"
] | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.